#varovas
1 messages · Page 1 of 1 (latest)
Hi there!
You can find an example of this here: https://stripe.com/docs/billing/subscriptions/subscription-schedules/use-cases#existing-subscription
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."
You need to make 2 API calls:
- Create the schedule (as shown above)
- Then update the schedule
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."
Can you share the request ID (req_xxx)? You can find it here https://dashboard.stripe.com/test/logs
Create: req_InWLBwg8dAAMMA
Update: req_netaRFrCVRNWIu
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.
So i need pass existing phase to update?
That is correct
Hmm
but current phase does not return its current iteration
Should I set it to 1 or something?
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.
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 ?
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.