#zaddler_unexpected
1 messages ยท Page 1 of 1 (latest)
๐ 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.
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
Oh, can you tell me where I can?
You disbale proration
But wait, you want to keep the customer on the premium till the end of the premium Plan ?
Yep
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
But is there any specific code that I have to add for these cases? It is only in the case if you do a downgrade
Yes you can follow this use case, its quiet similar to yours:
https://docs.stripe.com/billing/subscriptions/subscription-schedules/use-cases#downgrading-subscriptions
You schedule the udpate at the end of the freemium phase
That is, to create the subscription it is with creation, but to change the plan it is with subscription schedule, correct?
You can create and do the change using subscription schedule
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?
It depends on what you want to do exactly? take proration or not
You have a wide range of options
Check these guides and use cases:
https://docs.stripe.com/billing/subscriptions/upgrade-downgrade
https://docs.stripe.com/billing/subscriptions/prorations
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.
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 passproration_behavior: always_invoiceandbilling_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 passproration_behavior: noneandbilling_cycle_anchor: unchanged
I invite you to do some tests and simulation using Stripe Test clock:
https://docs.stripe.com/billing/testing/test-clocks
Okay, understood, I'll try it later, another thing, is there a way to test this with the Stripe interface in developer mode?
Yes you can use Stripe CLI
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"
}
);
What did you tried ? and what error are you getting ?
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.
I have had no errors, the behavior is not as desired
๐ taking over for my colleague. Let me catch up.
Alright
give me a couple of minutes and I will be right there with you
Right
would you mind sharing the request ID that you've tried?
where's the request ID?
Find help and support for Stripe. Our support site provides answers on all types of situations, including account information, charges and refunds, and subscriptions information. Get your questions answered and find international support for Stripe.
I think is this
taking a look give me a couple of minutes
Alright
when downgrading at the end of the billing cycle you need to use both proration_behavior: "none" and billing_cycle_anchor: "unchanged"
I just do it and keep it same
I just did it and it stays on Free if you have already paid for an expensive plan.
it Shouldn't show "Premium" after change from "Premium" to "Free"?
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
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?
yes instead of looking at the subscription's price you would look at the subscription's latest invoice items
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?
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
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
you shouldn't rely on customer.subscription.updated events for changing the subscription on your side
instead you should listen to invoice.paid events
stripe listen --forward-to localhost:3000/subscription/webhook
What is the difference between those 2 events?
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
and basically https://docs.stripe.com/api/invoices/object#invoice_object-billing_reason`subscription_create`, the different values (subscription_create,subscription_cycle, subscription_update, etc.) tells you what kind of action you need to perform
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
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?
do you want to still track the free subscription on Stripe?
Yes but only if you do not have an active paid subscription
then what I suggested should be appropriate for your use-case
instead of deleting a subscription
you would downgrade to the free price
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