#taisklein
1 messages ยท Page 1 of 1 (latest)
Hi there!
Do you pass an existing customer ID when creating the Checkout Session? https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-customer
So why don't you update the customer just before creating the Checkout Session?
Do I need to use the webhooks events to do that? I mean when customer created -> make the post to update the customer and assume that this is always after the checkout session is created? I use the stripe checkout with firebase extension
You could, but you don't need to use webhook event. In your existing code, just before creating the Checkout Session, write some code to update the customer.
Nice!! But here I dont have the customer ID
then I would need to get it
but do you mean here, right?
but I dont know if the customer is already created here
I though you already had a customer ID. If needed you could create one, and then pass it when you create the Checkout Session.
Here's the parameter to pass a customer ID when creating a Checkout Session: https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-customer
But taking a step back, can you clarify why exactly you need to update the customer before the payment is finished?
Nice!! Yes, I need to pass some metadata on the customer (user name and user tax ID) to integrate with e-notas
and when the customer is charged, the charge object must be send with this metadata
Got it! Then yes:
- First create the customer
- Then create the Checkout Session with that customer
- And then listen to the
checkout.session.completedevent to update the charge object
Thank you!! But I think I wont need to update the charge object, because if I update the customer object, when the customer is charged the charge object will already have the medatada sent, right?
If your customer has some metadata, then that metadata won't be added to the Checkout Session or PaymentIntent or Charge. It's up to you to update these objects with metadata if needed.
Ok, thank you!!
Happy to help ๐
๐ taking over for my colleague. Let me know if there's any follow-up Qs I can answer!