#dashydasher
1 messages · Page 1 of 1 (latest)
hello, this is the request id: req_ZYXNhrbDYvFQQV
code is here: https://pastie.io/jlzebi.php
is it because of the start_date in phase 0?
the same code worked for quite some time until now, and it only breaks in this case so something must be off
The start_date 1630947918 of phase 1 is a past date (6 September 2021), which means it has already started
you can modify the future phases, but not the current one
you mean of phase 0?
Yes, phase 0, sorry for the typo
im trying to set the end_date of current phase to now
if i send pahse 0 without the start_date: https://pastie.io/slprlm.json
im getting *** stripe.error.InvalidRequestError: Request req_D1qfu4PSTqevmQ: The subscription schedule update is missing at least one phase with a start_date to anchor end dates to.
so im sending the start_date with the same exact timestamp the subscription started
'start_date': subscription_data.start_date
so
im trying to replicate the error on my test data
check out this reqest: req_fcJsr4BbOiMPCA
i have also sent the past date in start_date of phase 0
but the request passed
how is that possible?
@warm wave
Hi! I'm taking over this thread. Please give me a few minutes to catch up.
sure thing, thanks
If I understand correctly, you are trying to update an existing subscription schedule to basically remove the first phase?
yes
I haven't tested it yet, but have you tried simply removing the phase you want to remove? Something like this (based on the code you shared):
{
"end_behavior": "release",
"proration_behavior": "create_prorations",
"phases": {
//"0": {
// "end_date": "now",
// "plans": {
// "0": {
// "price": "plan_HNyz6Xrr87WITx",
// "quantity": "1"
// }
// }
//},
"0": { // <--- start at 0
"start_date": "now",
"end_date": 1643874146,
"plans": {
"0": {
"price": "plan_HNyz6Xrr87WITx",
"quantity": "1"
}
}
},
"1": {
"start_date": 1643874146,
"plans": {
"0": {
"price": "plan_HBzD2QLoAS72ww",
"quantity": "1",
"tax_rates": ""
}
},
"proration_behavior": "create_prorations",
"collection_method": "charge_automatically"
}
}
}
OK, thanks for trying! Let me run some tests on my end.
sure, thanks a lot for helping me
I think I managed to make it work!
You use this code: https://pastie.io/slprlm.json
And you simply add a start_date to your first phase.
I recommend using the same start date that you used when creating this phase.
yeah
So something like start_date: 1641202494,
thats what I was initially doing
and it works except for this one case
req_ZYXNhrbDYvFQQV
In this case the start_date of the first phase was 1638810318, but when you tried to update it you set it to 1630947918. Since it's a different start date you get an error message.
alright
im not really sure how that happened
first I get the subscription data subscription_data = stripe.Subscription.retrieve(sub_id)
then i create the schedule from subscription sub_sched = stripe.SubscriptionSchedule.create(from_subscription=sub_id)
then I modify the the schedule and in phase 0 im setting start date the same as subscription start date: 'start_date': subscription_data.start_date
and somehow the subscription start date turns out different than schedule phase 0 start date?
guess I could just do 'start_date': sub_sched.phases[0].start_date and that should work every time
Strange, but yes I agree with your last sentence.