#ironbeard-subscription-update

1 messages · Page 1 of 1 (latest)

placid smeltBOT
hushed bluff
#

ironbeard-subscription-update

#

Hey @cursive vigil! Best to just ask your real question, we don't really re-open threads

cursive vigil
#

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}
  ]
})
hushed bluff
#

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

cursive vigil
#

But if I'm replacing an item for another, I need to include it with quantity=0, right?

hushed bluff
#

no

#

if you are replacing, the update is more complex

#

you have to pass {id : 'si_123', price: 'price_NEW'} to swap them

cursive vigil
#

Oh, that sounds familiar (it's been awhile since I originally wrote this code).

Does it work the same way when updating a Subscription?

hushed bluff
#

yes

cursive vigil
#

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

gilded pier
cursive vigil
#

yeah lol nice

#

But it seems like using deleted was not liked in this request: req_DQGf0KQousQoHl

gilded pier
cursive vigil
#

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.

gilded pier
#

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

cursive vigil
#

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?

gilded pier
#

Correct

cursive vigil
#

Okay! Thanks for helping clarify all this 🙂