#shehzadnizamani_docs
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/1316638305940537365
đ Have more to share? Add more details, code, screenshots, videos, etc. below.
When I make a schedule API call, user is charged immediately, and their trial period is gone.
This is the expected behavior.
I want to know best way to schedule a downgrade, so if downgrade is scheduled during trial, user's trial is retained
You'd need to thetrial_endexplicitly in the phases: https://docs.stripe.com/billing/subscriptions/subscription-schedules#using-trials
Thank you @bleak jay follow up question, can I get user's current trial_end value from user's existing subscription object? From what I have tried so far I am unable to get user's trial_end of has_trial values
Also I can find in Stripe documentation how can I set trial_end, your documentation explains that I can pass phases.trial_end here:
https://docs.stripe.com/api/subscription_schedules/create#create_subscription_schedule-phases-trial_end
But when I try to do this typescript throws an error, do you have a link to doc with code example which shows how I can pass trial_end while getting value of trial_end from user's existing subscription?
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
can I get user's current trial_end value from user's existing subscription object?
You can get from thetrial_endon existing subscription: https://docs.stripe.com/api/subscriptions/object#subscription_object-trial_end
But when I try to do this typescript throws an error
Could you share your code on setting thetrial_endon the phases?
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
I think I figured that out how to pass trial_end when scheduling subscription downgrade. Could you verify if this code is correct:
const subscriptionScheduleUpdated = await this.stripe.subscriptionSchedules.update( subscriptionSchedule.id, { end_behavior: 'release', proration_behavior: 'none', phases: [ { items: [ { price: subscription.items.data[0].plan.id, }, ], start_date: subscription.current_period_start, // end_date: endDate, iterations: 1, trial_end: endDate, }, { items: [ { price: newPriceId, }, ], start_date: endDate, }, ], } );
This looks correct to me! I'd recommend testing with test clock to check whether this works as expected: https://docs.stripe.com/billing/testing/test-clocks
Thanks, I will test this out with test clock. One last question, since we are going to be using schedules to downgrade a user's subscription. Related usecase is user cancelling their subscription while downgrade is scheduled. What does Stripe recommends we do in this case. There are two possible flows we can perform:
- Cancel upcoming downgrade i.e release the downgrade schedule, and then perform cancellation by updating subscription and setting cancel_at_period_end: true,
- Second option is we update future schedule, which was supposed to downgrade user's subscription and set schedule end_behavior: 'cancel,
I want to know what Stripe recommends we do when doing downgrades along with cancellations
Either way is fine, but option (1) may be easier to maintain since you don't have to keep track of another object type - Subcription Schedule
Yes that is my thought too, thank you for your help