#tymm

1 messages ยท Page 1 of 1 (latest)

dull eagleBOT
high trench
#

๐Ÿ‘‹ Hi there, Happy to help!
As the error mentions, Nothing to invoice for customer...

An invoice cannot be generated for the specified customer as there are no pending invoice items. Check that the correct customer is being specified or create any necessary invoice items first.
https://stripe.com/docs/error-codes#invoice-no-customer-line-items

vagrant mirage
#

hmm weird can u help me to check my code instead.. pretty sure i've put something into it

#
InvoiceCreateParams createParams = InvoiceCreateParams
                .builder()
                .setCustomer(customer.getId())
                .setCollectionMethod(InvoiceCreateParams.CollectionMethod.SEND_INVOICE)
                .setDaysUntilDue(1L)
                .setAutoAdvance(false)
                .build();
        
        Invoice invoice = Invoice.create(createParams);

        for (Map.Entry<String, Object> item : stripeProductQuantity.entrySet()) {
            InvoiceItem.create(
                    InvoiceItemCreateParams
                            .builder()
                            .setCustomer(customer.getId())
                            .setPrice(item.getKey())
                            .setQuantity(Long.valueOf(item.getValue().toString()))
                            .setInvoice(invoice.getId())
                            .build()
            );
        }
        return invoice.finalizeInvoice();
high trench
vagrant mirage
#

so i just omit setInvoice() in InvoiceItemCreateParams?

high trench
#

Sorry for my late reply

#

Let me do a quick test

nova steeple
#

Sorry, taking over here. Let me catch-up

nova steeple
#

You're still on the older API version though, 2020-08-27, so the behaviour differs and that you should create the Invoice Items first