# 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"`).

```kotlin
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
}
```

<Callout type="warning">

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

</Callout>

---

## 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.

```kotlin
// 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.

| Field | Description |
| :--- | :--- |
| `result` | The authorization outcome (e.g., `"Autorizada"`, `"Denegada"`). |
| `autorizationNumber` | The unique code provided by the issuer (if approved). |
| `responseCode` | The 4-digit status code (e.g., `"0000"` for OK, `"0190"` for denial). |
| `identifierRTS` | A 24-character SDK reference ID for the transaction. |
| `order` | The internal sequence number assigned by the SDK. |
| `isPinAuthenticated` | Indicates if the cardholder was verified via PIN. |

```kotlin
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.

<Callout type="tip">

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

</Callout>

## Next Steps

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

* [Create a Pre-authorized Payment](/en/get-mini/android-sdk/guides/process-preauthorized-payment) - Reserve funds for later capture.
* [Refund a Payment](/en/get-mini/android-sdk/guides/refund-payment) - Return funds to customers.
* [Security and Device Binding](/en/get-mini/android-sdk/core-concepts/security-device-binding) - Optimize your integration's security.