#clapynick-ReactJS
1 messages · Page 1 of 1 (latest)
Hi, I will go with your questions one by one
where do I update my database to “fulfil” the order?
You have 2 ways: Listen to your customer come back to your return_url, or listen to our webhook. Listening to webhook is recommended, because your customer can drop out of your flow, for example their connection lost, they accidentally closed the browser tab etc. So Webhook is the way to go
how will I know which user in my backend to update the coin count of
Yes using metadata to store user_id is a solution. Otherwise you can store your user_id and the PaymentIntent Id on your database. Then when you receive webhook, use the PaymentIntent Id to look up your user_id on your database
If I update my database within the webhook endpoint, and there is an error while trying to update the coin count (ie: some errors occurs with the db), how can I handle this? Can I somehow abort the payment
At the moment you receive the webhook event, that PaymentIntent is already considered succeed in Stripe's system. If any error occurs, you would want to find a sync mechanism from your system to align with Stripe.
There is no "somehow abort the Payment", you can refund an already successful Payment Intent, however I advise against it in your scenario(https://stripe.com/docs/api/refunds/create)
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
@fierce zodiac perfect, thanks for answering my questions. Much appreciated 🙏