> For the complete documentation index, see [llms.txt](https://docs.digitalriver.com/digital-river-api/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://docs.digitalriver.com/digital-river-api/order-management/accessing-invoices-and-credit-memos.md).

# Accessing invoices and credit memos

For some transactions, Digital River automatically generates the [order invoice](#order-invoices) and [credit memo](#credit-memos) files that you can access and then share with your customers. To do this, you can implement nearly identical solutions.

To localize these files, set the [checkout's](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/checkouts) [`locale`](/digital-river-api/integration-options/checkouts/creating-checkouts/designating-a-locale.md).

For testing purposes, we also allow you to generate [mock order invoices and credit memos](#mock-order-invoices-and-credit-memos).

## Order invoices

In transactions assigned to one of the following [selling entities](/digital-river-api/integration-options/checkouts/creating-checkouts/selling-entities.md), Digital River generates an order invoice in PDF that you can share with customers:

* `Digital River, Inc.`
* `DR globalTech Inc.`
* `Digital River Ireland Ltd.`
* `Digital River UK`
* `DR Japan`

### How to access the invoice file

By [listening for the order invoice created event](#listening-for-the-order-invoice-created-event) or by [retrieving the order](#retrieving-the-invoice-file-identifier-from-the-order), you can get an invoice's file identifier and then use it to generate a shareable link.

You can also [download an invoice in Digital River Dashboard](/digital-river-api/administration/dashboard/order-management/orders/downloading-an-invoice.md).

{% hint style="info" %}
If an [order's ](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/orders)`totalAmount` is `0`, then Digital River doesn't generate a customer invoice.
{% endhint %}

#### Listening for the order invoice created event

You can be notified when the invoice is created by listening for the [event ](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/events)with a [`type`](/digital-river-api/order-management/events-and-webhooks-1/events-1.md#event-types) of [`order.invoice.created`](https://docs.digitalriver.com/digital-river-api/order-management/pages/okHqAQ9d1PaLPLjq6nZF#order.invoice.created).

The event's [`data.object`](/digital-river-api/order-management/events-and-webhooks-1/events-1.md#event-data) contains an `id` and a `fileId`, both of which are identical and contain the invoice's [file ](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/files)identifier. You can use either to [create a publicly accessible link](#creating-a-publicly-accessible-link).

{% tabs %}
{% tab title="order.invoice.created" %}

```javascript
{
    "id": "c902f8aa-16fb-44ba-ba7b-f3c84061685a",
    "type": "order.invoice.created",
    "data": {
        "object": {
            "id": "6e5bf525-3907-40c5-86a9-f14ce4f33f35",
            "fileId": "6e5bf525-3907-40c5-86a9-f14ce4f33f35",
            "orderId": "188418250336",
            "customerId": "532736320336",
            "purpose": "customer_invoice",
            "invoiceURL": "https://api.digitalriver.com/files/6e5bf525-3907-40c5-86a9-f14ce4f33f35/content"
        }
    },
    "liveMode": false,
    "createdTime": "2021-04-28T02:04:13.591115Z",
    "versionIds": []
}
```

{% endtab %}
{% endtabs %}

{% hint style="warning" %}
In the event's `data.object`, the `invoiceURL` can only be accessed with your [confidential (secret) API key](https://docs.digitalriver.com/digital-river-api-reference/digital-river-api-reference-guide/api-structure#confidential-keys). Since your customers won't be able to access the contents of this link, don't share it with them.
{% endhint %}

#### Retrieving the invoice file identifier from the order

To access the customer invoice file, you can also [retrieve the order](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/orders#orders-id-1).

Once invoices are generated, Digital River populates the [order's ](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/orders)`invoicePDFs[]`. If `invoicePDFs[]` doesn't exist, then the [file(s)](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/files) have yet to be created.

Each element of this array contains a [file's ](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/files)unique `id` and `url`.

You'll need to use `invoicePDFs[].id` to [create a publicly accessible link](#creating-a-publicly-accessible-link).

{% hint style="warning" %}
In the [order](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/orders), the `invoicePDFs[].url` can only be accessed with your [confidential (secret) API key](https://docs.digitalriver.com/digital-river-api-reference/digital-river-api-reference-guide/api-structure#confidential-keys). Since your customers won't be able to access the contents of this link, don't share it with them.
{% endhint %}

{% tabs %}
{% tab title="Order" %}

```javascript
{
    "id": "188418250336",
    ...
    "invoicePDFs": [
        {
            "id": "6e5bf525-3907-40c5-86a9-f14ce4f33f35",
            "url": "https://api.digitalriver.com/files/6e5bf525-3907-40c5-86a9-f14ce4f33f35/content",
            "liveMode": false
        }
    ],
    ...
}
```

{% endtab %}
{% endtabs %}

### Creating a publicly accessible link

To create a publicly accessible link to the invoice [file](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/files), assign its identifier to `fileId` and send it in the body of a [`POST /file-links`](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/file-links#file-links-1) request.

The response contains a `url` you can share with your customers by email, in their account management portals, or by another method of your choice.

## Credit memos

A credit memo is a document issued to customers notifying them of a reduced amount they owe.

### How to access the credit memo file

By [listening for the credit memo created event](#listening-for-the-credit-memo-created-event) or by [retrieving the order](#retrieving-the-credit-memo-file-identifier-from-the-order), you can get a credit memo's file identifier and then use it to generate a shareable link.

#### Listening for the credit memo created event

You can be notified when a credit memo is created by listening for the [event ](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/events)with a [`type`](/digital-river-api/order-management/events-and-webhooks-1/events-1.md#event-types) of [`order.credit_memo.created`](https://docs.digitalriver.com/digital-river-api/order-management/pages/okHqAQ9d1PaLPLjq6nZF#order.credit_memo.created).

The event's [`data.object`](/digital-river-api/order-management/events-and-webhooks-1/events-1.md#event-data) contains an `id` and a `fileId`, both of which are identical and contain the credit memo's [file ](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/events)identifier. You can use either to [create a publicly accessible link](#creating-a-publicly-accessible-link-1).

{% tabs %}
{% tab title="order.credit\_memo.created" %}

```javascript
{
    "id": "d3786b5b-540b-4885-92a4-62f937d13f26",
    "type": "order.credit_memo.created",
    "data": {
        "object": {
            "id": "c233c10f-17e8-4799-a1ce-2469d042f29d",
            "fileId": "c233c10f-17e8-4799-a1ce-2469d042f29d",
            "orderId": "188466550336",
            "customerId": "532795950336",
            "purpose": "customer_credit_memo",
            "invoiceURL": "https://api.digitalriver.com/files/c233c10f-17e8-4799-a1ce-2469d042f29d/content"
        }
    },
    "liveMode": false,
    "createdTime": "2021-04-29T02:15:20.516626Z",
    "versionIds": []
}
```

{% endtab %}
{% endtabs %}

{% hint style="warning" %}
In the event's `data.object`, the `invoiceURL` can only be accessed with your [confidential (secret) API key](https://docs.digitalriver.com/digital-river-api-reference/digital-river-api-reference-guide/api-structure#confidential-keys). Since your customers won't be able to access the contents of this link, don't share it with them.
{% endhint %}

#### Retrieving the credit memo file identifier from the order

To access a customer's credit memo file, you can also [retrieve the order](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/orders#orders-id).

Once credit memos are generated, Digital River populates the [order's ](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/orders)`creditMemoPDFs[]`. If `creditMemoPDFs[]` doesn't exist, then the [file(s)](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/files) have yet to be created.

Each element of this array contains a [file's ](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/files)unique `id` and `url`.

You'll need to use `creditMemoPDFs[].id` to [create a publicly accessible link](#creating-a-publicly-accessible-link-1).

{% hint style="warning" %}
In the [order](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/orders), the `creditMemoPDFs[].url` can only be accessed with your [confidential (secret) API key](https://docs.digitalriver.com/digital-river-api-reference/digital-river-api-reference-guide/api-structure#confidential-keys). Since your customers won't be able to access the contents of this link, don't share it with them.
{% endhint %}

{% tabs %}
{% tab title="Order" %}

```javascript
{
    "id": "188418250336",
    ...
    "creditMemoPDFs": [
        {
            "id": "fb50c8c2-8b32-4a3d-9947-dbdef12a5cdc",
            "url": "https://api.digitalriver.com/files/fb50c8c2-8b32-4a3d-9947-dbdef12a5cdc/content",
            "liveMode": false
        }
    ],
    ...
}
```

{% endtab %}
{% endtabs %}

### Creating a publicly accessible link

To create a publicly accessible link to a customer's credit memo [file](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/files), assign its identifier to `fileId` and send it in the body of a [`POST /file-links`](https://docs.digitalriver.com/digital-river-api-reference/2021-12-13/file-links#file-links-1) request.

The response contains a `url` you can share with your customers by email, in their account management portals, or by another method of your choice.

## Mock order invoices and credit memos

You can also generate the order invoice and credit memo files in [test mode](https://docs.digitalriver.com/digital-river-api-reference/digital-river-api-reference-guide/best-practices#test-mode). Accessing them is the same as in the production environment.

The following are example mock tax invoice and credit memo PDFs:

{% file src="/files/-MVMHyzq1f3aveCeHKnO" %}
Sample VAT invoice
{% endfile %}

{% file src="/files/-MVMIFqfiOZifgzWvuBZ" %}
Sample credit memo
{% endfile %}
