# Data Models Glossary

This page serves as a reference for the core data classes and enumerations used in the `redsys-tpv-business-lib`. Understanding these models is essential for interpreting transaction results and configuring the TPV.

## Core Data Classes

### Transaction

The `Transaction` object is the central model representing a financial operation. It is returned in the Accepted or Denied states of payments, refunds, and history queries.

| Property | Type | Description |
| :--- | :--- | :--- |
| `type` | `OperationType` | The type of operation performed (e.g., PAYMENT, REFUND). |
| `result` | `OperationResult` | The final result of the operation (e.g., AUTHORIZED, DENIED). |
| `amount` | `Money?` | The amount of the transaction. |
| `tip` | `Money?` | The tip amount, if applicable. |
| `cardInfo` | `CardInfo` | Details about the card used in the transaction. |
| `operationInfo` | `OperationInfo` | Specific identifiers and authorization data from the host. |
| `commerceInfo` | `CommerceInfo` | Information about the merchant and terminal. |
| `dccInfo` | `DccInfo?` | Dynamic Currency Conversion details (only present if DCC was applied). |
| `digitalSignature` | `Bitmap?` | The signature captured on screen (optional). |
| `thirdDataInfo` | `ThirdDataInfo?` | Optional data for third-party integrations (e.g., invoice numbers). |
| `qrInfo` | `QrInfo?` | Information if the transaction was made via QR code. |
| `financialInfo` | `FinancialInfo?` | Deferred payments (Plazox) data. |
| `prnReceipt` | `PrnReceiptInfo?` | Configuration settings related to receipt printing. |
| `prnIssuer` | `String?` | Extra information related to card entity. |

### Money

Represents a monetary value.

| Property | Type | Description |
| :---- | :---- | :---- |
| `amount` | `BigDecimal` | The numeric value. |
| `currency` | `Currency` | The Java `Currency` instance (e.g., `Currency.getInstance("EUR")`). |

### CardInfo

Encapsulates data regarding the payment card.

| Property | Type | Description |
| :--- | :--- | :--- |
| `card` | `String?` | Masked card number (e.g., `************1234`). |
| `cardBrand` | `CardBrand?` | The detected brand of the card (e.g., `VISA`). |
| `cardBrandLabel` | `String?` | The full label of the card brand. |
| `aid` | `String?` | The EMV Application Identifier. |

### OperationInfo

Contains the technical details of the transaction execution.

| Property | Type | Description |
| :--- | :--- | :--- |
| `identifier` | `String` | The unique internal identifier for the operation. |
| `number` | `String?` | The sequential operation number (Ticket number). |
| `date` | `Date?` | The date and time the operation occurred. |
| `authorizationNumber` | `String?` | The authorization code from the bank. |
| `reference` | `String?` | The transaction reference. |
| `failedReasonInfo` | `FailedReasonInfo?` | Contains the error code and description if the operation failed. |
| `tvr` | `String?` | Terminal Verification Result (EMV tag). |
| `atc` | `String?` | Application Transaction Counter. |
| `resp` | `String?` | Response code (ISO 8583). |

### CommerceInfo

Identifies the merchant configuration used for the transaction.

| Property | Type | Description |
| :---- | :---- | :---- |
| `fucCode` | `String?` | The Merchant ID (FUC). |
| `terminal` | `String?` | The Terminal Number. |

### TpvInfo

The result of the initTpv call, containing device and merchant configuration.

| Property | Type | Description |
| :---- | :---- | :---- |
| `config` | `TpvConfig` | Configuration flags and merchant details. |
| `deviceInfo` | `TpvDeviceInfo` | Hardware-specific information. |
| `virtualTerminalList` | `List<TpvVirtualTerminal>?` | List of available virtual terminals (multi-terminal mode). |

### TpvConfig

Details specific configuration flags for the terminal.

| Property | Type | Description |
| :--- | :--- | :--- |
| `merchantName` | `String` | The commercial name of the merchant. |
| `fuc` | `String` | The Merchant ID. |
| `terminal` | `String` | The Terminal ID. |
| `currency` | `Int` | Numeric currency code (e.g., 978). |
| `showPreauthorizations` | `Boolean` | `true` if Pre-authorizations are enabled. |
| `noOriginal` | `Boolean` | `true` if "Refund without Original" is enabled. |

### DccInfo

Details regarding Dynamic Currency Conversion (if applicable).

| Property | Type | Description |
| :--- | :--- | :--- |
| `currencyChangeAmount` | `String?` | Amount in the foreign currency. |
| `currencyCode` | `String` | Foreign currency code (e.g., "USD"). |
| `markup` | `Float?` | The markup percentage applied. |
| `exchangeRate` | `String` | The applied exchange rate string. |

## Enumerations

### OperationType

Defines the classification of a transaction.

* `PAYMENT`  
* `REFUND`  
* `PREAUTH`  
* `PREAUTH_CONFIRM`  
* `PREAUTH_REPLACE`  
* `PREAUTH_CANCEL`  
* `UNKNOWN`

### OperationResult

Defines the final status of a transaction.

* `AUTHORIZED`  
* `DENIED`  
* `ANNUL`  
* `PREAUTH_NO_CONFIRM`  
* `UNKNOWN`

### CardBrand

Supported card brands and payment methods.

* `VISA`  
* `MASTERCARD`  
* `AMERICAN_EXPRESS`  
* `JCB`  
* `DINERS` (Note: sometimes mapped via other brands)  
* `BIZUM`  
* `ALIPAY`  
* `WECHAT`  
* `GOOGLE_PAY`  
* `APPLE_PAY` 
* `SAMSUNG_PAY`  
* `UNKNOWN`

### ProtocolErrorType

Categories for integration errors returned in RepositoryResult.ProtocolError.

* `MAPPING_DATA`: Internal error mapping service data.  
* `MAPPING_DOMAIN`: Error in the request data format sent by the app.  
* `TPV_NOT_INITIALIZED`: Operation attempted before initTpv().