#Mike M - SetupIntent
1 messages ยท Page 1 of 1 (latest)
Both of those are still relevant for setup intents https://stripe.com/docs/payments/intents?intent=setup
requires_payment_method indicates it is waiting for valid payment method info
Hi @zenith glen. How do you test those states? I can't find any test cards that ever seem to trigger them.
requires_payment_method is how every setup intent starts
For processing it is harder to say, let me thing on that for a moment.
Right. processing is an async state, so somehow my system needs to react to something that can happen in the future?
Presumably, there needs to be some kind of callback once processing is complete, all of which sounds very awkward!
In that case yes you would listen for webhook events. For payment methods that require it, that is what happens. I will check if there are cards where that really applies https://stripe.com/docs/api/events/types#event_types-setup_intent.succeeded
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
And if so how to test it
Thanks]
๐ I'm just hopping in since @zenith glen has to head out
give me a few minutes to catch up
Thanks @nova prawn
If you're only working with credit cards you shouldn't get a Setup Intent with a state of processing - that would be for other payment method types
Great, that was my hope
The state requires_payment_method doesn't make sense either
The code comment is:
// payment again```
So, I guess I'll just send them round the loop to collect payment details again in that case.
Yea requires_payment_method is the initial state a Setup Intent can be in when it's first created and has not associated Payment Method, and is also the state you return to if something fails during the confirmation process (we clear out that Payment Method so that you can collect details again)
Any way to simulate that failure so I can check the state works?
You can use a Setup Intent w/ one of the 3DS test numbers (https://stripe.com/docs/testing#regulatory-cards) and fail the authentication
That fails earlier in the process, when I still have the PaymentElement visible. It doesn't get as far as calling the callback URL.
What do you mean - are you trying to get to the redirect_url from a failed card setup intent?
No, sorry
If you look at the sample code, you see this:
stripe
.retrieveSetupIntent(clientSecret)
.then(({setupIntent}) => {
// Inspect the SetupIntent `status` to indicate the status of the payment
// to your customer.
//
// Some payment methods will [immediately succeed or fail][0] upon
// confirmation, while others will first enter a `processing` state.
//
// [0]: https://stripe.com/docs/payments/payment-methods#payment-notification
switch (setupIntent.status) {
case succeeded:
setMessage('Success! Your payment method has been saved.');
break;
case 'processing':
setMessage("Processing payment details. We'll update you when processing is complete.");
break;
case 'requires_payment_method':
// Redirect your user back to your payment page to attempt collecting
// payment again
setMessage('Failed to process payment details. Please try another payment method.');
break;
}
});```
Apart from succeeded, you also have processing, which we've decided is irrelevant and finally requires_payment_method, which seems like a catch-all failure.
I can't see how I would cause a requires_payment_method, after the SetupIntent has been processed.
In any case, my approach right now is that I check for succeeded and if it's not in that state, I fail the whole process and ask the user to start again.
I've never seen that happen after 3 days of using test cards however!
Ah, I think I see your confusion - so these samples are written with the thought that Payment Element can support a number of different payment method types. I don't think (but am not 100% sure) that you can have a status of requires_payment_method AFTER being redirected when using cards, but it's always possible there's some weird edge case that I'm not thinking of