#meisei81
1 messages · Page 1 of 1 (latest)
hi! that's because you're using an old API version basically, where the invoice items work differently
you need to either
- create the invoice items first, then create the invoice(which is not what our docs describe)
- upgrade to the latest stripe-java version
- use https://stripe.com/docs/api/invoices/create?lang=java#create_invoice-pending_invoice_items_behavior with
includeto opt into the current behaviour on older API versions
it's two major versions behind yes https://github.com/stripe/stripe-java/blob/master/CHANGELOG.md
it's just one year ago
I don't think I should upgrade so frequently
because we should test the whole business process
cool, I never said you had to upgrade, I gave you three options and only one of them was upgrading
- create the invoice items first, then create the invoice(which is not what our docs describe) --- about this option, is there any correct docs?
no since we deleted the docs for the old approach
but it's straightforward, you just call https://stripe.com/docs/api/invoiceitems/create and pass the customer ID (and not the invoice ID since you don't have one yet), and then create the Invoice
try it out and if you get stuck let me know and share the code you tried
this is my code
I've created the invoice item in step 1
And this is the full code what step 1 will execute
is there a problem exactly? do you get some error?
the error is "Nothing to invoice for customer; code: invoice_no_customer_line_items; request-id: req_e5ZSGgXfmxPfoV"
I'm so confused, that is the request you posted 30 minutes ago and I thought you were changing code to fix it per my advice?
it's weird. this customer has created some invoice before and the currency code is EUR. now I try to create a MAD currency code invoice, and the problem comes
no
i don't change any code
why not?
ok any way , looking for a sec
https://dashboard.stripe.com/test/logs/req_Lwv92R5dbTRA9W is you creating the invoice item
https://dashboard.stripe.com/test/logs/req_e5ZSGgXfmxPfoV is you creating the invoice which failed
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
Sign in to the Stripe Dashboard to manage business payments and operations in your account. Manage payments and refunds, respond to disputes and more.
it is weird it would return that error
often that means that something else (like a subscription) created an invoice for the same customer inbetween those requests
looking.
I created invoice successfully this morning
but it failed in afternoon
so I don't think it's the code issue
what happens if you try to create an invoice now?
but yeah weird, there was no other invoice
I've just created an invoice and it pay successfully
I don't know why those items didn't get pulled in
just did
cool. Must have been some timing issue then where the items weren't available for some reason and you'd have to retry the request
ultimatley this is why we changed the API to not work this way(create items first, then create the item), it's unreliable unfortunately
I'd suggest using the other approaches(opting into the new pending behavior or using the newer API version by upgrading stripe-java)
I've just created an invoice and got the same error Nothing to invoice for customer; code: invoice_no_customer_line_items; request-id: req_Q7JLJCm252Fn0c
The difference between this two requests, is that they are not the same product and price
and the currency code is eur and mad
you could try it
if you wait a couple of minutes and try to create the Invoice does that work?
i can wait
ok let me know
ah right I'm an idiot
the problem is you can not invoice that customer in MAD, because customers are locked to a currency for Invoices. You can only create EURO Invoices for them since they are locked to that currency. (https://support.stripe.com/questions/setting-a-customers-default-currency)
the API error is just confusing, what it means is it can't find any available items to invoice for(since there are only MAD items and the customer is locked to EUR) so that's why.
no, see the support article for the answer to that question
the customer's default currency is eur?