#elBR-preview-invoice
1 messages ยท Page 1 of 1 (latest)
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?
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
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.
That's what I was thinking, but double checking I'm seeing that might not be possible.
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
Then you can create a throwaway Customer object, and use it purely for previewing upcoming Invoices.
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?
This one, which creates Invoice Items:
https://stripe.com/docs/api/invoiceitems/create
If a value isn't provided for invoice then those items sit on the Customer until the next Invoice is generated.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
even if I pass an invoice_id to InvoiceItem.create?
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
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 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?
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?
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?
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?
the second
I don't understand why I should receive it as a response
it has nothing to do with my call arguments
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.
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.