#dan_docs

1 messages · Page 1 of 1 (latest)

verbal pythonBOT
#

👋 Welcome to your new thread!

⏲️ We'll be here soon! We typically respond in a few minutes, but in some cases we might need a bit more time (e.g., server's busy, you've got a complex question, etc.).

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can 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/1248008314084921385

📝 Have more to share? Add details, code, screenshots, videos, etc. below.

proper tinsel
#

Hello

#

You would call your backend in this case to retrieve the PaymentIntent to check its status

sinful burrow
#

Ok, the docs say:

Retry processing the original PaymentIntent. Don’t create a new one, as that could result in multiple authorizations for the cardholder.

proper tinsel
#

Correct

sinful burrow
#

But it isn't clear if that includes calling collectPaymentMethod or just using processPayment

#

FYI: we are forced to use the SDK because we have P400s to support still until October

#

We don't have a backend endpoint that exposes a GET payment-intent pass through to stripe yet. It would be most convenient if we can just use processPayment (EDITED)(

proper tinsel
#

Yeah if the result of processPayment is nil then you just call processPayment() again

#

Which yeah that works fine

#

You don't actually need to check the status

sinful burrow
#

Ok....

proper tinsel
#

If you attempt to call processPayment() on a PaymentIntent that is already succeeded then it will indicate that to you in the response

sinful burrow
#

I mean we would only do it if it was an error

proper tinsel
#

Ah right sorry

sinful burrow
#

I'm asking because we are seeing a lot of "No active payment intent" errors

#

I'll type up some psuedo code just to verify

proper tinsel
#

👍

sinful burrow
#

From the reference on the docs

#
async () => {
  const result = await terminal.processPayment(paymentIntent);
  if (result.error) {
    // Placeholder for handling result.error

    if(!result.paymentIntent){
      // Retry and poll until we get status
    }

  } else if (result.paymentIntent) {
    // Placeholder for notifying your backend to capture result.paymentIntent.id
  }
}
proper tinsel
#

You can't really poll here unless you call your backend

#

Or if you just retry

sinful burrow
#

The retry would use terminal.processPayment

proper tinsel
#

Yeah okay that works

sinful burrow
#

Can we just retry with the same client secret

proper tinsel
#

Yep

sinful burrow
#

Ok, a quick update

proper tinsel
#

Err sorry actually you don't pass the client secret here

#

You pass the full PaymentIntent object

sinful burrow
#

Ah good point

#

My eyes wondered in our code base and I was looking at the wrong line

#
const async () => {
  const result = await terminal.processPayment(paymentIntent);
  if (result.error) {
    // Placeholder for handling result.error

    if(!result.paymentIntent){
      // Retry and poll until we get status
      // convert this into something that would actually return a promise and resolve when we got something or timeout
       terminal.processPayment(paymentIntent)
    }

  } else if (result.paymentIntent) {
    // Placeholder for notifying your backend to capture result.paymentIntent.id
  }
}
proper tinsel
#

Yeah except you also need to handle declines in result.paymentIntent

sinful burrow
#

Yeah of course

proper tinsel
#

But overall you got it

sinful burrow
#

I left that part out, it is working well in our code right now

proper tinsel
#

Gotcha

sinful burrow
#

One more thing...

#

In the case:

if (processPaymentResult.error.payment_intent?.status === 'requires_confirmation') { ... }
#

We would probably do the same thing, to get an updated payment intent correct?

#

The docs say:

Call processPayment again with the same PaymentIntent to retry the request.

proper tinsel
#

Yeah you do the same as if it returns as nil -- you retry

sinful burrow
#

Ok, perfect

#

Thank you

proper tinsel
#

Sure

sinful burrow
#

Honestly, we have had this wrong in production for a while. I think the docs could be a little more clear on that

proper tinsel
#

That's fair -- I can pass on some feedback internally about that

sinful burrow
#

To specifically call processPayment until we get an updated PaymentIntent status

#

Thanks for the help!