#Lucas974

1 messages · Page 1 of 1 (latest)

sharp cipherBOT
hybrid pivot
#

You'd do this asynchonrously with the checkout.session.completed events

haughty saddle
#

Can you explain me how I could use it in my code?

hybrid pivot
#

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.completed events which fire ~before the success redirect.
haughty saddle
#

And just before the success redirect??

hybrid pivot
#

Yes, the checkout.session.completed fires before the redirect

haughty saddle
#

I use Vite with React-router-dom

#

(v6)

hybrid pivot
#

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

haughty saddle
#

except, if I ask for name and email before running the checkout and then autofill the name/email on the stripe form

hearty timber
#

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.

haughty saddle
#

ok thank's

haughty saddle
#

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 ?

hearty timber
#

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

haughty saddle
#

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?

hearty timber
#

I'm not sure what it means to 'plug the firebase in my development machine' unfortunately

haughty saddle
#

connect the firebase backend to my frontend

hearty timber
#

yeah I really don't know sorry, I've never used Firebase in general

haughty saddle
#

ok

#

imagine I use a live server

#

with a public IP address and a domain name

#

this time, do I need the stripe CLI?

hearty timber
haughty saddle
#

merci!