Take a payment
Register the result launcher, check NFC status, and start NFC or QR transactions.
Handling results
Call BlincPosSdk.registerLauncher() once in Activity.onCreate(), before setContent. This registers the result callback the SDK uses to return the payment outcome.
override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState)
BlincPosSdk.registerLauncher(this) { result ->
when (result.status) {
TransactionResult.Status.SUCCESS -> {
val txnId = result.transactionId
val amount = result.amount // in kobo, e.g. 100 = 1.00 NGN
val currency = result.currency
// Print receipt or update UI
}
TransactionResult.Status.CANCELLED -> {
// User cancelled
}
else -> {
val error = result.message
// Show error dialog
}
}
}
}TransactionResult fields
| Field | Type | Description |
|---|---|---|
status | Status | SUCCESS, FAILED, CANCELLED, or DEBITSUCCESSFUL (reserved; not emitted in this version, so always keep an else branch) |
transactionId | String? | Unique transaction reference (SUCCESS only) |
message | String? | Human-readable error or status message |
amount | Long? | Settled amount in kobo |
currency | String? | Currency code, e.g. "NGN" |
narration | String? | Payment narration from the consumer app |
transactionDate | String? | Settlement timestamp from the backend |
senderName | String? | Paying customer's account name |
senderAccountNumber | String? | Paying customer's account number |
beneficiaryName | String? | Merchant beneficiary account name |
beneficiaryAccountId | String? | Merchant beneficiary account ID |
responseCode | String? | Raw processor response code ("00" on success) |
NFC status
Check the device NFC state before starting an NFC transaction:
NfcStatus | Meaning |
|---|---|
AVAILABLE_ENABLED | NFC hardware present and switched on; safe to proceed |
AVAILABLE_DISABLED | NFC hardware present but turned off; prompt the user to enable it |
NOT_AVAILABLE | Device has no NFC hardware; fall back to QR |
HCE_NOT_SUPPORTED | NFC present but Host Card Emulation unsupported on consumer device; fall back to QR |
when (BlincPosSdk.getNfcStatus(context)) {
NfcStatus.AVAILABLE_ENABLED -> startNfcTransaction()
NfcStatus.AVAILABLE_DISABLED -> promptUserToEnableNfc()
NfcStatus.NOT_AVAILABLE,
NfcStatus.HCE_NOT_SUPPORTED -> startQrTransaction()
}
Dedicated POS terminals and HCEMany dedicated POS terminals report
HCE_NOT_SUPPORTEDbecause they operate in reader mode rather than card-emulation mode. This is expected: the SDK handles the reader-mode tap flow automatically. Use the status only to decide between NFC and QR fallback for the customer's device.
Starting transactions
Always call ensureRegistered() first. The methods below assume registration is complete.
Option A: NFC payment (preferred)
BlincPosSdk.startTransactionWithNFC(
context = this,
amount = 250000L, // 2,500.00 NGN in kobo
metadata = "{\"orderId\":\"ORD-99\"}", // optional JSON string
onPrintReceipt = { result ->
// Called when merchant taps "Print Receipt".
// Pass null to hide the button entirely.
printReceipt(result)
}
)Option B: QR code payment
BlincPosSdk.startTransactionWithQR(
context = this,
amount = 250000L,
metadata = "{}",
onPrintReceipt = { result -> printReceipt(result) }
)Option C: Merchant-entered amount
Pass null for amount to let the SDK display an on-screen keypad for the cashier:
BlincPosSdk.startTransactionWithNFC(
context = this,
amount = null
)Transaction method parameters
| Parameter | Type | Description |
|---|---|---|
context | Context | Activity or application context |
amount | Long? | Amount in kobo. null shows merchant keypad. |
metadata | String | Optional JSON string for custom data. Default: "{}" |
onPrintReceipt | ((TransactionResult) -> Unit)? | Callback when merchant taps Print Receipt. null hides the button. |
Updated about 2 months ago