#alexanderg-intents
1 messages · Page 1 of 1 (latest)
That one is in status:requires_payment_method in the API, which is not terminal. You can always attach a new PaymentMethod and attempt to process the payment again.
The terminal states are succeeded and canceled , anything else you can keep working with the state machine.
https://stripe.com/docs/payments/intents?intent=payment
also I'm confused a bit by that PaymentIntent, since you are creating it, getting an error, but then you retry the creation with the same idempotency key. That doesn't attempt a new charge or to process a payment(you'd want to use a different idempotency key if that's what you want), it just returns the saved API response again
You might find this article useful: https://dev.to/stripe/the-paymentintents-lifecycle-4f5o
I was just playing with idempotency key
How can I try the same failed payment intent again, but without changing the payment method, ie retry the same credit card?
For example the card had no funds left, but the client refilled it and I want to try to authAndCapture it again.
Basically I do not want to create an new payment intent but keep the same one with the same info and just try it again
You'd update the existing PaymentIntent and then confirm it again: https://stripe.com/docs/api/payment_intents/update#update_payment_intent-payment_method
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Sure, I will try it out. Thank you.
... again what do I need to update on PaymentIntent, nothing changed from client perspective?
When a PaymentIntent fails the PaymentMethod is automatically detached and it goes into the requires_payment_method status. So at that point if you want to try the same PaymentMethod again you'd have to reattach it to the PaymentIntent and confirm it once again (preferably confirm on the client in case 3DS is required)
So I need to reattach the same payment method and try to confirm again and it should work if the card is good?
btw, at the point of reconfirm there is no manual entry from the client, just the info I have saved from the previous attempt at Stripe
It depends, if the PaymentMethod wasn't previously attached to a customer it becomes "consumed" and can't be used again if the PaymentIntent fails. In that instance you'd have to collect the card details again
Makes sense, so in our case the method is not attached to customer so basically we cannot reuse the same method?
@wind tartan to keep me honest here, but I'm fairly certain that if the PaymentIntent fails and the PaymentMethod wasn't previously attached to a customer it gets "consumed" and can't be used again
yes, it's consumed and you'd create a new PaymentMethod
in practise the way you should do this is simply catching an error on your frontend and calling confirmPayment again.
like you call https://stripe.com/docs/js/payment_intents/confirm_payment , catch the error , show it to the user. The user changes some details and hits the pay button, and your code calls the same function again, repeat... The function collects the payment information from the frontend elements and re-attempts payment each time you call it.