#karls-invoice-creation
1 messages ยท Page 1 of 1 (latest)
Do you have an example charge ID or payment Intent ID?
Yes
in_1MmfqMG30Vl6ne6NZe1Huuwm
I see this message:
Invoice was finalized and automatically marked as paid because the amount due was $0.00
Mar 17, 2023, 4:09 PM
Thanks, looking now
The invoice was created without any line items. https://dashboard.stripe.com/logs/req_v6Z8RM401vScLJ
oh..
So my code is failing to create those. Let me see what is going on there.
I've walked my code... definitely should be adding an invoice line item.
Can we dig deeper on Stripe side?
I can help
karls-invoice-creation
Discord is a bit busy so taking over to give some relief to @sinful hearth
@somber lake did you maybe upgrade stripe-dotnet recently?
Oh, maybe....
https://stripe.com/docs/upgrades#2022-08-01 we changed the default behaviour of the Create Invoice API back in this API version
The pending_invoice_items_behavior parameter on create Invoice no longer supports the include_and_require value. When the parameter is omitted the default value of pending_invoice_items_behavior is now exclude.
By default now when you create an Invoice it does not pull in any pending InvoiceItem on the Customer.
I'm 41.7
So if you used to use an old stripe-dotnet from before that version and then you upgraded, you get the new behaviour
OK, wow! Looking at doc now. Is there a property I can set to achieve the original behaviour?
yes that's what I quoted above: https://stripe.com/docs/api/invoices/create#create_invoice-pending_invoice_items_behavior
you want to pass this parameter with the value include
ok, thank you very much.
of course! sorry those changes are tough to document in libraries like stripe-dotnet
we have wiki pages for major versions like https://github.com/stripe/stripe-dotnet/wiki/Migration-guide-for-v41 and https://github.com/stripe/stripe-dotnet/wiki/Migration-guide-for-v40 but developers don't often realize the implication of the change
Thank you for that.
Are we talking InvoiceItemService? I'm not seeing that parameter option.
..and InvoiceItemCreateOptions
InvoiceItemService is for InvoiceItem creation which is https://stripe.com/docs/api/invoiceitems/create
You want InvoiceService which is https://stripe.com/docs/api/invoices/create
which is what I linked you to ๐
Let me check that in my code, maybe I have been using the wrong Stripe object all along; but it was working ;/
You likely used to do this
1/ Create InvoiceItem via InvoiceItemService
2/ Create Invoice via InvoiceService -> Magically pulls in #1
1/ Create Invoice via InvoiceService
2/ Create InvoiceItem via InvoiceItemService and make sure to pass Invoice="in_123" to add it to the Invoice you created
But if you keep the old order you have to do this instead
1/ Create InvoiceItem via InvoiceItemService
2/ Create Invoice via InvoiceService and pass PendingInvoiceItemsBehavior="include" -> Magically pulls in #1
var service = new InvoiceService(client); var itemservice = new InvoiceItemService(client);
sorry is there a question? You just shared 2 line of codes, but hopefully what I explained in details above clears up the confusion
Sorry, got caught up reading the details you posted... but yeah, what I posted is the order which I am creating my objects... so I have to Create the Line Items first, then the Invoice Item with the new attribute "PendingInvoiceItemsBehavior"
the order of creating the "service" in your code is totally irrelevant
but yes mostly add the new parameter and it should work like before again
Gotcha! Now trying to find that Parameter...
Found it! (sheesh, just scroll a little farther Karl)
var invoptions = new InvoiceCreateOptions() { Customer = Request.CustomerStripeID, PendingInvoiceItemsBehavior = "include" };