#dan_docs
1 messages · Page 1 of 1 (latest)
👋 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.
Hello
You would call your backend in this case to retrieve the PaymentIntent to check its status
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.
Correct
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)(
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
Ok....
If you attempt to call processPayment() on a PaymentIntent that is already succeeded then it will indicate that to you in the response
I mean we would only do it if it was an error
Ah right sorry
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
👍
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
}
}
The retry would use terminal.processPayment
Yeah okay that works
Can we just retry with the same client secret
Yep
Ok, a quick update
Err sorry actually you don't pass the client secret here
You pass the full PaymentIntent object
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
}
}
Yeah except you also need to handle declines in result.paymentIntent
Yeah of course
But overall you got it
I left that part out, it is working well in our code right now
Gotcha
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.
Yeah you do the same as if it returns as nil -- you retry
Sure
Honestly, we have had this wrong in production for a while. I think the docs could be a little more clear on that
That's fair -- I can pass on some feedback internally about that