# Request Parameters

This reference lists the **public functions and parameters** the Slim Pack library exposes, with their **exact parameter names and signatures**.

This guide applies to **Slim Pack**.

The tables below reflect the real invocation model used by the library. Parameters are listed **exactly as they must appear in code**, without aliases, translations, or inferred fields.

## Initialization and Lifecycle Functions

These are the functions that are used to initialize and manage the TPVPC lifecycle.

### fnDllIniTpvpcLatente

Initializes the TPVPC and opens communication with the PIN pad. This function **must be called once** when the application starts.

**Function signature (C#):**

`int fnDllIniTpvpcLatente(string cComercio, string cTerminal, string cClaveFirma, string cConfPuerto, string cVersion);`

| Parameter     | Type   | Required | Description                                                                               |
| ------------- | ------ | -------- | ----------------------------------------------------------------------------------------- |
| `cComercio`   | String | Yes      | Merchant identifier (FUC) provided by the acquirer.                               |
| `cTerminal`   | String | Yes      | Terminal identifier assigned to the PIN pad.                                              |
| `cClaveFirma` | String | Yes      | Signature key associated with the merchant and terminal.                                  |
| `cConfPuerto` | String | No       | Port configuration. If empty or null, the value is loaded from local TPVPC configuration. |
| `cVersion`    | String | No       | Protocol version (`"5.1"`, `"6.1"`, `"8.1"`). If empty, the configured default is used.   |

**Return value**: `0` if initialization succeeds. Any other value indicates a library-level error.

### fnDllParaTpvpcLatente

Stops communication and releases all internal resources.

**Function signature:**

`int fnDllParaTpvpcLatente();`

This function has **no input parameters**.

---

## Payment and Financial Operations

All financial operations are executed through exported functions that receive **typed parameters** and return an **XML response buffer**. A return value of `0` only indicates that the operation was processed; authorization must always be validated from the XML.

### fnDllOperPinPad

Executes a **PAGO** or **PREAUTORIZACION** using a physical PIN pad.

**Function signature:**

`int fnDllOperPinPad(string cImporte, string cFactura, string cTipoOper, StringBuilder cXMLResp, int iTamMaxResp);`

| Parameter     | Type         | Required | Description                                         |
| ------------- | ------------ | -------- | --------------------------------------------------- |
| `cImporte`    | String       | Yes      | Amount in format `XXXXXXXXX.XX`.                    |
| `cFactura`    | String       | Yes      | Merchant operation reference.                       |
| `cTipoOper`   | String       | Yes      | Operation type: `"PAGO"` or `"PREAUTORIZACION"`.    |
| `cXMLResp`    | StringBuffer | Yes      | Output buffer that receives the XML response.       |
| `iTamMaxResp` | Integer      | Yes      | Maximum buffer size (recommended: at least `8192`). |

### fnDllOperManualExt

Executes a **PAGO** or **PREAUTORIZACION** using **manual card data entry**.

**Function signature:**

`int fnDllOperManualExt(string cTarjeta, string cCaducidad, string cCVC2, string cImporte, string cFactura, string cTipoOper, StringBuilder cXMLResp, int iTamMaxResp);`

| Parameter     | Type         | Required    | Description                                                  |
| ------------- | ------------ | ----------- | ------------------------------------------------------------ |
| `cTarjeta`    | String       | Yes         | Card number (15–19 digits).                                  |
| `cCaducidad`  | String       | Yes         | Expiration date in `AAMM` format.                            |
| `cCVC2`       | String       | Conditional | Security code, required depending on merchant configuration. |
| `cImporte`    | String       | Yes         | Amount in format `XXXXXXXXX.XX`.                             |
| `cFactura`    | String       | Yes         | Merchant operation reference.                                |
| `cTipoOper`   | String       | Yes         | `"PAGO"` or `"PREAUTORIZACION"`.                             |
| `cXMLResp`    | StringBuffer | Yes         | Output XML buffer.                                           |
| `iTamMaxResp` | Integer      | Yes         | Maximum buffer size.                                         |

---

## Confirmation and Refund Operations

A confirmation captures a previously authorized pre-authorization; a refund returns funds. Both travel through the same family of functions, and which one you call depends on where the card and the original reference come from.

| Function | Use it when | Parameters |
| :--- | :--- | :--- |
| `fnDllOperComContable` | You have the original `pedido`. Serves both operations through `cTipoOper`. | `cNumPedido`, `cRTSOriginal`, `cImporte`, `cFactura`, `cTipoOper`, `cXMLResp`, `iTamMaxResp` |
| `fnDllComContableTrj` | The card is read again on the PIN pad. | `cImporte`, `cFactura`, `cNumPedido`, `cRTSOriginal`, `cXMLResp`, `iTamMaxResp` |
| `fnDllDevSinOrigTrj` | Refund with no original reference, card read on the PIN pad. | `cImporte`, `cFactura`, `cXMLResp`, `iTamMaxResp` |
| `fnDllOperDevSinOrig` | Refund with no original reference, card entered manually. | `cTarjeta`, `cCaducidad`, `cImporte`, `cFactura`, `cXMLResp`, `iTamMaxResp` |
| `fnDllOperComContableTerminal` | The operation was made on a different terminal. | `cNumTerminal`, `cNumPedido`, `cRTSOriginal`, `cImporte`, `cFactura`, `cTipoOper`, `cXMLResp`, `iTamMaxResp` |

`cTipoOper` appears only in the two `ComContable` functions that serve both operations, and takes `DEVOLUCION` or `CONFIRMACION`. The others carry the operation in their own name.

| Parameter | Type | Description |
| :--- | :--- | :--- |
| `cNumPedido` | String | Order number of the original operation. The `pedido` field appears in every TPVPC operation response. Mandatory in Transparent mode. |
| `cRTSOriginal` | String | RTS identifier of the original transaction, from the `identificadorRTS` field. Optional; recommended in Transparent mode. |
| `cImporte` | String | Amount to refund or confirm, in `XXXXXXXXX.XX` format. |
| `cFactura` | String | Value the merchant supplies to label the operation. The TPVPC performs no validation on it. |
| `cTipoOper` | String | `DEVOLUCION` or `CONFIRMACION`. |
| `cTarjeta` / `cCaducidad` | String | Card number and expiry, for the manual-entry refund only. |
| `cNumTerminal` | String | Terminal that ran the original operation, for the cross-terminal variant only. |
| `cXMLResp` | Buffer | Buffer that receives the XML result. |
| `iTamMaxResp` | Integer | Maximum size of the response buffer. |

## Recurring Payments

Recurring mode is a session switch, not a parameter. Two functions toggle it, and neither takes arguments:

| Function                   | Signature                        | Effect                                                       |
| :------------------------- | :------------------------------- | :----------------------------------------------------------- |
| `fnDllActivaRecurrente`    | `void fnDllActivaRecurrente()`   | Every operation run from here on carries a recurring token.  |
| `fnDllDesActivaRecurrente` | `void fnDllDesActivaRecurrente()` | Operations go back to being ordinary payments.               |

`fnDllIniTpvpcLatente` deactivates recurring mode, so activate it again after every initialization.

The token itself comes back in the `<token>` element of the payment's XML response.

## Authorization Validation

All financial operations are considered **AUTHORIZED** only if the XML response contains:

```xml
<estado>F</estado>
<resultado>Autorizada</resultado>
```

Any other combination must be treated as **DENIED**, regardless of numeric codes or library return values.