#ironbeard-subscription-update
1 messages · Page 1 of 1 (latest)
ironbeard-subscription-update
Hey @cursive vigil! Best to just ask your real question, we don't really re-open threads
ah, no worries
req_km88vQYYZNPui3
err.. *I'm trying to update a subscription by adding a second Price/Item
The API request I'm making looks like this:
stripe.Invoice.upcoming(**{
'subscription_proration_behavior': 'always_invoice',
'subscription_billing_cycle_anchor': 'now',
'customer': 'cus_Mos6mXiGV6TgEx',
'subscription': 'sub_1M5EMBCoTIfwbn28Oe5mTVFK',
'coupon': None,
'subscription_items': [
{'price': 'price_1M2FdFCoTIfwbn28Vuj7loHt', 'quantity': 1, 'metadata': {}},
{'price': 'price_1M2FdFCoTIfwbn28i4KkF0Gu', 'quantity': 1}
]
})
yeah the items is a merge between what is already on the subscription and what you are adding
so only pass the additional Price id, not both
But if I'm replacing an item for another, I need to include it with quantity=0, right?
no
if you are replacing, the update is more complex
you have to pass {id : 'si_123', price: 'price_NEW'} to swap them
Oh, that sounds familiar (it's been awhile since I originally wrote this code).
Does it work the same way when updating a Subscription?
yes
I can't seem to find documentation of it, and another dev earlier said they didn't think this was allowed, but does specifying deleted=True on a SubscriptionItem while fetching an upcoming Invoice do anything?
It seems my original code tried to send SubscriptionItems with deleted=True when adding a SubscriptionItem that was an upgrade of current SubscriptionItems
What version are you using? I don't see that as an option to update a Subscription Item: https://stripe.com/docs/api/subscription_items/update
Ah, wait you mean here: https://stripe.com/docs/api/subscriptions/update#update_subscription-items-deleted
Actually, I just found it : https://stripe.com/docs/api/subscriptions/update#update_subscription-items-deleted
yeah lol nice
But it seems like using deleted was not liked in this request: req_DQGf0KQousQoHl
Sorry if I'm confused but that looks like a call to Create a Subscription. In that case we do not allow the items.deleted parameter: https://stripe.com/docs/api/subscriptions/create#create_subscription-items
Gotcha, so when creating a subscription, items.deleted not allowed, but it is allowed for Invoice.upcoming or to update a subscription?
I guess it makes sense to now allow it for creating a Subscription, somehow I think my code got confused and slipped it in there.
Yes. Because why would you pass an item that you immediately wanted deleted
If you don't want that item on the Sub, don't pass it. But if you have an item already on an existing Sub and you want to remove it, that makes sense
So, since the "upcoming Invoice" is a merge on items as noted by koopajah above, I don't need to specify any existing items in my "Invoice upcoming" or my "Subscription updated" calls unless I'm deleting them, right?
Correct
Okay! Thanks for helping clarify all this 🙂