#cian54

1 messages ยท Page 1 of 1 (latest)

swift gardenBOT
pale hare
#

Hi there @maiden imp !

#

So sorry, missed your message.

#

Can you explain a little more what you mean here?

#

I'm not sure I understand the confusion

twilit birch
#

Hi @maiden imp jumping in as my teammate needs to step away soon. Are you trying to update the Subscription so that you change the Price it is currenlty subscribed to rather than adding an additional Price to the Subscription? If so, then you will need to pass the ID of the existing Subscription Item when updating the Subscription, otherwise the request will create a new Subscription Item for the new Price and add it to the Subscription.
https://stripe.com/docs/api/subscriptions/update#update_subscription-items-id

maiden imp
#

this exacly what I'm doing

#

but I get multiplee price in one subscription

twilit birch
#

You will need to include items.id as well as items.price

#

What is the code you're using to create those update requests?

maiden imp
#
const { subscription } = options

const price = await retrievePriceByCode(subscription.subscriptionCode)
const subscriptionNewDetails = {
  items: [{ price: price.id }]
}

const updatedSubscription = stripe.subscriptions.update(subscriptionId, subscriptionNewDetails)
twilit birch
#

Yup, you'll need to change that.

  items: [{ price: price.id }]
}```

will also need to be revised to, but for that you will first need to retrieve the ID of the existing Subscription Item
```const subscriptionNewDetails = {
  items: [{ 
          id: <SUBSCRIPTION_ITEM_ID>,
          price: price.id 
}]
}```

You can use our sample code, for upgrading a Subscription to a new price that is found here, as a reference:
https://stripe.com/docs/billing/subscriptions/upgrade-downgrade#changing
maiden imp
#

what is that <SUBSCRIPTION_ITEM_ID> ?

#

Ah the current item id ?

twilit birch
#

Exactly, if you look at the sample code in the doc, it shows how they get it to pass to items.id. It's the ID of the existing Item.

maiden imp
#

Understood, thank you ๐Ÿ™

twilit birch
#

Any time!