#manuel_subscription-pending-updates-delete

1 messages ยท Page 1 of 1 (latest)

graceful sphinxBOT
#

๐Ÿ‘‹ 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.

prime mantle
mighty harbor
#

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].

prime mantle
#

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 :/

mighty harbor
#

Can you share that request ID?

prime mantle
#

yep

#

req_Fybfr6LSHfxTGy

mighty harbor
#

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}}"
}],
)
prime mantle
#

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?

mighty harbor
#

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

prime mantle
#

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?

mighty harbor
#

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

prime mantle
#

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.

mighty harbor
#

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.

prime mantle
#

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

mighty harbor
#

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.

graceful sphinxBOT
#

manuel_subscription-pending-updates-delete

prime mantle
#

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?

mighty harbor
#

Correct

prime mantle
#

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?

mighty harbor
#

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).

prime mantle
#

Ok cool, thank you so much

#

I think that's all, thank you so so much for your help

#

๐Ÿ™๐Ÿป