Happy Business Starts Here

Fetching the last version of the invoice PDF

Fetching the last version of the invoice PDF



We are having a hard time when trying to retrive the last version of the invoice PDF. We are having an integration between Zuora and our internal invoice distributor tool. When we send the invoice to that tool, we should be able to take only the last version of the PDF, because that contains the OCR, which is the reference for payment and is mandatory to be on the invoice. Here are the steps:

1. A new invoice is created in draft status - Zuora generates a PDF on the invoice (PDF version 1)

2. Invoice is posted - no new PDF is generated (still PDF version 1)

3. OPTIONAL: Some comments are added to the invoice (PDF version 2)

4. Integration calculates the OCR and updates a custom field in Zuora which stores this information

5. Integration tries to regenerate the PDF (PDF version 2 or 3).


Also, we are having Sequential Billing document number enabled, which leads to multiple versions of the PDF (because the invoice number is going to be changed when the invoice is posted).


Sometimes there are some delays and the regerenation doesn't happen in some seconds, so we cannot know for sure if the last PDF is the one regenerated by our user, since we are only receving a list of URLs to obtain the PDFs. 

One suggestion that we were thinking of is to add in the API also the ID of the user which created the PDF. In this way, when we will see our user's ID, we will know for sure that we are fetching the right version of it.