#b-train_api
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/1243155462069686307
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
note that with Schedules there is no concept of adding things in a "relative" way, what you pass to phases is declarative and has to include the current state of the subscription as well (if you pass one phase, that is not adding one phase to what already exists, it's replacing what exists, with one phase)
This one is the new price invoice:
in_1PJYZfK2LjZlz2WUjERZM35i
Old price that keeps being billed:
in_1PJYX8K2LjZlz2WUfrenCl9L
hmm I'm not sure what you mean , this all looks normal.
req_P1TixyeWHUoOwT, that is you creating a subscription, where the first phase lasts for one iteration, on a $200 Price.
the next phase starts at the end of that period and switches to a $1.99 Price.
You used test clocks and advanced them
as expected, you have an initial period and invoice for $200, and then the next period starts with an invoice for $1.99. What did you want instead?
Sorry, i Sent the wrogn Id for the old invoice. the problem is that this invoice keeps appearing in the next months.
See this one:
in_1PJYZdK2LjZlz2WUiXecwOmr
sure, that's normal too? It's a normal subscription, you started it for a $200 price, it recurs every month for $200. You didn't make any updates to that subscription as far as I can see(correct me if I 'm wrong!). What did you did you expect to happen differently?
in req_P1TixyeWHUoOwT did you mean to create that Schedule for that existing Subscription? Because you didn't, you created a new Schedule + Subscription.
I tried to schedule a down grade to a lower price yes
then you need to do https://docs.stripe.com/billing/subscriptions/subscription-schedules/use-cases#existing-subscription so the schedule is actually for the exisitng subscription
So how can i schedule an update?
Do you have an example of schedule a downgrade for exsiting subscription?
it's https://docs.stripe.com/billing/subscriptions/subscription-schedules/use-cases#existing-subscription to create the Schedule object
and then you'd adapt https://docs.stripe.com/billing/subscriptions/subscription-schedules/use-cases#downgrading-subscriptions so it calls subscriptionSchedule->update on the ID returned, instead of subscriptionSchedule->create
OH okay let me try and get back to you!
Thank you!
It says - Error updating subscription: StripeInvalidRequestError: You cannot set phases if from_subscription is set.
So what should i change here:
const schedule = await stripe.subscriptionSchedules.create({
from_subscription: subscriptionId,
end_behavior: 'release', // keep the subscription active after the schedule ends
phases: [
{
items: [{
price: currentPriceId, // continue with current price
quantity: 1
}],
iterations: 1 // current phase lasts until the next billing cycle
},
{
items: [{
price: newPriceId, // new downgraded price
quantity: 1
}],
iterations: 12 // continue with new price for 12 cycles or indefinitely
}
],
});
And BTW how do i set it to keep on like that forever and not only for 12 iterations?
it has to be two separate calls
one to create the schedule using from_subscription, then another to update it
And BTW how do i set it to keep on like that forever and not only for 12 iterations?
end_behavior: 'release', , which you already have
technically you could do iterations:1 or just omit it on the second phase. The point is after the end of the described phases, the schedule stop applying to the subscription. Then if end_behavior: 'release', the subscription just continues forever in whatever state is in at that time, or with end_behavior: 'cancel' it would cancel
I am sorry but i have hard time to make this work wit the 2 separate calls, can you proivde any example for that?
what do you have so far?