#arvindkgs
1 messages ยท Page 1 of 1 (latest)
no there isn't. You'd create the items one by one with an API call to the Invoie Item create endpoint
So first create invoice and then pass along that invoice id next when calling create invoice item api?
@hybrid hazel ๐
@hybrid hazel Also when does from_invoice work? Is it only on one-off invoices?
yes, as is explained in https://stripe.com/docs/invoicing/integration.
what is from_invoice exactly, do you have a link to what you're looking at
https://stripe.com/docs/api/invoices/create its in the api params for create invoice
Complete reference documentation for the Stripe API. Includes code snippets and examples for our Python, Java, PHP, Node.js, Go, Ruby, and .NET libraries.
it links to some documentation, it's some feature for copying an existing invoice to a new one, did you have a specific question?
Yes, I tried to use it, but it does not work for invoices generated from subscriptions. Is this expected behavior?
I am not revising a invoices after finalization. This is while creating a new invoice via api
Ohh does from_invoice become a revision of earlier invoice
I thought it just copies the values
I don't really know or understand that invoice revision feature, I've never used it or spoke to a user who was using it
Also I just tried the api to create invoice first and I am getting error
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.```
This is request body
{
"collection_method": "send_invoice",
"due_date": "1695895200",
"auto_advance": "false",
"customer": "cus_OL86sE8CaHbzmt"
}```
This is response
{
"error": {
"code": "invoice_no_customer_line_items",
"doc_url": "https://stripe.com/docs/error-codes/invoice-no-customer-line-items",
"message": "Nothing to invoice for customer",
"param": "customer",
"request_log_url": "https://dashboard.stripe.com/test/logs/req_0KaV5o81cHlC5j?t=1690455620",
"type": "invalid_request_error"
}
}```
This is the request id - req_0KaV5o81cHlC5j
it's because you're using an old API version where Invoices worked differently
it used to be that you had to create the items first ,and then create the Invoice to "pull them in"
relates to https://stripe.com/docs/upgrades#2022-08-01
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.
so if you want to follow our docs while using the old API version, you need to pass https://stripe.com/docs/api/invoices/create#create_invoice-pending_invoice_items_behavior as exclude (to opt into the current behaviour)
How do I use new api version ? Update stripe jar? I am using java
you'd have to update the version of stripe-java yes(note of course that will involve various breaking changes so you need to read the Changelog carefully and test existing code)
or as I mentioned you can pass an API parameter to opt in to the current Invoice item behaviour
okay I will try it thank you
note that you'll probably have to use .putExtraParam("pending_invoice_items_behavior", "exclude") directly on a InvoiceCreateParams in order to pass the parameter, since I assume the old library version doesn't expose that argument
Isn't exclude the default behaviour ? Below is from the stripe api docs
```How to handle pending invoice items on invoice creation. One of include or exclude. include will include any pending invoice items, and will create an empty draft invoice if no pending invoice items exist. exclude will always create an empty invoice draft regardless if there are pending invoice items or not. Defaults to exclude if the parameter is omitted.``
Isn't exclude the default behaviour ?
on the current API version it is
you're not on the current API version. The docs are all written from the perspective of what the latest API version does
on the old version the default behaviour is "include_and_require" , which is the idea that we can't create the Invoice unless you create the items first ,and then create the Invoice to "pull them in"
The stripe java library I am using has invoiceCreateParams.setPendingInvoiceItemsBehavior() , does this mean I am using new api? How can we check what version api I am on?
no it just means it has that parameter, we added it at some point to help with the migration and I was over-zealous in assuming you were an older version of the library that didn't have it yet
I see from the stripe logs API version 2020-08-27
So I can use invoiceCreateParams.setPendingInvoiceItemsBehavior() or I have to use .putExtraParam("pending_invoice_items_behavior", "exclude")
Sure thanks