#mathan
1 messages · Page 1 of 1 (latest)
👋 Hi there, Happy to help!
You can create a subscription schedule from an existing subscription:
https://stripe.com/docs/api/subscription_schedules/create#create_subscription_schedule-from_subscription
Then you should make an Update Call on that subscription Schedule:
https://stripe.com/docs/api/subscription_schedules/update#update_subscription_schedule-phases
with phases that ends at the current subscription end date
what is the code structure of create and updating in current subscription with a plan in PHP?
can you expand on the question a little?
I want to schedule the next cycle in the current subscription with another plan so what is the API structure in php
have you tried anything so far? what does your existing code look like?
No, i don't know how to add for the current subscription, if I add the from_subscription key I got error!
what's the error?
stripe->subscriptionSchedules->create([
'customer' => 'cus_4QFK8XrieeBDYp',
'start_date' => 1664272678,
'from_subscription' => 'sub_xxx',
'end_behavior' => 'release',
'phases' => [
[
'items' => [
[
'price' => 'plan_JiX4v6L7JY0Vyt',
'quantity' => 1,
],
],
'iterations' => 12,
],
],
]);
it's right?
no
you have to make two requests, one which is just ->create using from_subscription , to create the Schedule
then you have to make a second request to update that new Schedule
can you share the create and update API example from the scenario?
https://stripe.com/docs/billing/subscriptions/subscription-schedules/use-cases#existing-subscription has an example of the creation API.
when I create, how can I update it? any examples or structues?
Hi! I'm taking over this thread.
You can see some examples of updating a subscription schedule here: https://stripe.com/docs/billing/subscriptions/subscription-schedules#updating
I need to add only start_date what i do in end_date?
For the first phase, it should be start_date: subscription.current_period_start and end_date: subscription.current_period_end.
And then the second phase: start_date: subscription.current_period_end.
i don't understand the 2 phases concept?
If I understood correctly, you want the subscription to stay as is until the end of the current billing period, and then update the price of the subscription for the new billing period?
If so your schedule needs two phase:
- first phase, that ends at the end of the current billing cycle and keeps the same existing price
- second phase, that starts at the next billing period and changes the price