#mangel_terminal-processing-payment

1 messages ยท Page 1 of 1 (latest)

obsidian plazaBOT
gusty pivotBOT
#

Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.

obsidian plazaBOT
#

๐Ÿ‘‹ Welcome to your new thread!

โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

๐Ÿ”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1242119851007279104

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

slate wing
#

Hello

#

Can you clarify a little bit what the exact issue is here?

mighty flume
#

Hi I am trying to resolve this error when creating a payment intent.
`
reader = await stripe.terminal.readers.processPaymentIntent(reader.id,intent.id);

`

ERROR:
`/Users/angell/src/demo/node_modules/stripe/cjs/RequestSender.js:96
err = new Error_js_1.StripeAuthenticationError(jsonResponse.error);
^

StripeAuthenticationError: Invalid API Key provided: pi_3PIHt***************F6z3`

#

Here is the serialized location and reader:

LOCATION: {"id":"tml_FiuXCQpknBASRm","object":"terminal.location","address":{"city":"Prairie Village","country":"US","line1":"4501 w 70th st","line2":"","postal_code":"66208","state":"KS"},"display_name":"HQ","livemode":false,"metadata":{}} READER: {"id":"tmr_FjdygQpwbvIHHQ","object":"terminal.reader","action":null,"device_sw_version":"","device_type":"simulated_wisepos_e","ip_address":"0.0.0.0","label":"Sim 2","last_seen_at":1716156499399,"livemode":false,"location":"tml_FiuXCQpknBASRm","metadata":{},"serial_number":"5cfa7398-ff9d-4dc4-b8ad-ab51b0325194","status":"online"}

#

And here is the intent:
INTENT: {"id":"pi_3PIHtvEPuIFxKCqt13WNF6z3","object":"payment_intent","amount":1000,"amount_capturable":0,"amount_details":{"tip":{}},"amount_received":0,"application":null,"application_fee_amount":null,"automatic_payment_methods":null,"canceled_at":null,"cancellation_reason":null,"capture_method":"manual","client_secret":"pi_3PIHtvEPuIFxKCqt13WNF6z3_secret_MtcF3JddsyVbgsMi3pdInxHdl","confirmation_method":"automatic","created":1716156499,"currency":"usd","customer":null,"description":null,"invoice":null,"last_payment_error":null,"latest_charge":null,"livemode":false,"metadata":{},"next_action":null,"on_behalf_of":null,"payment_method":null,"payment_method_configuration_details":null,"payment_method_options":{"card_present":{"request_extended_authorization":false,"request_incremental_authorization_support":false}},"payment_method_types":["card_present"],"processing":null,"receipt_email":null,"review":null,"setup_future_usage":null,"shipping":null,"source":null,"statement_descriptor":null,"statement_descriptor_suffix":null,"status":"requires_payment_method","transfer_data":null,"transfer_group":null}

slate wing
#

Seems like you are mixing up keys here

#

The Reader is on one account and your PaymentIntent is on a different account

mighty flume
#

Those keys are coming back from the retrieval:

`async function retrieveLocation () {
const location = await stripe.terminal.locations.retrieve('tml_FiuXCQpknBASRm');

return location;
};

async function retrieveReader () {
const reader = await stripe.terminal.readers.retrieve('tmr_FDOt2wlRZEdpd7');

return reader;
};`

#

I only have one key in the code when I require("stripe")

slate wing
#

Yeah I'm not talking about your object IDs

#

I'm talking about your API key

mighty flume
#

I have my sk_test key in the require("stripe"). I know its valid because the location and reader that I retrieve match exactly what I see in the dashboard.

slate wing
#

That location and that reader are also on different accounts

#

So yeah I'd recommend starting again create a new location and a new Reader on the account that you are currently testing on

mighty flume
#

I only have one account. That is very confusing.

slate wing
#

Hmm okay let's pause for a second

#

I do see something weird here.

#

So the ID tmr_FDOt2wlRZEdpd7 you are saying you get that ID from calling: ```async function retrieveLocation () {
const location = await stripe.terminal.locations.retrieve('tml_FiuXCQpknBASRm');

return location;
};``` ?

mighty flume
#

tmr_FDOt2wlRZEdpd7?

slate wing
#

Yes

#

Can you add a log in that function for location and show me the payload?

mighty flume
#

LOCATION: {"id":"tml_FiuXCQpknBASRm","object":"terminal.location","address":{"city":"Prairie Village","country":"US","line1":"4501 w 70th st","line2":"","postal_code":"66208","state":"KS"},"display_name":"HQ","livemode":false,"metadata":{}}

That is what I expect- it matches my location in the dashboard.

slate wing
#

(List Readers for that location and let me know what you see?)

#

Okay yeah I still don't really understand where you got tmr_FDOt2wlRZEdpd7 from...

#

Like when I look at that location in your Dashboard and click on your simulated reader I see a different Reader ID...

#

AH

#

lol

#

That Reader ID is what is in our API Reference

#

So you likely grabbed that on accident

mighty flume
#

Oh crap- really?

slate wing
#

Yeah check on the Reader ID in your Dashboard or list via the API

#

Then trying using that Reader ID

mighty flume
#

Actually- that code I pasted is a function that I am not calling (most likely from the docs). I am calling the reader directly with the correct id.

reader = await stripe.terminal.readers.retrieve('tmr_FjdygQpwbvIHHQ');

#

I an getting back the correct serial number:

"serial_number":"5cfa7398-ff9d-4dc4-b8ad-ab51b0325194"

#

Sorry about the confusion!! My code is retrieving the reader with the correct ID I see in the dashboard.

#

Here is the result of readers.list:

READERS: {"object":"list","data":[{"id":"tmr_FjdygQpwbvIHHQ","object":"terminal.reader","action":null,"device_sw_version":"","device_type":"simulated_wisepos_e","ip_address":"0.0.0.0","label":"Sim 2","last_seen_at":1716216654520,"livemode":false,"location":"tml_FiuXCQpknBASRm","metadata":{},"serial_number":"5cfa7398-ff9d-4dc4-b8ad-ab51b0325194","status":"online"}],"has_more":false,"url":"/v1/terminal/readers"}

obsidian plazaBOT
#

๐Ÿง‘โ€๐Ÿ’ป How to format code on Discord

Inline code: wrap in single backticks (`)

This:

The variable `foo` contains the value `bar`.

Will turn into this:

The variable foo contains the value bar.

Code blocks: wrap in three backticks (```)

Also, you can specify the language after the first three backticks to get syntax highlighting.

This:

```javascript
function foo() {
return 'bar';
}
```

Will turn into this:

function foo() {
  return 'bar';
}```

Notes about **code blocks**:
- Specifying the language is optional (e.g., you can omit `javascript` in the example above)
  - If you don't specify the language you won't get syntax highlighting
- When you're inside a code block (after you type \`\`\`) the `Return`/`Enter` key will add a new line instead of sending your message
  - Once you end the code block `Return`/`Enter` works normally again

You can [read more about message formatting on Discord's website.](https://support.discord.com/hc/en-us/articles/210298617)
slate wing
#

Okay

#

Can you show me your full relevant code here?

mighty flume
#
var location;
var reader;
var processResult
  try {
    location = await retrieveLocation();
    console.log("LOCATION: " + JSON.stringify(location));
  } catch (error) {
    console.error("Error:", error);
  }
  var config = {simulated: true};


const readers = await stripe.terminal.readers.list({
  limit: 3,
});
 console.log("READERS: "+JSON.stringify(readers));

 reader = await stripe.terminal.readers.retrieve('tmr_FjdygQpwbvIHHQ');

 console.log("READER: "+JSON.stringify(reader));



    try {
    const token = await getToken();
    console.log("TOKEN2: " + JSON.stringify(token));
  } catch (error) {
    console.error("Error:", error);
  }

  try {
    intent = await createIntent();
    console.log("INTENT: " + JSON.stringify(intent));
  } catch (error) {
    console.error("Error:", error);
  }

  console.log("INTENT ID:"+intent.id);
    console.log("INTENT client_secret:"+intent.client_secret);

  processResult = await stripe.terminal.readers.processPaymentIntent(reader.id,intent);
  console.log(JSON.stringify(processResult));
#

  const paymentIntent = await stripe.paymentIntents.create(
  {
    amount: 1000,
    currency: 'usd',
    payment_method_types: ['card_present'],
    capture_method: 'manual'
  }

)```
slate wing
#

What is your intent variable there?

#

In processResult = await stripe.terminal.readers.processPaymentIntent(reader.id,intent);

#

That needs to be {payment_intent: 'pi_xxxx'}

#

Can you check on that?

mighty flume
#

I pasted in createIntent()

#

above

#

Oh- yeah. I was trying a few things before this chat. I had intent.id

#

I just ran: ``` processResult = await stripe.terminal.readers.processPaymentIntent(reader.id,intent.id);

#

and get the StripeAuthenticationError: Invalid API Key provided: pi_3PIXf***************7SMe error

slate wing
#

See above

#

that should be an object with the payment_intent parameter

mighty flume
#

What do I need to do different? I am passing in an intent from const paymentIntent = await stripe.paymentIntents.create( { amount: 1000, currency: 'usd', payment_method_types: ['card_present'], capture_method: 'manual' }

slate wing
#

You pass just the PaymentIntent ID

#

The code would look like:
processResult = await stripe.terminal.readers.processPaymentIntent(reader.id, {payment_intent: intent.id});

obsidian plazaBOT
mighty flume
#

Whoa! That worked. Why does process payment need to wrap a single string in an object? Not very intuitive. Especially given the cryptic error. But thanks! Hopefully I will be able to capture the payment next.

paper mantle
#

HI ๐Ÿ‘‹

I'm stepping in as my colleague needs to go

#

I think you are all set but if you have more questions I will be happy to help