#NEWJOSSY
1 messages ยท Page 1 of 1 (latest)
Hello there )
Hi
You can cancel the subscription schedule via this API:
https://stripe.com/docs/api/subscription_schedules/cancel
Yeah but it will cancel subscription immediately
I want subscription to be canceled on the next payment date and when the next phase of schedule will be active
#dev-help message this is branch for reference
Not sure I understand exactly your use case ? you mean once the next invoice is paid, you want to cancel the subscription regardless if the Subscription Schedule ends or not ? or you want to wait until all subscription_schedule's phases to end then cancel the subscription ?
Okay let me explain more detailed
User requested to change billing cycle from monthly to annual. I have implemented that using Stripe Schedules
If user requested this change, his subscription is managed by scheduler now, and I cannot use Subscription API with property.
SubscriptionUpdateOptions options = new() { CancelAtPeriodEnd = true };
If I'll use Cancel for Scheduler, subscription will be immediately canceled and the next invoice for new annual subscription will be cancelled too. What I want is to cancel current monthly subscription at the date when invoice for new annual subscription should be paid. Here is my code for reference how I update billing cycle for customer from Monthly Standard subscription to Annual Standard subscription.
`SubscriptionScheduleCreateOptions createOptions = new()
{
FromSubscription = oldSubscription.Id,
};
SubscriptionScheduleService service = new SubscriptionScheduleService();
var schedule = await service.CreateAsync(createOptions);
SubscriptionScheduleUpdateOptions updateOptions = new SubscriptionScheduleUpdateOptions
{
Phases = new List<SubscriptionSchedulePhaseOptions>
{
new SubscriptionSchedulePhaseOptions
{
Iterations = 1,
StartDate = schedule.CurrentPhase.StartDate,
Items = new List<SubscriptionSchedulePhaseItemOptions>
{
new SubscriptionSchedulePhaseItemOptions { Price = oldSubscription.Items.Data[0].Price.Id },
},
},
new SubscriptionSchedulePhaseOptions
{
Items = new List<SubscriptionSchedulePhaseItemOptions>
{
new SubscriptionSchedulePhaseItemOptions { Price = newSubscriptionPriceId },
},
},
},
};
await service.UpdateAsync(schedule.Id, updateOptions);`
And here is the branch for this implementation discussed yesterday #dev-help message
Thanks for sharing these details.
What I want is to cancel current monthly subscription at the date when invoice for new annual subscription should be paid
I don't understand what you want to cancel? the existing Subscription is converted to a Subscription Scheduler. There'll be no new monthly invoices once the new annual Subscription is in place. The Subscription Schedule is just a wrapper to your existing Subscription. So you should just manipulate the new subscription scheduler.
Here is the result of canceled schedule
And here is the result of cancelling subscription via Subscription API
The second one cancels at May 4
When the first one cancels at the same moment when schedule was canceled
The second one is still active until May 4
I want the same behavior for schedule
So you configure you schedule to end on May 4th (the last phase need to end on May 4th) and you set end_behaviorto cancel:
https://stripe.com/docs/api/subscription_schedules/update#update_subscription_schedule-end_behavior
That are separate API calls
I need to update the scheduler, but how can I update phase?
You can update phases too:
https://stripe.com/docs/api/subscription_schedules/update#update_subscription_schedule-phases
How do i specify exact phase for edit ?
When doing phase update, you need to pass all phases (including the current one).
๐ taking over for my colleague. Let me know if there's any follow-up Qs I can answer!
the second phase has the same start_date and end_date
end_date: "1683201568"
start_date: "1683201568"
I want to cancel current user subscription on the next payment date. Like it's done with Subscription API
In Subscription API we have CancelAtPeriodEnd = true, is there any similar property in Subscription Scheduler ?
Hi ๐ when you mention Subscription Scheduler, are you referring to our Subscription Schedules?
If so, then you have those cancel the associated Subscription at the end of their lifecycle by setting the end_behavior to release:
https://stripe.com/docs/api/subscription_schedules/update?lang=node#update_subscription_schedule-end_behavior
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.