#admin1

1 messages · Page 1 of 1 (latest)

wild iglooBOT
outer nebula
#

Hi there!

grizzled mountain
#

yes please wait

#

req_6q4TSIW8QkfWke

shrewd stump
#

Hey! Taking over for my colleague. Let me catch up.

grizzled mountain
#

sure

shrewd stump
#

Thanks for sharing.
The error message looks explicite:

You can not update a phase that has already ended. Trying to update phase 0.
You are modifying the start date of the first phase: actually the start date is at 2022-10-14 08:20:07 +0000 (1665735607) in your request you are passing 1665735353

#

You need to pass the same start date to the request which should be 1665735607

grizzled mountain
#

but in the phase why the expired plan is listed ?

#

if you see the end date for the phase one it is expired

#

and the my current plan which i have upgraded is in the phase two

shrewd stump
#

but in the phase why the expired plan is listed ?
it's expired yes but it is something that define the subscription_schedule, so need to keep it

#

when doing further update, and you can't modify it as it's expired as you mentioned

grizzled mountain
#

ok so can you tell me how can i modify the subscription now

#

what will be the proper way

shrewd stump
#

As I mentioned above, you need to set the right start date of the first phase in the update request.

You need to pass the same start date of the phase 0 which should be 1665735607 and not 1665735353

grizzled mountain
#

so i need to pass that phase 0 and in the phase 1 the current plan which i want to continue till its expiration and in the phase 2 the new plan that i want to schedule right?

shrewd stump
#

Yes exactly

grizzled mountain
#

ok let me try it

#

i still got the error
req_MaUdbBFD7XUeH6

shrewd stump
#

I think the error is explicit yet again:

There is a gap between phase 0 (1665735353, 1665735607) and phase 1 (1665735353, 1697271353).
the start_date of the phase 1 must be the end_date of the phase 0

grizzled mountain
#

yes it is

#

but the stating period for my current plan is 1697271353

shrewd stump
#

According to the requestId you shared, the start_date of the two phases are the same 1665735353 is it normal ?

grizzled mountain
#

it shound be

#

let me debug it once kindly help help me with it please

#

so 1 firstly i have created a subscription
like this
subscription = stripe.Subscription.create(
customer=customer.id,
items=[{"price": data["price_id"],},],
payment_behavior="default_incomplete",
payment_settings={"save_default_payment_method": "on_subscription"},
expand=["latest_invoice.payment_intent"],
)

#

i am using the django

#

and then i have downgraded the subscription pass by passing current phase in phase 0 and new phase in phase 1

#

so my subscription was schedule for update when the current subscription expires

vapid plover
#

What's the ID of your schedule?

grizzled mountain
#

which shcedule

#

the downgrade one

#

?

vapid plover
#

The sub_sched_xxx ID

grizzled mountain
#

sub_sched_1Lsj5aCy95Kg2yHQwWVp93hm

vapid plover
#

And what's the issue exactly?

grizzled mountain
#

well can you tell me how can i modify my subscription which has scheduled attach to it

vapid plover
#

You can't modify a subscription controlled by a schedule. You either:

  • Release it from the schedule to modify it directly.
  • Update the schedule to reflect the changes you want.
grizzled mountain
#

thank you

#

now can you tell me if i realise the schedule will the current phase how will current phase will behaviour

#

will it end at expiration?

vapid plover
#

The subscription will remain in the current state/billing period

#

It just means any future phases won't occur

grizzled mountain
#

thank you

#

if i were to modify the schedule can i start the new plan stright away with proration behaviour

#

updated_subscription = stripe.Subscription.modify(
sub_id,
payment_behavior="pending_if_incomplete",
proration_behavior="always_invoice",
items=[
{
"id": stripe_current_subscription["items"]["data"][0].id,
"price": price_id,
}
],
)

#

like this behaviour i need to modify my subscription

vapid plover
#

You're confusing yourself here. You say 'modify schedule' then share code to update a subscription

#

Which is it?

grizzled mountain
#

i want this behaviour in modify schedule

vapid plover
#

You need to update the phases parameter to reflect what you want to happen

grizzled mountain
#

updated_subscription = stripe.SubscriptionSchedule.modify(
stripe_current_subscription.schedule,
end_behavior="release",
phases=[
# only adding the phase for the new plan
{
"start_date": datetime.now(),
# "end_date": stripe_current_subscription.current_period_end,
"items": [
{
"price": stripe_current_subscription.plan.id,
"quantity": stripe_current_subscription.quantity,
}
],
}
],
)

vapid plover
#

But overall, it should work. Did you try it?

grizzled mountain
#

yes i forgot about the proration

#

ill try it and let you know

#

i cannot add the payment behaviour for schedule like subscription

#

?

vapid plover
#

No, pending updates aren't possible with schedules

grizzled mountain
#

ok

#

so how can i handle them

vapid plover
#

I guess you'd need to release the subscription from the schedule and update the subscription directly

#

Not sure why you need a schedule if you only have a single phase

grizzled mountain
#

this is the case where i want to update the scheduled subscription

#

so ..

#

firstly it will have two phases

#

well it is quite complicated

#

but i guess i figured out the solution thank you so much for your help.

vapid plover
#

sure, np

grizzled mountain
#

i am implementing the logic and testing all the scenarios if there is any issue ill let you kow