#manuel_subscription-pending-updates-delete
1 messages ยท Page 1 of 1 (latest)
๐ Welcome to your new thread!
โฒ๏ธ We'll be here soon! Typically we respond in a few minutes, but sometimes we might take a bit longer if the server is busy or if you have a particularly tricky question.
โฑ๏ธ We close idle threads, which makes them read-only. Once a thread is closed it won't be reopened, but you can always start a new thread if you have another question.
๐ This thread will always be available, even after it's closed. You can find it again using Discord's search, or you can save this link: https://discord.com/channels/841573134531821608/1445099036632813801
๐ Have more to share? Add more details, code, screenshots, videos, etc. below.
Below are links to other discussions we've had with you in the past week in case you want to review that information. If your question is related to one of these previous discussions, please provide a comprehensive summary of the current state and what you need help with now. We help many users simultaneously, so a summary allows us to resolve your issue as soon as possible.
- manuel_api, 6 days ago, 22 messages
im using this:
https://docs.stripe.com/billing/subscriptions/change-price
https://docs.stripe.com/billing/subscriptions/pending-updates
Upgrade or downgrade subscriptions by replacing prices with proration options including immediate, next period, or no proration for billing adjustments.
In that case you cannot delete the Subscription item, as the API error says. Instead of deleting the Subscription item, you can perform an in-place replacement.
So instead of deleting item[0], you replace the price and quantity with the details in item[1].
It's the first code snippet here: https://docs.stripe.com/billing/subscriptions/change-price#changing
But if I only send the price and quantity, it tells me it can't be done because there's already an item in the subscription with that ID :/
Can you share that request ID?
Okay you are missing the ID. Look at the code snippet I mentioned
subscription = stripe.Subscription.modify(
"sub_xxxxxxxxx",
items=[{
"id": "{{SUB_ITEM_ID}}", # <- you need to add this
"price": "{{NEW_PRICE_ID}}"
}],
)
Ohhh nice
Ok ty so much
I understand
And what if, for example, the customer wants to remove the product itself from the subscription?
and add another one within that same request?
The in-place method in the code snippet above essentially does this.
So, if I Subscribe to Price A for Product A, and then you change my Subscription to use Price B for Product B using the code I just shared, when my payment succeeds I will no longer be subscribed to Price/Product A, only Price/Product B
Nice
Thanks, I understand now.
I would need to pass the sub_item_id and price_id with deleted set to True for when I want to remove something from my subscription. Did I understand correctly?
No
Wait. do you ONLY want to remove an item?
I just want to make sure we're talking about a different type of request
These would be both use cases: when I just want to delete a single item and when I want to delete a single item and add another within the same request.
Okay....but as the error you got says, you can not use deleted: True with pending updates.
This is what we just talked about
So, if you want to use pending updates and only change the Price if the payment is successful, you need to use in-place replacement. That is the code snippet I shared.
Okay, and what if I only want to change the quantity it has?
For example, if I want to increase the quantity of one item and remove another item from the same subscription, is that possible?
in the same request
You cannot use the delete parameter with pending updates, period.
So you would need to either not use that for such a request, or make 2 API requests.
manuel_subscription-pending-updates-delete
Okay, so if I want to increase or decrease the quantity, I use what you indicated, and if I want to completely remove something from the subscription, I would have to use another request without the pending update.
right?
Correct
Ok great!
And one last thing, let's say the client wants to change the payment frequency (monthly payment will now be annual payment). Can I use the same method you suggested, or would it require a separate, individual request?
In that case you can use the method I described. The only difference would be that you are switching from a Price with a monthly billing frequency to a yearly billing frequency.
But the operation would be the same, changing an existing Subscription item from Price A (monthly) to Price B (yearly).