#dashydasher

1 messages · Page 1 of 1 (latest)

warm wave
#

Hi there, can you share with me your code and request ID?

buoyant forge
#

hello, this is the request id: req_ZYXNhrbDYvFQQV

#

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

warm wave
#

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

buoyant forge
#

you mean of phase 0?

warm wave
#

Yes, phase 0, sorry for the typo

buoyant forge
#

im trying to set the end_date of current phase to now

#

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

halcyon palm
#

Hi! I'm taking over this thread. Please give me a few minutes to catch up.

buoyant forge
#

sure thing, thanks

halcyon palm
#

If I understand correctly, you are trying to update an existing subscription schedule to basically remove the first phase?

buoyant forge
#

yes

halcyon palm
#

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"
        }
    }
}
buoyant forge
#

getting that i cant modify the start date of current phase

#

req_brIO3SgMzYx9Zc

halcyon palm
#

OK, thanks for trying! Let me run some tests on my end.

buoyant forge
#

sure, thanks a lot for helping me

halcyon palm
#

I think I managed to make it work!

#

I recommend using the same start date that you used when creating this phase.

buoyant forge
#

yeah

halcyon palm
#

So something like start_date: 1641202494,

buoyant forge
#

thats what I was initially doing

#

and it works except for this one case

#

req_ZYXNhrbDYvFQQV

halcyon palm
#

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.

buoyant forge
#

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

halcyon palm
#

Strange, but yes I agree with your last sentence.