#karls-invoice-creation

1 messages ยท Page 1 of 1 (latest)

sharp gobletBOT
sinful hearth
#

Do you have an example charge ID or payment Intent ID?

somber lake
#

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

sinful hearth
#

Thanks, looking now

somber lake
#

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?

maiden sundial
#

I can help

#

karls-invoice-creation

#

Discord is a bit busy so taking over to give some relief to @sinful hearth

somber lake
#

Thank you.

#

Need to dig deeper on Stripe side, look at logs maybe?

maiden sundial
#

@somber lake did you maybe upgrade stripe-dotnet recently?

somber lake
#

Oh, maybe....

maiden sundial
#

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.

somber lake
#

I'm 41.7

maiden sundial
#

So if you used to use an old stripe-dotnet from before that version and then you upgraded, you get the new behaviour

somber lake
#

OK, wow! Looking at doc now. Is there a property I can set to achieve the original behaviour?

maiden sundial
#

you want to pass this parameter with the value include

somber lake
#

ok, thank you very much.

maiden sundial
#

of course! sorry those changes are tough to document in libraries like stripe-dotnet

somber lake
#

Thank you for that.

#

Are we talking InvoiceItemService? I'm not seeing that parameter option.

#

..and InvoiceItemCreateOptions

maiden sundial
#

which is what I linked you to ๐Ÿ™‚

somber lake
#

Let me check that in my code, maybe I have been using the wrong Stripe object all along; but it was working ;/

maiden sundial
#

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

somber lake
#

var service = new InvoiceService(client); var itemservice = new InvoiceItemService(client);

maiden sundial
#

sorry is there a question? You just shared 2 line of codes, but hopefully what I explained in details above clears up the confusion

somber lake
#

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"

maiden sundial
#

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

somber lake
#

Gotcha! Now trying to find that Parameter...

somber lake
#

Found it! (sheesh, just scroll a little farther Karl)

#

var invoptions = new InvoiceCreateOptions() { Customer = Request.CustomerStripeID, PendingInvoiceItemsBehavior = "include" };

maiden sundial
#

๐Ÿ‘

#

Are you all set?

sharp gobletBOT