Currently have a web app hosted on github pages.
I want to use firebase functions stripe to handle payments.
I have most things set up and now am calling the method stripe.redirectToCheckout({ sessionId })
However, on a successful payment, I want to update the database but I don't see an option add a callback. It only redirects me to a success/failure page. Im thinking of maybe redirecting back to the webapp but with some queryParams. Then check if query param is there on page load, update DB. But that seems incorrect and people could just then navigate to the specific URL to be added into the database.
How do I achieve what I am trying to do?
CodePudding user response:
You should ideally use Stripe Webhooks. You can create a HTTP function and specify it's URL for the webhook from Stripe Dashboard. So whenever an event (e.g. checkout session completed or failed) triggers the webhook, it'll send the event details to your Cloud Function and there you can update the database as required. There is no client side involved in this so risk is negligible.
Also checkout the Firebase Stripe Extension that might do most of the work for you.