#naughty developer-subscription-schedules
1 messages · Page 1 of 1 (latest)
Hi 👋 seems like your request is either not passing in information for the current phase when making changes to the schedule, or is trying to make changes to the start date of the current phase.
$subscriptionSchedule = $stripe->subscriptionSchedules->create([
'from_subscription' => strval($stripe_id),
]);
$stripe->subscriptionSchedules->update(
$subscriptionSchedule->id,
[
'end_behavior' => 'release',
'phases' => [
[
'start_date' => $stripe_subscription->current_period_start,
'end_date' => $stripe_subscription->current_period_end,
'items' => [
[
'price' => strval($stripe_subscription->items["data"][0]["price"]["id"]),
'quantity' => strval($stripe_subscription->quantity)
],
],
],
[
'start_date' => $stripe_subscription->current_period_end,
'items' => [
[
'price' => strval($price_id),
'quantity' => strval($stripe_subscription->quantity)
],
]
],
]
]
);
im not really modifying the start period of the current phase
i set a scheduling for new price to start as soon as the first one is ended
Thanks for that snippet, could you also share the ID of a request that raised the error you mentioned so I can compare that with your code?
req_U3Be84HnD3WiDM
Thank you. That Subscription Schedule looks like it already had two phases defined, and your update request seemed to pass in two phases. Were you trying to update an existing phase, or add a new one to the list of phases that are already there?
i release any previous subscription schedules in case there is one already set up .
i make a new schedule and update it in two phases .
phase 1 is my current subscription and next phase is the one i desire on the end of 1st one.
Looking at the creation request for that Subscription Schedule, I see that it was created with two phases. From your description, it sounds like once you create the Subscription Schedule you then make a request to update it, am I understanding that correctly? And if so, what is it that you're trying to change with the update?
i have a package x which is paid , i do scheduling when i try to shift package x to package y which is free package.
in scheduling
i put up package x which is my current package as phase 0 and in next phase i put up package y in phase 1 which is activated when x is ended
in short im downgrading a subscription at period end
i took the inspiration from this post
https://stackoverflow.com/questions/16820212/stripe-downgrade-a-user-at-period-end
it worked perfectly before today ,idk what changed
Apologies for the delay, the server got a little busy. I'm focusing on this thread now and taking a closer look at the schedule and request.
thanks
When the Subscription Schedule was first created, it was created with two phases:
Phases:
0: [
Start: 1658151060 (Jul 18, 2022),
End: 1658583168 (Jul 23, 2022),
]
1: [
Start: 1658583168 (Jul 23, 2022),
End: 1690119168 (Jul 23, 2023),
]
https://dashboard.stripe.com/test/logs/req_3ahXvqJIebelGd
When you made the update request, the Subscription Schedule was still in the first phase, so it still contained two phases. This means in your update request, when you only passed two phases, this was interpreted as updates to the two current phases of the Subscription Schedule.
The update contents:
Phases:
0: [
Start: 1658151168 (Jul 18, 2022),
End: 1658583168 (Jul 23, 2022),
]
1: [
Start: 1658583168 (Jul 23, 2022),
End: not defined
]
(Bolded the mismatch in timestamps between the update request and the Subscription Schedule object)
oh i get it , thanks for the detailed analysis toby
i was busy being naughty , i didnt realize what i was doing wrong lmao
Hehe, happy to help!