#okay
1 messages · Page 1 of 1 (latest)
hello!
Is it possible to tell the differentiate when a subscription is renewed and when a subscription plan changes?
you can tell from the billing_reason : https://stripe.com/docs/api/invoices/object#invoice_object-billing_reason
I want it also make it so that when a user upgrades to a higher tier, the difference between the higher tier and lower tier will be added to their account. (e.g basic offers 50, premium offers 150. User upgrades from basic to premium, giving them 100 more credits)
I'm afraid i don't quite understand the ask or issue, can you elaborate more?
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Let’s say I have 3 products, which each give a certain amount of credits every month. These credits are handled on our application, so you don’t need to worry much about what they do.
Here are the example subscriptions:
Basic: 50 credits per month
Plus: 100 credits per month
Premium: 150 credits per month
I want to make it so that when a user upgrades tiers through the billing portal, they will receive the difference of credits. So if a user is on the basic plan and then upgrades to the premium plan, they will instantly receive an extra 100 credits. I can do this by getting the product id from the event and subtracting monthly credit count it offers by the users current monthly credits. Then the result amount of credits will be added to the user.
However, the issue is that a user can upgrade to premium, then downgrade to basic, then to premium again, etc. for infinite credits. Is there is a way to check the highest subscription tier a user had within the current billing period?
Is there is a way to check the highest subscription tier a user had within the current billing period?
No, that's something which you would need to keep track of yourself
Do you think checking to see if the invoice was $0 is a valid method instead?
Because if the user downgrades then upgrades it doesn’t cost anything
i'd suggest testing it out yourself to see if it fits your use case. In case you haven't seen this yet, you can use test clocks to mimic the passing of time : https://stripe.com/docs/billing/testing/test-clocks