#yony

1 messages ยท Page 1 of 1 (latest)

quaint basaltBOT
swift drum
#

Does the user ID here refer to Stripe customer ID or your own defined user ID?

tender kestrel
#

Our own defined user id

swift drum
#

Am I right to understand that you would like to store your own defined user ID in the Checkout Session that you will be able to retrieve it when receiving checkout.session.completed event?

tender kestrel
#

Yes, correct.
when receiving checkout.session.completed event, we want to store the subscription id for our own define user ID in the database.

swift drum
tender kestrel
#

Ok, so i can add a custom field in the metadata like the following?

const session = await stripe.checkout.sessions.create({ success_url: 'https://example.com/success', line_items: [ {price: 'price_H5ggYwtDq4fbrJ', quantity: 2}, ], mode: 'payment', user_id: '126373889494' });

swift drum
#

Nope. You should set your user_id kay-value pair in metadata field. For example,

const session = await stripe.checkout.sessions.create({
  success_url: 'https://example.com/success',
  cancel_url: 'https://example.com/cancel',
  line_items: [
    {price: 'price_xxx', quantity: 2},
  ],
  mode: 'payment',
  metadata: {
    user_id: 'user_123',
  },
});
tender kestrel
#

Ok checking

#

Ok great, I was able to get the user_id in the checkout session. Thanks very much @swift drum for your help.

swift drum
#

No problem! Happy to help ๐Ÿ˜„

tender kestrel
#

Just one last question, how to get the custom user_id metadata from the checkout.session.completed webhoook event?
is this going to be something like
event.data.object.metadata.user_id?

swift drum
#

It looks right to me

tender kestrel
#

Ok great, thanks @swift drum