Downloading the invoice

Learn how to download the invoice PDF file for an order.

An invoice represents a document associated with a sale you provide to the shopper. The invoice itemizes the products or services rendered and includes their cost, quantity, fees, duties, and taxes. It also establishes an obligation on the part of the shopper to pay you for those products and services.

Invoices can be especially useful when selling to other businesses. For business transactions, it's often customary to send customers an invoice, which they pay at a later time, rather than immediately billing a credit card you have on file.

This topic explains how to download the invoice PDF file.

Invoice PDF download scenarios

You can download the invoice PDF programmatically or from a webhook notification.

Downloading the invoice PDF programmatically

To download the invoice PDF programmatically:

  1. Get the receipt for the order's invoice and download the PDF in the 200 OK response.

Step 1: Getting the download information for the order's invoice

Use the GET /v1/orders/{orderId}/invoices request to get the specified orders (orderId) invoice download information. An order may contain more than one invoice (invoiceUrl). This request includes all downloadable invoice URLs (invoiceURL) in the response. You can use the receipt identifier (receiptId) to download the invoices one by one.

curl --location --request GET 'https://api.digitalriver.com/v1/orders/{orderId}/invoices' \
--header 'authorization: basic ***\
...

Step 2: Getting the receipt for the invoice

Use the GET /v1/orders{orderId}/invoices/{receiptId} request to download the invoice by its invoice identifier (receiptId) for a specific order (orderId).

curl --location --request GET 'https://api.digitalriver.com/v1/orders/{orderId}/invoices/{receiptId}' \
--header 'authorization: basic ***\
...

Downloading the invoice PDF via a webhook notification

To download the invoice PDF from an invoice URL:

Step 1: Getting the file identifier for the invoice

When the invoice file is created, it triggers the order.invoice.created event and you will receive a notification. Choose one of the following options:

  • Copy the value for the fileId. You will need that value to get the invoice PDF file.

  • Copy the value for the invoice URL and paste it into your browser's address field.

{
    "id": "db375d32-52c0-4188-a05c-552933d254c5",
    "type": "order.invoice.created",
    "data": {
        "object": {
            "id": "9e00869b-e2f5-4663-aacb-e33687466020",
            "fileId": "9e00869b-e2f5-4663-aacb-e33687466020",
            "orderId": "851511800082",
            "customerId": "503451273389",
            "purpose": "customer_invoice",
            "invoiceURL": "https://api.digitalriver.com/files/9e00869b-e2f5-4663-aacb-e33687466020/content"
        }
    },
    "liveMode": false,
    "createdTime": "2020-10-14T09:03:33.988Z"
}

Step 2: Getting the invoice PDF file

Use the GET /files/{fileId}/content request to fetch the invoice PDF file specified by the file identifier (fileId) provided in the notification.

curl --location --request GET 'https://api.digitalriver.com/files/{fileId}/content' \
--header 'authorization: basic***\
...

Last updated

Was this helpful?

#1249: DOC-395 CCAvenue

Change request updated