ToroClient

class ToroClient(applicationContext: Context, config: ToroConfig, miuraManager: MiuraManager = MiuraManager.getInstance(), logger: ToroLogger? = null)

The main entry point for the Toro SDK. This class provides methods to start transactions and manage the selected device.

Parameters

applicationContext

The application context.

config

The configuration for the Toro SDK.

See also

Constructors

Link copied to clipboard
constructor(applicationContext: Context, config: ToroConfig, miuraManager: MiuraManager = MiuraManager.getInstance(), logger: ToroLogger? = null)

Types

Link copied to clipboard
object Companion

Properties

Link copied to clipboard

Lists all Miura devices which have been paired in bluetooth settings excluding selectedBluetoothDevice.

Link copied to clipboard

True when the ToroClient instance is fully initialised, false otherwise.

Link copied to clipboard

Indicates whether a session is open on the selectedBluetoothDevice or selectedUsbDevice depending on the ToroConfig.connectionMode.

Link copied to clipboard

The selected Miura device for transactions. This will be persisted across app restarts. Only applicable when ToroConfig.connectionMode is ConnectionMode.BLUETOOTH.

Link copied to clipboard

The selected Miura device for transactions via USB. This will be persisted across app restarts. Only applicable when ToroConfig.connectionMode is ConnectionMode.USB.

Link copied to clipboard

Callback for handling the result of the signature activity. Used for creating an ActivityResultLauncher for the signature activity.

Link copied to clipboard

The current state of the transaction.

Link copied to clipboard

Lists all Miura devices currently attached to the system via USB excluding selectedUsbDevice.

Functions

Link copied to clipboard

Cancels the current transaction (if there is one in progress). Will also close the bluetooth session if it is open.

Link copied to clipboard

Closes the current session if there is one open.

Link copied to clipboard
suspend fun deleteDeviceLogs()
Link copied to clipboard
@JvmName(name = "ensureDeviceReady")
fun ensureDeviceReady(listener: DeviceSetupListener)

Java-friendly version of ensureDeviceReady driven by a DeviceSetupListener instead of Kotlin function-type callbacks. See ensureDeviceReady for full behaviour.

fun ensureDeviceReady(listener: DeviceSetupListener, forceSoftwareReset: Boolean)
fun ensureDeviceReady(forceSoftwareReset: Boolean, onStateChanged: (DeviceSetupState) -> Unit, onManualEccSigningRequired: (csr: ByteArray) -> Unit = {}, onSuccess: () -> Unit, onError: (ToroException) -> Unit)

When forceSoftwareReset is true, attempts to reinstall both MPI and OS even if their versions already match, then handles pending TMS updates as usual.

fun ensureDeviceReady(onStateChanged: (DeviceSetupState) -> Unit, onManualEccSigningRequired: (csr: ByteArray) -> Unit = {}, onSuccess: () -> Unit, onError: (ToroException) -> Unit)

Ensures the selected device is in a Toro-compatible state: resets OS and MPI to the required versions if needed, then checks for and applies any pending TMS updates (ECC certificate signing, key injection, configuration).

Link copied to clipboard
Link copied to clipboard

Information about the selected Miura device selectedBluetoothDevice. Uses a session open to the selected device, waiting for one still opening, and leaves it open. Otherwise opens its own session, replacing any other, and closes it afterwards.

@JvmName(name = "getDeviceInfo")
fun getDeviceInfo(cb: ToroCallback<MiuraDeviceInfo?>)

Java-friendly version of ToroClient.getDeviceInfo

Link copied to clipboard
suspend fun getDeviceLogs(onProgress: (progress: Float) -> Unit? = null): String
Link copied to clipboard
Link copied to clipboard
suspend fun installEccTerminalCert(certData: ByteArray)

Installs a signed ECC terminal certificate (terminal-ecc-cert.json) onto the selected device. The device restarts automatically on success.

@JvmName(name = "installEccTerminalCert")
fun installEccTerminalCert(certData: ByteArray, cb: ToroCallback<Unit>)

Java-friendly version of installEccTerminalCert. The device restarts automatically on success. See installEccTerminalCert for full behaviour (TEST devices only).

Link copied to clipboard

Opens a session with the selectedBluetoothDevice or selectedUsbDevice depending on the ToroConfig.connectionMode.

Link copied to clipboard
fun sendCancellationAdvice(originalTransaction: OriginalTransactionDetails, onCompleted: (ResponseCode) -> Unit, onError: (error: ToroException) -> Unit)

Sends cancellation advice to the gateway for an already completed transaction.

Link copied to clipboard
fun sendCompletionAdvice(originalTransaction: OriginalTransactionDetails, onCompleted: (ResponseCode) -> Unit, onError: (ToroException) -> Unit)

Sends financial completion advice to the gateway for a transaction which has already been authorised (but not yet captured).

Link copied to clipboard
fun sendDiagnosticRequest(onCompleted: (rawResponse: String) -> Unit, onError: (ToroException) -> Unit)

Handles the device session as getDeviceInfo does.

Link copied to clipboard

Sets the CardEventListener to receive card event updates.

Link copied to clipboard
fun setConfig(newConfig: ToroConfig)

Updates the configuration for the Toro SDK. Useful if you need to dynamically change the config after the application has already initialized the Toro SDK.

Link copied to clipboard

Sets the ActivityResultLauncher for the SDK internal signature activity. This should be set in an Activity/Fragment where the transaction state will be TransactionState.AWAITING_SIGNATURE. The activity will only be used for capturing signatures when signatureMode in ToroConfig is set to APP. Using the default config, the SDK will try collect the signature from the Miura device instead.

Link copied to clipboard

Sets the TransactionStateListener to receive transaction state updates.

Link copied to clipboard
Link copied to clipboard
fun startTransaction(amount: Int, type: TransactionType, currencyCode: CurrencyCode, metadata: TransactionMetadata? = null, onCompleted: (TransactionReceipt) -> Unit, onCancelled: (CancellationType) -> Unit, onError: (ToroException) -> Unit, onGratuityConfirmed: (gratuityAmount: Int, gratuityPercentage: Int) -> Unit? = null)

Starts a transaction with the specified amount and currency code on the selected device.