#ironbeard - Subscription Update

1 messages ยท Page 1 of 1 (latest)

potent moon
#

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"
}
winged cedar
#

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?

potent moon
#

That's what the error message is responding with

message: "Cannot add multiple subscription items with the same plan: price_XXXXXXXXT7",

winged cedar
#

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)

potent moon
#

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?

winged cedar
#

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!)

potent moon
#

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.

winged cedar
#

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.

potent moon
#

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

winged cedar
#

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!

potent moon
#

Right right right...sorry yeah. It's the subscription item that identifies the relationship between the price record and the subscription record

winged cedar
#

๐Ÿ‘ All good ๐Ÿ™‚ I think I understand it all now, thanks!