#Alex from Fuxam
1 messages · Page 1 of 1 (latest)
the right way is to use a Schedule.
When you use from_subscription, it creates a Schedule that has one phase which represents the current billing period.
to then say that you want something to change in future, you update the schedule to set two phases(one the current one, and one that starts at the end of the curent phase and use the new plan)
for example I do it something like this.
// schedule a change from gold to silver at the end of the period
$sched = \Stripe\SubscriptionSchedule::create([
'from_subscription' => $subscription->id,
]);
\Stripe\SubscriptionSchedule::update($sched->id, [
'phases' => [
[
"start_date" => $subscription->current_period_start,
"end_date" => $subscription->current_period_end,
'items' => [
[
'price' => $gold->id,
'quantity' => 1,
],
],
],
[
"start_date" => $subscription->current_period_end,
'items' => [
[
'price' => $silver->id,
'quantity' => 1,
],
],
],
],
"end_behavior" => "release"
]);