#p3dry-metered-subscription-update
1 messages ยท Page 1 of 1 (latest)
HI ๐ I'm doing some testing to confirm as this scenario is a bit nuanced, but I believe Usage Records are associated with a specific Subscription Item. So if you delete the Subscription Item and then add a new one, I wouldn't expect the Usage Record to carry over to the new item, however I'm uncertain if updating the existing Subscription Item would preserve that Usage Record.
If you remove a fixed price item from a subscription the price it's prorated so it's not lose. We want something like that. We want to preserve the previous usage.
Like the fixed price item we don't want to preserve the old item.
We want to preserve the usage. Which can be added to the next invoice
There is an automatic way to do so or manual or something.
thxs @sterile wyvern !!
Ah, so you're looking to prorate metered prices based on their existing usage record. I don't think there is an out-of-the-box approach for handling this, but bear with me while I double check that.
Not prorating but saving the current usage. I mean it's easy multiply usage by price and save it on next invoice
And you want the previous usage to be charged based on the price that is being removed, not the new metered price that is being added, correct?
If so, I'd recommend taking a look at the following approach and see if it fits what you're looking for:
- When upgrading/updating the subscription, retrieve the usage summary for the current period
https://stripe.com/docs/api/usage_records/subscription_item_summary_list - Create a one-off invoice item (and provide the ID of the subscription to associate it with):
https://stripe.com/docs/api/invoiceitems/create
That invoice item will be swept into the next invoice for that subscription if you provided a subscription ID when creating the invoice item, otherwise it will be included on the next invoice for the customer.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.