#Luis G - webhook metadata
1 messages · Page 1 of 1 (latest)
Where are you setting the metadata? On the Checkout Session or on its payment_intent_data?
And what event are you listening for?
on the backend first I create the session stripe.checkout.sessions.create and then the update stripe.webhookEndpoints.update y listen to charge.succeeded
I do receive the notification but the metadata object is empty
For the charge.succeeded notification?
yes
That event won't have the Checkout Session's metadata. You will want to listen for the checkout.session.completed event
thanks, I will try that
@craggy bolt is the workflow that I am using the correct one?
It sounds like your workflow is basically correct from what you have told me. Taking the payment via Checkout and listening for its success on a webhoook is a common way to do things
@craggy bolt There is something I still don't understand. Let's say that I have two users that start payment at the same time, so I update the metadata with two new entries. Then one user completes the payment and the other doesn't. I receive one notification, but how do I know which user paid?
Hi 👋 stepping in for @craggy bolt
Let me catch up a bit
Okay so when you say
I have two users..
Are these users Stripe customers?
@river breach ok thanks!
A checkout session is specific to an individual customer so I would think you could use the metadata and checkout.session.completed webhook event to identify which user completed their checkout.
so in the metadata I will have some ids, then the checkout session is completed, I will receive a post request with the metadata, how will I identify which id is the one of the completed session?
Well the Checkout Session object includes both a Stripe customer ID attribute as well as a customer email: https://stripe.com/docs/api/checkout/sessions/object#checkout_session_object-customer
Each checkout session is specific to a single customer. So the customer associated with the session when it is created should be the one who completes it.
ok ok, so I have to also save that info from my end? seems so complicated instead of just sending the id... What if the user opens two checkout sessions?
Okay...let's step back. How are you creating checkout sessions for a specific user?
Well checkout sends the user to the Stripe hosted page so your app loses direct interface with the user.
So I would think dropping a metadata: customer1 field in your checkout session and then listening for checkout.session.complete and checking the metadata on the Session object returned in the webhook event would still be a good approach.
Otherwise you could keep the user on your site by using Payment Intents and Stripe elements directly but that would be a lot more engineering on your part