Quick Start: Your First Sale
This quickstart guide walks you through implementing a complete payment transaction using the Get Mini Android SDK. You’ll configure your project, authenticate your merchant credentials, initialize the PIN pad, and execute a test sale transaction. This tutorial follows the essential “happy path” using the core library components.
Requirements
Before starting this quickstart, ensure you have the following:
- Android Studio: Latest stable version installed.
- Physical Device: Required for testing (emulators do not support Bluetooth PIN pad connectivity).
- Credentials:
- App License Key: Provided by Get Mini support.
- User Credentials: Username and password (the FUC and Terminal are retrieved dynamically during login).
- Physical PIN pad: A certified Bluetooth PIN pad and its serial number.
- SDK JAR: The
redcls-itpvpc-android.jarfile.
This guide assumes you have already reviewed the Configure Android Permissions setup. If not, ensure your AndroidManifest.xml includes the necessary Bluetooth and Internet permissions.
Step 1: Configure Project Dependencies
The Get Mini Android SDK is distributed as a local JAR library. Add it to your project’s app/libs/ folder and configure your app/build.gradle file:
dependencies {
// Core SDK
implementation files('libs/redcls-itpvpc-android.jar')
}In most projects, no additional dependencies are required. If you encounter cryptographic provider or JSON parsing errors during login, refer to the Troubleshooting section or the full Add the SDK to Your Project guide.
Sync your project with Gradle files after making these changes.
Step 2: Initialize the Library and Login
Before processing transactions, you must configure the environment and authenticate to retrieve the terminal data.
// 1. Configure the environment (INTEGRACION for testing, REAL for production)
RedCLSConfigurationLibrary.setiEntorno(RedCLSConstantes.ENTORNO_INTEGRACION)
// 2. Set your application license
RedCLSConfigurationLibrary.setAppLicense("YOUR_APP_LICENSE_KEY")
// 3. Simplified login example to retrieve available terminals
val loginData = RedCLSLoginData(context, "username", "password")
Thread {
val loginResponse = RedCLSMerchantConfigurationManager.login(loginData)
if (loginResponse.code == 0) {
// Retrieve the first available terminal
val terminalData = loginResponse.merchantList[0].terminalList[0]
Log.d("GetMini", "Authenticated for Terminal: ${terminalData.terminal}")
// Proceed to Pinpad initialization (Step 3)
initializePinpad(terminalData)
} else {
Log.e("GetMini", "Login failed: ${loginResponse.desc}")
}
}.start()Step 3: Initialize the PIN pad
The RedCLSPinPadManager handles the connection and initialization of the physical device. You must implement RedCLSPinPadInterface to handle connection events.
class PinpadHandler(private val context: Context, private val terminalData: RedCLSTerminalData) : RedCLSPinPadInterface {
private var pinpadManager: RedCLSPinPadManager? = null
fun start() {
// Minimal Bluetooth connection using Pinpad Serial Number
val config = RedCLSConfigurationPinPadData("PINPAD_SERIAL_NUMBER")
pinpadManager = RedCLSPinPadManager(this, config, terminalData)
pinpadManager?.connectWithPinPad()
}
override fun getContext(): Context = context
override fun conexionPinPadRealizada() {
Log.d("GetMini", "Connected. Initializing...")
// Finalize initialization to sync keys/params
Thread {
val initResponse = pinpadManager?.inicializarPinpad()
if (initResponse?.status == 0) {
Log.d("GetMini", "Pinpad Ready")
// Now you can make a payment (Step 4)
}
}.start()
}
override fun pinPadNoEncontrado() {
Log.e("GetMini", "Pinpad not found or Bluetooth error")
}
// Additional mandatory interface methods (DCC selection, etc.)
override fun seleccionMonedaPagoDCC(dccData: RedCLSDCCSelectionData): String = dccData.currencyChangeCode
}Step 4: Execute a Payment Transaction
Once the PIN pad is “Ready”, use the operativaConTarjeta method. The SDK will handle card reading, PIN entry, and authorization.
fun makeSale(amount: String) {
val saleData = RedCLSOperativeWithCardData(amount)
// Optional: Add a reference/invoice number
saleData.invoice = "INV-12345"
Thread {
val saleResponse = pinpadManager?.operativaConTarjeta(saleData)
if (saleResponse?.status == 0) {
val tx = saleResponse.transactionData
if (tx.result == "Autorizada") {
Log.d("GetMini", "Success! Auth: ${tx.autorizationNumber}")
} else {
Log.w("GetMini", "Transaction Denied")
}
} else {
Log.e("GetMini", "Error: ${saleResponse?.msgKO}")
}
}.start()
}Step 5: Handle the Transaction Result
Store the following key fields from RedCLSTransactionData for your records and receipt printing:
| Field | Description |
|---|---|
autorizationNumber | The unique authorization code from the issuer. |
identifierRTS | A 24-character SDK reference for the transaction. |
order | The internal transaction order number. |
card | Masked card number (e.g., ************1234). |
isPinAuthenticated | If true, the user entered a PIN (no signature needed). |
Troubleshooting
- Dependency Errors
In most projects, no additional dependencies are required. However, if you encounter NoSuchAlgorithmException or JSON parsing errors during login, you may need to add BouncyCastle and Gson to your app/build.gradle. See Add the SDK to Your Project for the specific implementation details.
- Login Fails (99 or similar codes): Verify your App License Key and that you have a stable internet connection.
- PIN pad Not Found: Ensure Bluetooth is enabled on the Android device and the PIN pad is in pairing mode.
- Initialization Error: Ensure the terminal is correctly provisioned in the Get Mini portal for your FUC.
Next Steps
- Configure Android Permissions - Detailed guide on handling runtime permissions.
- Transaction Lifecycle - Understand the full payment states.