#polar_subscription-item-updates
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/1226906152898658375
๐ 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.
- polar18_webhooks, 40 minutes ago, 10 messages
Thanks!
You've tried using the Invoice line item API: https://docs.stripe.com/api/invoices/update_line ?
Do you have a request ID you can share where you tested that?
We're using the python library, and the docs said that endpoint is not supported, but I was using stripe.InvoiceItem.modify (which seems like it may not do the same thing)
req_8YsOzNzjS3GOr0 and req_jS6fquIPs0GbBu are two request IDs
I noticed I can't see those requests in my stripe dashboard for some reason though, but the error message is: InvalidRequestError: Request req_8YsOzNzjS3GOr0: When passing an invoice's line item id, you may only update tax_ratesordiscounts`.
You wouldn't modify the Invoice Item if it is already associated to the Invoice
What version of the SDK are you using?
You should be modifying the actual invoice line item afaik -- what error do you see that indicates that isn't supported?
Put the error message above: InvalidRequestError: Request req_8YsOzNzjS3GOr0: When passing an invoice's line item id, you may only update tax_rates or discounts.
And for the line item, we're using the python library and the docs said it's not supported in python: We show the cURL request because this method is currently unsupported in the Python client. To see it in the library, let us know about your use case. https://docs.stripe.com/api/invoices/update_line
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
Let me grab our version
We're currently on 2.55.0
API version is 2022-08-01
Ah right right
Okay one min
Hmm yeah okay it looks like that was actually added to the Python SDK in 8.4.0: https://github.com/stripe/stripe-python/blob/master/CHANGELOG.md#840---2024-02-22
Python library for the Stripe API. . Contribute to stripe/stripe-python development by creating an account on GitHub.
So you are going to need to upgrade to utilize that
Ah yeah looks like https://github.com/stripe/stripe-python/pull/1241 added it
Codegen for openapi v840.
Changelog
Add InvoiceLineItem.modify method.
We are currently in the process of upgrading, however it'll likely be a bit before we can catch all the way up to 8.4.0. Do you know if there's another way we'd be able to do this in the meantime?
Not that I'm aware of, no. I tihnk you could not pass an Invoice ID for the Invoice Item and then you should be able to update the Price using the Invocie Item update API and then it would be picked up by the next finalized Invoice. This would work as long as you aren't having multiple Invocies created/finalized at the same time so that the wrong one picks it up.
Sorry not sure I understand, I am passing the invoice item ID - are you suggesting I need to pass the invoice ID instead?
You are creating a one-off Invoice item to be picked up by a Subscription Invoice here, right?
Or am I misunderstanding and you are trying to upgrade the Line Item that is generated from a recurring Subscription's Subscription Item?
If so, you can't do that. You would need to actually update the Subscription itself to cut a new Invoice
And void the current one.
There's an existing invoice and item, and we want to update the item to point to a different plan and price
So essentially upgrade the line item like in your second message
That Invoice and item was generated via a Subscription renewal?
Or you create the Invoice Item yourself via a separate request (using https://docs.stripe.com/api/invoiceitems/create) ?
Correct for which one ๐
You can't mess with the Subsciption-generated Line Item here
Correct the invoice and item are generated via the subscription renewal
Okay yeah then you can't update that Item in terms of changing the Price
That item is tied to the Subscription Item -- the Price on the Subscription itself
So you need to update the Subscription in this case, not that Invoice
So ideally you make this update before the renewal occurs.
If it is during the 1 hr period while the renewal Invoice is in draft then you would perform the update of the Subscription (using proration_behavior: always_invoice - https://docs.stripe.com/api/subscriptions/update#update_subscription-proration_behavior to force a new Invoice) and then void the previous Invoice that is in draft
Sorry, had to jump to another meeting
Thanks for the options
We're looking at the last option there, but probably wouldn't go with that as we want to continue relying on the recurring invoice for some internal handling on recurring invoices
We may just need to look at the version upgrade to get access to modifying invoice items
Hi ๐
My colleague had to step away so I've taken over.
As I understand your situation, and as my colleague explained, you cannot modify the price the line item is associated with on the Invoice. You must modify the Subscription Item before the invoice is generated
Will that still be true after we've upgraded to version 8 when InvoiceItem.modify is available?
Yes
Your invoices are being generated by a Subscription. So you need to update the Subscription.
The ability to update InoivceItems would only be relevant if you were attempting to update one-off invoices
It's not only technically not possible, it also doesn't make sense to attempt to update the Invoice Item when it's being created by a Subscripton.
Can you describe your larger business case here?
Thanks for the information. Yes, let me take a step back and describe the larger business case so we can see if another approach makes sense
We're looking to implement scheduled automatic upgrades for customers based off the last usage in a billing cycle. So say a customer was on a plan that supported 10 widgets, if they had 11 widgets when their billing cycle rolled around, we'd like to update their subscription and their recurring invoice to have a plan that supports at least 11 widgets
Originally we looked at implementing this via Subscription Schedules, however that would require a larger time commitment that there was some hesitation on.
One alternative idea might be to listen for invoice.payment_succeeded events from recurring invoices, and then do an upgrade off of that immediately after the recurring invoice goes through
Yes that's a change you would need to make on the Subscription prior to when the recurring Invoice is generated.
Given that you want to trigger a possible update based on the previous biling cycle, perhaps you could listen to the invoice.upcoming webhook event. https://docs.stripe.com/api/events/types#event_types-invoice.upcoming
You can customize how many days in advance that webhook event fires in your Dashboard
Yeah bismarck pointed out that event, the only concern there was keeping the subscription change in sync with the many changes the customer can make throughout the rest of their billing cycle
You could then trigger your determination and update the Susbcription
I'm not sure I follow. Can you be more concrete, maybe provide an example, of the situation you are concerned about?
Sure, we don't want to upgrade them until the recurring invoice (or afterwards in the next billing cycle) so if we were to use the invoice.upcoming event we'd be using Subscription Schedule to schedule a change just for their widget subscription item. Our subscriptions tend to have between 3-7 subscription items, and customers regulaly update other subscription items, so we'd need to propagate those immediate subscription item updates to the subscription schedule. Definitely possible, just was more of a concern with the time crunch we have
- I thought we were still talking about Subscriptions only, not schedules
- If you update after the recurring Invoice has been generated, you can use prorations to append the new item to the next Invoice, or you can generate an additional invoice. But you cannot update the Invoice already generated.
- Yeah just wanted to clarify why we wouldn't use just subscriptions in the
invoice.upcomingcase - Gotcha, thanks for the explanation. We'll likely plan to generate a new invoice associated with a subscription update after the recurring invoice goes through
I appreciate the explanations and patience
Okay great. So you woudl want to update the susbcription directly to modify the price(s) for individual items. We document this here: https://docs.stripe.com/billing/subscriptions/upgrade-downgrade
When you make those updates you will also want to pass the proration_behavior: "always_invoice". https://docs.stripe.com/api/subscriptions/update#update_subscription-proration_behavior.
This will generate a new Invoice to collect payment for the extra widget.
Thanks!
Sure thing! Happy to shed what ๐ก I can ๐