#ironbeard - update subscription
1 messages ยท Page 1 of 1 (latest)
Hello! Just starting a thread for you -- I'll review and respond as soon as I can ๐
hey again ironbeard ๐
to add new items, you only need to send those
to update existing items you need to specify the subscription item id of the existing ones
wihtout an id and update item entry is considered new
Gotcha. So I think in my case the only situations would be adding new items (so only send those in the update call) but also cancelling potentially one of many items. Would that be done in a delete call? I'd want the subscription to persist (assuming there's still prices that weren't cancelled)
or do I send an update with an id of the removed item and a quanity of zero?
You'd want to delete the item directly if you're not replacing the price with another:
https://stripe.com/docs/api/subscription_items/delete
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Gotcha. And if I always use proration_behavior='invoice_always' it will charge the prorated amount when the update call is made, right? Not at the next billing cycle?
with, I suppose the exception of when deleting an item, it would offer credit on the upcoming invoice
Hmm let me poke at this a bit, updating using the id and quantity 0 might work here ๐ค
I think it makes sense to just delete the subscription item, I think I'm okay with that workflow unless you see some reason that updating quantity zero would be better
Only because of the always invoice hevaiour -- you might wish to update to 0 quantity to invoice first, then delete it
oh right
you can use item.deleted:
https://stripe.com/docs/api/subscriptions/update?lang=node#update_subscription-items-deleted
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Ohh, I see. But I suppose when I'm deleting an item, I wouldn't want it to invoice immediately (as there would be nothing to charge?), it should just be applied as credit to the next bill, right?
yep that's right - in that case using the delete api directly works fine ๐
(you could also use update sub with deleted -- will have the same result)
If I use update (with deleted=True in the item object), is it okay to use the price id instead of the SubscriptionItem id?
oh, I guess you kind of said that earlier "without a SubscriptionItem id, an item is considered new", right? I guess my issue is I'm storing Price Ids of a user's subscriptions locally on the Customer, not the SubscriptionItem ids. So I'd need to fetch all SubscriptionItems and compare their price ids to the ones I want to delete, then use the correct SubscriptionItem IDs in a modify call with delete=True?
Yea to update/delete you need that item id
cool cool. Okay! Should be good for now. I have another question about my workflow, but I need to implement some other stuff first. Have a great day ๐
Great! yea feel free to drop by again when you get to the next piece ๐