Getnet DocsGetnet Docs

Create a Pre-authorized Payment

Pre-authorization allows you to verify card validity and reserve a specific amount on the cardholder’s account without capturing the funds immediately. This is a common requirement for hotels, car rentals, and other service providers where the final amount is settled later.

Requirements

Before starting the pre-authorization flow, ensure:

  1. The SDK is initialized and the merchant is logged in.
  2. The PIN pad is connected and in a “Ready” state.
  3. Your application must persist the key fields (like identifierRTS, order, etc.) returned after the pre-authorization, as they are required for confirmation or cancellation.

Step 1: Create the Pre-authorization

The pre-authorization process is identical to a standard sale but with a different operation type. The customer must present their card and enter their PIN if requested.

import redcls.itpvpc.data.RedCLSOperativeWithCardData
import redcls.itpvpc.constants.RedCLSiTPVPCGeneration

// 1. Prepare the data
val amount = "100.00"
val preAuthData = RedCLSOperativeWithCardData(amount)

// 2. Set the operation type to PRE-AUTHORIZATION
preAuthData.setTipoPago(RedCLSiTPVPCGeneration.TIPO_OPERACION_PREAUTORIZACION)
preAuthData.setOpcionAutorizacionParcial(true) // Required for certain MCCs (June 2024 update)

// 3. Execute the operation (must be on a background thread)
Thread {
    val response = pinpadManager.operativaConTarjeta(preAuthData)

    if (response.status == 0) {
        val txData = response.transactionData
        if (txData.result == "Autorizada") {
            // CRITICAL: Persist at least the following fields:
            // identifierRTS, order, fuc, terminal, operationDate, amount
            // If applicable, also save txData.amountPartialAuthorized
            savePreAuthFields(txData)
            Log.d("GetMini", "Pre-auth approved: ${txData.autorizationNumber}")
        } else {
            Log.w("GetMini", "Pre-auth denied: ${txData.responseCode}")
        }
    } else {
        Log.e("GetMini", "SDK Error: ${response.status} - ${response.msgKO}")
    }
}.start()

Step 2: Confirm the Pre-authorization

Once the final amount is known, you “confirm” the pre-authorization to capture the funds. This step does not require the physical card to be present.

You must use the RedCLSPreautorizationManager and provide the RedCLSTransactionData from the original pre-authorization. This manager is part of the Get Mini Android SDK.

import redcls.itpvpc.managers.RedCLSPreautorizationManager
import redcls.itpvpc.data.RedCLSConfirmationData

// 1. Prepare the confirmation data using the saved transaction info
val isPartialAuth = savedTransactionData.amountPartialAuthorized != null
val confirmationData = RedCLSConfirmationData(terminalData, savedTransactionData, isPartialAuth)

// Optional: You can specify a different (lower) amount if needed
// savedTransactionData.amount = "85.50"

Thread {
    val confirmResponse = RedCLSPreautorizationManager.peticionConfirmacion(context, confirmationData)

    if (confirmResponse.status == 0) {
        Log.i("GetMini", "Funds captured successfully")
    } else {
        Log.e("GetMini", "Confirmation failed: ${confirmResponse.msgKO}")
    }
}.start()

The confirmation amount can be less than or equal to the pre-authorized amount. If you confirm for a smaller amount, the remaining funds are released back to the customer’s account.


Step 3: Cancel or Replace (Optional)

If the service is cancelled or you need to update the pre-authorization amount, you can use the following methods:

Cancellation (Anulación)

Releases the reserved funds immediately.

val cancelResponse = RedCLSPreautorizationManager.peticionAnulacionPreautorizacion(
    terminalData,
    savedTransactionData
)

Replacement (Reemplazo)

Updates the reserved amount while maintaining the original pre-authorization.

val newAmount = "150.00"
val replaceResponse = RedCLSPreautorizationManager.peticionReemplazoPreautorizacion(
    newAmount,
    terminalData,
    savedTransactionData
)

Best Practices

  • Persist Key Fields: Do not rely on saving the entire SDK object. Persist at least:
    • identifierRTS
    • order
    • fuc / terminal
    • operationDate / amount
  • Expiration: Pre-authorizations typically have a limited lifespan (often 7 days) before the reservation is automatically released by the issuer.

Next Steps