#Admiral

1 messages ยท Page 1 of 1 (latest)

prisma quartzBOT
somber python
#

Hello ๐Ÿ‘‹
The error message seems quite clear no?
You're trying to modify start date of current phase whiuch isn't allowed

dry pilot
#

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?

somber python
#

Sure, please provide as much details as possible ๐Ÿ™‚

dry pilot
#

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

somber python
#

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?

dry pilot
#

so when user completes the checkout session, in webhook, I try to create a schedule from existing subscription

somber python
dry pilot
#

I really appreciate the time you spent on this, thank you so much, so you think by removing start date, it should work?

prisma burrow
#

๐Ÿ‘‹

#

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

dry pilot
#

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',
]);

prisma burrow
#

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 ๐Ÿ™‚

dry pilot
#

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?

prisma burrow
#

You want to set the trial after the Subscription has already started?

dry pilot
#

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.

prisma burrow
#

I assume you want the trial on Subscription creation though, no?

dry pilot
#

yes

prisma burrow
#

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.

dry pilot
#

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.

prisma burrow
#

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

dry pilot
#

I really appreciate your patience, thanks a lot. I'll try it out and reach out in case any error happens ๐Ÿ™‚