PHP SDK Api Create Multiple invoices issue

I am using Square PHP-SDK, I am able to completely create, publish and send an invoice by itself. I am trying to make it so that I can parse a csv to create invoices automatically.
In the sandbox dashboard, it is showing that multiple orders and invoices are listed but it is only completing the first invoice, the others are showing in the developer dashboard under the api logs but are not completing to show under a separate invoice in the dashboard.
On the page that is parsing the csv, it is only showing a single invoice id. I cannot seem to figure out why it is only creating 1 invoice and not multiple invoices…any ideas or suggestions on where to check? I am getting 200 response on the sandbox dashboard for all…

:wave: I’m Square Dev AI, here to help answer your question!
Based on the information you’ve provided, the following documentation will help answer your question:

Additional Documentation

Create and Publish Invoices
Pay or Refund Invoices
Square Sandbox

If this documentation helped you find a solution, please check the box indicating that this reply solves the problem.
Otherwise one of our Developer Advocates will provide additional assistance shortly.

It seems like you’re able to create multiple invoices but they are not being fully processed. This could be due to a few reasons:

  1. Check if your CSV parsing is working correctly. Ensure that each row in your CSV file is being read and processed correctly. You might be facing an issue where only the first row is being read and the rest are being ignored.

  2. Ensure that each invoice has a unique idempotency key. The idempotency key is used to prevent duplicate requests. If you’re using the same idempotency key for all your invoices, only the first one will be processed and the rest will be ignored as duplicates.

  3. Check if there are any errors in your API requests. Even though you’re getting a 200 response, there might be errors in the request body that are preventing the invoices from being processed. You can check the API logs in the developer dashboard for any error messages.

  4. Make sure you’re calling the PublishInvoice endpoint for each invoice. Creating an invoice and publishing it are two separate steps. After you create an invoice, you need to call the PublishInvoice endpoint to send it to the customer and start the payment process.

  5. Ensure that each invoice has all the required fields. If any required fields are missing from the invoice, it will not be processed.

If you’ve checked all these points and you’re still facing issues, you might need to debug your code to see where the problem lies.

This answer was reviewed by @Bryan-Square.

Hey, I appreciate the assistance! After looking through my echo results, i noticed that the idempotency was identical for each call to an invoice. I got that changed and boom, multiple invoices showed up and nothing in the error log! I literally just figured that out minutes before I checked my email and saw that I had a response and saw what you suggested.
Now, I just need to fix my csv parsing, i am getting some duplicated invoices and some rows that should be on one invoice popping over to different invoices for different customers…
Besides that, I think I am almost there, hopefully! Thank you again. I will be back if I can’t figure something else out.

Glad to hear that things are moving along. :slightly_smiling_face: