#bmizerany

1 messages ยท Page 1 of 1 (latest)

cedar geyserBOT
soft sigil
oblique herald
#

Im aware of that, but not how to do it via a portal session

#

am I thinking about this wrong maybe?

#

does that work in the same way that subscription_data does? I'm assuming no, but hopeful I'm wrong! ๐Ÿ™‚

soft sigil
#

Whoops misread your message. Unfortunately that doesn't exist on the customer portal as far as I am aware

oblique herald
#

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

soft sigil
#

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?

oblique herald
#

I want to attach metadata to subscriptions created in portal sessions

soft sigil
#

I mean even taking a step back from that, what do you want to do with that metadata?

oblique herald
#

I want to supress duplicate subscriptions without relying on a local catalog of IDs

soft sigil
#

And how are these subscriptions currently getting duplicated? The customer portal can't create subscriptions as far as I am aware, just update them.

oblique herald
#

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

proven musk
#

Are there any outstanding questions I missed?

oblique herald
#

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?

proven musk
#

Yeah, so I have an idea that might work, so tell me if I'm off:

  1. Create the Portal Session
  2. Set up a webhook endpoint to listen for billing_portal.session.created Event :https://stripe.com/docs/api/events/types#event_types-billing_portal.session.created
  3. Code your webhook handler to get the Customer ID from the Billing Portal object in the webhook payload
  4. Use the Customer ID to make a Retrieve Customer API call and expand the Subscriptions list to get all the Subscriptions for that Customer: https://stripe.com/docs/api/customers/object#customer_object-subscriptions
oblique herald
#

I mean. That is one way to do it.

#

Wait. that doesn't tell me which sub the portal created

proven musk
#

The portal doesn't create subscriptions though

oblique herald
#

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

proven musk
#

I don't understand the question

oblique herald
#

Probably because I'm confused and new to the portal, I assumed it handled creating and managing a subscription.

proven musk
#

Nope. Just managing. No creation

oblique herald
#

Do I need to tell the portal which subscription to update?

proven musk
#

The Billing Portal uses a Customer, not a Subscription. Customers can have multiple Subscriptions, so it will display all active Subscriptions for a Customer

oblique herald
#

I just saw that