#cian54
1 messages ยท Page 1 of 1 (latest)
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
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
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
None of the requests that are updating that Subscription include the ID of a Subscription Item, they only contain a Price ID and metadata.
https://dashboard.stripe.com/test/logs/req_hyi04NIT5EBTT6
https://dashboard.stripe.com/test/logs/req_Ftf18cJjxcj4D0
https://dashboard.stripe.com/test/logs/req_MiaajgV16f2AFw
You will need to include items.id as well as items.price
What is the code you're using to create those update requests?
const { subscription } = options
const price = await retrievePriceByCode(subscription.subscriptionCode)
const subscriptionNewDetails = {
items: [{ price: price.id }]
}
const updatedSubscription = stripe.subscriptions.update(subscriptionId, subscriptionNewDetails)
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
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.
Understood, thank you ๐
Any time!