# DE63 Receipt Template

DE63 in the middleware response carries a JSON receipt payload that the POS device renders and prints. It is populated for all approved and declined financial transactions (Sale, Pre-Auth, Auth-Compl, Refund, Void) as well as Settlement. Reversal (0400) and Key Exchange (0800) messages do not carry a receipt.

**Source:** `jpos/src/main/java/org/jpos/tcpay/service/ReceiptGenerator.java`

---

## Top-level structure

```
r.type   — Transaction type string (e.g. "Sale", "Refund", "Pre-Auth")
r.e      — Ordered array of receipt elements, rendered top-to-bottom by the device
```

---

## Element types

| Element key | Description |
|-------------|-------------|
| `lg` | Logo image printed at the top of the receipt |
| `txt` | Single text line |
| `dualField` | Two label-value pairs printed side by side on one line |
| `ls` | Blank line separator |
| `emv` | Instructs the device to print EMV chip details locally from its ICC data |

---

## Element properties

| Property | Applies to | Description |
|----------|------------|-------------|
| `url` | `lg` | Full URL of the logo image |
| `va` | `txt` | Text value to print |
| `al` | `txt` | Text alignment: `LEFT`, `CENTER`, `RIGHT` |
| `fs` | `txt`, `dualField` | Font size: `"0.5:0.5"` (small), `"1:1"` (normal), `"2:2"` (large), `"3:3"` (extra large) |
| `b` | `txt` | Bold flag: `1` = bold |
| `lf` | `txt` | Number of blank lines to add after this element |
| `leftLabel` | `dualField` | Left-side label text |
| `leftValue` | `dualField` | Left-side value text |
| `leftChars` | `dualField` | Character width allocated to the left column |
| `rightLabel` | `dualField` | Right-side label text |
| `rightValue` | `dualField` | Right-side value text |
| `rightChars` | `dualField` | Character width allocated to the right column |
| `rightAlign` | `dualField` | Alignment of right-side value: `LEFT` or `RIGHT` |

---

## Receipt field reference

| Element in `r.e` | Label on receipt | Explanation |
|-----------------|-----------------|-------------|
| `lg.url` | *(logo image)* | Merchant logo fetched from URL and printed at the top of the receipt |
| `txt.va` — merchant name | e.g. `Demo Merchant LLC` | Merchant trading name configured in the rules engine |
| `txt.va` — merchant address | e.g. `123 Main St, Colombo` | Merchant location configured in the rules engine |
| `dualField` — TID / MID | `TID:` / `MID:` | Terminal ID and Merchant ID as returned by the bank |
| `dualField` — DATE / TIME | `DATE:` / `TIME:` | Local transaction date (DD/MM/YYYY) and time (HH:MM:SS) from DE13 and DE12 |
| `txt.va` — scheme + entry mode | e.g. `VISA (CONTACTLESS)` | Card network (detected from AID or BIN) and how the card was read: `CHIP`, `CONTACTLESS`, `MAGNETIC STRIPE`, `MANUAL`, or `FALLBACK` |
| `txt.va` bold — transaction type | e.g. `Sale` | Transaction type derived from MTI and processing code: `Sale`, `Pre-Auth`, `Auth-Compl`, `Refund`, `Void-Sale`, `Void-Preauth`, `Void-Completion` |
| `txt.va` — masked PAN | e.g. `************2805` | Cardholder card number with only the last 4 digits visible (from DE2) |
| `dualField` — BATCH NO / RECEIPT NO | `BATCH NO:` / `RECEIPT NO:` | Batch number and receipt/STAN number from the bank |
| `txt.va` — RRN | e.g. `RRN: 617514000006` | Retrieval Reference Number from DE37, used for dispute and reconciliation |
| `txt.va` fs `3:3` — amount | e.g. `AED5.00` | Transaction amount in local currency printed in extra-large font (DE4 ÷ 100) |
| `txt.va` — approval code | `APPROVAL CODE: 123456` | 6-character authorization code returned by the bank (DE38); present on approved transactions only |
| `txt.va` — account message | `PLEASE DEBIT MY ACCOUNT` | Consumer instruction: `PLEASE DEBIT MY ACCOUNT` for Sale/Pre-Auth/Auth-Compl; `PLEASE CREDIT MY ACCOUNT` for Void/Refund |
| `ls` | *(blank line)* | Adds vertical spacing between receipt sections |
| `txt.va` — signature line | `Sign:_ _ _ _ _...` | Blank line for cardholder handwritten signature; printed only when CVM result is SIGNATURE REQUIRED |
| `txt.va` — `/` | `/` | Closing separator below the signature line |
| `emv: "local"` | *(EMV data block)* | Triggers the device to print EMV chip details (AID, TVR, TSI, CID, AC) sourced from the ICC data in DE55 |
| `txt.va` — app version | e.g. `APP VER: V3.8.7-SNAPSHOT` | POS application software version from DE56 |
| `txt.va` — footer message | e.g. `Powered by DataAegis` | Merchant-configured footer message from rules engine |
| `txt.va` — footer description | e.g. `Thank you for shopping` | Secondary footer text from rules engine |

---

## Sample — Approved Sale

```json
{
  "r": {
    "type": "Sale",
    "e": [
      { "lg": { "url": "https://cdn.example.com/logo.png" } },
      { "txt": { "va": "Demo Merchant LLC", "al": "CENTER" } },
      { "txt": { "va": "123 Main St, Colombo", "al": "CENTER" } },
      {
        "dualField": {
          "leftLabel": "TID:", "leftValue": "8900901", "leftChars": 18,
          "rightLabel": "MID:", "rightValue": "01000006", "rightChars": 20,
          "rightAlign": "LEFT", "fs": "0.5:0.5"
        }
      },
      {
        "dualField": {
          "leftLabel": "DATE:", "leftValue": "24/06/2026", "leftChars": 18,
          "rightLabel": "TIME:", "rightValue": "19:48:37", "rightChars": 20,
          "rightAlign": "LEFT", "fs": "0.5:0.5"
        }
      },
      { "txt": { "va": "VISA (CONTACTLESS)", "al": "LEFT" } },
      { "txt": { "va": "Sale", "al": "LEFT", "b": 1 } },
      { "txt": { "va": "************2805", "al": "LEFT" } },
      {
        "dualField": {
          "leftLabel": "BATCH NO:", "leftValue": "000002", "leftChars": 18,
          "rightLabel": "RECEIPT NO:", "rightValue": "000006", "rightChars": 20,
          "rightAlign": "LEFT", "fs": "0.5:0.5"
        }
      },
      { "txt": { "va": "RRN: 617514000006", "al": "LEFT", "fs": "0.5:0.5" } },
      { "txt": { "va": "AED5.00", "al": "CENTER", "fs": "3:3" } },
      { "txt": { "va": "APPROVAL CODE: 123456", "al": "CENTER" } },
      { "txt": { "va": "PLEASE DEBIT MY ACCOUNT", "al": "CENTER" } },
      { "ls": {} },
      { "txt": { "va": "Sign:_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ", "al": "CENTER" } },
      { "txt": { "va": " /", "al": "CENTER" } },
      { "emv": "local" },
      { "txt": { "va": "APP VER: V3.8.7-SNAPSHOT", "al": "CENTER" } },
      { "txt": { "va": "Powered by DataAegis", "al": "CENTER" } },
      { "txt": { "va": "Thank you for shopping", "al": "CENTER" } }
    ]
  }
}
```
