#kshitij khanal
1 messages · Page 1 of 1 (latest)
What error are you getting after adding items?
message
:
"Failed to unsubscribe the subscription."
statusCode
:
400
I want to unsubscribe one of the line item from the subscription
Can you share the request ID with me so I can take a closer look?
subscriptionId and planId?
Subscription ID works fine
sub_1NT7DmFMyqmnT60ruJ41fbxU
You're getting an error because you're passing in a Product ID (prod_xxx) as a plan - you need to be passing in a price and the Price ID that you want in items
can i use product id?
No, you can't use product ID for this
Also, why are you trying to remove the only items this subscription has? As far as I know, a Subscriptoin has to have at least one item on it
It is dynamic, it can have multiple items as well as single item for a subscription. I am trying to use the same api for all cases.
If you have a single item for the subscription I'm pretty sure it won't work and we wouldn't let you delete it - you'd have to cancel the subscription instead
I have a list of subscription items page, where i can unsubscribe one of the item. The item can be subscribed individually as well as i can purchase a basket of items in a single subscription. I won't know how i subscribed to that item. However i have subscribed, either individually or in a bundle, i should be able to unsubscribe it.
So, i used priceId as a parameter for unsubscription even if the subscription might have a single item.
I understand that, but what I'm saying is that I'm fairly sure that request won't succeed in stripe - if you're subscribed to a single item the only way to immediately unsubscribe is by cancelling the subscription
So, it means i need to have an extra check whether the subscription has multiple items or a single item and call the update api likewise with priceId and without it accordingly?
Let me ask a quick clarifying question - are you always cancelling/unsubscribing at the END of the current period (by setting cancel_at_period_end: true), or are you also cancelling immediately?
We are unsubscribing at the end of the current period. But we may also unsubscribe immediately in some cases in future.
Why are you passing in items again, if all you're doing is unsubscribing at the end of the current period? Why aren't you just passing in cancel_at_period_end?
because the subscription might have more than one lineitems. And we always need to unsubscribe for only a single line item.
That's not how cancel_at_period_end works though - when you set that it applies to the WHOLE subscription
By passing in items all you're doing is changing the items the subscription is currently subscribed to
Is there any way I can handle this. Its that we have 3 items that can be purchased individually and the same 3 items can be purchased as a bundle also.
The way to do this would be by using Subscription Schedules to change what items are on the subscription during a certain time period - you can read about them generally here (https://stripe.com/docs/billing/subscriptions/subscription-schedules) and there are some example use cases here (https://stripe.com/docs/billing/subscriptions/subscription-schedules/use-cases#upgrading-subscriptions)
👍