#beast_schedule-udpate
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/1281340412522664027
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
const subscriptionSchedule =
await stripe.subscriptionSchedules.create({
from_subscription: stripeSubscription.id,
});
await stripe.subscriptionSchedules.update(subscriptionSchedule.id, {
phases: [
{
items: [
{
price: stripeSubscription.items.data[0].price
.id,
quantity: 1,
},
],
start_date: stripeSubscription.current_period_start,
end_date: stripeSubscription.current_period_end,
},
{
items: [
{
price: new_price_id,
quantity: 1,
},
],
start_date: stripeSubscription.current_period_end,
},
],
proration_behavior: 'none',
});
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Hi there ๐ looking at the code you shared and the request, it looks like you're using the Subscription's current period's start date, rather than reusing the start date of the first phase of the Subscription Schedule.
but why are those even different in the first /place? If I immediately create the subscription schedule off the subscription, shouldnt they be the same
and so should the end date be the current phases' end date too?
Updated code now:
const subscriptionSchedule =
await stripe.subscriptionSchedules.create({
from_subscription: stripeSubscription.id,
});
await stripe.subscriptionSchedules.update(subscriptionSchedule.id, {
phases: [
{
items: [
{
price: stripeSubscription.items.data[0].price
.id,
quantity: 1,
},
],
start_date:
subscriptionSchedule.current_phase?.start_date,
end_date: subscriptionSchedule.current_phase?.end_date,
},
{
items: [
{
price: new_price_id,
quantity: 1,
},
],
start_date:
subscriptionSchedule.current_phase?.end_date,
},
],
proration_behavior: 'none',
});
Let me take a closer look at those objects. While I do, yes, if you don't want to change the phase length of the Subscription Schedule then you should provide the existing end_date for its phases.
Hm, I'm not spotting where that start_date is coming from, checking with some teammates.
So the code above performs unexpectedly. So the subscription has been extended 8 weeks via free trial days. I want the subscription schedule to update the product when the free trial days run out, but instead it ignores the subscription's added free trial days and will just rebill the subscription at the regular interval (no free trial days factored in) and then updates the product to the new product at the date of subscription's end date + free trial days
This doesn't make sense as I just confirmed in testing the start_date and end_date im passing in are the correct dates.
the end_date being the subscription's end date + free trial days
await stripe.subscriptions.update(stripe_subscription_id, {
trial_end: new_end_date_epoch,
proration_behavior: 'none',
});
I run this right before running the code above
I don't see phases.trial in your Subscription Schedule update request, to indicate the phase should be a trial period:
https://docs.stripe.com/api/subscription_schedules/update#update_subscription_schedule-phases-trial
Subscription Schedules are pretty finicky, they will unset most values for a phase if you don't pass those values back in as part of your update request.
no because I first add free trial days to the subscription, and then create a subscription schedule around that
but now im thinking I should just not do the first part and do it all in the sub schedule
but would just be much easier for me to do it this way
So I'm a little confused. Looking at the creation request for the Subscription Schedule that you were trying to update, I see that trial is set to true for the first phase and that trial_end for that phase matches the trial_end on the Subscription object. Can you elaborate on what you mean when you say the trial period is being ignored?
But in general I agree, it sounds like it likely would be easier to create the Subscription Schedule sooner and then use it to structure your upcoming changes.
Can you elaborate on what you mean when you say the trial period is being ignored?
When I create the sub schedule, it updates the price id at the correct time, but when looking at the subscription, for some reason it still gets renewed / billed at the regular interval time of the subscription.
Ie:
Subscription created for 3 month cadency, Sept 1 -> Dec 1
I add 20 free trial days (so should now renew on dec 21)
Create sub schedule and update it using above code
after math is:
Subscription gets rebilled on Dec 1 for the original price id
Subscription gets updated to new price id on Dec 21
When it should just bill the customer on dec 21 for the new price id
beast_schedule-udpate
๐ taking over. I skimmed the thread but I'm not really following what you're describing yet. SubscriptionSchedules can be really tricky to understand and debug.
But if you take an existing Subscription and explicitly pass trial_end when you update it it should work. You seem to mention both the Subscription and SubscriptionSchedules APIs so I'm not fully following yet
Yeah so my original intent is for a subscription:
Add x free trial days to it
So sept 1 -> dec 1
add 20 free trial days (should renew dec 21)
and then I want to create a sub schedule to update the price id on the subscription such that on dec 21 the user gets billed for the new price id
Is the Subscription already on a trial for sept 1 -> dec 1?
okay so what do you expect to happen when you switch to a trial suddenly? Like that Subscription will be on a full trial period from now until Dec 21.
Or are you trying to explicitly have only Dec 1 -> Dec 21 in a trial?
Actually I just abandoned the free trial approach and just used a sub schedule instead and now it's working. I just wanted to be lazy and use this inital approach to save me time - I'm sorry to have wasted your time koopjah!
no waste at all. This is just so hard to do right, it's definitely not just you