#xsliii_code
1 messages Β· Page 1 of 1 (latest)
π 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.
Hi, let me help you with this.
Why are you setting it to 0 if you want the quantity to be 5?
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.
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?
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:
- If subscriptions use any of the following, customers can only cancel them in the portal (they canβt update such subscriptions):
- Multiple products
https://docs.stripe.com/customer-management#customer-portal-limitations
You will need to make that update to the subscription directly, and manage the associated payment flows
Thanks for your answer!
This would be my new approach:
- I show the new prices for the Subscription Changes via "stripe.invoices.retrieveUpcoming" in my app, and ask to confirm these.
- After Confirm, i update directly via api with stripe.subscriptions.update and a second lineItem with priceId
- 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.
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
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
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 is the correct usage, yes, but it is limited to updating a single subscription item. For example, updating a software license from 5 seats to 10 seats per month.
Your use case doesn't work today because it is a second product/item.
Thanks for confirming, I will do it like this π
Alright, thank you for your help.
NP!
I'll share feedback internally that you'd like to be able to use this with multiple products π
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.
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)
Does a product id lead you also to my account?
pro plan = prod_NWkOEVa9aTrSSK
additional item = prod_NmiBNjU4rGkC2d