#pascal_lin-subscriptions
1 messages · Page 1 of 1 (latest)
hello! you'll want to look into Subscription Schedules -
https://stripe.com/docs/billing/subscriptions/subscription-schedules
https://stripe.com/docs/billing/subscriptions/subscription-schedules/use-cases
I have been seems this docs: https://stripe.com/docs/billing/subscriptions/subscription-schedules/use-cases#downgrading-subscriptions
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\"}"
}
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
- convert the Subscription into a Subscription Schedule
- Then update / set the phases on the newly created Subscription Schedule
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
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.
okay, thanks a lot, I will following your idea now
@weary citrus hi, how can I setting a subscription scheduler start_date field to manage the start start of scheduler?
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"
]);
I am trying to change the subscription items(change price) on next period by subscription scheduler
the above is how I change a subscription currently on one plan to a different plan at the end of the current period.
ok, thanks, let me try
@weary citrus you code example works fine, thanks for helping me🙇♂️
I am wrong about setting phases of the scheduler before😂
no worries, it happens