#Rylan-checkout-metadata

1 messages ยท Page 1 of 1 (latest)

worn nacelle
#

Hi there! The easiest way to handle this is to add metadata to your Checkout Session.

#

The other option is to create the Customer ID ahead of the Checkout Session (create it when you customer authenticates) and then pass that Customer ID to the Checkout Session instead of having Checkout create it.

proud marten
#

How do I add that metadata to the Checkout Session?

worn nacelle
proud marten
#

How do I test via the Stripe CLI?

#

If I do ./stripe trigger checkout.session.completed, what my webhook receives has no metadata

worn nacelle
proud marten
#

wonderful thank you!

worn nacelle
#

Sure thing!

proud marten
#

I'm struggling to understand how to correctly add metadata to the PaymentIntent

./stripe trigger checkout.session.completed --add payment_intent:metadata={user_id: "123"}
`stripe trigger` accepts at maximum 1 positional argument. See `stripe trigger --help` for supported flags and usage
#

This seems to work. Am I using this correctly?

./stripe trigger --add payment_intent:metadata="{"user_id": "123"}" checkout.session.completed
worn nacelle
#

So yes that works, but it mostly depends on which webhook event you are listening to for where you want to set the metadata.

#

So that the metadata is carried down to the PaymentIntent

#

That is fine if you are using the payment_intent.succeeded event in your webhook handler.

#

If you are using checkout.session.completed then you want ./stripe trigger --add checkout_session:metadata="{"user_id": "123"}" checkout.session.completed I believe

#

Hmm actually that isn't right.

proud marten
#

The previous snippet I posted doesn't work either

#

Let me show you:

#
deus-backend-app-1  |       "id": "cs_test_a1oPOhqN9FpYbPsDitCMaBX6GQcTn0pNW7ZTGvQ4Be7t6DVh4Lg4GJ9K90",
deus-backend-app-1  |       "livemode": false,
deus-backend-app-1  |       "locale": null,
deus-backend-app-1  |       "metadata": {},
deus-backend-app-1  |       "mode": "payment",
deus-backend-app-1  |       "object": "checkout.session",
#

metadata is empty

#

Do I want override, not add?

#

override didn't work either

worn nacelle
#

Yeah it is empty because that is the session object, not the PaymentIntent

#

I don't remember the syntax for session object, one sec.

proud marten
#

Thank you ๐Ÿ™‚

#

I just noticed that the event type coming through is not a checkout.session.completed, but rather a customer.created

#

Let me know what the right syntax is?

worn nacelle
#

stripe trigger --add checkout_session:metadata.user_id=โ€œ123โ€ checkout.session.completed

#

Sorry, hadn't messed with this in a while

#

Took a moment

#

But the above should work