#lec1892

1 messages · Page 1 of 1 (latest)

sterile stoneBOT
last crow
#

Hello 👋

1 - how does stripe understand what is a downgrade and what is an upgrade?
Stripe doesn't really know if its an upgrade or a downgrade from an API perspective, The API just looks at the price object you pass in and calculate proration accordingly

2 - is it possible to create a price tree in stripe so I can query the tree to know when an upgrade or downgrade is happening?
Not really, what's the end goal here?

nimble frigate
#

my backend app needs to know when a customer performed an upgrade or downgrade
it would be easier to query this information from stripe instead of creating some kind of structure on our side
simply relying on the price monetary value to know if it is upgrade or downgrade is not enough for my use case

last crow
#

But your backend should know this already when you make a request to update the subscription though right?

Like let's say customer A is currently subscribed to price_123 and chooses price_456 to update to.
You can query your own database or Stripe API to see if the amount on the price is higher or lower. Based on that, you can determine if its an upgrade or downgrade

it would be easier to query this information from stripe instead of creating some kind of structure on our side
simply relying on the price monetary value to know if it is upgrade or downgrade is not enough for my use case
I don't know what you mean by that. If the amount/price is not the differentiating factor then what is?

nimble frigate
#

But your backend should know this already when you make a request to update the subscription though right?
The user performs the upgrade/downgrade directly on the stripe hosted customer portal. So my backend only knows that something happened when it receives a webhook from stripe.

If the amount/price is not the differentiating factor then what is?
The stakeholders from the project I'm working on want to have a dynamic structure. I as a developer just need to provide this structure to them, so they can tell what is an upgrade and what is a downgrade regardless of the monetary amount of each price, following their own business rules.

last crow
#

The user performs the upgrade/downgrade directly on the stripe hosted customer portal. So my backend only knows that something happened when it receives a webhook from stripe.
I see that the upgrade happens on the customer portal but the prices were defined by you/your stakeholders. So you would know what price reflects an upgrade versus what price reflects a downgrade. That's not something Stripe can decide.

The stakeholders from the project I'm working on want to have a dynamic structure. I as a developer just need to provide this structure to them, so they can tell what is an upgrade and what is a downgrade regardless of the monetary amount of each price, following their own business rules.
Exactly. From stripe perspective, "updates" are differentiated by either the amount or the recurring interval.
There's nothing else that can be configured. You would know what price the customer has subscribed to, so you'll need to map each price you configure to reflect an upgrade or downgrade.

You could use Price object metadata property for that.

nimble frigate
#

I was thinking about metadata also. Ok. Thank you.