#Nick-

1 messages · Page 1 of 1 (latest)

quartz umbra
#

hello, I believe there's no way to convert between metered <> licensed, you have to create a new Subscription

trim mason
#

ok I figured out a workaround. Create a licensed subscription item with the same term as the metered price is allowed (in this case term is monthly)

Delete the metered subscription item

Update the licensed (monthly) subscription item to the yearly one

soft yew
#

Can you share your exact code?

#

you shouldn't have to go through the monthly one and I think you are misunderstanding how the Update Subscription API works

#

the items array parameter will merge with the existing items already

#

so if you are on Price A and you pass items: [{price: 'B'}] then you end up with Price A and Price B

#

if you want to switch from Price A to Price B you have to do items: [ { id: 'si_123', price: 'B' } ] where si_123 is the id of the existing SubscriptionItem on that Subscription

#

You can also so items: { id: 'si_123', deleted: true, clear_usage: true }, { price: 'B' } ] which basically deletes the current SubscriptionItem and adds a new one

trim mason
#

I haven't been passing the items array for subscription updates, I've been using the sub item update API directly

#

I updated my initial message with the commands run for each error

#

I believe using this API with create/update would be the same as using the items array, if you used it properly, right?

soft yew
#

maybe

#

Sorry hard to grasp what you mean honestly

#

Those are just the Stripe CLI too so hard to get overall context

#

You're saying you have a Subscription on Price A, that is monthly and metered and if you move to Price B that is yearly you get your error?

trim mason
#

Correct. In this command:

stripe subscription_items update si_MJ28nOif8c4HPb --price price_1LaKy2I67GP2qpb4kUjysjHB
{
  "error": {
    "message": "Cannot update plans with different usage types. The plan for the subscription item with the ID si_MJ28nOif8c4HPb is of usage type metered, and you are trying to update to licensed.",
    "type": "invalid_request_error"
  }
}

Sub item si_MJ28nOif8c4HPb is a monthly metered price, and it's simply trying to update that specific sub item with the new yearly, licensed price price_1LaKy2I67GP2qpb4kUjysjHB

soft yew
#

what is the Subscription id though?

trim mason
#

sub_1LaQRLI67GP2qpb4sVYPK6dL is the subscription ID, but isn't necessary because the sub item ID maps 1:1 to the subscription

soft yew
#

That subscription has multiple prices though

#

like it has 2, and you're just changing 1, so it's totally normal it errors

trim mason
#

Yeah sorry the sub isn't in the same state as it was when I wrote the initial message

#

I can create another one to show you one sec

#

sub_1LaQmII67GP2qpb4h1zanQ2Y
Has a single metered price as the only sub item

#

si_MJ2sb3Kq9dG7OE is the sub_item id. So I can run stripe subscription_items update si_MJ2sb3Kq9dG7OE --price price_1LaKy2I67GP2qpb4kUjysjHB where price_1LaKy2I67GP2qpb4kUjysjHB is a yearly, licensed price

#

Which results in:

stripe subscription_items update si_MJ2sb3Kq9dG7OE --price price_1LaKy2I67GP2qpb4kUjysjHB
{
  "error": {
    "message": "Cannot update plans with different usage types. The plan for the subscription item with the ID si_MJ2sb3Kq9dG7OE is of usage type metered, and you are trying to update to licensed.",
    "type": "invalid_request_error"
  }
}
soft yew
#

Damn that error message is bad

#

Can you try via the Update Subscription API with my trick?

#

this one: items: { id: 'si_123', deleted: true, clear_usage: true }, { price: 'B' } ]

soft yew
#

Okay I asked another colleague too and they didn't know about that error either. I'll flag internally to see if we can just improve this. It feels "arbitrary" to have that error and maybe we can improve this

trim mason
#

Sorry stepped out. So you think that this shouldn't actually be an error?

rough stirrup
#

Hi, koopajah stepped away so chiming in here.

#

An error is intended to be sent but I think that specific error message is not clear so we're providing this feedback of improving the verbiage on that error.

trim mason
#

Ah ok, sounds good

#

I think I'm fine with my workaround for now but thanks @soft yew, @quartz umbra and @rough stirrup!