#Lucas974
1 messages · Page 1 of 1 (latest)
You'd do this asynchonrously with the checkout.session.completed events
Can you explain me how I could use it in my code?
There's nothing you can write in your front-end redirectToCheckout code that will persist data from the Checkout page into Firebase after payment. You either need to:
- Do it prior to
redirectToCheckout. - Utilise a webhook and listen for
checkout.session.completedevents which fire ~before the success redirect.
Webhook details here: https://stripe.com/docs/payments/checkout/fulfill-orders
And just before the success redirect??
Yes, the checkout.session.completed fires before the redirect
But you can't action those events in your React/JavaScript code. You need a backend component: https://stripe.com/docs/webhooks
Yeah that's not really relevant. What you want to do isn't possible with a backend/server component, as described with the webhooks flow
except, if I ask for name and email before running the checkout and then autofill the name/email on the stripe form
that might be possible but I feel like we're getting off topic.
Ultimately, you need to use a webhook endpoint be notified of the successful payment, so you can update your databases/'ship' the customer their order etc, and as part of that webhook handling you can access all the information the customer entered into Checkout and generate an email to send to them.
ok thank's
And regarding the webhooks, I need to run the stripe CLI everytime, keep this running on my server?
even in production?
or this is a tool I use only one time to generate a customize endpoint ?
it's a tool you use locally so that a server hosted on your development machine can be accessed by the external internet(since Stripe needs to send an event to you) during development
when you go live your backend code is hosted on a server somewhere(maybe it's a Firebase function for instance) and you put the URL of that server in your Stripe settings as where we should send the event
This is a bit difficult to understand this part
If I plug the firebase in my development machine
do I need also the stripe cli?
I'm not sure what it means to 'plug the firebase in my development machine' unfortunately
connect the firebase backend to my frontend
yeah I really don't know sorry, I've never used Firebase in general
ok
imagine I use a live server
with a public IP address and a domain name
this time, do I need the stripe CLI?
you don't need it, since you could create a webhook endpoint in your Stripe dashboard, using that domain name, and we'd send events there. https://stripe.com/docs/webhooks/go-live#configure-webhook-settings
merci!