#Luis G - webhook metadata

1 messages · Page 1 of 1 (latest)

craggy bolt
#

Where are you setting the metadata? On the Checkout Session or on its payment_intent_data?

#

And what event are you listening for?

leaden hemlock
#

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

craggy bolt
#

For the charge.succeeded notification?

leaden hemlock
#

yes

craggy bolt
#

That event won't have the Checkout Session's metadata. You will want to listen for the checkout.session.completed event

leaden hemlock
#

thanks, I will try that

#

@craggy bolt is the workflow that I am using the correct one?

craggy bolt
#

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

leaden hemlock
#

@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?

river breach
#

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?

leaden hemlock
#

@river breach ok thanks!

river breach
#

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.

leaden hemlock
#

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?

river breach
leaden hemlock
#

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?

river breach
#

Okay...let's step back. How are you creating checkout sessions for a specific user?

leaden hemlock
#

I feel I am doing something wrong, seems too complicated with webhooks metadata

river breach
#

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