#horlaarsco_schedule-downgrade
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/1243240431878275252
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
@hoary echo You can use Subscription Schedules https://docs.stripe.com/billing/subscriptions/subscription-schedules/use-cases#downgrading-subscriptions
horlaarsco_schedule-downgrade
Oh didnt know about that, checking out the docs
When i call generate invoice is there a proration behaviour i can pass that will return 0 if it looks like a downgrade or is it safe to assume if i am getting negative from generate invoice it is a downgrade
I don't know what you mean by "generate Invoice" I'm sorry. You said you wanted to downgrade at the end of the period so there won't be no Invoice
Invoice would only be generated when the schedule takes effect right?
I pay for $100/year on January 1st. On May 23 I ask you to switch me to $10/month. You decide that instead of crediting me, it's best if I use my full year first so you put me on a SubscriptionSchedule so that on January 1st 2025 I switch to $10/month. There will be no Invoice until that January 1st 2025 when I switch to monthly
Does that make sense?
Yes that does what im confused about now is how to configure the phases
I try this:
const schedule = await this.stripe.subscriptionSchedules.create({
from_subscription: subscriptionId,
});
await this.stripe.subscriptionSchedules.update(schedule.id, {
phases: [
{
start_date: schedule.phases[0].start_date,
end_date: schedule.phases[0].end_date,
items: [
{ price: schedule.phases[0].items[0].price as string, },
],
},
{
start_date: schedule.phases[0].end_date,
items: [{ price:newPrice, quantity:sameQuantity }],
},
],
});
Getting: The last phase must specify either iterations (preferred) or end_date (advanced) if end_behavior is not `release
Hi ๐
I'm stepping in as my colleague needs to go. Can you outline the specific changes you want to make between the phases?
I just want to update the priceId to the new priceId at the end, quantity and everything else remains same
Okay, then what you have above should do the trick. I recommend you generate this in test mode and test out the schedule changes using our Test Clocks
https://docs.stripe.com/billing/testing/test-clocks
I get this error though
The last phase must specify either iterations (preferred) or end_date (advanced) if end_behavior is not `release
RIght, sorry. So you just want the subscription to make that one change and then continue like that unless canceled?
Yes, the current subscription would remain active unless cancelled but the downgrade should only happen at the end of the current billing period
Okay so in that case you would specify the end_behavior: "release" when creating the subscription: https://docs.stripe.com/api/subscription_schedules/create#create_subscription_schedule-end_behavior
Also I would put an interations: 1 in your second phase. That means that, after single billing cycle on the newPrice the schedule will be removed but the underlying Subscription will continue with the newPrice
const schedule = await this.stripe.subscriptionSchedules.create({
from_subscription: subscriptionId,
});
await this.stripe.subscriptionSchedules.update(schedule.id, {
phases: [
{
start_date: schedule.phases[0].start_date,
end_date: schedule.phases[0].end_date,
items: [{ price: schedule.phases[0].items[0].price as string }],
},
{
start_date: schedule.phases[0].end_date,
items: [{ price, quantity }],
iterations: 1,
},
],
end_behavior: 'release',
});
This seems to work, but just to confirm here is the scenario I want. I have a yearly subscription that started Jan 1st 2024 and would end Dec 31st 2024. I then choose to downgrade to monthly today.
If i run the above code with the subscription and the monthly priceId. My subscription would remain as is till 31st December 2024 and then on Jan 1st 2025, I'll be active with a monthly subscription?
I recommend you use Test Clocks to get a clear picture of exactly what changes will take place when. It's much easier than trying to reason through it just looking at your code