#surajpatidar
1 messages · Page 1 of 1 (latest)
hi, could you elaborate on what you're trying to do? do you have any code you've tried so far?
yes
i wan to achive subscription using schedule
but i want work like susbcription.modify work with price change
I think I understand. So what have you tried so far? did you run into a specific error?
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",
},
],
)
in this code what id do for upgrade plan immeditly effect with extra cost
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
okay but i have problem is
in downgrade
in downgrade i want effect show after the current priod end
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
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? 🙂
This Subscription is managed by a Schedule and can't be updated this
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.
okay
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,
},
],
},
],
});
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,
},
],
},
],
});
but it charge both this month extra and nex month plan charge
sorry, I can't understand your English.
Can you share an example in_xxx where that is the case?
yes