#surajpatidar

1 messages · Page 1 of 1 (latest)

wicked parrotBOT
mystic magnet
#

hi, could you elaborate on what you're trying to do? do you have any code you've tried so far?

chrome tide
#

yes

#

i wan to achive subscription using schedule

#

but i want work like susbcription.modify work with price change

mystic magnet
#

I think I understand. So what have you tried so far? did you run into a specific error?

chrome tide
#

stripe.SubscriptionSchedule.modify(
user.subscription.schedule.id,
proration_behavior="always_invoice",
phases=[
{'items':
[
{
'price': new_plan.id,
'quantity': 1,
}
],
'end_date': end_date,
'start_date': start_date,
"proration_behavior": "always_invoice",
},

                    ],
                )
chrome tide
mystic magnet
#

if you want it to be immediate then it's probably best to just update the Subscription itself directly, no need to use a Schedule I think

chrome tide
#

okay but i have problem is

#

in downgrade

#

in downgrade i want effect show after the current priod end

mystic magnet
#

yep, so you'd use the Schedule to do downgrades and update the Sub directly for upgrades

#

is there an error if you try to update the Sub directly? I don't remember if it's possible or not

chrome tide
#

yes

#

it show subscription handle from schedule

mystic magnet
#

what does that mean?

#

like I think I know what you mean, like you got a specific error message like "This Subscription is managed by a Schedule and can't be updated" , but then why would you not just tell me the exact error message? 🙂

chrome tide
#

This Subscription is managed by a Schedule and can't be updated this

mystic magnet
#

ok! that's what I thought

#

then yeah, you have to use a Schedule to update instead. That's pretty complicated unfortuantely

#

you would need to pass two phases, where the first phase ends "now", and the second phase starts "now" too, with the new price.

mystic magnet
#

something like this

#
subscriptionSchedule = await stripe.subscriptionSchedules.update(subscriptionSchedule.id, {
  phases: [
    {
      start_date:subscriptionSchedule.phases[0].start_date,
      end_date:"now", // end now
      items: [
        {
          price: 'plan_DQYe83yUGgx1LE',
          quantity: 1,
        },
      ],
    },
    {
      start_date:"now", //start now
      items: [
        {
          price: 'plan_O2lRwXzbB8f7gh', // new price
          quantity: 1,
        },
      ],
    },
  ],
});
chrome tide
#

but it not charge immeditly

#

i have already try

mystic magnet
#

it does if you pass proration_behavior:"always_invoice"

#
subscriptionSchedule = await stripe.subscriptionSchedules.update(subscriptionSchedule.id, {
  proration_behavior:"always_invoice",
  phases: [
    {
      start_date:subscriptionSchedule.phases[0].start_date,
      end_date:"now", // end now
      items: [
        {
          price: 'plan_DQYe83yUGgx1LE',
          quantity: 1,
        },
      ],
    },
    {
      start_date:"now", //start now
      items: [
        {
          price: 'plan_O2lRwXzbB8f7gh', // new price
          quantity: 1,
        },
      ],
    },
  ],
});
chrome tide
#

but it charge both this month extra and nex month plan charge

mystic magnet
fresh pagoda
#

Can you share an example in_xxx where that is the case?

chrome tide
#

yes