#Taylor

1 messages · Page 1 of 1 (latest)

amber parcelBOT
pulsar forge
#

how are you passing in that metadata?

If you pass in the metadata in https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-metadata, only the Checkout Session object will contain the metadata.

If you pass the metadata into subscription_data.metadata - the Subscription will contain that metadata, and so will the Invoice Line Items : https://stripe.com/docs/api/invoices/line_item#invoice_line_item_object-metadata

simple tree
#

I just add the userid in the frontend payment link with url parameters

pulsar forge
#

ah, i got a bit confused and thought you were passing in info in the metadata. Yes, the client_reference_id can only be found on the Checkout Session object. So only checkout.* events have it

#

you can always make a subsequent request to update the metadata on other related objects upon receipt of the checkout.session.completed events

simple tree
#

are you saying like updating a customers metadata with the user id?

pulsar forge
#

yes, if you need the user id on a Customer object. Based off your code though, it looks like you want it on the Subscription object instead

simple tree
#

So on checkout.subscription.completed I can do something like stripe.customers.update(session.id, { metadata: { clerkId: session.client_reference_id, } }) and then on the rest of the event types sent to my webhook I can grab the metadata: clerkId with the session.id and use that to update my clerk user data

#

would this work or am I missing something

pulsar forge
#

i think you meant checkout.session.complete . Upon receipt of that event, you can get the Subscription id from : https://stripe.com/docs/api/checkout/sessions/object#checkout_session_object-subscription

You'll then do something like

  'sub_1NsbqpJQtHgRImA7w2roaRjv',
  {metadata: {some_id: session.client_reference_id}}
);```