I am building a web shop checkout page, and I am stuck with one problem - how can I be sure that the user really paid?
Stack: Quarkus + Angular
I have integrated a Stripe payment method in my checkout page. Each time the checkout page is opened, I get a Stripe Intent from backend. Then, after the user has entered the card info and clicked on "Pay" I get in frontend a response from stripe that "ok, the user has paid!", I call then an PUBLIC endpoint on my server (from frontend) and I say, ok, the user has paid, confirm the order.
How can I be sure that the customer actually paid? He could just call my PUBLIC server endpoint and confirm the order, and I would not know that the stripe payment actually never happened.
My guess was, maybe I can call the stripe server and ask, "hey, was there actually a payment done with this stripe intent"?
What is the best practice here, how I should implement the confirm order part?
You would want to listen for the relevant webhook events rather than waiting on a callback from the client. On the client, the customer could close the browser window or quit the app before the callback executes.
You can refer to https://stripe.com/docs/payments/accept-a-payment?platform=web&ui=elements#web-post-payment for what events to listen for.
You can also read up on webhooks in more detail here : https://stripe.com/docs/webhooks