#xsliii_code

1 messages Β· Page 1 of 1 (latest)

little glacierBOT
#

πŸ‘‹ Welcome to your new thread!

⏲️ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

⏱️ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

πŸ”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1364947292641034331

πŸ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

fair sky
#

Hi, let me help you with this.

#

Why are you setting it to 0 if you want the quantity to be 5?

hollow terrace
#

That it is initially included to update later on when the customer decides to add 5.

#

Would this be a more appropriate way of doing so?

const portalSession = await stripe.billingPortal.sessions.create({
customer: 'cus_XXXX',
return_url: 'https://your-app.com/account',
flow_data: {
type: 'subscription_update_confirm',
subscription_update_confirm: {
subscription: 'sub_XXXX',
items: [
{
id: 'si_existing_item_id', // Existing subscription item ID
price: 'price_existing', // Existing price ID
},
{
price: 'price_new_feature', // New feature's price ID
quantity: 1, // Desired quantity
},
],
},
},
});

#

example: in my app, the customer buys a pro plan and is then allowed to buy additional stuff like rooms.
when he decides to buy 5 additional rooms, i want to send him to a stripe hosted site, that he confirms the subscription change of 1x Pro Plan + 5 additional rooms -> new invoice costs effective immediately.

the update is then handled in the app via webhooks.

little glacierBOT
hollow terrace
#

So my plan would be to send him to the billingPortal with "subscription_update_confirm" and the added/ updated lineItem.

I'm not sure if this is the correct workflow?

modern salmon
#

Hey there, stepping in for Vanya who needs to step away

#

When you try this, I assume you are encountering an error?

#

The customer portal doesn't support updates on subscription with multiple items/products:

Customer portal limitations
The customer portal has the following limitations:

#

You will need to make that update to the subscription directly, and manage the associated payment flows

hollow terrace
#

Thanks for your answer!

This would be my new approach:

  1. I show the new prices for the Subscription Changes via "stripe.invoices.retrieveUpcoming" in my app, and ask to confirm these.
  2. After Confirm, i update directly via api with stripe.subscriptions.update and a second lineItem with priceId
  3. webhook will inform me about updated subscription, so that i can allow this in my app.

Is this correct?

#

Side-Question: what is then a usual workflow for subscription_update_confirm ? I taught this will allow me to change an active subscription where customer has to confirm directly in the stripe hosted site.

modern salmon
# hollow terrace Thanks for your answer! This would be my new approach: 1. I show the new prices...

Yes that sounds right. And if you want to match any prorated amounts to the penny, you can include proration_date in the upcoming invoice and subscription update request so that changes are applied with the same start date.
https://docs.stripe.com/api/invoices/create_preview#create_create_preview-subscription_details-proration_date
https://docs.stripe.com/api/subscriptions/update#update_subscription-proration_date

modern salmon
hollow terrace
hollow terrace
modern salmon
#

NP!

#

I'll share feedback internally that you'd like to be able to use this with multiple products πŸ™‚

hollow terrace
#

Thanks! I've also read about this earlier in the stripe forum from other users trying the same. Might be a good thing to have all handling in the stripe hosted website without doing Previews or any other custom implementation to show that the subscription will change.

modern salmon
#

If you can share any object ID from your account, I can attach your account to the feedback entry to allow us to contact you in future if we are working on this.

#

(and price or sub id will do, like price_123 or sub_456)

hollow terrace