#HeyHey-subscription-upgrade

1 messages · Page 1 of 1 (latest)

clear tiger
tender dagger
#

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

clear tiger
tender dagger
#

So you would have to charge them for what they have used so far in the month and invocie and downgrade

clear tiger
clear tiger
tender dagger
#

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

clear tiger
#

But you'd need to reset the billing anchor to bill them immediately at the new price

tender dagger
#

But didnt i need prorations to "always_invoice"

clear tiger
#

Yes, but you don't want to create proration for their unused time in the billing cycle. Right?

tender dagger
#

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
clear tiger
#

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.

tender dagger
#

I like the second option

clear tiger
tender dagger
#

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

tender dagger
clear tiger
#

It's an epoch timestamp, seconds since 1/1/70

clear tiger
tender dagger
clear tiger
#

You can just pass now and we take care of it

tender dagger
#

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

clear tiger
#

You'll need to pass proration_behaviour: 'none' too

tender dagger
#

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

clear tiger
#

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

tender dagger
#

Okay thanks, how long is this thread active? Since i have to be away for some hours

clear tiger
#

We'll probably archive it after a couple hours. But we can easily unarchive it later or reference it for future questions

tender dagger
#

Okay thank you

thorny scroll
#

Hello!

tender dagger
#

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

thorny scroll
#

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?

tender dagger
#

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

thorny scroll
#

Let me check something real quick...

tender dagger
#

Ok

thorny scroll
#

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

tender dagger
#

So the status on the update subscription would be "past_due" if it didnt succeed the payment

thorny scroll
#

If the status of the subscription is past_due after a subscription update the it didn't succeed paying for that update

tender dagger
#

what event will i get if the card has insuffcient funds

thorny scroll
#

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

tender dagger
#

Hey, thank you

thorny scroll
#

👋

tender dagger
#

Trying to downgrade a subscription and getting this error

thorny scroll
#

Is this through the dashboard? Do you have the subscription ID I can take a look at?

tender dagger
#

This is from our front end

thorny scroll
#

Gotcha - so do you have the request ID that corresponds to this failure?

tender dagger
#

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

thorny scroll
#

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

tender dagger
#

Let me try to create a subscription and downgrade it

#

got the same

thorny scroll
#

Do you have the subscription ID or request ID for that?

tender dagger
#

yes

#

sub_1K75kUD3xpLeaDGmURCqNfue

thorny scroll
#

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?

tender dagger
#

Let me check

thorny scroll
#

"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

tender dagger
#

Ahh my bad, i was coding both upgrade and downgrade, and forgot to change the check that the tier is lower than the current subscription

#

Works now