#sai_rez
1 messages · Page 1 of 1 (latest)
Hello! We'll be with you shortly. 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.
- sai_rez, 3 days ago, 11 messages
I am in the process of writing some integration tests using Stripe API and want to understand this behaviour.
I am creating two draft invoices with different amounts for a test customer and finalising them so their status is open. The first invoice is not attached to a subscription while the second is.
I noticed when logging the results of the invoices, that the first invoice has an amount due of 0 and it's status is paid, while the second invoice has an amount which is the sum of the first and second, and it's status is open.
As I haven't manually paid the invoices, I was expecting both to have a status of open, could you explain why the first invoice in this scenario automatically pays and its amount is transferred to the second invoice?
I noticed when logging the results of the invoices, that the first invoice has an amount due of 0 and it's status is paid
can you share the Invoice ID (in_xxx)?
in_1OfKXkCXkWwmRJKmALsjKnEm
If I link both invoices to a subscription, both remain open after finalising which is what I am expecting for me test, however when one isn't it's amount get's transferred to the second one if that makes sense
what's the issue exactly? you created that Invoice but didn't add any Invoice Item to it, so it's expected that the total is 0.
Step 1: create an Invoice
Step 2: add InvoiceItems to the Invoice
Step 3: finalize the invoice
looks like you forgot to do step 2.
Ah yes sorry, both invoices have an invoice item created
the one you shared has no InvoiceItems.
Hmm how does an invoice item link to an invoice, I am currently using a customer ID, is that the correct way?
It depends on how you set this parameter: https://stripe.com/docs/api/invoices/create#create_invoice-pending_invoice_items_behavior
But it's either pulling InvoiceItems from the customer object, or directly adding the InvoiceItems to the Invoice itself
Ok thanks I will take a look at those, how can you confirm if an invoice has an invoice item?
you can look at the Invoice in the dashboard or with the API
in the API you want to check the lines property: https://stripe.com/docs/api/invoices/object#invoice_object-lines
Okay thanks, I'll take look!