# Create a Pre-authorized Payment

Pre-authorization operations (`PREAUTORIZACION`) allow merchants to **reserve** funds on a customer’s card without capturing them immediately. This two-phase model is used when the final amount is known only after service completion (for example, hotels, car rentals, or fuel stations).

This guide applies to **TpvpcImplantado**.

A pre-authorization never captures funds by itself. It must be followed by a **confirmation** (`CONFIRMACION`), which captures all or part of the reserved amount. If you don't confirm it, the reserved funds release automatically once the expiration window passes, or you can release them earlier with a refund — see the [Refund a Payment](/en/get-central/tpvpc-payment-guides/process-a-refund) guide.

## Requirements

Before you begin, ensure the following prerequisites are met:

* **Get Central** (TPVPC) installed and successfully initialized via `fnDllIniTpvpcLatente`
* **Pre-authorization capability** enabled for your merchant by the acquirer
* **Physical PIN pad** connected and available for the initial card-present step

Pre-authorizations are subject to an expiration window defined by the card scheme and issuer. If not confirmed within this period, the reserved funds are automatically released.

## Pre-authorization Process Overview

The complete flow consists of two mandatory operations:

1. **PREAUTORIZACION** – Card-present operation that reserves funds
2. **CONFIRMACION** – Subsequent operation that captures the reserved amount

## Step 1: Execute a PREAUTORIZACION

The pre-authorization is a card-present operation. The TPVPC activates the PIN pad, guides the cardholder interaction, and requests a reservation of funds.

To initiate the reservation, invoke the standard PIN pad operation with the operation type set to `PREAUTORIZACION`. The following parameters are required:

| Parameter     | Type    | Required | Description                                                        |
| ------------- | ------- | -------- | ------------------------------------------------------------------ |
| `cImporte`    | String  | Yes      | Amount to reserve, format `XXXXXXXXX.XX` (for example, `100.00`).  |
| `cFactura`    | String  | Yes      | Merchant reference identifying the pre-authorization.              |
| `cTipoOper`   | String  | Yes      | Must be set to `PREAUTORIZACION`.                                  |
| `cXMLResp`    | Buffer  | Yes      | Output buffer that will receive the XML response.                  |
| `iTamMaxResp` | Integer | Yes      | Maximum size of the response buffer (minimum recommended: `8192`). |

Here is an example in C#:

```csharp
StringBuilder xmlResponse = new StringBuilder(8192);

int result = fnDllOperPinPad(
    "100.00",           // cImporte
    "STAY-2023-001",    // cFactura
    "PREAUTORIZACION",  // cTipoOper
    xmlResponse,
    xmlResponse.Capacity
);
```

## Step 2: Validate the Pre-authorization Result

After execution, the TPVPC returns an XML document describing the result of the reservation.

The pre-authorization must be considered **AUTHORIZED** only if the XML contains both:

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

If either element is missing or has a different value, the pre-authorization must be treated as **DENIED**, and no confirmation must be attempted.

Persist the merchant reference (`cFactura`) and relevant response data, as they are mandatory for the confirmation step.

## Step 3: Capture the Pre-authorization

Once the final amount is known, the reserved funds must be captured by executing a **CONFIRMACION** operation. This operation does not require the physical card to be present.

The confirmation runs through `fnDllOperComContable`, the same function as a referenced refund, with a different `cTipoOper`. It must reference the original pre-authorization by its `pedido`:

| Parameter      | Type    | Required | Description                                                        |
| -------------- | ------- | -------- | ------------------------------------------------------------------ |
| `cNumPedido`   | String  | Yes      | Order number of the original pre-authorization, from the `pedido` field of its response. |
| `cRTSOriginal` | String  | No       | RTS identifier of the original pre-authorization. Recommended.     |
| `cImporte`     | String  | Yes      | Final amount to capture, format `XXXXXXXXX.XX`.                    |
| `cFactura`     | String  | Yes      | Purchase reference for this confirmation. The TPVPC does not validate it. |
| `cTipoOper`    | String  | Yes      | Must be set to `CONFIRMACION`.                                     |
| `cXMLResp`     | Buffer  | Yes      | Output buffer that will receive the XML response.                  |
| `iTamMaxResp`  | Integer | Yes      | Maximum size of the response buffer (minimum recommended: `8192`). |

Here is an example in C#:

```csharp
StringBuilder xmlResponse = new StringBuilder(8192);

int result = fnDllOperComContable(
    "916548",            // cNumPedido — the pre-authorization's pedido
    "",                  // cRTSOriginal
    "85.00",             // cImporte
    "STAY-2023-001-FIN", // cFactura
    "CONFIRMACION",      // cTipoOper
    xmlResponse,
    xmlResponse.Capacity
);

if (result != 0)
{
    // Technical execution error
}
```

## Step 4: Validate the Confirmation Result

The confirmation is successful only if the XML response contains:

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

Only after this validation should the transaction be considered fully captured and finalized.

## Next Steps

After completing a pre-authorization and confirmation cycle, you can proceed with further operational tasks:

* To reverse a confirmed transaction or release reserved funds, refer to the [Refund a Payment](/en/get-central/tpvpc-payment-guides/process-a-refund) guide.
* For details on generating and printing receipts, see the [Generate and Print Receipts](/en/get-central/tpvpc-payment-guides/generate-and-print-receipts) documentation.