Downloading the invoice
Learn how to download the invoice PDF file for an order.
Last updated
Was this helpful?
Learn how to download the invoice PDF file for an order.
Last updated
Was this helpful?
An invoice represents a document associated with a sale you provide to the shopper. The invoice itemizes the products or services rendered, including 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 later, rather than immediately billing a credit card you have on file.
This topic explains how to download the invoice PDF file.
You can download the invoice PDF programmatically or from a webhook notification.
To download the invoice PDF programmatically, follow these steps:
To get the download information for the order's invoice, send a request
. Replace {orderId}
with the actual order ID. This request retrieves all downloadable invoice URLs (invoiceURL) for the order. Each invoice can be individually downloaded using the provided receiptId
.
Example request:
Example 200 OK
response:
Replace {orderId}
with the order's identifier and {receiptId}
with the invoice's identifier. Ensure your 'authorization' header contains the correct basic auth credentials. You will receive a 200 OK response that includes the PDF file of the invoice:
You must enable the following events when creating a webhook in Global Commerce before you can perform this task:
order.invoice.created
: The creation of an order invoice triggers this event.
To retrieve the invoice PDF file, follow these steps:
Wait for the order.invoice.created
event: This event is triggered when an invoice file is created.
Obtain the fileId
: In the notification you receive, locate the "fileId"
value. Here's an example snippet:
Replace {fileId}
with the actual fileId
value and <YourAuthCredentials>
with your appropriate authorization header value.
By performing these steps, you will be able to download the invoice PDF file associated with the generated fileId
.
To retrieve the receipt for an invoice, send a request to download the invoice by its unique invoice identifier (receiptId
) for a specified order (orderId
):
Retrieve the Invoice PDF: Use the fileId obtained to fetch the invoice PDF by sending a request as shown below: