#aubreywodonga
1 messages · Page 1 of 1 (latest)
Hi there
In terms of storing in your database I would recommend using Webhooks as otherwise you might not ingest the data since the customer could lose network connection between the time they initiate the SetupIntent confirmation and when it succeeds.
In terms of immediate showing of the added PaymentMethod, you want to pass the PaymentMethod to your backend and retrieve it and pass that information back to the frontend.
Ah, I forgot completely about webhooks that might be triggered on adding a new payment method, thank you!
On your second point that's essentially what I am trying to do, but my issue was that I wasn't sure where I could access the paymentMethod since as I understand it wouldn't exists until the successful addition+redirect.
I'll look into the webhooks now and come back if I have any issues, thanks again!
Yep that's right, so upon the redirect that is when you fetch your backend.
The SetupIntent ID will be appended to the redirect URL as a query param
So on the redirect you basically show a "loading spinner" while you fetch your backend, retrieve the PM based on the SetupIntent (you can actually just retrieve the SetupIntent and expand payment_method here: https://stripe.com/docs/api/setup_intents/object#setup_intent_object-payment_method) and then pass the info you want back to your frontend.
Oh man, I was looking for exactly that and somehow completely missed the payment_intent key on the setup intent object! 😅 Thanks!