#ironbeard - Subscription Update
1 messages ยท Page 1 of 1 (latest)
Hi ๐
This request (thanks for the ID BTW!) shows two prices passed in the items parameter.
Here's the POST body (Ids obscured):
{
cancel_at_period_end: "False",
payment_behavior: "default_incomplete",
items: {
0: {
price: "price_XXXXXXXXXXXXT7"
},
1: {
price: "price_XXXXXXXXXiv"
}
},
proration_behavior: "always_invoice"
}
Hmm, interesting. Sorry to take your time, let me check something (I have models that mimic Subscriptions etc that take care of sending the stripe API hooks, but it should have only sent one Price)
So, the original Subscription had both of those Prices, and then my request sent them both, which caused the issue, right?
That's what the error message is responding with
message: "Cannot add multiple subscription items with the same plan: price_XXXXXXXXT7",
Gotcha, I think I found the issue in my code. If I had only sent one of those two prices in my update, would Stripe had accepted it? (working to get to the point where I can test that)
Well both are currently associated with that subscription so sending either should trigger this error. What is the desired outcome you have in mind?
You aren't providing an quantities either, so how do you expect these prices to be applied?
Oh, good point about quantities. I suppose the goal is to update the subscription in a way that basically cancells one price but keeps the other
Like if they're subscribed to both Major Texas Metros and Newsletter, but want to update their subscription to only be Newsletter
should I sent it with quantity: 0?
(no rush, I know you guys got lot's going on!)
Okay what I would try, in your testing, is making the update call with just the price of the item you want them charged for. But you need to structure your request so it knows what price you are replacing. Take a look at the code snippet here: https://stripe.com/docs/billing/subscriptions/upgrade-downgrade
You can see you both pass the ID of the current item and the one it is being replaced with. I would also try setting the quantity to 0.
ah, gotcha. Upgrade/downgrade was also something I was gonna ask about. Thanks!
Okay, I'll mess around with this, should be good to go for now. Thanks ๐
If you have a second, what does the id in the item object refer to? Line 12 in the Python code for the link you posted.
Have you tried printing it out? When I have built this it's the price_XXXXX ID but it's always good to double check
I guess I'm confused because both id and price are specified in the example. But yeah, I'll try retrieving it and looking in the response
Oh, it's an si_xxx ID, so I suppose that's a SubscriptionItem? So I suppose I use that to tell Stripe which item to change. But I wouldn't include the id if I'm adding an entirely new Price. ๐
Okay, thanks!
Right right right...sorry yeah. It's the subscription item that identifies the relationship between the price record and the subscription record
๐ All good ๐ I think I understand it all now, thanks!