# Protocol and Type Reference

The Get Mini framework defines a series of Data Transfer Objects (DTOs) and protocols to manage merchant context, hardware initialization, and transaction results.

## Configuration & Merchant DTOs

These types are used to establish the identity and environment of the merchant.

### CommonUtils (Environment Setup)

Environment configuration is handled via global methods rather than a configuration object.

| Identifier | Description |
| :---- | :---- |
| `"des"` | Development environment |
| `"int"` | Integration/Testing environment |
| `"ccal"` | Certification environment |
| `"real"` | Production environment |

### MerchanDTO

Required to link a physical PIN pad to a merchant account during initialization.

| Property | Type | Description |
| :---- | :---- | :---- |
| `fuc` | String | 9-digit merchant code |
| `terminal` | String | Terminal number (e.g., "1") |
| `claveComercio` | String | Merchant security key |
| `nombreComercio` | String | Name displayed to the user |

## Protocol Definitions

Implement these protocols in your delegates to receive SDK callbacks.

### RedsysBTPinpadPaymentDelegate

Handles the lifecycle of a payment transaction and real-time user feedback.

| Method | When Called | Parameters |
| :---- | :---- | :---- |
| `onPaymentProcess` | State changes in the PIN pad | `id` (Result), `NSError` |
| `onPaymentFeedback` | Real-time choice required (DCC/Installments) | `RespuestaTransaccionDTO`, `NSError` |
| `onPaymentFinished` | Transaction completes (Approved/Denied) | `RespuestaTransaccionDTO`, `NSError` |

### RedsysBTPinpadInitDelegate

Monitors the connection and key-injection process of a PIN pad.

| Method | When Called | Parameters |
| :---- | :---- | :---- |
| `onInitProcess` | Status update during Setup | `id` (Status string) |
| `onInitFinished` | Setup complete | `PinpadConfig`, `NSError` |

## Transaction Data Types

### PagoDTO

Defines the parameters for a specific payment attempt.

| Property | Type | Description |
| :---- | :---- | :---- |
| `valorCompra` | Int | Amount in cents (e.g., 1050 for 10.50€) |
| `moneda` | Int | ISO 4217 code (e.g., 978 for EUR) |
| `tipoOper` | String | "Autorización" or "Preautorización" |
| `emailCliente` | String | (Optional) Triggers automatic receipt email |
| `tlfCliente` | String | (Optional) Triggers automatic receipt SMS |

### RespuestaTransaccionDTO

The primary result object returned after a transaction attempt.

| Property | Type | Description |
| :---- | :---- | :---- |
| `estado` | String | "F" (Finalized), "G" (Denied), "T" (Technical Error) |
| `resultado` | String | "Autorizada" or "Denegada" |
| `identificadorRTS` | String | 24-char unique key for refunds and queries |
| `literales` | Array | Array of strings required for the receipt |
| `autenticadoPorPin` | Bool | Indicates if a physical signature is required |
| `token` | String | (Pay by Reference) Card token for recurring payments |

## Inquiry & Management DTOs

### OperacionDTO

Represents a past transaction retrieved via the history query.

| Property | Type | Description |
| :---- | :---- | :---- |
| `importe` | String | Formatted amount (e.g., "10.50") |
| `fechaOperacion` | NSDate | Timestamp of the transaction |
| `numAutorizacion` | String | Gateway authorization code |
| `factura` | String | Your internal invoice/order ID |

### PerfilComercioRespuesta

Returned by `peticionPerfilComercio` to check active terminal features.

| Property | Type | Description |
| :---- | :---- | :---- |
| `permitePreauto` | Bool | Merchant can perform Pre-authorizations |
| `permiteDCC` | Bool | Merchant can handle installments/currency conversion |
| `permiteEntradaManual` | Bool | Merchant can type card numbers manually |

## Enumerations

### PinpadTechnology

Specifies the communication protocol for the hardware.

| Value | Description |
| :---- | :---- |
| `pinpadBluetooth` | Standard Bluetooth connection (Most devices) |
| `pinpadBluetoothPan` | Bluetooth Personal Area Network (FlyPOS devices) |
| `pinpadBluetoothSMPP` | Secure Bluetooth communication |

| `pinpadWifi` | Connection via local network/Wi-Fi |

## Implementation Notes

1. **Amount Formats**: Always check if a method expects cents (Int) or formatted strings (String). Payments usually use cents; refunds use strings.
2. **Result Codes**: A code of 117 in `error.code` specifically indicates a "Wrong PIN" denial.
3. **Data Persistency**: The SDK uses local SQLite storage for certain modules; ensure you include the `-lsqlite3` linker flag.