Getnet DocsGetnet Docs

Create a Single-Step Payment

Single-step payments, or direct sales, authorize and capture the transaction amount in a single operation. This is the standard flow for point-of-sale transactions where the cardholder is present and the product or service is provided immediately.

Requirements

Before you can process a payment, the following lifecycle steps must be completed:

  1. Global Configuration: Library environment and license must be set.
  2. Authentication: A successful login to obtain RedCLSTerminalData.
  3. PIN pad Initialization: The physical device must be connected and initialized (inicializarPinpad returned status 0).

Step 1: Prepare the Transaction Data

The SDK uses the RedCLSOperativeWithCardData class to define the transaction parameters. Unlike other systems, the amount is passed as a String with two decimal places (e.g., "10.00").

import redcls.itpvpc.data.RedCLSOperativeWithCardData

// Define the transaction amount and reference
val amount = "25.00"
val saleData = RedCLSOperativeWithCardData(amount).apply {
    this.invoice = "INV-123456" // Optional reference number
}

Ensure the amount string uses a dot . as the decimal separator and contains exactly two decimal positions.


Step 2: Execute the Payment

The transaction is performed via the operativaConTarjeta method of your RedCLSPinPadManager instance. This operation is synchronous and handles the entire flow: card detection, PIN entry (if applicable), and online authorization.

// This must be run on a background thread
Thread {
    try {
        val response = pinpadManager.operativaConTarjeta(saleData)

        if (response.status == 0) {
            val tx = response.transactionData
            if (tx.result == "Autorizada") {
                Log.i("GetMini", "Approved! Auth: ${tx.autorizationNumber}")
            } else {
                Log.w("GetMini", "Denied. Code: ${tx.responseCode}")
            }
        } else {
            Log.e("GetMini", "SDK Error: ${response.status} - ${response.msgKO}")
        }
    } catch (e: Exception) {
        Log.e("GetMini", "Payment Exception: ${e.message}")
    }
}.start()

Step 3: Handle the Transaction Result

The RedCLSTransactionData object contains all the necessary information for your records and receipt printing.

FieldDescription
resultThe authorization outcome (e.g., "Autorizada", "Denegada").
autorizationNumberThe unique code provided by the issuer (if approved).
responseCodeThe 4-digit status code (e.g., "0000" for OK, "0190" for denial).
identifierRTSA 24-character SDK reference ID for the transaction.
orderThe internal sequence number assigned by the SDK.
isPinAuthenticatedIndicates if the cardholder was verified via PIN.
fun handleSuccess(tx: RedCLSTransactionData) {
    when (tx.result) {
        "Autorizada" -> {
            Log.i("GetMini", "Approved! Auth: ${tx.autorizationNumber}")
            // Proceed to print/display receipt
        }
        "Denegada" -> {
            Log.w("GetMini", "Transaction Denied. Code: ${tx.responseCode}")
        }
    }
}

Troubleshooting Common Payment Issues

  • Timeout: The PIN pad may time out if the user takes too long to present the card or enter the PIN. Ensure the device is reachable and the battery is sufficient.
  • Card Denied: If the result is “Denegada”, the cardholder should contact their bank. You can find the specific reason code in tx.responseCode.
  • PIN pad Lost: If the connection drops during payment, the method will return an error status. You must re-initialize the connection before retrying.

Always store the identifierRTS and autorizationNumber. You will need these if you need to process a Refund (Devolución) later.

Next Steps

After mastering single-step payments, you can explore advanced transaction types: