#OptimalSurprise-lifetime-revenue
1 messages · Page 1 of 1 (latest)
Hi there! Can you tell me more about exactly what you mean by that and exactly what you are looking to do?
Yes sure
So we have usage based plans e.g. volume based pricing
We'd like to charge our customers based on their lifetime usage and not just the usage in the month / billing period
Okay so sounds like you would need to retrieve the lifetime volume of the Customer and then adjust the Subscription accordingly.
Is the question how to actually do that?
Yes exactly
So i think we can get the usage record summary but I'm not sure how far we can go back
Okay so you likely want to list invoices for the Customer: https://stripe.com/docs/api/invoices/list
You can use those invoices to get the lifetime volume.
Then you would have different Prices based on different volume segments
And upgrade/downgrade the Customer's Subscription(s) based on their total lifetime volume
Which field should I look at in invoices to get the lifetime volume?
Also do we do the downgrade/ upgrade after invoice.paid is fired by the webhook?
The invoice object has a total which includes discounts/taxes or an amount_paid depending on which you want to use.
And yeah you likely would want to check each billing cycle so after invoice.paid would work well.
Is this the same approach used for graduated pricing?
Yeah pretty much. You would adjust your tiers based on lifetime volume.