#zaddler_unexpected

1 messages ยท Page 1 of 1 (latest)

hybrid stormBOT
#

๐Ÿ‘‹ Welcome to your new thread!

โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.

โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.

๐Ÿ”— This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1215260520379326534

๐Ÿ“ Have more to share? Add more details, code, screenshots, videos, etc. below.

steady vectorBOT
strong patrol
#

Stripe's behavior will cause him to change it to Free when he has already paid for the Premium Plan
It depends on how you are doing the updates

#

You can set proration to none

craggy jay
#

Oh, can you tell me where I can?

strong patrol
#

But wait, you want to keep the customer on the premium till the end of the premium Plan ?

strong patrol
#

I'm not if you can achieve that using the Dashboard

#

You need to use Stripe APIs, in your case you can use Subscirption Schedulers

craggy jay
strong patrol
#

You schedule the udpate at the end of the freemium phase

craggy jay
#

That is, to create the subscription it is with creation, but to change the plan it is with subscription schedule, correct?

strong patrol
#

You can create and do the change using subscription schedule

craggy jay
#

Let's assume that I go from a 2.99 premium plan (already paid) to a larger plan that is premium plus (3.99), is there a specific subscription schedule for this case?

strong patrol
#

It depends on what you want to do exactly? take proration or not

#

You have a wide range of options

craggy jay
#

The only thing I want is that when you change from a cheap plan to a more expensive one, I make the payments, and the changes are prorated, but when you go from an expensive plan to a cheaper plan, I just want you to keep the higher plan but charge in the following month the cheapest plan.

strong patrol
#

The only thing I want is that when you change from a cheap plan to a more expensive one, I make the payments, and the changes are prorated,
I think you already know how to achieve this.
but when you go from an expensive plan to a cheaper plan, I just want you to keep the higher plan but charge in the following month the cheapest plan.
You can use Subscription Scheduler for this

#

The only thing I want is that when you change from a cheap plan to a more expensive one, I make the payments, and the changes are prorated,
You can achieve this using the API https://docs.stripe.com/api/subscriptions/update
you pass proration_behavior: always_invoice and billing_cycle_anchor: now
but when you go from an expensive plan to a cheaper plan, I just want you to keep the higher plan but charge in the following month the cheapest plan.
you pass proration_behavior: none and billing_cycle_anchor: unchanged

craggy jay
#

Okay, understood, I'll try it later, another thing, is there a way to test this with the Stripe interface in developer mode?

strong patrol
#

Yes you can use Stripe CLI

craggy jay
#

I just tried this, and it doesn't work as it should

#

This is my code:

    const updatedSubscription = await this.stripe.subscriptions.update(
      activeSubscription.id,
      {
        items: [
          {
            id: activeSubscription.items.data[0].id,
            deleted: true,
            quantity: 1
          },
          {
            price: priceId,
            quantity: 1
          }
        ],
        default_payment_method: defaultPaymentMethod,
        proration_behavior: "none",
        billing_cycle_anchor: "unchanged"
      }
    );
strong patrol
#

What did you tried ? and what error are you getting ?

craggy jay
#

I'm trying to switch from a more expensive plan to a cheaper plan, but the expensive plan stays active, and the next one changes it to the cheaper plan.

steady vectorBOT
craggy jay
daring cave
#

๐Ÿ‘‹ taking over for my colleague. Let me catch up.

craggy jay
#

Alright

daring cave
#

give me a couple of minutes and I will be right there with you

craggy jay
#

Right

daring cave
#

would you mind sharing the request ID that you've tried?

craggy jay
#

where's the request ID?

daring cave
craggy jay
#

req_97Ajr64LKYXRFE

#

req_N9r7BhgtD1x6x3

craggy jay
daring cave
#

taking a look give me a couple of minutes

craggy jay
#

Alright

daring cave
#

when downgrading at the end of the billing cycle you need to use both proration_behavior: "none" and billing_cycle_anchor: "unchanged"

craggy jay
#

I just do it and keep it same

daring cave
#

you need to advance the clock to next billing month

#

to see the changes

craggy jay
#

I just did it and it stays on Free if you have already paid for an expensive plan.

craggy jay
daring cave
#

oh I see what you mean

#

the thing with this approach is that the price is changed directly on the subscription but no invoices are generated

#

so if you use the invoice.paid events to fulfill the subscriptions then you don't really care about the price on the subscription now

#

once the next invoice is paid (with the free plan), you can use the billing_reason: 'subscription_update' to switch your customer from one subscription to another

craggy jay
#

I understand, but then if you request the subscription ID it will tell you that the free subscription is active when really, it should be premium, right?

#

That is, to know the last active subscription is it through the invoice ID?

daring cave
#

yes instead of looking at the subscription's price you would look at the subscription's latest invoice items

craggy jay
#

Is there a way to know what the customer's active subscription is, whether to send them an invoice or subscription? or how can I know?

daring cave
#

you look at the customer subscriptions

#

but instead of looking at the price on the subscription item you would look at the subscription's latest_invoice items

#

but in all cases, you should rely on your own system to keep track of that

#

like if you're correctly using the webhook events and updating your system accordingly you won't really need to fetch the subscription objects from Stripe though

craggy jay
#

Honestly, the only thing I do is go by subscription.customer_updated and there I get the latest invoice which is latest_invoice, I guess it's okay to do it that way, right? by webhook events

daring cave
#

you shouldn't rely on customer.subscription.updated events for changing the subscription on your side

#

instead you should listen to invoice.paid events

craggy jay
#

stripe listen --forward-to localhost:3000/subscription/webhook

#

What is the difference between those 2 events?

daring cave
#

the customer.subscription.updated happens when any update occur on the customer's subscription whether it generates a payment or not

#

the invoice.paid event has a billing_reason field that describes why the invoice got created in the first place

craggy jay
#

I understand, but one question, I need that in my system, when a user deletes or cancels a subscription completely, upon completion, I need it to automatically generate a free subscription, I am guided by customer.subscription.deleted, is that okay? Or does it have to be on the invoice?

daring cave
#

do you want to still track the free subscription on Stripe?

steady vectorBOT
craggy jay
#

Yes but only if you do not have an active paid subscription

daring cave
#

then what I suggested should be appropriate for your use-case

#

instead of deleting a subscription

#

you would downgrade to the free price

craggy jay
#

I understand, I have made my system under the customer.subscription.updated event, and it has worked for me, I will try invoice, the issue with invoice is that I do not see that it sends the canceled_at event