I'm using react-native / firebase / stripe. I'm building a marketplace app, with customer to customer sell. When a customer buy a product ( there is only 1 available) , i'm getting a server notification from stripe to tell me that the paymentIntent has been confirmed. I check if the firebase doc is still available, if so, then i move it to another collection. If the doc is not available it means someone has already bought the article. In this case i have 2 customers who bought the same article. I have to refund the second one but i will be loosing the stripe fees. Is there any way to avoid this ? Thanks
CodePudding user response:
Not sure if you're only accepting card payments but if you are then you should probably look into this guide here [1] where you confirm the PaymentIntent server-side. This would allow you to check if you have inventory before confirming the PaymentIntent.
If you're not just accepting card payments, then there's a beta [2] here for a similar flow that would allow you to run custom actions before confirming a PaymentIntent.
[1] https://stripe.com/docs/payments/accept-a-payment-synchronously?platform=react-native
[2] https://stripe.com/docs/payments/run-custom-actions-before-confirmation