stripe-paymentsrace-condition

How to handle product availability/taxes/shipping with Stripe PaymentIntent?


With PaymentIntents API we set up an Intent with the total and take user to the Checkout. There are a few reasons where I do not want to confirm the sale until I have been to my server after the user clicks "Buy".

1) Is the item still available? Another user may have been quicker through checkout.

2) What are the final taxes for the user(Tax rate lookups can get expensive)? User is shown "Estimated taxes". Don't want to make final calculation for every person who goes to checkout. Many bail.

3) Shipping quotes may not be exact(not in my case) but also depending on the state(US) may again change the tax.

Stripe wants us to confirm the payment on the front end. How do I solve these issues?

What is the best practice? As the Charges API allowed us to go to the server, figure all those things out and then initiate a charge with the final amount. Or exit if needed.


Solution

  • You can confirm on the server side by following https://stripe.com/docs/payments/accept-a-payment-synchronously