# Code Tables Reference

This document acts as a central repository for all standardized codes used as variables in Host System Requirements and Pinpad Responses. These identifiers are essential for parsing data, identifying errors, and configuring transaction behaviors.

## Transaction type codes (TTY)

Defined in the `[TTY]` field during initialization (**Y19**). It dictates the financial nature of the operation.

| Code   | Value    | Description                                         |
| ------ | -------- | --------------------------------------------------- |
| **00** | Purchase | Standard purchase of goods or services.             |
| **01** | Debit    | Standard debit transaction.                         |
| **02** | Credit   | Standard credit transaction.                        |
| **09** | Cashback | Purchase with cash withdrawal (Compra con Vuelto).  |
| **20** | Refund   | Reversal or return of funds (Anulación/Devolución). |

## Account type codes (TDC)

Used in the `[TDC]` field of the **Y15** command to suggest a target account type to the EMV kernel.

| Code  | Value           | Description                                   |
| ----- | --------------- | --------------------------------------------- |
| **N** | Not specified   | Default value indicating no preference.       |
| **1** | Check Account   | Standard checking account (Cuenta Corriente). |
| **2** | Savings Account | Standard savings account (Cuenta de Ahorro).  |

## Communication error codes (Y0E)

Returned by the Pinpad in the `[COE]` field of a **Y0E** response when a transaction fails or is interrupted.

| Code   | Message              | Cause / Meaning                                                 |
| ------ | -------------------- | --------------------------------------------------------------- |
| **01** | **CANCELADO**        | The user pressed the red "Cancel" button or Host sent `Y06`.    |
| **02** | **FALLA LECTURA**    | Chip/Stripe read failure or fallback restriction triggered.     |
| **03** | **TARJETA INVÁLIDA** | Card application not supported or card is blocked.              |
| **04** | **ERROR EMV**        | Protocol failure during the EMV Level 3 flow.                   |
| **05** | **ERROR PIN**        | Secure entry failed or was cancelled by the user.               |
| **06** | **MONTO INVÁLIDO**   | The amount provided is malformed or exceeds maximum parameters. |
| **07** | **TIMEOUT**          | The user action or command wait time has expired.               |
| **08** | **SIN LLAVES**       | Missing DUKPT injection in Slot 3/4 or missing RSA keys.        |
| **99** | **ERROR GRAL**       | Unhandled internal exception or general system fault.           |

## Common EMV tags (CPG - TLV)

In a **Y02** response, the `[CPG]` field contains a string of Tag-Length-Value (TLV) encoded data. These tags are critical for constructing authorization messages.

| Tag      | Name                          | Description                                                    |
| -------- | ----------------------------- | -------------------------------------------------------------- |
| **9F26** | Application Cryptogram        | The primary cryptogram (ARQC or TC) generated by the card.     |
| **9F10** | Issuer Application Data       | Proprietary data required by the issuer for validation.        |
| **9F37** | Unpredictable Number          | Terminal-generated random number for transaction uniqueness.   |
| **95**   | Terminal Verification Results | Results of offline validations performed by the terminal.      |
| **9B**   | Transaction Status Info       | Indicates the functions performed during the transaction flow. |
| **9C**   | Transaction Type              | Internal EMV code (e.g., `00` for Goods, `09` for Cashback).   |

> You will need a standard TLV parser on the Host System side to extract these specific values for your ISO 8583 authorization messages.

## Mode of entry (MDI)

Identifies the physical hardware interface used to present the card.

| Character | Mode            | Hardware Interface              |
| --------- | --------------- | ------------------------------- |
| **C**     | **Chip**        | EMV Contact Slot.               |
| **B**     | **Banda**       | Magnetic Stripe Reader (Swipe). |
| **L**     | **Contactless** | NFC Antenna (Tap).              |
| **M**     | **Manual**      | Manually keyed card entry.      |
| **E**     | **Error**       | The card could not be read.     |

## PAN encryption control (ENC)

Set in the `[ENC]` field of `Y19` and `Y02` to control DUKPT encryption of the PAN.

| Code  | Behavior                                                                  |
| ----- | ------------------------------------------------------------------------- |
| **0** | PAN DUKPT encryption disabled.                                            |
| **1** | PAN DUKPT encryption enabled.                                             |
| **2** | PAN encrypted using slot 3, with DUKPT enabled (forces single-key mode).  |

## Master key position (PMK)

Set in the `[PMK]` field of `Y19` and `Y02`. Only the PIN PMK is informed; the PAN PMK is always the PIN PMK plus one.

| Value     | PIN PMK   | PAN PMK       |
| --------- | --------- | ------------- |
| **0–9**   | The value | The value + 1 |
| **N**     | —         | —             |

A value of `N` means no PIN is requested and no PMK is informed; the firmware defaults to slot 3 for the PIN and slot 4 for the PAN when a key is present. The default master key position (POSMK) is `3`.

## Key serial numbers (KSN)

DUKPT returns a Key Serial Number alongside each encrypted element.

| Field     | Length               | Description                                |
| --------- | -------------------- | ------------------------------------------ |
| `KSN-PAN` | 20 digits (10 bytes) | KSN for the DUKPT-encrypted PAN.           |
| `KSN`     | 20 digits (10 bytes) | KSN for the DUKPT PIN.                      |

> Key slots, independent counters, and PAN masking are explained in [Pinpad Encryption](https://docs.globalgetnet.com/en/products/in-store-payments/host-to-host?doc=h2h-pinpad-encryption).