#Admiral
1 messages ยท Page 1 of 1 (latest)
Hello ๐
The error message seems quite clear no?
You're trying to modify start date of current phase whiuch isn't allowed
yes, but I talked to one of your colleagues, he advised me to use start_date if I want to cancel subscription. I'm confused now, can I explain you what I'm trying to accomplish?
Sure, please provide as much details as possible ๐
I have yearly subscription, as user subscribes for that subscription, I want to trigger a schedule so it cancels the subscription after 1 year. and user doesn't get invoice after one year anymore
Gotcha. Give me just a sec
Are you trying to create a schedule from an existing subscription? OR are you starting a schedule when the user subscribes?
so when user completes the checkout session, in webhook, I try to create a schedule from existing subscription
Gotcha. So when you create a schedule from a subscription like this
https://stripe.com/docs/billing/subscriptions/subscription-schedules/use-cases#existing-subscription
The schedule has already started once it was created.
Now when you try and update it later on, you're setting a start_date which I think isn't needed here
I really appreciate the time you spent on this, thank you so much, so you think by removing start date, it should work?
๐
When you update a Sub Schedule the first phase must mirror the current period of the Subscription
So you need to use the Subscription's current_period_start for the start_date of Phase 0
gotcha, and would you please tell me whether I need to set anything else?
$stripe->subscriptionSchedules->update($schedule->id, [
'phases' => [
[
'items' => [
[
'price' => $itemPrice,
'quantity' => $itemQuantity,
],
],
'iterations' => 1,
'start_date' => 'now',
],
],
'end_behavior' => 'cancel',
]);
As we discussed yesterday the best way is to just test it!
We can't really tell you what will and won't work just from looking at a snippet of code.
So test it out and then if you get an error you troubleshoot based on the error.
If you don't get an error then you check to see if it is doing what you want/expect ๐
and one more question please, if I want to set a one day free trial in schedule as well, all I need to do is to set trial_end to 1 day in unix format? or I need to grab this value again from subscription?
You want to set the trial after the Subscription has already started?
no in next step, I wanna add 1 day free trial to my subscription, and now I want to update my schedule as such so it considers 1 day free trial as well.
I assume you want the trial on Subscription creation though, no?
yes
So then you wouldn't do that in the Schedule at all. You just create the Subscription with a trial and the Schedule will take the fact that the Subscription is on a trial into account in Phase 0.
thanks a lot for your clarification, because one of your colleagues said since I'm setting phases in schedule, it'll wipe out the previous and I need to use trial_end again to set it in a phase.
Hmmm I don't think that is the case but I don't remember 100%. Best thing to do is to try it out and see
I really appreciate your patience, thanks a lot. I'll try it out and reach out in case any error happens ๐