#pascal_lin-subscriptions

1 messages · Page 1 of 1 (latest)

floral sky
#

but I am confuse about using subscription scheduler to manage exist subscription...

#

I also trying to using this parameter to make it work, but it seems could not setting phase while setting from_subscription

#
{
    "Succeed": false,
    "Err": "{\"status\":400,\"message\":\"You cannot set `phases` if `from_subscription` is set.\",\"request_id\":\"req_AwcJWv3IHV7YPA\",\"type\":\"invalid_request_error\"}"
}
gilded heron
#

yeah, you can't set the phase and convert an existing subscription into an subscription schedule

#

you need to do it in separate API calls

#
  1. convert the Subscription into a Subscription Schedule
  2. Then update / set the phases on the newly created Subscription Schedule
floral sky
#

but by doing this way, will I lost the existed subscription id?

#

I mean while I am doing step 1 —— convert subscription into a scheduler

weary citrus
#

you don't lose it no. The subscription still exists.

#

you're not converting it, you're create a schedule that manages the existing subscription.

floral sky
#

okay, thanks a lot, I will following your idea now

floral sky
#

@weary citrus hi, how can I setting a subscription scheduler start_date field to manage the start start of scheduler?

weary citrus
#

not sure I follow the question, what did you try or what problem did you run into it?

#

maybe this helps you

// 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,
      'plans' => [
        [
          'plan' => $silver->id,
          'quantity' => 1,
        ],
      ],
      "prorate" => "true"
    ],
    [
      "start_date" => $subscription->current_period_end,
      'plans' => [
        [
          'plan' => $gold->id,
          'quantity' => 1,
        ],
      ],
    ],
  ],
  "end_behavior" => "release"
]);
floral sky
#

I am trying to change the subscription items(change price) on next period by subscription scheduler

weary citrus
#

the above is how I change a subscription currently on one plan to a different plan at the end of the current period.

floral sky
#

ok, thanks, let me try

floral sky
#

@weary citrus you code example works fine, thanks for helping me🙇‍♂️

#

I am wrong about setting phases of the scheduler before😂

echo sedge
#

no worries, it happens