Add the dependency
Add the SDK to your build.gradle.kts. See Maven Central or MVN Repository for the latest version.
implementation("com.finix:pax-mpos-sdk-android:3.8.0")Add permissions
Add the following to your AndroidManifest.xml:
<!-- Network communication -->
<uses-permission android:name="android.permission.INTERNET" />
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE" />
<!-- Bluetooth communication (API 30 and below) -->
<uses-permission android:name="android.permission.BLUETOOTH" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" android:maxSdkVersion="30" />
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
<uses-permission android:name="android.permission.ACCESS_FINE_LOCATION" />
<!-- Bluetooth communication (API 31+) -->
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />BLUETOOTH_SCAN, BLUETOOTH_CONNECT, and location permissions are required for API 31+.
ProGuard rules
If your build uses ProGuard, add the following to your proguard-rules.pro:
-dontwarn retrofit.**
-keep class retrofit.** { *; }
-keepattributes Signature
-keepattributes Exceptions
-keepattributes RuntimeVisibleAnnotations
-keepattributes RuntimeInvisibleAnnotations
-keepattributes RuntimeVisibleParameterAnnotations
-keepattributes RuntimeInvisibleParameterAnnotations
-keepattributes *Annotation*
-keep class okhttp3.** { *; }
-keep interface okhttp3.** { *; }
-dontwarn okhttp3.**
-dontwarn java.nio.file.*
-dontwarn org.codehaus.mojo.animal_sniffer.IgnoreJRERequirement
-keep class com.google.gson.stream.** { *; }
-dontwarn com.finix.mpos.sdk.**
-keep class com.finix.mpos.sdk.** { *; }
-keep class com.finix.mpos.models.** { *; }
-keep class com.finix.common.networking.models.** { *; }
-dontwarn java.lang.invoke.StringConcatFactoryInitialize the SDK
Create an MPOSFinix instance with your credentials:
Connect to a device
Call connect() with the PAX D135 Bluetooth name and MAC address:
| Callback | Trigger |
|---|---|
onSuccess | Device connected and ready to process transactions. |
onError | Connection failed. Check Bluetooth pairing and device proximity. |
onProcessing | Connection step in progress. Display currentStepMessage to the user if desired. |
Device management
| Method | Description |
|---|---|
isConnected() | Returns whether the device is currently connected. |
disconnect() | Closes the Bluetooth connection to the device. |
resetDevice(MPOSConnectionCallback) | Resets the device and re-establishes the connection. Accepts the same MPOSConnectionCallback as connect(). |
resetDevice() and disconnect() each provide two overloads:
- Suspend overload (
suspend fun resetDevice()) — no callback required. Use this when calling from within a Kotlin coroutine. - Callback overload (
resetDevice(MPOSConnectionCallback)) — for traditional asynchronous handling outside of coroutines.
// build.gradle.kts
dependencies {
implementation("com.finix:pax-mpos-sdk-android:3.7.0")
}
// AndroidManifest.xml
// Add INTERNET, ACCESS_WIFI_STATE, ACCESS_COARSE_LOCATION, ACCESS_FINE_LOCATION.
// For API 30 and below: BLUETOOTH, BLUETOOTH_ADMIN (with maxSdkVersion="30").
// For API 31+: BLUETOOTH_SCAN, BLUETOOTH_CONNECT.
// proguard-rules.pro
// -dontwarn com.finix.mpos.sdk.**
// -keep class com.finix.mpos.sdk.** { *; }
// -keep class com.finix.mpos.models.** { *; }
// -keep class com.finix.common.networking.models.** { *; }
val mpos = MPOSFinix(
context,
MerchantData(
merchantId = "MUxxxxxx",
mid = "",
deviceId = "DVxxxxx",
env = Environment.SB,
userId = "USxxxxxxxxx",
password = ""
)
)
mpos.connect(
deviceName = "PAX_D135_XXXX",
deviceAddress = "XX:XX:XX:XX:XX:XX",
callback = object : MPOSConnectionCallback {
override fun onSuccess() {
// device ready — start a transaction
}
override fun onError(errorMessage: String) {
// connection failed
}
override fun onProcessing(currentStepMessage: String) {
// show progress to the user
}
}
)
mpos.isConnected()
mpos.disconnect()
mpos.resetDevice(object : MPOSConnectionCallback {
override fun onSuccess() { }
override fun onError(errorMessage: String) { }
override fun onProcessing(currentStepMessage: String) { }
})