#Filip | Tenderly - upcoming invoice

1 messages ยท Page 1 of 1 (latest)

gusty stratus
#

Hi there!

#

You want to retrieve the upcoming invoice's line item?

lament nebula
#

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

gusty stratus
#

I don't think you can edit the upcoming invoice. You should wait for the invoice to be created before editing it.

lament nebula
#

I can do that with .GetNext()

#

In the docs it says I can do that ๐Ÿค”

gusty stratus
#

Can you clarify what you are trying to do?

lament nebula
#

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.

gusty stratus
#

So you want to be able to paginate the invoice item on an upcoming invoice?

lament nebula
#

Yes

gusty stratus
#

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",
  }
);
lament nebula
#

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.

hexed cargo
#

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?

lament nebula
#

On the future invoice, yes.

hexed cargo
lament nebula
#

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

hexed cargo