#elBR-preview-invoice

1 messages ยท Page 1 of 1 (latest)

steady moth
#

Hi ๐Ÿ‘‹ that is a possibility, did you create Invoice items for the Customer that you used which haven't been picked up by the generation of another Invoice yet?

pallid cypress
#

I don't want to consider them

#

I want to preview the invoice for just the items that I pass to the call

#

how can I do that?

#

is there any parameter I can pass?

#

on creating invoice there is pending_invoice_items_behavior: "exclude"

#

but on the preview is not

steady moth
#

That is currently not possible with the endpoint that retrieves an upcoming invoice. If you don't have anything applied at the Customer level that could impact the calculation of the Invoice, then you can omit the customer parameter so the Invoice doesn't pull in pending items for that Customer.

#

You can instead leverage customer_details to populate any necessary details.

pallid cypress
#

this is how I am calling it

#

you mean to not pass the customer_id?

steady moth
#

That's what I was thinking, but double checking I'm seeing that might not be possible.

pallid cypress
#

ah ok. So than how can I calculate

#

the calculation is not based on customer

#

I just need to get the data of the invoice based on some items

steady moth
#

Then you can create a throwaway Customer object, and use it purely for previewing upcoming Invoices.

pallid cypress
#

ok, but I am curious in what cases to the customer are registered pending invoice items?

#

what api call can cause the customer to have pending invoice items?

steady moth
pallid cypress
#

even if I pass an invoice_id to InvoiceItem.create?

steady moth
#

No, if you pass an Invoice's ID to the invoice parameter then the Invoice Items are attached to that Invoice.

You can list the pending Invoice Items for a Customer to get a better idea of what they are and maybe get some insight on where they're from.
https://stripe.com/docs/api/invoiceitems/list#list_invoiceitems-pending

pallid cypress
#

I checked them through the dashboard

#

and removed them

#

but I continue to get another item in my upcoming invoice

#

eventhought there is no pending invoice item

#

cus_MOs2IOoXt2O5q0

#

can you please check why I am getting another item in my upcoming invoice please?

steady moth
#

Preview Invoices are simulated rather than generated, so I can't look at the response that you're receiving. What are you seeing in that response that is unexpected?

pallid cypress
#

I am getting two invoice line items

#

Instead I am passing only one

#

Can you please try to make a request for the upcoming invoice with my customer id and check the result?

steady moth
#

No, we cannot make requests for your account.

#

Which of the items shown in the response is the not the one that you passed in?

pallid cypress
#

the second

#

I don't understand why I should receive it as a response

#

it has nothing to do with my call arguments

steady moth
#

You aren't specifying a value for the subscription field, so the system is pulling in the next upcoming invoice from the Customer's Subscriptions, as mentioned here:
https://stripe.com/docs/api/invoices/upcoming#upcoming_invoice-subscription

Creating a throwaway Customer object to use for just previewing invoices is likely the easiest path to avoid pulling in other information from your existing Customer record.