#jonathan-webhook
1 messages · Page 1 of 1 (latest)
Hello! stripe.confirmCardPayment returns a Promise which resolves with a result object. That result object will have a paymentIntent property if the payment was successful. This, of course, is happening client side, so you can't trust that, but what you can do is:
- Send the Payment Intent ID from the frontend to your backend (
result.paymentIntent.id) - Fetch the Payment Intent using that ID on your server
- Check the status, confirm you really got paid, then take whatever steps are appropriate (flagging in your DB, rendering the next page, etc.)
See the Returns section here for details: https://stripe.com/docs/js/payment_intents/confirm_card_payment
You need to depend on webhooks for cases where the customer drops off during the payment flow and the client-side code doesn't run, but you can use the approach above in addition to that rather than waiting for the webhook when the client-side code does run and the customer is on-session.
Got it thanks! So it seems like the best way forward is to handle a successful payment in two places - 1) in response to the client given a successful confirmCardPayment call and 2) when a the payment_intent.succeeded webhook gets called in case the customer drops off.
That means the logic handling the successful payment must be idempotent
Yep, exactly!
jonathan-stripe.js-electron