Initialize the SDK
Before processing any transactions, you must initialize the Get Mini Android SDK. This process establishes the environment, validates your application license, and authenticates your merchant credentials to prepare the SDK for payment operations.
The SDK lifecycle follows a specific sequence: Configuration → Authentication (Login) → PIN pad Initialization.
Requirements
Before starting, ensure the following steps are complete:
- SDK Added: The
redcls-itpvpc-android.jarmust be in yourlibs/folder. - Mandatory Dependencies: Ensure the following libraries are added to your
build.gradle(required for login/security):org.bouncycastle:bcprov-jdk16:1.45com.google.code.gson:gson:2.8.5
- Permissions: The following permissions must be declared and granted:
android.permission.BLUETOOTHandroid.permission.BLUETOOTH_ADMINandroid.permission.INTERNETandroid.permission.ACCESS_NETWORK_STATE
- Credentials: You need an App License and valid User Credentials (username/password).
Step 1: Library Configuration
The first step in the SDK lifecycle is setting up the global configuration. This must be done every time the application starts.
import redcls.itpvpc.RedCLSConfigurationLibrary
import redcls.itpvpc.constants.RedCLSConstantes
// 1. Set the execution environment (REAL by default)
RedCLSConfigurationLibrary.setiEntorno(RedCLSConstantes.ENTORNO_INTEGRACION)
// Available environments:
// RedCLSConstantes.ENTORNO_REAL
// RedCLSConstantes.ENTORNO_INTEGRACION
// RedCLSConstantes.ENTORNO_CCAL (Certification)
// RedCLSConstantes.ENTORNO_DESARROLLO (Redsys Internal)
// 2. Initialize your unique Application License
RedCLSConfigurationLibrary.setAppLicense("YOUR_APP_LICENSE_KEY")Step 2: Merchant Authentication (Login)
Next, you must authenticate to retrieve the merchant and terminal details required for transactions. This step is mandatory before any PIN pad operation.
import redcls.itpvpc.RedCLSMerchantConfigurationManager
import redcls.itpvpc.data.RedCLSLoginData
val loginData = RedCLSLoginData(context, "username", "password")
Thread {
val response = RedCLSMerchantConfigurationManager.login(loginData)
if (response.code == 0) {
// Retrieve the specific terminal you will use for transactions
val terminal = response.merchantList[0].terminalList[0]
Log.d("GetMini", "Login successful for FUC: ${terminal.fuc}")
// Proceed to Pinpad setup using the 'terminal' object
} else {
Log.e("GetMini", "Login failed: ${response.desc}")
}
}.start()To avoid requiring user credentials on every app launch, consider implementing Transparent Login (Auto-login) after the first successful authentication.
Step 3: PIN pad Connection and Initialization
The final stage of the lifecycle is binding the SDK to the physical PIN pad. You must connect to the device and perform a one-time initialization to synchronize keys and terminal parameters.
- Implement the Interface: Your class must implement
RedCLSPinPadInterfaceto listen for connection events. - Connect: Call
connectWithPinPad()using the PIN pad’s serial number. - Initialize: Once connected, call
inicializarPinpad().
override fun conexionPinPadRealizada() {
Log.d("GetMini", "Connection established. Starting initialization...")
Thread {
// RedCLSInitPinpadResponse contains a 'status' field (0 for OK)
val initResponse = pinpadManager.inicializarPinpad()
if (initResponse.status == 0) {
Log.i("GetMini", "SDK Fully Initialized and Ready for Sales")
} else {
Log.e("GetMini", "Initialization failed: ${initResponse.msgKO}")
}
}.start()
}Handling Failures in the Lifecycle
- Configuration Errors: Ensure the
App Licenseis valid for the current environment. A license generated for Integration will not work in the Real environment. - Login Errors: Verify internet connectivity. The SDK must communicate with the payment host to validate credentials.
- PIN pad Errors: Ensure the PIN pad is powered on, in Bluetooth pairing mode, and within range of the Android device.
Next Steps
With the SDK successfully initialized, you can explore detailed connectivity and payment guides:
- Manage Bluetooth Connectivity - Deep dive into PIN pad lifecycle and status monitoring.
- Process Single-Step Payments - Execute standard sale transactions.
- Security and Device Binding - Understand terminal association and security.