#jstawski - API Invoice
1 messages · Page 1 of 1 (latest)
You need to create line items and the invoice in separate API calls. It's up to you whether you create the items first or the invoice first
how do I make sure the Invoice is in draft mode?
When you first create an invoice it is in Draft mode by default. If you run into an issue where it auto-advances you can set auto_advance to false
Sure thing 🙂
so i'm creating the invoice first, but i'm getting the exception: "Stripe.StripeException: Nothing to invoice for customer"
Invoice Create Options have AutoAdvance = false
and a Customer
Hello! You need to set pending_items_invoice_behavior to exclude to create an empty Invoice with the API: https://stripe.com/docs/api/invoices/create#create_invoice-pending_invoice_items_behavior
almost there
I now get, "This property cannot be expanded (PaymentIntent)."
after trying to Pay an invoice
Can you give me the request ID showing that error? Here's how you can find a request ID: https://support.stripe.com/questions/finding-the-id-for-an-api-request
anyway I can review a log on the dashboard?
I don't have the request available anymore
Yeah, if you go into the Developer section of the Dashboard you'll find Logs there.
Ah, okay, so PaymentIntent is not a valid value for expansion. Try payment_intent instead.
The API reference shows you the property names on objects you can expand: https://stripe.com/docs/api/invoices/object#invoice_object-payment_intent
Does paying the invoice generate a receipt/invoice email automatically?
If you have Stripe configured to do that, yes.
That's expected, we do not send emails in test mode.
ok, good to know
the settings within the portal says "Email finalized invoices to customers"
I am not finalizing, instead i'm paying... in other words I'm using the Pay API
I assume it is the same thing
Those are two seperate things but test mode won't send emails for either.
Finalizing an invoice is when the invoice moves from a draft state to an open state where your users can pay it
Paying the invoice is, well, paying the invoice
Test mode mostly does not send emails. Are you just confirming that this is the expected behavior? Or are you trying to see something about this email.
I want to make sure that in production, when my system automatically pays for the invoice (through stripe API), the customer will receive an email to the email on file
- I create a draft invoice
- I add Invoice Items to the Invoice
- I pay the invoice
Will the customer receive an email with a receipt/invoice if we do the above?
Yes, an email will be sent when that happens in production https://stripe.com/docs/receipts#receipts-with-billing
when I say "I Pay the invoice" I mean the code calls PayInvoice
Sadly the email itself is not testable in test mode right now
Slight correction: that email will be sent in production as long as you have "email customers for successful payments" turned on in your email receipt settings https://dashboard.stripe.com/account/emails