#atilla_subscription-update-prices

1 messages · Page 1 of 1 (latest)

lavish jettyBOT
#

👋 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/1377298813567631370

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

covert cloak
#

invoice = stripe.Invoice.upcoming(
subscription=self.subscription_id,
)
lines = invoice["lines"]["data"]
if len(lines):
for line in lines:
if "Unused" in line["description"]:
stripe.InvoiceItem.delete(line["invoice_item"])

sage smelt
#

Hi yes the latest api version had a ton of breaking changes. You should always read the changelog thoroughly before upgrading

covert cloak
#

can you tell me what options there is?

#

cuz i see no option :\

sage smelt
#

Did you click the link above

#

It's the changelog

#

And explains in detail what the alternative is

#

You really should read the entire changelog before upgrading an api version

#

There's a ton of breaking changes besides this

covert cloak
#

can you help me understand the alternative

#

i did read that before coming here

#

thats how i know was removed

#

but i dont see giving other endpoint

sage smelt
#

It's the first sentence

#

`We’re removing the GET /v1/invoices/upcoming API in favor of the Create Preview Invoice API.

`

#

The create preview invoice api

#

That's the alternative

covert cloak
#

i need to remove items that are made by subsption

#

so creating the invoice does not apply here , its made by stripe when i change the invoice to have less items

sage smelt
#

Where did I say you have to create an invoice?

covert cloak
#

create preview invoice

sage smelt
#

It functions the same as upcoming invoice

#

Please read the links I send you

covert cloak
#

🙂

#

reading now

#

i dont get it

#

how to i do retrive/list for an preview invoice ?

#

based on a subscription

#

please point it out for me

sage smelt
#

I shared the api spec

#

What specifically don't you understand

covert cloak
#

i have this invoice

#

its an upcoming/preview invoice

#

how do i retrive this object ?

#

using an api (rest or python sdk)

sage smelt
#

I shared the api endpoint with you...

#

Same as you did with upcoming invoice

covert cloak
#

okey i get it now

#

thats so confusing jezz

#

the name is "create"

#

but i can see now saying "The identifier of the subscription for which you’d like to retrieve the upcoming invoice. I"

#

thats what i needed

#

thx

#

all set

#

i guess editing it will be using the same endpoint

sage smelt
#

What do you mean by editing it

covert cloak
#

i will need to remove some items from the preivew invoice

#

the unused items, e.g. in the image above

sage smelt
#

To be clear your code here:

            subscription=self.subscription_id,
        )
        lines = invoice["lines"]["data"]
        if len(lines):
            for line in lines:
                if "Unused" in line["description"]:
                    stripe.InvoiceItem.delete(line["invoice_item"])```
Does not remove items from the preview
#

That code deletes the invoice items

#

So they no longer will exist on the actual, real invoice (not just the preview)

#

You want to do the same thing?

covert cloak
#

i'm pretty sure the code deletes items from preview

sage smelt
#

It does not

covert cloak
#

upcoming *

sage smelt
#

Oh wait

#

Yes

#

You're right

#

I wasn't aware InvoiceItem.delete worked with preview line items

#

Recommend testing it, but it should function the same with the new endpoint

covert cloak
#

okey will give it a try, if works from dashboard will work from api

#

stripe._error.InvalidRequestError: Request req_omWzqJHOID9DBe: No such Invoice Item: 'il_tmp_1RTkLjJVbFQb3xmWWUHGc1Vk'(livemode=false)

#

does not work

sage smelt
#

Ah yeah so I guess it's not supported

#

I didn't think it was tbh

#

I'm surprised this worked in the upcoming invoice api

#

Why do you need this functionality

#

What are you building

covert cloak
#

we build already

#

we are doing an upgrade

#

for zerobounce

sage smelt
#

Can you explain the use-case for deleting invoice items from an upcoming invoice

#

I don't get it

covert cloak
#

sure

#

here is the main flow we had

#

customer has bought in past few days a monthly sub of 45$ with 4 items

#

same month customer decided to change the sub to one item that costs 49$
we are changing the sub without charging but we create a payment intent for 4$ on the side

#

so now the customer can use the 49$ item directly

#

the problem is with the next invoice that shows 0$

#

it should be 49$

#

we want to keep same flow, without canceling, reseting the billing cycle etc

#

so maybe its in the subscription modify that we need to look into

sage smelt
#

How are you updating

#

Can you share a sample subscription id so I can take a look and maybe make a suggestion

covert cloak
#

sub_1RTkLKJVbFQb3xmWQXZOIJbM

sage smelt
#

I don't really understand what you're doing here

#

You don't seem to be changing the subscription's price

#

To change the price

#

And just disable the proration

covert cloak
#

reading

lavish jettyBOT
covert cloak
#

subscription = stripe.Subscription.modify(
"sub_xxxxxxxxx",
items=[{"id": "{{SUB_ITEM_ID}}", "deleted": True}, {"price": "{{NEW_PRICE_ID}}"}],
)

#

actually i think its fine if we add deleted

#

testing now

#

we already do exactly that

#

"proration_behavior": "none",

#

if we add deleted might work

vapid summit
#

Hello 👋

I am stepping in as my colleague has to go. I strongly recommend you follow the guidance our docs provide for modifying subscriptions that my colleague has already provided.

covert cloak
#

still can't figure it out, can you help continue this edge case ? @vapid summit ?

vapid summit
#

Are you following the guide we provided?

covert cloak
#

yes but its a bit more than that

#

we have a legacy code that was doing strange things and we can migrate it to new version

#

cant&

vapid summit
#

I recommend you revise your integration to follow our best practices for updating subscriptions