#davidthorand
1 messages ยท Page 1 of 1 (latest)
Hello! We'll be with you shortly. Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- davidthorand, 21 hours ago, 19 messages
- davidthorand, 3 days ago, 15 messages
Hi
Can you share an example please ?
Sure! So let's say a customer is on the "Starter" Plan and now wants to upgrade to the "Pro" Plan. I want them to see a preview of what to expect cost-wise from the new plan. So what I'd so is retreive an upcoming invoice with the requested plan/it's price ID.
So far so good. Another thing that needs to be kept in mind is that in case of the new price having a higher amount than the current price, the upgrade should happen immediately. In case of a downgrade, it should happen at the end of the current billing period.
Does that help?
Do you have a Subscription Id ?
Yes
the upgrade should happen immediately. In case of a downgrade, it should happen at the end of the current billing period.
YOu can manage this using Subscription Schedule
Yes, but I want to show the customer a preview first before creating a schedule of the actual subscription update
When downgrading try to set the proration date as the end of the current billing period:
https://stripe.com/docs/api/invoices/upcoming#upcoming_invoice-subscription_proration_date
Does not seem to work:
[1] { currentPeriodEnd: '2024-12-12T11:53:26.000Z' }
[1] { newPeriodStart: '2023-12-12T12:24:38.000Z' }
[1] { newPeriodEnd: '2024-01-12T12:24:38.000Z' }
What is the issue/result ?
The expected newPeriodStart is after currentPeriodEnd. But it's not
These fields refer to what in Stripe API ?
Can you share the SusbcriptionId you are doing your test with
The fields come from:
const currentPeriodEnd: currentSubscription.current_period_end;
const newPeriodStart = previewInvoice.lines.data[0].period.start;
const newPeriodEnd = previewInvoice.lines.data[0].period.end;
The Subscription ID is: sub_1OLWURAuRq0b7FtTBvRzrK9l
Why you are comparing the preview invoice dates with the current subscription period ?
What value are you passing to the proration_date ?
currentPeriodEnd
I'm just trying to access the date when the updated subscription starts and will be renewed. I mean I can definitely calculate this myself but I'd like to prevent mixing Stripe logic with custom stuff
Hi! I'm taking over from my colleague. Please, give me a moment to catch up.
Could you please share the Request ID req_xxx? https://support.stripe.com/questions/finding-the-id-for-an-api-request
I don't see that you're sending the subscription_proration_date: https://stripe.com/docs/api/invoices/upcoming#upcoming_invoice-subscription_proration_date
Yes, you're right. I commented it out to try something different. New Request ID incoming
req_8eAYDugyr1E5vR
Do the responses differ? (I can't see the response of the GET requests on my side)
Haven't compared every value but the relevant ones seem to be the same (new period start & end)
I need a moment to check something...
I see that the proration_behavior is identical to always_invoice (bills immediately) when you change the billing cycle: https://stripe.com/docs/billing/subscriptions/upgrade-downgrade#immediate-payment
Maybe that's the reason why it ignores the subscription_proration_date.
So what should it be then? none? Because then the request would fail since you can not specify a proration date if no proration is being done (see req_PdQRvz50Pbiz4l)
By default the proration date is "now"
And when I set it to create_prorations the result is the same as before
"create_prorations" falls back to "always_invoice" in the case when you change the billing cycle, as the above article suggests. Meaning, no matter what proration_behavior you set, it will be always_invoice.
I don't follow. So how can I make it work then?
Updating subscriptions is always tricky, let me try a few ideas...
It's weird that almost all update scenarios work perfectly fine except downgrading from a yearly interval to a monthly interval
Ok, as a workaround you can add a trial period till the end of the current cycle: https://stripe.com/docs/api/invoices/upcoming#upcoming_invoice-subscription_trial_end
This did not work either, plus it broke some other already working scenarios
req_HGbetjxZ1G9uDG
Or does it need to be combined with another param?
Can you try proration_behavior: "none"?
Same result. Is there really no "standard" way of letting the customer preview what happens to their subscription if they change to another price?
I am actually not sure what do you want to calculate if you update (yearly -> monthly) the subscription at the end of the current cycle? The bill will just be the monthly amount, that's it. Unless there's a misunderstanding.
Expected outcome is that the customer sees the following information:
- When will the next charge occur?
- What will it cost?
- When will it renew after the first charge?
So let's say you have a yearly plan since today and want to upgrade to a monthly plan for 20 EUR/mo. The data would be:
- Next charge: 12.12.2024
- Cost: 20 EUR/mo
- Renews at: 12.01.2025
You can't really set upgrades/downgrades on X date in future like that where the billing interval changes (i.e. yearly -> monthly) without using a schedule. We will always immediately reset the billing anchor in those scenarios
If your intention is to schedule these upgrades/downgrades on a specific date, look at: https://stripe.com/docs/billing/subscriptions/subscription-schedules/use-cases#upgrading-subscriptions
Which is why the endpoint returns a new period date of now
@errant totem for the actual subscription change, a schedule is definitely needed.
Just so we are on the same page here: There is no "stripe native way" to do what I want to do so I just have to handle it myself, right?
๐ sorry for the delay, stepping in as ynnoj needed to step away
Hey again ๐
Yes you are correct -- if you don't have a schedule attached then you would need to implement logic yourself
Got it! I guess I'll do that then, thanks for clarifying ๐
In the meantime I already took a look at how schedules work. It's not possible to schedule an update for an existing subscription, isn't it? It always creates a new one, right?
You can attach a schedule to an existing Subscription, yes.
You use from_subscription when you create the Schedule: https://stripe.com/docs/api/subscription_schedules/create#create_subscription_schedule-from_subscription
Then you update the Schedule to correspond with what you want
Ahhh I see. So I create the schedule for the existing subscription, add phases etc. afterwards and when it finally releases, it's still the same subscription as before, yes?
Yep
Does it need to be activated somehow? Or will this happen automatically once I added the phases etc.?
It happens immediately once phases are associated
Awesome
it's still the same subscription as before,
It is the same as the final phase
To be clear
But the same subscription ID, right?
Yes
Then it's exactly what I need, thank you ๐
Great!
Final question for today (hopefully): Is there some kind of service similar to the dev-help here which is more about plan modeling etc.? Would be super helpful to get some feedback on my setup here
We are happy to talk about any technical questions so we will help if we can, but otherwise you would want to reach out to our Support team via https://support.stripe.com/contact/login about any non-technical questions.