# Create a Pre-authorized Payment

This guide walks you through processing a pre-authorization transaction using the Getnet Payment App. Pre-authorization temporarily holds funds on a customer's credit card for a future capture, commonly used for hotel reservations or car rentals where the final amount may vary.

## Before you begin

Before following the steps, you need to:

* Getnet Payment App installed on the terminal.
* Knowledge of installment plan codes, if applicable.

## How it works

All pre-authorization actions use the `getnet://payment/v1/pre-auth` URI. The `operation` parameter selects the action:

| `operation` | Action | Description |
| :--- | :--- | :--- |
| `"0"` | Create | Reserve funds on the card. |
| `"1"` | Modify | Update an existing pre-authorization. |
| `"2"` | Remove | Cancel a pre-authorization. |
| `"3"` | Confirm | Capture the reserved funds. |
| `"4"` | Retrieve | List pending pre-authorizations. |

<Callout type="warning">

The create operation returns an `authorizationRefCode`. This value is the pre-authorization identifier. You send it back as `reservation_id` to modify, confirm, or remove the pre-authorization. Store it after every create.

</Callout>

## Step 1: Create a pre-authorization

To reserve an amount on the customer's card, send an Intent with `operation` set to `"0"`.

**Request Parameters**

| Parameter | Description | Required |
| :--- | :--- | :--- |
| `operation` | Set to `"0"` to create the pre-authorization. | Yes |
| `originalAmount` | Value in local currency to perform the transaction. | Yes |
| `amount` | Value to reserve. The last two digits are the decimal portion (e.g., `"10000"` = \$100.00). | No |
| `installments` | Number of installments for the credit transaction. | No |
| `plan_id` | Installment plan to be used. See [Installment Rules](/en/app2app/reference-a2a/installment-rules). | No |
| `interest` | Whether the plan includes interest (`true`) or is interest-free (`false`). | No |
| `operationMode` | `"0"` for manual (terminal calculates) or `"1"` for calculated (app calculates). | No |
| `skipReceipt` | Set to `"true"` to bypass the customer receipt screen. | No |
| `skipConfirmation` | Set to `"true"` to skip the installment detail confirmation screen. | No |
| `callerId` | Unique identifier to correlate request with response. | No |
| `allowPrintCurrentTransaction` | Set to `"false"` to receive receipt data as `automationSlip`. | No |

The following code block shows how to create a pre-authorization:

```kotlin
private val REQUEST_CODE = 1001

private fun createPreAuth() {
    val intent = Intent(Intent.ACTION_VIEW, Uri.parse("getnet://payment/v1/pre-auth"))

    intent.putExtra("operation", "0") // 0 = create
    intent.putExtra("amount", "10000") // $100.00
    intent.putExtra("originalAmount", "10000")
    intent.putExtra("installments", "1")
    intent.putExtra("plan_id", "plan_emisor")
    intent.putExtra("operationMode", "0")
    intent.putExtra("skipReceipt", "true")

    startActivityForResult(intent, REQUEST_CODE)
}
```

**Response Parameters**

| Parameter | Description | Required |
| :--- | :--- | :--- |
| `result` | Status of the transaction; `"0"` indicates success. | Yes |
| `resultDetails` | Additional information when the transaction fails. | No |
| `amount` | Value processed for the pre-authorization hold. | Yes |
| `authorizationRefCode` | Pre-authorization identifier. Store it — you send it as `reservation_id` to modify, confirm, or remove the pre-authorization. | No |
| `inputType` | How the card was read (chip, contactless, or magnetic stripe). | Yes |
| `authorizationCode` | Transaction authorization code from the issuer. | No |
| `nsu` | Getnet transaction authorization code for the terminal. | No |
| `cardLastDigits` | Last 4 digits of the card used. | No |
| `brand` | Card brand (e.g., Visa, Mastercard). | No |
| `gmtDateTime` | Timestamp of the transaction in UTC 0 (MMDDhhmmss). | No |
| `automationSlip` | JSON receipt data when `allowPrintCurrentTransaction` is `"false"`. | No |

Example of handling the create response:

```kotlin
override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) {
    super.onActivityResult(requestCode, resultCode, data)

    if (requestCode == REQUEST_CODE && resultCode == RESULT_OK) {
        val extras = data?.extras
        val result = extras?.getString("result")

        if (result == "0") {
            // SUCCESS: store the pre-authorization identifier
            val reservationId = extras?.getString("authorizationRefCode")
            val amount = extras?.getString("amount")

            // Store authorizationRefCode - you send it as reservation_id later
            saveReservationId(reservationId)
        } else {
            val errorDetails = extras?.getString("resultDetails")
            Log.e("PreAuth", "Pre-authorization failed: $errorDetails (Code: $result)")
        }
    }
}
```

Store the `authorizationRefCode` from the response. This identifier is required to confirm, modify, or remove the pre-authorization. If it is not provided in subsequent operations, the funds are automatically released after the hold period expires.

## Step 2: Confirm a pre-authorization

After the service or product is delivered, confirm the pre-authorization to convert the temporary hold into a finalized payment. This captures the funds and completes the transaction.

**Request Parameters**

| Parameter | Description | Required |
| :--- | :--- | :--- |
| `operation` | Set to `"3"` to capture the pre-authorized funds. | Yes |
| `reservation_id` | The `authorizationRefCode` received in Step 1. | Yes |
| `amount` | Updated final amount to capture. If omitted, the app uses the original held value. | No |

```kotlin
private fun confirmPreAuth(reservationId: String, finalAmount: String? = null) {
    val intent = Intent(Intent.ACTION_VIEW, Uri.parse("getnet://payment/v1/pre-auth"))

    intent.putExtra("operation", "3") // 3 = confirm
    intent.putExtra("reservation_id", reservationId)

    finalAmount?.let { intent.putExtra("amount", it) }

    startActivityForResult(intent, REQUEST_CODE)
}
```

Verify success by checking that `result` equals `"0"` in `onActivityResult`.

## Modify a pre-authorization

To update the held amount before capture, send `operation` set to `"1"` with the `reservation_id`. See [Modify a Payment](/en/app2app/post-payment-a2a/modify-payment) for the full flow.

## Remove a pre-authorization

To cancel a pre-authorization and release the held funds, send `operation` set to `"2"` with the `reservation_id`.

```kotlin
private fun removePreAuth(reservationId: String) {
    val intent = Intent(Intent.ACTION_VIEW, Uri.parse("getnet://payment/v1/pre-auth"))

    intent.putExtra("operation", "2") // 2 = remove
    intent.putExtra("reservation_id", reservationId)

    startActivityForResult(intent, REQUEST_CODE)
}
```

## Retrieve pending pre-authorizations

To list pending pre-authorizations, send `operation` set to `"4"`. You can narrow the results with the filter parameters `filterReservationId`, `filterInitialDate`, `filterFinalDate`, `filterAuthorizationCode`, `filterCardLastDigits`, and `filterAllowedBrands`. The response returns a `pendingAuthorizations` list of up to the 30 most recent pending pre-authorizations. See [Deeplink Parameters](/en/app2app/reference-a2a/deeplink-parameters).

## Next steps

* [Modify a Payment](/en/app2app/post-payment-a2a/modify-payment) — Update the amount of a pre-authorization.
* [Deeplink Parameters](/en/app2app/reference-a2a/deeplink-parameters) — Complete pre-authorization request and response fields.
* [Result Codes and Data Structures](/en/app2app/reference-a2a/result-codes-data-structure) — Full list of status codes.