#kosherslayer
1 messages · Page 1 of 1 (latest)
Hello there
const subscriptionUsageUpdated = await stripe.subscriptions.update(
subscription_usage.id,
{
cancel_at_period_end: false,
proration_behavior: "create_prorations", // prorate charge at EOM
items: [
{
id: subscription_usage.items.data[0].id,
price: subscriptionItems.report_id,
},
{
id: subscription_usage.items.data[1].id,
price: subscriptionItems.white_label_id,
},
{
id: subscription_usage.items.data[2].id,
price: subscriptionItems.invoicing_id,
},
],
}
);
How I'm updating my usage subscription
Hey
So what you want to do here is create an Invoice Item for the cost of the usage on the previous Price (the $2 Price). Then you clear usage and update the Subscription. Then that Invoice Item will be picked up by the next Invoice that is created when the Subscription cycles
ohh got it. Could you link the docs for this?
There aren't really docs per-say. You want to use https://stripe.com/docs/api/invoiceitems/create to create the Invoice Item and you can pass the subscription parameter to make sure that Invoice Item gets picked up by an Invoice related to the relevant Subscription
You would then clear usage using https://stripe.com/docs/api/usage_records/create
so i'd make that api call with the price of the usage item with the amount I retrieve for that usage item (and the subscription)
Pretty much
You'll need a separate Price object here since you wouldn't use a metered-based Price for your Invoice Item in this case.
oh hm. Why couldn't I used a meter based price for the invoice item? I don't want to have to create two price objects for every usage item I have
Well this isn't going to be a recurring Price -- it is just a one-time Price here. What I'd do is actually just use price_data to pass the relevant amount inline using: unit_amount (https://stripe.com/docs/api/invoiceitems/create#create_invoiceitem-price_data-unit_amount)
👋 Also hopping in here since bismark has to head out soon - another alternative is that you can leave both subscription items (the item for the $2/usage + the item for the $1/usage) on the subscription and just stop reporting usage on the old $2 price after they upgrade