POS API reference
Reference

POS API reference

Methods and types for the merchant SDK. Install com.wollette:wollette-sdk-pos on Android. For setup, see Install the POS SDK. Consumer APIs have a separate reference.

Entry point and configuration

WollettePosSdk(context: Context, config: WollettePosConfig). Keep one instance per API/storage namespace. Synchronous methods perform storage/crypto work and should run off the UI thread. Suspending payment, recovery and key calls also perform synchronous persistence/signing; call them from an IO coroutine context.

TypeFields / defaults
WollettePosConfigapiBaseUrl: String (HTTPS; shared parser appends /api/v1 or preserves that existing suffix), storageId: String = "default", requestTimeoutMillis: Int = 60_000
PosTerminalmerchantId, branchId, posId, serialNo, deviceName: strings; capabilities: set of strings
PosDeviceAssociationActual registered serialNo and capabilities
PosKeyMaterialposId, serialNo, value (raw Base64 PKCS#8); createdDateTimeMillis, expiryDateTimeMillis, minRotationDateTimeMillis
PosKeyInfoThe same three timestamps, without private material

Timestamps use Kotlin Long, in Unix milliseconds. Pass the existing host serial and complete backend capability set. Never generate a consumer serial for POS. See session/context validation.

Session, association and keys

Network methods are suspend.

MethodResultNetwork
applySession(accessToken: String, expirySeconds: Int)UnitNo; host owns login/refresh
selectTerminal(value: PosTerminal)UnitNo; validates merchant/branch access
clear()UnitNo; clears credentials/context/key, retains financial journal
ensureDeviceAssociation()PosDeviceAssociationGET; confirmed 404 permits POST then GET
importKey(material: PosKeyMaterial)PosKeyInfoNo; validates and verifies secure-storage readback
keyInfo()PosKeyInfo?No
keyState()PosKeyStateNo
createKey()PosKeyInfoPOST; existing server key may return HTTP 412
rotateKey()PosKeyInfoPATCH; explicit replacement of known local key
recoverKeyByRotation()PosKeyInfoPATCH; explicit replacement after lost/unknown key outcome
signPayment(orderId: String, cryptogram: String)StringNo; Base64 signature
signRefund(orderId: String, originalPaymentRequestId: String, cryptogram: String)StringNo; Base64 signature

PosKeyState: MISSING, READY, ROTATION_DUE, EXPIRED, RECOVERY_REQUIRED. Native key mutation is explicit. Automatic maintenance in the RN integration is host orchestration of these methods, performed before a new financial operation.

Import requirements, key mutation/recovery and signature bytes define their semantics. A pending financial operation can block key mutation; resolve/acknowledge it first.

Payments and financial recovery

Signatures (onStage defaults to an empty callback):

Kotlin
suspend fun pay(request: PosPaymentRequest, reader: PosNfcReader,
                onStage: (PosPaymentStage) -> Unit = {}): PosPaymentResult
suspend fun pay(request: PosPaymentRequest, coordinator: PosPaymentCoordinator,
                onStage: (PosPaymentStage) -> Unit = {}): PosPaymentResult
suspend fun refund(request: PosPaymentRequest, originalPaymentRequestId: String,
                   reader: PosNfcReader, onStage: (PosPaymentStage) -> Unit = {}): PosPaymentResult
suspend fun refund(request: PosPaymentRequest, originalPaymentRequestId: String,
                   coordinator: PosPaymentCoordinator, onStage: (PosPaymentStage) -> Unit = {}): PosPaymentResult
suspend fun recoverOperation(replayInitiation: Boolean = false,
                             onStage: (PosPaymentStage) -> Unit = {}): PosPaymentResult
fun pendingOperation(): PosOperationSnapshot?
fun acknowledgeOperation(idempotencyId: String)
fun cancelOperation()
ModelFields
PosLocationlat, lon: Double
PosPaymentRequestorderId: String, amount: MonetaryAmount, location: PosLocation, reference: String (defaults to order ID)
PosPaymentResultidempotencyId, requestId: strings; status: PosPaymentStatus; failureReason: String?
PosOperationSnapshotidempotencyId, orderId: strings; kind: PosTransactionKind; phase: PosOperationPhase; optional requestId and status
PosPayeraccountToken, aisAccountId, aisConsentId, cryptogram, signature: strings; keep native and never log

PosTransactionKind: PAYMENT / REFUND. Status values are AUTHORIZED, DECLINED, BLOCKED, FAILED, TIMED_OUT, PENDING_AUTHORIZATION.

Journal phases are READING_NFC, PREPARED, SUBMITTED_UNKNOWN, RESULT, CANCELLED_BEFORE_SUBMISSION. READING_NFC also covers BLE acquisition.

Stages are ATTEMPT_STARTED, WAITING_FOR_TAG, TAG_DETECTED, AID_SELECTED, DATA_EXCHANGED, ATTEMPT_FAILED, NFC_SELECTED, BLE_SELECTED, BLE_ADVERTISING, BLE_EXCHANGING, SIGNING, SUBMITTING, RESULT, CANCELLED, OUTCOME_UNKNOWN. Marshal UI updates to the UI thread.

A result must be durably recorded by the host before acknowledgement. Pending, timed-out or unknown submitted operations block acknowledgement and new initiation. Cancellation after POST is never server cancellation. See result handling and immutable recovery before implementing retry.

Where the identifiers come from

ValueSourceKeep it for
orderIdYour host checkout/order systemMatching the attempt and result to the original host flow
referenceYour host; defaults to orderIdThe submitted reference
idempotencyIdSDK-generated for one retained initiationExact recovery/replay and local acknowledgement
requestIdWollette's financial result or retained snapshot, when knownStatus recovery and the original payment ID for refunds
Terminal merchant/branch/POS/serialApproved terminal provisioningRestoring the original recovery context

Store the host flow before initiation and the returned identifiers/results durably. An empty SDK journal after acknowledgement does not replace those records. See result handling.

pay

Acquire payer data and request payment authorisation. Key maintenance and host order completion are separate.

Kotlin
suspend fun pay(
    request: PosPaymentRequest,
    reader: PosNfcReader,
    onStage: (PosPaymentStage) -> Unit = {},
): PosPaymentResult
ContractBehaviour
Required stateAllowed merchant session, original selected terminal, compatible capabilities and usable signing key
Required requestHost order ID, positive finite amount, uppercase currency code and valid location
Optional/defaultreference defaults to order ID; onStage defaults to an empty callback
ReturnsPosPaymentResult: operation ID, request ID, status and optional failure reason
Side effectsRetains an encrypted operation, acquires payer data and can submit a financial POST
Existing operationIdentical retained intent/result returns the cached status, even pending/timed out; a different or unresolved intent is rejected
Retry/recoveryRefresh saved status with recoverOperation; do not repeat pay to poll
ErrorsSession/context/key/validation, transport, storage and financial HTTP failures; inspect retained state after exceptions/cancellation

The coordinator overload replaces reader with coordinator: PosPaymentCoordinator. The work belongs on an IO dispatcher; dispatch UI updates to the main thread. See accept a payment.

refund

Uses the payment request model plus the original payment's server request ID.

Kotlin
suspend fun refund(
    request: PosPaymentRequest,
    originalPaymentRequestId: String,
    reader: PosNfcReader,
    onStage: (PosPaymentStage) -> Unit = {},
): PosPaymentResult

originalPaymentRequestId is required and is not the order ID or refund operation ID. Session, terminal, acquisition, retained-operation, return/error and recovery contracts follow pay. The host validates refund eligibility and remaining refundable amount. A coordinator overload is also available. See refund a payment.

recoverOperation

Return a cached definitive result, query a known request ID, or explicitly replay the saved unknown submission.

Kotlin
suspend fun recoverOperation(
    replayInitiation: Boolean = false,
    onStage: (PosPaymentStage) -> Unit = {},
): PosPaymentResult
ContractBehaviour
Required stateActive allowed merchant session, original selected terminal and retained operation in the same API/storage namespace
DefaultreplayInitiation=false; no automatic financial POST replay
Known requestGET by saved request ID; no new payer scan/signature
Unknown submissiontrue permits the exact saved POST only when eligible and 0–29 days old
After 29 daysKnown request-ID GET remains available; an unknown submission needs external reconciliation
Returned valuePosPaymentResult; pending/timed-out results remain outstanding
Key dependencyUses the saved signature or GET; does not need the old private key
ErrorsMissing/mismatched/unresolved operation, expired replay window, session/context/storage/HTTP errors and native cancellation

Do not reconstruct a similar request or choose a fresh idempotency ID. See operation recovery.

acknowledgeOperation

Remove an allowed local journal entry after safe host handling.

Kotlin
fun acknowledgeOperation(idempotencyId: String)

The ID must match the retained operation. There must be no active protected operation, and the attempt must either never have been submitted or have a definitive authorised/declined/blocked/failed result. Save the host result and duplicate-prevention state first. Pending, timed-out and unknown submitted operations cannot be acknowledged.

This performs local storage work; it neither completes an order nor cancels a server payment. Call it off the main thread. Validation/context/storage errors and OPERATION_UNRESOLVED / OPERATION_IN_PROGRESS can reject it. See result recording.

NFC and Bluetooth acquisition types

APIConfiguration / purpose
AndroidPosNfcReader(activity, continuousDiscovery = false)Foreground Android ISO-DEP reader; implements both PosNfcReader and PosPayerSource
PosNfcPayerSource(reader)Adapts a custom reader. A legacy PosNfcReader can claim only after its read returns; implement PosPayerSource directly for arbitration before exchange
PosPaymentCoordinator(sources, timeoutMillis = 40_000, continuousDiscovery = false)One source per transport; first claim wins; never submits a financial POST
AndroidPosBlePayerSource(context, profile, sessions, continuousDiscovery = false)Android foreground BLE peripheral
BackendPosBleSessionProvider(sdk)Concrete session-create, decrypt and acknowledged-close adapter
PosBleGattProfile.WOLLETTE_PAYMENT_V1Shared v1 service/session/claim/payload UUIDs

PosPayerSource exposes transport (NFC/BLE) and acquire(context, claim, onStage). PosPayerContext carries request, terminal, idempotencyId, optional originalPaymentRequestId, and derived kind. A custom source must call claim immediately before exchange, stop if rejected, and release resources on cancellation. PosNfcReader.read(orderId, amount, onStage) returns the complete PosPayer.

Custom PosBleSessionProvider.prepare(context) returns a PosBleSession. Sessions expose descriptor: ByteArray, exchangeTimeoutMillis: Long (default 40,000), suspending decodePayer(envelope, challenge) and close() (default no-op). Descriptor limit is 512 bytes. The decoder must verify POS/session/challenge binding. Use the concrete provider for the current backend contract. See NFC/BLE setup examples.

Input validation

Text inputs must be non-empty and trimmed, with no control characters or pipe (|). POS IDs cannot be . or ... Use only the documented capability values.

Payment/refund amounts must be present, finite and greater than zero; currency must match [A-Z]{3}. That shape check does not establish which currencies the environment supports. Confirm units, decimal precision and rounding with Wollette; see Money values. Coordinates must be finite and within latitude −90…90 and longitude −180…180. The optional request reference defaults to the order ID.

Local validation does not enforce your refund limits or complete an order. See POS errors and retry rules for failures, including outcomeUnknown.

Backend money representation

Core MonetaryAmount rounds construction to two decimal places with HALF_UP. See Money values for the scope of that fact. Keep approved operation-specific units/currencies/provider rules separate from the local input checks above; do not assume minor-unit integers or multiply by 100.