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.
| Type | Fields / defaults |
|---|---|
WollettePosConfig | apiBaseUrl: String (HTTPS; shared parser appends /api/v1 or preserves that existing suffix), storageId: String = "default", requestTimeoutMillis: Int = 60_000 |
PosTerminal | merchantId, branchId, posId, serialNo, deviceName: strings; capabilities: set of strings |
PosDeviceAssociation | Actual registered serialNo and capabilities |
PosKeyMaterial | posId, serialNo, value (raw Base64 PKCS#8); createdDateTimeMillis, expiryDateTimeMillis, minRotationDateTimeMillis |
PosKeyInfo | The 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.
| Method | Result | Network |
|---|---|---|
applySession(accessToken: String, expirySeconds: Int) | Unit | No; host owns login/refresh |
selectTerminal(value: PosTerminal) | Unit | No; validates merchant/branch access |
clear() | Unit | No; clears credentials/context/key, retains financial journal |
ensureDeviceAssociation() | PosDeviceAssociation | GET; confirmed 404 permits POST then GET |
importKey(material: PosKeyMaterial) | PosKeyInfo | No; validates and verifies secure-storage readback |
keyInfo() | PosKeyInfo? | No |
keyState() | PosKeyState | No |
createKey() | PosKeyInfo | POST; existing server key may return HTTP 412 |
rotateKey() | PosKeyInfo | PATCH; explicit replacement of known local key |
recoverKeyByRotation() | PosKeyInfo | PATCH; explicit replacement after lost/unknown key outcome |
signPayment(orderId: String, cryptogram: String) | String | No; Base64 signature |
signRefund(orderId: String, originalPaymentRequestId: String, cryptogram: String) | String | No; 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):
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()| Model | Fields |
|---|---|
PosLocation | lat, lon: Double |
PosPaymentRequest | orderId: String, amount: MonetaryAmount, location: PosLocation, reference: String (defaults to order ID) |
PosPaymentResult | idempotencyId, requestId: strings; status: PosPaymentStatus; failureReason: String? |
PosOperationSnapshot | idempotencyId, orderId: strings; kind: PosTransactionKind; phase: PosOperationPhase; optional requestId and status |
PosPayer | accountToken, 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
| Value | Source | Keep it for |
|---|---|---|
orderId | Your host checkout/order system | Matching the attempt and result to the original host flow |
reference | Your host; defaults to orderId | The submitted reference |
idempotencyId | SDK-generated for one retained initiation | Exact recovery/replay and local acknowledgement |
requestId | Wollette's financial result or retained snapshot, when known | Status recovery and the original payment ID for refunds |
| Terminal merchant/branch/POS/serial | Approved terminal provisioning | Restoring 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.
suspend fun pay(
request: PosPaymentRequest,
reader: PosNfcReader,
onStage: (PosPaymentStage) -> Unit = {},
): PosPaymentResult| Contract | Behaviour |
|---|---|
| Required state | Allowed merchant session, original selected terminal, compatible capabilities and usable signing key |
| Required request | Host order ID, positive finite amount, uppercase currency code and valid location |
| Optional/default | reference defaults to order ID; onStage defaults to an empty callback |
| Returns | PosPaymentResult: operation ID, request ID, status and optional failure reason |
| Side effects | Retains an encrypted operation, acquires payer data and can submit a financial POST |
| Existing operation | Identical retained intent/result returns the cached status, even pending/timed out; a different or unresolved intent is rejected |
| Retry/recovery | Refresh saved status with recoverOperation; do not repeat pay to poll |
| Errors | Session/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.
suspend fun refund(
request: PosPaymentRequest,
originalPaymentRequestId: String,
reader: PosNfcReader,
onStage: (PosPaymentStage) -> Unit = {},
): PosPaymentResultoriginalPaymentRequestId 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.
suspend fun recoverOperation(
replayInitiation: Boolean = false,
onStage: (PosPaymentStage) -> Unit = {},
): PosPaymentResult| Contract | Behaviour |
|---|---|
| Required state | Active allowed merchant session, original selected terminal and retained operation in the same API/storage namespace |
| Default | replayInitiation=false; no automatic financial POST replay |
| Known request | GET by saved request ID; no new payer scan/signature |
| Unknown submission | true permits the exact saved POST only when eligible and 0–29 days old |
| After 29 days | Known request-ID GET remains available; an unknown submission needs external reconciliation |
| Returned value | PosPaymentResult; pending/timed-out results remain outstanding |
| Key dependency | Uses the saved signature or GET; does not need the old private key |
| Errors | Missing/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.
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
| API | Configuration / 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_V1 | Shared 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.