Terminal

class Terminal

Entry point of the APA POS SDK. Create one instance per terminal and reuse it; instances are thread-safe.

Types

Link copied to clipboard
class Builder

Builds an Terminal. Requires terminalId and connectionOptions to be set.

Link copied to clipboard
object Companion

Functions

Link copied to clipboard

Asks the terminal to abort its current work.

Link copied to clipboard

Same as abort, but runs on a background thread and returns an Async wrapping it.

Link copied to clipboard

Opens a shift via service-request/activate. ActivateData.userId is sent as ecrId for this call, and a successful request updates getState unless the SDK is disconnected.

Link copied to clipboard

Same as activate, but runs on a background thread and returns an Async wrapping it.

Link copied to clipboard

Validates a remote connection by fetching an access token and querying the terminal. Updates getState accordingly and throws if the terminal cannot be reached.

Link copied to clipboard

Same as connect, but runs on a background thread and returns an Async wrapping it.

Link copied to clipboard

Closes the current shift via service-request/deactivate and returns the clearing data. A successful request updates getState unless the SDK is disconnected.

Link copied to clipboard

Same as deactivate, but runs on a background thread and returns an Async wrapping it.

Link copied to clipboard

Clears the cached access token obtained by connect and moves getState to TerminalState.DISCONNECTED.

Link copied to clipboard

Same as disconnect, but runs on a background thread and returns an Async wrapping it.

Link copied to clipboard

Reads the persisted status of a previously started transaction.

Link copied to clipboard
fun finalBalance(correlationId: String = UUID.randomUUID().toString()): FinalBalanceResult

Queries the terminal's current final balance/clearing totals.

Link copied to clipboard
fun finalBalanceAsync(correlationId: String = UUID.randomUUID().toString()): Async<FinalBalanceResult>

Same as finalBalance, but runs on a background thread and returns an Async wrapping it.

Link copied to clipboard
Link copied to clipboard

Recovers a pre-transaction wait after a restart using its persisted transactionId. Checks the recorded status before returning; throws IllegalStateException unless it is TransactionStatus.INITIALIZED. The returned handle waits for the pre-transaction to finish. Previously collected loyalty data cannot be recovered and is null in the result.

Link copied to clipboard
fun reboot(correlationId: String = UUID.randomUUID().toString()): RebootResult

Asks the terminal to reboot, using the generic terminal command channel (there is no dedicated reboot endpoint on the terminal service).

Link copied to clipboard
fun rebootAsync(correlationId: String = UUID.randomUUID().toString()): Async<RebootResult>

Same as reboot, but runs on a background thread and returns an Async wrapping it.

Link copied to clipboard
fun resume(transactionId: String): TransactionStep

Recovers an UncommittedTransactionResult for WAITING_FOR_COMMIT or TransactionResult for a settled operation. While the terminal reports IN_PROGRESS, this blocks the calling thread and re-polls the status every 250 ms until it settles into one of the states above. Polling is bounded by TerminalOptions.commitTimeout; if the transaction is still IN_PROGRESS once that budget elapses, or the status is UNKNOWN, this throws IllegalStateException - call resume again to keep waiting. A failed or timed-out status request throws TerminalException; it does not establish the payment outcome. Recovery may be repeated with the same transaction ID. Only data available from the status endpoint is recovered. Missing authorisation data is null.

Link copied to clipboard

Starts a pre-transaction wait ahead of the actual payment amount being known - triggers the background wait (see PreTransactionProgress class docs) on its own cancellable background thread right away, and returns a PreTransactionProgress immediately without waiting for it to complete. Call PreTransactionProgress.getResult to retrieve the outcome once available, or PreTransactionProgress.cancel to stop waiting.

Link copied to clipboard

Asynchronous variant of startPreTransaction. PreTransactionCall.onResult fires once the background wait completes.

Link copied to clipboard

Reverses a concluded transaction. ReversalRequest.transactionId is also used as this call's X-Correlation-ID.

Link copied to clipboard

Same as startReversal, but runs on a background thread and returns an Async wrapping it.

Link copied to clipboard
fun startServiceRequest(request: ServiceRequest = ServiceRequest.configure()): ServiceRequestResult

Runs configuration and/or initialisation, according to request - see ServiceRequest. The default request runs both configuration and initialisation for every acquirer.

Link copied to clipboard

Same as startServiceRequest, but runs on a background thread and returns an Async wrapping it.

Link copied to clipboard

Starts a transaction synchronously. Returns UncommittedTransactionResult when a commit decision is required, otherwise TransactionResult. Failed payments are results; communication failures throw TerminalException. Run on a worker thread when used from a UI.

Link copied to clipboard

Starts a transaction in the background. Use the returned handle to receive the final TransactionResult and to resolve deferred commit decisions.