Transaction receipts over the API
List, read, and print the receipts WinkPG generates for a transaction, get one on demand when a terminal needs to print before the receipt exists, and email or text one to the customer.
This guide is for developers who want to print or show the receipt WinkPG keeps for a transaction: a terminal application that prints a copy at the counter, or an online checkout that shows the receipt again later. It covers how receipts are generated, the five receipt requests, sending a receipt to the customer, and what a receipt does and doesn't contain.
What a receipt is
A receipt records one event in a transaction's life, such as the authorization, the capture, or a refund, exactly as it stood at that moment. It never changes after it's generated. A transaction can have several receipts, one for each event, numbered in the order they were generated.
Every receipt has a type:
receiptType |
Records |
|---|---|
Authorization |
The sale or authorization result. This is the receipt a terminal prints after a sale. |
Capture |
The capture of an authorization. |
Refund and PartialRefund |
A full or partial refund. A transaction can have several partial refund receipts. |
Void, Reversal, and PartialReversal |
A void or a full or partial reversal. |
OnDemand |
A copy requested on demand, such as a reprint. |
SplitTenderSummary |
The total of a completed split tender group, on the group's primary transaction. |
WinkPG generates the receipt for each event in the background, shortly after the event. A transaction you've just created can therefore have no receipt yet. The transaction's receiptIds lists the receipts it has, oldest first.
The requests
Every receipt request names the merchant and the transaction in the path, in the same way as the follow-up operations on a transaction.
| Request | Returns |
|---|---|
GET /api/transactions/by-merchant/{merchantId}/{transactionId}/receipts |
A summary of each receipt, oldest first. |
GET /api/transactions/by-merchant/{merchantId}/{transactionId}/receipts/{receiptId} |
One receipt, as JSON. |
GET /api/transactions/by-merchant/{merchantId}/{transactionId}/receipts/{receiptId}/html |
One receipt, rendered as an HTML document. |
POST /api/transactions/by-merchant/{merchantId}/{transactionId}/receipts |
The receipt of the type you ask for, generated first if the transaction doesn't have one yet. |
POST /api/transactions/by-merchant/{merchantId}/{transactionId}/receipts/{receiptId}/send |
Whether the receipt was emailed or texted to the address or number you give. |
The three GET requests need an API key with the transactions:read scope. The two POST requests need transactions:write: one can store a new receipt, and the other sends a message to your customer.
A receipt that belongs to another merchant, or to another transaction of the same merchant, returns HTTP 404, the same as a receipt id that doesn't exist. Always address a receipt under the transaction it belongs to.
List a transaction's receipts
The list returns a summary of each receipt: its id, receiptType, sequenceNumber, generatedAtUtc, whether the transaction was approved, the total, and whether the receipt has been emailed.
An empty list isn't an error. It means no receipt has been generated yet. If you need the receipt now, request it with the POST described in Get a receipt on demand instead of polling the list.
Read a receipt
Read one receipt as JSON when your application lays out its own printout. The response carries what's printed on the gateway's receipt: the merchant's name, address, and terminal ID, the status and authorization code, the amounts, the payment method, any custom fields the merchant shows on receipts, and the dates.
statusDisplay is one of Approved, Partially Approved, Pending, Not Completed, or Declined. authorizationCode is present only on an approved receipt.
Print the gateway's receipt
The /html request returns the receipt WinkPG renders for email and the payment pages, as a complete HTML document with inline styles. Send it to a printer or show it in a web view as it is.
The response is served with a Content-Security-Policy that sandboxes the document: it can't run script, and it can load only its own styles and images. If you show it inside your own page, put it in a sandboxed iframe rather than inserting the markup into the page.
Get a receipt on demand
When the terminal needs to print before the background receipt exists, ask for it directly:
POST /api/transactions/by-merchant/{merchantId}/{transactionId}/receipts
Content-Type: application/json
{
"receiptType": "Authorization"
}
The response is the receipt, in the same shape as the single-receipt GET. The request is safe to repeat:
- A type the transaction already has returns that receipt. Asking for
Authorizationtwice returns the same receipt id both times, and so does asking after the background receipt was generated. OnDemandreturns the most recent receipt when it's also an on-demand copy, so a retry doesn't make a second copy. Asking again after another receipt was generated makes a new copy.SplitTenderSummarycan't be requested. WinkPG generates it once the whole split tender group completes, and the request returns HTTP400.
receiptType is required. A request without it returns HTTP 400.
Send a receipt to the customer
Email or text a receipt to the customer at the counter. The send needs the Send receipts permission, which roles that can generate receipts hold, along with the permission to read the receipt. Name the channel and one recipient for it:
POST /api/transactions/by-merchant/{merchantId}/{transactionId}/receipts/{receiptId}/send
Content-Type: application/json
{
"channel": "Email",
"emailAddress": "jordan.lee@example.com"
}
To text it instead, send "channel": "Text" with a mobileNumber such as +15555550123. Include only the recipient for the channel you choose; a request that names both returns HTTP 400. A mobile number needs 10 to 15 digits, and a 10-digit number without a country code is read as a North American number.
- Email sends the receipt as it prints, the same email the virtual terminal sends, and records the address on the receipt. Receipt emails must be enabled for the merchant; when they aren't, the request returns HTTP
403with the codeTransactions:ReceiptEmailDisabled. - Text sends a short summary: the merchant's name, the amount and status, the card brand and last four digits, the date, and the approval code. It contains no link.
The response tells you whether the message went out:
{
"receiptId": "8c3f2a4e-3333-4e4d-9b5a-23456789abcd",
"channel": "Text",
"sent": false,
"notSentReason": "RecipientOptedOut"
}
sent is false with notSentReason set to RecipientOptedOut when the mobile number has opted out of text messages. Sending again won't reach the customer until they opt back in, so offer email instead.
Each API key can send 10 receipts a minute, and the receipts of one transaction can be sent 5 times an hour. Past either limit the request returns HTTP 429 with a Retry-After header.
What a receipt never contains
A receipt identifies a card by its brand and last four digits only. It never carries the full card number, the expiration date, the security code, or a payment token, in the JSON or in the HTML. That makes a receipt safe to print, email, and keep in your own records.
See also
- Card-present payments over the API for the sale request a terminal sends before it prints.
- Refunds, voids, and reversals for the operations that produce refund, void, and reversal receipts.
- Transaction lifecycle and settlement for the events a transaction moves through.