#mathan

1 messages · Page 1 of 1 (latest)

dry saffronBOT
hearty kestrel
worldly trout
#

what is the code structure of create and updating in current subscription with a plan in PHP?

tender pine
#

can you expand on the question a little?

worldly trout
#

I want to schedule the next cycle in the current subscription with another plan so what is the API structure in php

tender pine
#

have you tried anything so far? what does your existing code look like?

worldly trout
#

No, i don't know how to add for the current subscription, if I add the from_subscription key I got error!

tender pine
#

what's the error?

worldly trout
#

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?

tender pine
#

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

worldly trout
#

can you share the create and update API example from the scenario?

tender pine
worldly trout
#

when I create, how can I update it? any examples or structues?

cerulean vale
#

Hi! I'm taking over this thread.

worldly trout
cerulean vale
#

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.

worldly trout
#

i don't understand the 2 phases concept?

cerulean vale
#

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