Accept a WollettePay payment
Call pay to acquire payment data and request authorisation. Your app records the result and completes the order.
Before calling
- Attach a valid merchant session and select the terminal.
- Confirm the device association and required capabilities.
- Resolve any retained operation.
- Prepare a usable terminal key.
- Keep the payment screen in the foreground and obtain required permissions.
- Load the order's amount, currency and location.
The POS quickstart covers setup.
The complete native starters include a checkout store, payment/refund controls and recovery actions. The snippets below show the SDK calls inside that host flow. See pay for the method contract.
Use the approved order amount and currency. The core money model rounds to two decimal places with HALF_UP, but provider rules and supported currencies remain operation-specific. Do not multiply by 100 by assumption.
Payment at a glance
Save the original checkout/order before initiation. This diagram starts with payer acquisition and shows one authorised-payment path:
flowchart TD
accTitle: Example successful payment flow
accDescr: One successful path with host order completion before SDK acknowledgement.
Transfer["POS SDK<br/>Receive payer details over NFC or Bluetooth"] --> Authorize["Wollette API<br/>Return AUTHORIZED"]
Authorize --> Save["Your app<br/>Save result and prevent duplicates"]
Save --> Complete["Your app + backend<br/>Complete the order"]
Complete --> Acknowledge["Your app → SDK<br/>Acknowledge saved operation"]Acknowledgement may happen before order completion once the result and duplicate-prevention state are durable. It removes the SDK's saved operation; it does not complete the order or cancel a server payment. Pending, timed-out and unknown submissions stay retained for recovery. Follow Save before acknowledging for the exact boundary.
Submit the request
val request = PosPaymentRequest(
orderId = orderId,
amount = MonetaryAmount(value = 12.50, currencyCode = "GBP"),
location = PosLocation(lat = latitude, lon = longitude),
)
val result = withContext(Dispatchers.IO) {
sdk.pay(request, AndroidPosNfcReader(foregroundActivity))
}Imports are shown in the quickstart. Replace the sample values with the order's values. reference defaults to orderId; supply it explicitly if your integration needs a separate reference. The SDK generates the operation's idempotencyId.
Use the coordinator overload to offer NFC and Bluetooth together.
Handle the status
| Status | What your app does |
|---|---|
AUTHORIZED | Save the authorised method and request ID; continue remaining split/order-completion steps |
DECLINED | Save the definitive result and offer an appropriate next choice |
BLOCKED | Save the definitive result and explain that the payment was blocked |
FAILED | Save the definitive failure and offer the supported next action |
PENDING_AUTHORIZATION | Retain the operation; recover its known request ID |
TIMED_OUT | Retain the operation; timeout is not a definitive failure |
The result includes requestId, idempotencyId and optional failureReason. Stage events such as DATA_EXCHANGED and Bluetooth transfer acknowledgements are not authorisation results.
Save before acknowledging
The following helpers accept an app-owned persistence function. Save the result against the order so it survives an app restart. Save the state that prevents this authorised method from being initiated again. If saving fails, throw and leave the SDK operation intact.
suspend fun recordPaymentResult(
sdk: WollettePosSdk,
result: PosPaymentResult,
saveToOrder: suspend (PosPaymentResult) -> Unit,
) {
saveToOrder(result)
when (result.status) {
PosPaymentStatus.AUTHORIZED,
PosPaymentStatus.DECLINED,
PosPaymentStatus.BLOCKED,
PosPaymentStatus.FAILED -> withContext(Dispatchers.IO) {
sdk.acknowledgeOperation(result.idempotencyId)
}
PosPaymentStatus.PENDING_AUTHORIZATION,
PosPaymentStatus.TIMED_OUT -> Unit
}
}The helper uses Dispatchers and withContext from kotlinx.coroutines. These helpers do not complete an order. Your application still needs its own order-completion and recovery logic.
If another split method or order completion fails, keep the authorised WollettePay method and retry only the unfinished host step. Calling pay after acknowledgement can create another payment.
Handle exceptions and cancellation
The SDK retains an encrypted operation record. Repeating the same intent returns any retained result, including pending or timed-out status; it does not refresh that status. Use recoverOperation to query the saved request. A different intent is rejected with OPERATION_UNRESOLVED.
After an exception, cancellation or restart, inspect the saved operation. Even HTTP 401 or 412 can follow submission; do not refresh a token and blindly call pay again. Renew the host session, then recover the original operation.
Verify the integration
| Scenario | Expected host/SDK outcome |
|---|---|
| Definitive result, host save succeeds | Persist the result and duplicate-prevention state, then acknowledge |
| Host save fails | No acknowledgement; retained result can be recovered |
| Authorised method, later host completion fails | Resume the unfinished order step; do not initiate the method again |
| Pending or timed-out result | Keep the operation; recover the request status |
| App closes after submission | Restore the original context and recover; do not ask for another tap |
| The same checkout opens after acknowledgement | Host receipt prevents another initiation, even though the SDK journal is empty |
These are acceptance criteria. Wollette must supply approved fixtures to reproduce each financial outcome; the downloaded apps do not simulate a successful backend payment.
Connect authorisation to host completion
Persist the original checkout/refund flow before initiation. After a definitive result, save the request, result and order relationship durably. Acknowledgement is allowed only when host handling prevents that flow from initiating again. Completing the order is a separate host/backend operation.
If order or split completion fails after authorisation, retain the authorised method and retry only that unfinished host step. After acknowledgement or process restart, the durable receipt must still prevent another charge for the same completed/authorised flow. The SDK journal does not replace your order system.
Use repeatable tests, including failed host save, failed completion and response loss. Count financial creations separately from HTTP attempts during exact replay.