#bmizerany
1 messages ยท Page 1 of 1 (latest)
Yes there is! The checkout session create call has a subscription_data argument just for this purpose https://stripe.com/docs/api/checkout/sessions/create#create_checkout_session-subscription_data-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.
Im aware of that, but not how to do it via a portal session
am I thinking about this wrong maybe?
I see that I can add metadata to a configuration https://stripe.com/docs/api/customer_portal/configuration#portal_configuration_object-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.
does that work in the same way that subscription_data does? I'm assuming no, but hopeful I'm wrong! ๐
Whoops misread your message. Unfortunately that doesn't exist on the customer portal as far as I am aware
Okay. I wonder if there is a way to work backwards to the portal config that was in effect when the checkout session it created to create/update the subscription
than I can use meta on the config, and "attach" it to the subscription by unwinding the thread back
Can you tell me what more about what you are looking to do overall with this? Are you tracking something about your customer portal usage or about what your users are doing?
I want to attach metadata to subscriptions created in portal sessions
I mean even taking a step back from that, what do you want to do with that metadata?
I want to supress duplicate subscriptions without relying on a local catalog of IDs
And how are these subscriptions currently getting duplicated? The customer portal can't create subscriptions as far as I am aware, just update them.
I think have my answer, but here is one thing I'm hoping to accomplish with metadata: Attach a known stable identifier I can deterministically create (e.g. bring my own ID) and attach that to a subscription I create, then later look that back up using my ID (not stripe's).
I might choose to use that ID for a portal session to attach to a sub, or directly create the sub myself
either way, I only want one subscription
Hi there ๐ taking over, as my colleague needs to step away
It sounds like you're pretty much set, but I'll drop this here for you: https://stripe.com/docs/api/subscriptions/search
You can search for specific metadata values using the Search API.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Are there any outstanding questions I missed?
It seems I cannot do what I want, I was just clarifying
I'm aware of search on metadata
I want to attach metadata to the subscription a portal session creates or updates
e.g. add context to the portal session that sticks it on the sub, like subscription_data on checkout sessions
thank you all for your help.
Is there a way to know which subscription is owned by the Portal?
for a customer?
Yeah, so I have an idea that might work, so tell me if I'm off:
- Create the Portal Session
- Set up a webhook endpoint to listen for
billing_portal.session.createdEvent :https://stripe.com/docs/api/events/types#event_types-billing_portal.session.created - Code your webhook handler to get the Customer ID from the Billing Portal object in the webhook payload
- Use the Customer ID to make a Retrieve Customer API call and
expandthe Subscriptions list to get all the Subscriptions for that Customer: https://stripe.com/docs/api/customers/object#customer_object-subscriptions
I mean. That is one way to do it.
Wait. that doesn't tell me which sub the portal created
The portal doesn't create subscriptions though
How does it manage to maintain one active subscription from the initial "signup" to changes in plans?
across sessions?
I would image there is something tracking which subscription to update, or if a subscription needs to be created
I don't understand the question
Probably because I'm confused and new to the portal, I assumed it handled creating and managing a subscription.
Nope. Just managing. No creation
Do I need to tell the portal which subscription to update?
I don't see how to tell a billing portal session which subscription to change https://stripe.com/docs/api/customer_portal/sessions/create
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
The Billing Portal uses a Customer, not a Subscription. Customers can have multiple Subscriptions, so it will display all active Subscriptions for a Customer
I just saw that