App‑to‑App ECR Integration
The App‑to‑App ECR integration allows merchant POS applications to communicate directly with the mada POS app on Android devices. It uses Android Intent‑based communication to send transaction requests and receive responses, eliminating the need for TCP/IP or COM connections.
For environment setup and middleware details, refer to App-to-App ECR Library.
Prerequisites
- Android 8.0 (API level 26) or higher
- mada POS app installed and configured (App‑to‑App flows do not use NamiPay app)
- Merchant POS app with valid Cash Register Number (CRN)
- Proper Android permissions configured (network, broadcast intents)
Supported Connections
| Connection Type | Supported | Notes |
|---|---|---|
| TCP/IP (Wi‑Fi) | ✔ | Preferred connection for stability. |
| Bluetooth | ✔ | Fallback mode; requires pairing. |
| App‑to‑App | ✔ (Android only) | Requires mada app installed; not supported via NamiPay. |
Transaction Flow
Initialize App‑to‑App → Configure POS → Build Request → Launch mada POS App → Execute Transaction → Receive Response → Parse Response
Integration Steps
Step 1: Initialize App‑to‑App Service
Use the following code to initialize App‑to‑App communication.
val appToApp = AppToAppConnect()
Step 2: Configure POS Application
Use the following code to set CRN, printer, and build request data.
val crn = "12345678"
val printerChoice = 1 // 0 = disable, 1 = enable
val ecrRefNo = crn + EncryptionUtil.getSixDigitUniqueNumber()
val dateTimeStamp = EncryptionUtil.getFormattedDateTime()
val requestData = "$dateTimeStamp;$amount;$printerChoice;$ecrRefNo!"
val signature = EncryptionUtil.getSha256Hash(requestData + crn)
Step 3: Launch mada POS App
Use the following code to send the request via Intent.
val intent = Intent("com.mada.pos.TRANSACTION")
intent.putExtra("request", requestData)
intent.putExtra("signature", signature)
intent.putExtra("packageName", "com.yourmerchantapp.ecr")
startActivity(intent)
Step 4: Handle Response
Use the following code to receive and parse the response.
val response = intent.getStringExtra("response")
val fields = response?.split(",") ?: listOf()
val responseCode = fields[0]
val approvalCode = fields[1]
val amount = fields[2]
val timestamp = fields[3]
val ecrRefNo = fields[4]
val receiptData = fields[5]
Key Rules
- Always initialize AppToAppConnect before transactions.
- TCP/IP is the preferred connection; App‑to‑App is fallback mode.
- App‑to‑App flows must use the mada app, not NamiPay.
- Transaction type 6 represents the end‑to‑end payment flow.
- Other transaction types (Refund, Reversal, Reconciliation, etc.) are supported via App‑to‑App.
Final Integration Flow
Initialize App‑to‑App Service
↓
Set Configuration (CRN, printer, request data)
↓
Launch mada POS App (Intent)
↓
Execute Transaction
↓
Receive Response (CSV string)
↓
Parse Response (split and map fields)
Installation Notes
- Requires Android 8.0+.
- Merchant POS app must be signed and packaged correctly.
- mada POS app must be installed and configured on the device.
- Cashier setup (CRN, printer configuration) must be completed at first launch.
- No DLLs or native libraries required — integration is Intent‑based.
Updated 14 days ago
