#jonathan-webhook

1 messages · Page 1 of 1 (latest)

crude copper
#

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:

  1. Send the Payment Intent ID from the frontend to your backend (result.paymentIntent.id)
  2. Fetch the Payment Intent using that ID on your server
  3. Check the status, confirm you really got paid, then take whatever steps are appropriate (flagging in your DB, rendering the next page, etc.)
#

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.

royal pine
#

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

crude copper
#

Yep, exactly!

dense lily
#

jonathan-stripe.js-electron