7. Status & Utility Methods
These synchronous helper methods let you inspect the current state of the SDK and the underlying hardware at any time after initialize() succeeds.
Method Reference
| Method | Returns | Description |
|---|---|---|
| isServiceAlive() | Boolean | Returns true if hardware service is connected. |
| getDetectedOEM() | OEM | Returns the detected OEM enum value. |
| isPrinterReady() | Boolean | Returns true if printer is ready. |
| cancelTransaction() | Unit | Requests cancellation of current transaction. |
isServiceAlive()
if (pos.isServiceAlive()) {
// Hardware service is connected
// Safe to call startPayment()
}
if (pos.isServiceAlive()) {
// Hardware service is connected
// Safe to call startPayment()
}
getDetectedOEM()
val oem = pos.getDetectedOEM()
Log.d(TAG, "Running on: $oem")
OEM oem = pos.getDetectedOEM();
Log.d(TAG, "Running on: " + oem);
isPrinterReady()
if (pos.isPrinterReady()) {
pos.print(receiptBitmap) { ok, msg ->
Log.d(TAG, "Print result: $ok")
}
} else {
Log.w(TAG, "Printer not ready")
}
if (pos.isPrinterReady()) {
pos.print(receiptBitmap, (ok, msg) ->
Log.d(TAG, "Print result: " + ok));
} else {
Log.w(TAG, "Printer not ready");
}
cancelTransaction()
// Call this if you need to abort an in-progress transaction
pos.cancelTransaction()
// Call this if you need to abort an in-progress transaction
pos.cancelTransaction();
NOTE
Cancellation is a request — the SDK will call onCancelled() on the PaymentResultListener once the hardware acknowledges the cancel.