#HeyHey-subscription-upgrade
1 messages · Page 1 of 1 (latest)
Hey, would you be factoring in any prorations? You likely just need to pass proration_behaviour: 'always_invoice' when making the upgrade: https://stripe.com/docs/billing/subscriptions/upgrade-downgrade#immediate-payment
So you can upgrade the subscription and invoice immedietly and downgrade without invocing until the next cycle
So you upgrade their subscription id with the items price as the priceid ur upgrading to
Well, you can also downgrade and have prorated charges
So you would have to charge them for what they have used so far in the month and invocie and downgrade
Yeah, basically! You're updating the relevant Subscription Item to the Price object you want
Well in most scenarios they're billed at the beginning of the billing cycle. So you'd be refunding/crediting them if you switched mid cycle
But then they have access more exclusive stuff and if they downgrade i dont want them to pay less for that period they had more exclusive features available
You'd want to disable prorations then: https://stripe.com/docs/billing/subscriptions/prorations#disable-prorations
But you'd need to reset the billing anchor to bill them immediately at the new price
But didnt i need prorations to "always_invoice"
Yes, but you don't want to create proration for their unused time in the billing cycle. Right?
My goal is
User at tier 2 subscription plan:
-> Upgrades to tier 3, then charge for tier 3 immedietly and keep the
same cycle
User downgrades from tier 3 subscription plan:
-> Then we charge for the time used in tier 3, and set them on the
tier 2 plan with same cycle
For example, I'm on your 'standard' price which is $10 p/m. My billing cycle runs from the 1st of the month and you charge me $10 on December 1st. On December 15th I decide I want to upgrade to your $50 p/m price.
You have 2 options:
• Create prorations (i.e. refund me for the unused time on the $10 p/m price, which will offset against the $50 p/m). This will invoice immediately.
• Don't create prorations, and reset the billing cycle date to now (15th) and charge me for $50 immediately.
I like the second option
If you want to keep the same billing cycle then you need to use a trial to avoid the prorations. This is all documented here: https://stripe.com/docs/billing/subscriptions/billing-cycle
Okay, thanks. I have another question, currently stripe is in test mode and the billing cycle doesnt make sense
1639488714
this is one of the billing cycle anchors i get
But thats like jan 19 1970
For the second option how do i do this, i had to use trial?
Not it isn't: Tue Dec 14 2021 13:31:54 GMT+0000
It's an epoch timestamp, seconds since 1/1/70
If you're not bothered about the billing date you can just pass billing_cycle_anchor when updating: https://stripe.com/docs/billing/subscriptions/billing-cycle#changing
And billing_cycle_anchor would be just Date.now() / 1000 in js
Okay thanks il try to make this work, so if i got everything right
When upgrading a subscription i set the new priceid on the subscription id and pass billing_cycle_anchor: "now"
without any proration and trails
You'll need to pass proration_behaviour: 'none' too
Okay so all that info would charge them instantly for upgrading tier
And for downgrading i need to do the same?
And refund the remaining of the month at current tier
If you want to prorate the unused time when downgrading then you'd pass proration_behaviour: 'always_invoice', no need to change the billing cycle in that case
Okay thanks, how long is this thread active? Since i have to be away for some hours
We'll probably archive it after a couple hours. But we can easily unarchive it later or reference it for future questions
Okay thank you
Hello!
Thank you @thorny scroll ! I have a question regarding the update of a subscription
Do i need to listen to any event to know if it succeded or not?
const update = await stripe.subscriptions.update(
getSub.subscriptionId,
{
billing_cycle_anchor: 'now',
proration_behavior: 'none',
items: [
{
id: getSub.stripe.items.data[0].id,
price: getUpgrade.priceId,
},
],
}
)
Doing this atm
But i noticed my payment_intent.succeeded recieves an event from doing this aswell
So i was wondering if there is any change this fails, and what events i should listen for
Well, by default the update to the subscription can succeed but the invoice payment can still fail - are you asking how to track whether the invoice generated by the update has been paid for successfully?
Yes
I get this from the update aswell
So i can check for active?
Or can the status on update be active but invoice payment still fail
Let me check something real quick...
Ok
Just wanted to double check the behavior - yes, if payment on the newly created invoice fails for a subscription update then the status should transition to past_due. Alternatively, you could also just listen for the webhook events like invoice.payment_failed and payment_intent.payment_failed to be automatically notified of the failures through your webhook
So the status on the update subscription would be "past_due" if it didnt succeed the payment
If the status of the subscription is past_due after a subscription update the it didn't succeed paying for that update
what event will i get if the card has insuffcient funds
You'll just get the failure events I mentioned earlier, the specifics about why the payment was declined (like for insufficient funds) would be found in last_payment_error on the Payment Intent
👋
Trying to downgrade a subscription and getting this error
Is this through the dashboard? Do you have the subscription ID I can take a look at?
This is from our front end
Gotcha - so do you have the request ID that corresponds to this failure?
Let me see
My front end dev didnt have the sub id
I cant find it on stripe dashboard either
const update = await stripe.subscriptions.update(
getSub.subscriptionId,
{
proration_behavior: 'always_invoice',
items: [
{
id: getSub.stripe.items.data[0].id,
price: getUpgrade.priceId,
},
],
}
)
This is what i do to downgrade though
getUpgrade.priceId is just a call to get the price from our db
Do you see any failing upgrade requests in your dashboard at all? from a quick look I see nothing wrong with this code, but the request is really what we need to be able to tell what's wrong
Do you have the subscription ID or request ID for that?
Hm....I'm not seeing an upgrade request come into us at all. Have you added logging before your update request to confirm your code is reaching that point?
Let me check
"You can't use downgrade to upgrade sub" isn't an error that would come for us, so I'm guessing something is failing before you hit the code to make the update