#varovas

1 messages · Page 1 of 1 (latest)

unborn sapphireBOT
graceful harness
#

Hi there!

mossy sinew
#

I saw this example, but then I cannot set schedule start_date

#

I get an error: "You can not modify the start date of the current phase."

graceful harness
#

You need to make 2 API calls:

  1. Create the schedule (as shown above)
  2. Then update the schedule
mossy sinew
#

I create schedule this way:

\Stripe\SubscriptionSchedule::create([
'from_subscription' => 'sub_GB98WOvaRAWPl6',
]);

#

Then i update schedule:

\Stripe\SubscriptionSchedule::update(
$subscriptionSchedule->id,
[
'phases' => [
[
'items' => [
[
'price' => '{{PRICE_DIGITAL}}',
'quantity' => 1,
],
[
'price' => '{{PRICE_PRINT}}',
'quantity' => 1,
],
],
'iterations' => 1,
'start_date' => 1677621600,
]
]
]);

#

And then I get an exception "You can not modify the start date of the current phase."

graceful harness
mossy sinew
#

Create: req_InWLBwg8dAAMMA
Update: req_netaRFrCVRNWIu

wise pulsar
#

Hi there 👋 jumping in as my teammate needed to step away, apologies for the delay. Please bear with me another moment while I catch up on the context here.

#

You're receiving that error because you're only passing in one phase, so our system thinks you're trying to update the current phase rather than adding a new one.

When updating a Subscription Schedule, you will need to include the state of the existing phases that you don't want to change as well.

mossy sinew
#

So i need pass existing phase to update?

wise pulsar
#

That is correct

mossy sinew
#

Hmm

#

but current phase does not return its current iteration

#

Should I set it to 1 or something?

wise pulsar
#

I believe that is expected since when the Subscription Schedule is created it only has a single phase with no expected end to that phase. You will need to provide enough information to indicate when you want the first phase to end and the second to begin. You can do this by defining iterations (usually the easiest approach so you don't have to calculate timestamps) or you can take explicit control over that using start_date and end_date for your phases.

mossy sinew
#

Yes, what I am trying to do is. I create schedule with an example that you provided. Then schedule has only phase. I am adding a new phase and set start_date to subscription current_period_end

#

So the question is, what should I do for the current phase. Add iterations: 1 or set end date to current_period_end ?

wise pulsar
#

Either should work, so I would suggest using whichever approach looks more natural to you, so if/when you need to review the code in the future it is more intuitive to you.