#atilla_subscription-update-prices
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/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.
- atilla_api, 5 days ago, 21 messages
- atilla_api, 6 days ago, 15 messages
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"])
Hi yes the latest api version had a ton of breaking changes. You should always read the changelog thoroughly before upgrading
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
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
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
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
Where did I say you have to create an invoice?
create preview invoice
🙂
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
I don't understand the question
I shared the api spec
What specifically don't you understand
i have this invoice
its an upcoming/preview invoice
how do i retrive this object ?
using an api (rest or python sdk)
I shared the api endpoint with you...
You call it and pass the subscription id: https://docs.stripe.com/api/invoices/create_preview#create_create_preview-subscription
Same as you did with upcoming invoice
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
What do you mean by editing it
i will need to remove some items from the preivew invoice
the unused items, e.g. in the image above
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?
i'm pretty sure the code deletes items from preview
It does not
upcoming *
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
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
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
Can you explain the use-case for deleting invoice items from an upcoming invoice
I don't get it
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
This is odd to me
How are you updating
Can you share a sample subscription id so I can take a look and maybe make a suggestion
sub_1RTkLKJVbFQb3xmWQXZOIJbM
I don't really understand what you're doing here
You don't seem to be changing the subscription's price
Why don't you do https://docs.stripe.com/billing/subscriptions/change-price
To change the price
And just disable the proration
reading
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
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.
still can't figure it out, can you help continue this edge case ? @vapid summit ?
Are you following the guide we provided?
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&
I recommend you revise your integration to follow our best practices for updating subscriptions