#andygee
1 messages · Page 1 of 1 (latest)
Hi there, I don't think your customer can set a metadat and client_reference_id through customer billing portal.
Hi Jack, the metadata is attached to the product and the client_reference_id is set in the url of the payment link, and i need this information back whenever a customers subscription is updated. Is this possible?
In the webhook
You need to listen to checkout.session.completed event. in the event hanlding, you can get the client_reference_id directly from the session object (https://stripe.com/docs/api/checkout/sessions/object?lang=node#checkout_session_object-client_reference_id). But you need to expand the line_items (https://stripe.com/docs/api/checkout/sessions/object?lang=node#checkout_session_object-line_items) to retrieve the prices, and the associated products
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Thanks, this information does not seem to be available in the "customer.subscription.updated" though when a user has updated their subscription.
What information? do you have the event ID?
The details i need back are the metadata i added to the product and the client_reference_id that i added to the url of the payment link
You have the product ID in the response, you can retrieve (https://stripe.com/docs/api/products/retrieve?lang=node#retrieve_product) the product object and get its metadata.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
cool, i can see that the metadata would be returned but how about retrieving the client_reference_id?
Thanks for your help btw
You need to listen to checkout.session.completed event. in the event hanlding, you can get the client_reference_id directly from the session object (https://stripe.com/docs/api/checkout/sessions/object?lang=node#checkout_session_object-client_reference_id).
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
that works in the "checkout.session.completed" webhook event but not the "customer.subscription.updated" when the user has updated their subscription.
The "client_reference_id" is not returned in the "customer.subscription.updated" webhook
the client_reference_id is set on the checkout session object, and you can't retrieve it from a different subscriptoin object.
Right ok, so the client_reference_id is not the way to store a user ID when using a payment link to purchase a subscription? Is there a payment link param i can use to send the user ID from my site over to stripe and then retrieve it in any webhook?
Hi! I'm taking over from my colleague. Please, give me a moment to catch up.
Payment Links are not designed to be used with persistent customers. If you have a web server that generates Payment Links, it's better to use Stripe Checkout: https://stripe.com/docs/payments/checkout
Hi vanya, right ok, thanks, I had a feeling I might be stretching the limits of what a payment link has been built for. Thanks
Yes, as soon as it gets to automatically generating the link, it's better to switch to Checkout.
Happy to help!