#Filip | Tenderly - upcoming invoice
1 messages ยท Page 1 of 1 (latest)
Yes, but I want to edit items also (e.g. add one price and remove other one)
And I assume those items should appear as prorated items in upcoming invoice
I don't think you can edit the upcoming invoice. You should wait for the invoice to be created before editing it.
Can you clarify what you are trying to do?
Our user has current subscription with PRICE_A attached to it.
Users wants changes from PRICE_A to PRICE_B and adds PRICE_C to the subscription. But before he executes update subscription we are showing next invoice to the customer with edited items in order for him to be aware what would occur.
In order to do so, we are calling .GetNext() with current subscription and updated invoice items:
PRICE_A - deleted
PRICE_B - added
PRICE_C - added
And in the response we get prorated items with exact amount how much user should pay if these changes would apply.
And this works as expected the problem that we have is that line items for upcoming invoice are limited to 10 in the .GetNext() call and we want to have a way to expand that list. The docs says to use upcoming_invoice_lines-invoice_items and that it supports editing invoice items (same as GetNext) but I cannot see that in the code of the SDK so my question is how to achieve behaviour described in the documentation from SDK.
So you want to be able to paginate the invoice item on an upcoming invoice?
Yes
Got it, give me a few minutes to look into this.
Actually it's possible to do with a trick!
When you want to paginate that invoice, you use the same API you would for a normal invoice and simply pass upcoming as the invoice id.
In Node.js it would look something like this:
stripe.invoices.retrieveLines(
"upcoming",
{
customer: "cus_123",
subscription: "sub_123",
}
);
I'm already doing that, but I need to edit invoice_items on top of that.
specifically this field:
https://stripe.com/docs/api/invoices/upcoming_invoice_lines#upcoming_invoice_lines-invoice_items
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
I mean in node.js (because it doesn't have type safety) I can do this
stripe.invoices.retrieveLines(
"upcoming",
{
customer: "cus_123",
subscription: "sub_123",
invoice_items: items,
}
);
But that is not available in distribution of SDK that I'm using, so I assume it is available on the API side but not in generated SDK.
I hoped that there is a hack, similar to the .AddExpand() or something like that, where I can send invoice items even doe they are not part of the SDK.
Hi there. Taking over for soma as they have to step out
Just to clarify, you need to edit the invoice items on an invoice?
On the future invoice, yes.
You should be able to just use this endpoint: https://stripe.com/docs/api/invoiceitems/update
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
I want to preview invoice with edited items. Sorry, I understood you initial question wrongly.
I think you will get what I mean if you re-read our conversation in this thread
Hi sorry I haven't had a chance to re-read everything. Discord is so busy at the moment. I think you should be able to use this endpoint: https://stripe.com/docs/api/invoices/upcoming#upcoming_invoice-invoice_items
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.