#kitem-Subscription
1 messages ยท Page 1 of 1 (latest)
Hey, sure, this sub_sched_1LAUUaE9n8wrXE2iHxzlaNZv
(is in test mode)
actually I want to schedule the update on sub_1LAURhE9n8wrXE2iBwK4YWeo
\Stripe\SubscriptionSchedule::create([
'customer' => $customer_stripe,
'end_behavior' => 'release',
'start_date' => $current_period_end,
'phases' => [
[
'items' => [
[
'price' => $price_id,
'quantity' => 1,
],
],
'iterations' => 1,
],
],
]);
this is the code used
OK, you should use the from_subscription param to create a subscription schedule for an existing subscription https://stripe.com/docs/api/subscription_schedules/create?lang=curl#create_subscription_schedule-from_subscription
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
After that, you can update the schedule's phases by including the downgrade phase https://stripe.com/docs/api/subscription_schedules/update?lang=curl#update_subscription_schedule-phases
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
ok, so specify the phases is mandatory, because I've tried to do that with from_subscription
in this way
$subscriptionUpdate = \Stripe\SubscriptionSchedule::create([
'end_behavior' => 'release',
'from_subscription' => $subscription_id,
'phases' => [
[
'items' => [
[
'price' => $price_id,
'quantity' => 1,
],
],
'iterations' => 1,
],
],
]);
this seems update directly the subscription, without waiting for the end of the current cycle
so I need to add there the "current phase" with the current price_id and the next phase with the new downgraded price_id?
You don't need to pass the phases when creating a subscription schedule with from_subscription param
ok but i don't want to update the subscription now, I want to schedule the update to the end of the current billing cycle
so you mean, something like this?
$subscriptionUpdate = \Stripe\SubscriptionSchedule::create([
'end_behavior' => 'release',
'from_subscription' => $subscription_id,
'items' => [
[
'price' => $price_id,
'quantity' => 1,
],
],
'iterations' => 1,
]);
You need to make two API calls
- Create the subscription schedule with from_subscription param
- Update the subscription schedule with the downgrading phase.
Ok, so is mandatory to
- create subscription schedule (only with from_subscription param?)
- update subscription schedule with the downgrade plan
to achieve this result, I'll try now
basically, like this stackoverflow response
https://stackoverflow.com/a/62308324/9267861
Yes exactly like this ๐