Stripe: do checks before accepting a payment

Viewed 44

I have stripe already integrated and working but now I'm trying to manage some "corner cases" that can happen in a regular usage and found a case that i'm not sure how to manage.

In my platform all the products i will provide are going to be unique and buyable only once. If 2 people try to buy the same product concurrently, one of them will get it, and the other should get an error when trying to complete the payment.

Currently i have setup webhooks so the backend is able to detect the case but i don't know how to notify stripe to cancel that PaymentIntent at that exact moment, being able to notify also the user.

Is there anything i can do to achieve this? would i be able to cancel the PaymentIntent on that moment so the user can have a custom error message?

Thanks a lot!

0 Answers
Related