#rovarma-checkout

1 messages · Page 1 of 1 (latest)

placid moat
#

@thin adder I would say our advice is https://stripe.com/docs/payments/checkout/custom-success-page , when the user is redirected, you can retrieve the CheckoutSession and then show the appropriate UI based on it, and update your database at the same time. You should listen for webhooks too, but you just set things up so the same actual code gets runs idempotently regardless of which entry point(page or the webhook) is used.

Also, we don't seem to document this anywhere, but we do wait up to 10 seconds on Checkout until webhooks are delivered and acknowledged(i.e. after the user hits pay, the page spins for a while), which is designed to allow you to get the event before the customer comes back.

thin adder
#

@placid moat thanks for the info! I can't find it now, but the reason we're not currently doing this in the success page is because the docs warned that there is no guarantee that the user actually lands on that page (for example, if they close the tab).

Nevertheless, running the update code in both the webhook & success page endpoints makes sense and should solve the issue for us. Thanks for the help!

(WRT the 10 second delay, thanks that's good to know!)

placid moat
#

yep there's not guarantee, so you do need webhooks too, but if they do hit the page you can just retrieve the session object from the API at that point(make sure you do that, and don't just assume that someone visiting the page mean they paid) and reconcile your backend at that point, if you set up the code so it doesn't matter if the webhook also tries to do the same thing