#Mike M - SetupIntent

1 messages ยท Page 1 of 1 (latest)

zenith glen
#

requires_payment_method indicates it is waiting for valid payment method info

echo fox
#

Hi @zenith glen. How do you test those states? I can't find any test cards that ever seem to trigger them.

zenith glen
#

requires_payment_method is how every setup intent starts

#

For processing it is harder to say, let me thing on that for a moment.

echo fox
#

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!

zenith glen
#

And if so how to test it

echo fox
#

Thanks]

nova prawn
#

๐Ÿ‘‹ I'm just hopping in since @zenith glen has to head out

#

give me a few minutes to catch up

echo fox
#

Thanks @nova prawn

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

echo fox
#

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.

nova prawn
#

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)

echo fox
#

Any way to simulate that failure so I can check the state works?

nova prawn
echo fox
#

That fails earlier in the process, when I still have the PaymentElement visible. It doesn't get as far as calling the callback URL.

nova prawn
#

What do you mean - are you trying to get to the redirect_url from a failed card setup intent?

echo fox
#

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!

nova prawn
#

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

echo fox
#

Yup, that's exactly what I'd assumed

#

I think the documentation could be a little clearer on that, after all, I imagine that card payments are the default option!