Configure NFC and Bluetooth
Use a payment coordinator to offer NFC and Bluetooth LE on the same POS screen. The first transport to claim the attempt wins; the SDK sends one financial request.
Prepare both devices
A payment test needs a consumer app presenting payer data and a merchant POS requesting authorisation. Start with consumer setup and POS association, then use one of these roles:
| Transport | Consumer | POS | Setup before exchange | Evidence |
|---|---|---|---|---|
| NFC | Physical Android device with HCE and NFC, API 24+ | Physical Android NFC reader | Activated wallet, selected linked account, association/payment keys; merchant session, original terminal, usable key, NFC and BAAS capabilities | Implemented roles; full device/payment acceptance pending |
| Bluetooth LE | Physical foreground iPhone consumer, iOS 15.1+ | Android POS peripheral with BLE support, API 24+ | Shared v1 profile, backend adapters, completed AIS/PIS and association, permissions and trusted keys | Full radio/backend/financial acceptance pending |
This is an implementation-role table, not a certified hardware list. Obtain an approved device pair and accounts from Wollette. Android POS Bluetooth support does not establish Android consumer Bluetooth support. iOS consumer payments.pay has no NFC/HCE implementation; its payment-data transfer uses the explicit Bluetooth client.
Prepare the terminal
Complete session and association setup, resolve any pending operation, and prepare a usable terminal key.
BAAS is required. NFC also requires NFC. A Bluetooth source can work without NFC capability; do not add an invented Bluetooth capability value to the backend.
Configure platform permissions
| Platform | NFC | Bluetooth |
|---|---|---|
| Android POS | Current foreground Activity; NFC available and enabled. Permission is declared by the library | Library declares legacy permissions through API 30 and BLUETOOTH_ADVERTISE/BLUETOOTH_CONNECT for Android 12+. Your app requests applicable runtime Nearby Devices permissions |
Android POS uses the Bluetooth peripheral role; the SDK adds no scan/location permission for that role. Your checkout still supplies location for payment requests.
Create the coordinator
The following examples enable continuous foreground discovery on the coordinator and both sources. Imports are those used in the quickstart.
val coordinator = PosPaymentCoordinator(
sources = listOf(
AndroidPosNfcReader(foregroundActivity, continuousDiscovery = true),
AndroidPosBlePayerSource(
context = applicationContext,
profile = PosBleGattProfile.WOLLETTE_PAYMENT_V1,
sessions = BackendPosBleSessionProvider(sdk),
continuousDiscovery = true,
),
),
continuousDiscovery = true,
)
val result = withContext(Dispatchers.IO) {
sdk.pay(request, coordinator = coordinator)
}
// Refund: sdk.refund(request, originalPaymentRequestId, coordinator)Create one coordinator per call. It only acquires payer data; sdk.pay or sdk.refund owns signing, financial submission and the journal. Neither the coordinator nor the POS Bluetooth provider creates or rotates the terminal key automatically.
Handle result using payment result and acknowledgement rules.
Understand selection and timeout
- Configure at most one source per transport.
- Built-in sources discover before claiming. Exactly one can claim; built-in NFC readers and conforming
PosPayerSourceimplementations claim before exchange. - The losing source is cancelled and its late results are ignored.
- A hardware/permission/unavailable error before selection can leave the other source usable.
- A selected source's failure ends the attempt. There is no automatic switch to the other transport.
- The default coordinator deadline is 40 seconds. With continuous discovery enabled, that deadline starts after a source claims. The backend Bluetooth session can impose a shorter remaining lifetime.
A legacy custom reader implementing only PosNfcReader is adapted by PosNfcPayerSource, which can claim only after read returns its payer. Implement PosPayerSource directly when your custom reader needs arbitration before exchange. The financial engine still uses only the selected payer.
The native NFC readers stop retrying once they have claimed a coordinator operation, including when used through the pay(..., reader) overload. Their standalone read APIs have separate read-attempt behaviour; those retries must not be treated as payment retries.
After acquisition failure, inspect and acknowledge a never-submitted attempt before an explicit new try.
Stop on lifecycle changes
Cancel the owning coroutine or call cancelOperation() on screen exit, backgrounding, logout and terminal changes. Your app still owns screen and context lifecycle.
Marshal stage callbacks to your UI thread. A Bluetooth write acknowledgement or DATA_EXCHANGED stage means transport progress, not payment success.
The customer's iPhone uses the separate consumer Bluetooth client. It selects one suitable terminal over a bounded discovery window. Multiple suitable terminals produce an ambiguity error; signal strength is a discovery filter, not proof of terminal identity or physical distance.
Backend provider contract
The concrete providers use:
| Operation | API used by the reviewed adapter |
|---|---|
| POS creates a payment session | POST merchant-branch-pos/{posId}/payment-sessions |
| Consumer resolves the POS public key | GET merchant-branch-pos/{posId}/public-keys?paymentSessionId=... |
| POS closes the session | DELETE merchant-branch-pos/{posId}/payment-sessions/{id} |
The POS supplies its operation ID as the external posSessionId. A GATT descriptor identifies the session; it is not a trusted public key. The consumer resolves the key through its authenticated API.
Local POS validity is capped at 30 seconds, including session creation latency. The provider permits one decode attempt and requires a successful close response before releasing payer data to the financial engine. Close failure prevents that financial POST. Losing/cancelled sessions receive best-effort cleanup; the server TTL handles an unknown session ID or failed cleanup.
Missing preparation routes (404/405) make unselected Bluetooth unavailable while leaving NFC eligible. Confirm the routes and their authorisation in your deployed environment.
Custom adapters and wire format
Prefer the SDK's v1 profile and concrete providers. A custom PosPayerSource must claim immediately before exchange, stop if the claim is rejected and release resources on cancellation.
The shared profile has service, session, claim and payload UUIDs. The descriptor is limited to 512 bytes. The transfer uses a fresh 16-byte challenge, ordered write-with-response frames and an encrypted envelope capped at 65,536 bytes.
Envelope encryption uses a fresh AES-256-GCM key wrapped with RSA OAEP SHA-256/MGF1 SHA-256. Associated data binds the expected POS, session and challenge. A custom decoder must verify that binding; there is no plaintext fallback. The inner consumer cryptogram/signature remains subject to backend verification.
The repository describes some framing choices as provisional. Confirm a supported partner protocol before implementing a custom adapter.
Run an NFC test
- Prepare the approved order and both signed-in apps. On POS restore the original terminal, inspect/recover any outstanding operation, then verify association and a usable key.
- On the Android consumer select the linked account with completed PIS, pass the host FCM token for association and arm
payments.pay. A wallet screen alone does not provide HCE. - On POS enable the foreground reader.
- Confirm the consumer is ready and the POS is waiting, then present the devices. A data-exchanged stage proves transfer only.
- Inspect the financial result. Save it durably with the host order before SDK acknowledgement; finish host completion under the result rules. Pending/unknown results remain outstanding.
- On screen exit stop consumer payment mode and cancel POS acquisition. After submission inspect/recover the same operation; local cancellation does not cancel the server payment.
Run a Bluetooth test
- Prepare the approved accounts/order and original POS key/context, resolving retained financial work first. Confirm the backend session/public-key/close adapters are deployed in the matching environment.
- Configure the shared v1 GATT profile,
BackendPosBleSessionProvideron POS and the concrete consumer payload provider on the iPhone, following the examples above and consumer setup. - Enable radio/permissions. The implemented Android POS role is a peripheral: request applicable Android 12+
BLUETOOTH_ADVERTISE/BLUETOOTH_CONNECTruntime permissions; this role adds no scan/location permission. The checkout's geographic location input is separate. The consumer iPhone needs its Bluetooth usage description. - Keep both payment screens foreground. POS advertises; the consumer waits for one suitable terminal. With several candidates, separate the devices and explicitly retry; do not pick an arbitrary terminal.
- After exchange the consumer may show details sent. POS still needs a definitive financial result and host completion. Confirm the consumer's final-result delivery contract with Wollette.
- On navigation, backgrounding, logout or account/terminal changes, cancel the relevant task/client/coordinator. Restore the original context and inspect retained POS state after restart before a new charge.
Diagnose a two-device test
| Symptom | Check and action | Expected result |
|---|---|---|
| No Bluetooth discovery | Foreground screens, matching profile/adapters, radio, role-specific permissions and backend session creation | One suitable POS appears; otherwise capture sanitised device/phase evidence |
| Several terminals | Separate nearby devices and explicitly retry | One eligible terminal; no automatic strongest-signal selection |
| Permission denied | Explain the needed permission and let the user correct system settings | The next explicit attempt can acquire |
| Exchange failed | Cancel acquisition and inspect the retained operation | Acknowledge only an abandoned never-submitted attempt; submitted work uses recovery |
| Details transferred, no final result | Inspect the POS request/journal and recover the same operation | Definitive status or an explicit unresolved state; no new payment identity |
Repeatable payment tests
Obtain approved accounts/orders, exact amounts, expected server outcomes, failure controls and request-count access before running these scenarios. The procedure does not claim that every outcome can currently be forced. Record actual observations in the acceptance CSV; all 18 imported acceptance scenarios start as NOT_RUN with named owners unassigned.
Test-pack handoff
Ask the payments/backend owner to fill in this handoff for each scenario before the run:
| Input | Required detail |
|---|---|
| Owner and environment | Named operator/contact, approved API environment and SDK/host versions |
| Accounts and devices | Test consumer/merchant, original terminal context and approved physical device pair |
| Order and money | Unique host flow, eligible original payment for refunds, exact amount/currency under the confirmed money policy |
| Outcome control | Documented fixture or fault-control name, how to activate it and how to reset it |
| Expected observations | Exact expected status, retained journal phase, host order/result state and financial creation count |
| Evidence and escalation | Safe request-count/evidence access and the named reconciliation contact |
The expected states below are acceptance criteria. They become repeatable backend tests only when the approved fixtures/controls and actual observations are supplied. Unit fakes can help test app behaviour separately; they do not establish live radio or financial acceptance.
| Starting state | Action with approved fixture/control | Expected SDK state | Expected host handling |
|---|---|---|---|
| Ready payment | Run one approved successful payment | AUTHORIZED, retained until safe acknowledgement | Save result, complete once, retain receipt; one financial creation |
| Controlled rejection | Run the designated decline fixture | Configured DECLINED, BLOCKED or FAILED; definitive result retained | Save outcome, acknowledge safely, offer an explicit new choice |
| Delayed result | Submit once and recover the known request | PENDING_AUTHORIZATION / TIMED_OUT; still outstanding | Keep order incomplete and use GET recovery |
| Lost initiation response | Let the request reach the server, drop its response, restart and explicitly recover | Unknown submitted operation; exact saved replay retains body/signature/ID | Restore original flow; verify one financial creation despite repeated HTTP attempts |
| Pending/result at process exit | Kill after journal write and restart with the same context | Retained snapshot/cached result or same-request GET | Restore host receipt; no second authorisation |
| Host result-save failure | Inject storage failure before acknowledgement | Native definitive result stays retained | Repair storage, save the same result; no new initiation |
| Host completion failure after acknowledgement | Fail completion after a durable receipt, then restart | Journal may be clear; host receipt remains | Retry completion only, preserving the authorised request |
| Full or partial refund | Use an eligible original request and approved amount in a distinct refund flow | Retained refund result; same recovery rules | Enforce remaining refundable amount and prevent duplicate refund |
| Lost/corrupt host or SDK record | Use an isolated test fault and preserve correlation data | Block unsafe fresh initiation | Named operations owner reconciles original order/request |
| Unknown submission beyond replay window | Use an approved clock/storage harness | RECOVERY_WINDOW_EXPIRED; journal retained | Reconcile externally; known request IDs may still use GET |
| Interrupted activation | Interrupt approved AIS/Griffin/PIS and restore session | Inspect saved target before general progress | Resume the matching operation; record real bank/identity returns |
For each run record SDK/host versions, physical device/OS, environment, starting state, exact fixture/actions, expected and observed SDK/host state, HTTP attempts, financial creations and evidence. An exact replay may make another HTTP POST with the same identity; that is different from creating another financial request. Never edit a live journal to manufacture a test outcome.
Run local recovery tests
These SDK suites use isolated stores and fake transports. They require an authorised SDK checkout and native toolchain, but no live account or radio device. From the SDK repository root:
./android/gradlew -p android :wollette-sdk-pos:testDebugUnitTest --tests 'com.wollette.pos.PosPaymentsTest'| Scenario | Kotlin method in PosPaymentsTest |
|---|---|
| Cached authorisation | authorizedResultIsCachedUntilHostAcknowledgesCompletion |
| Lost response/recreation | lostResponseRequiresExplicitExactReplayAfterRecreation |
| Pending known request | knownPendingRequestUsesGetOnlyAndPreservesAuthorization |
| Server status mapping | allServerStatusesAreReturnedWithoutDeclineCollapsing |
| Expired replay | replayWindowCannotOutliveServerIdempotency |
| Cancellation after dispatch | cancellationAfterDispatchRetainsUnknownOperation |
| Native result-store failure | postResponseStorageFailureReportsUnknownWithoutLosingMarker |
| Full/partial refund fields | refundPayloadAndSignaturePreserveOriginalAndPayerFields |
Append a method name to the --tests selector to run one case. Inspect the assertions and fake request counts. These results do not prove deployed backend, radio or financial behaviour. The acceptance CSV defines all 18 live/partner scenarios; it records no execution passes.
Inject host failures in a test build
Use test-only adapters for these two boundaries:
- Result save fails: fail host order/receipt persistence after the SDK returns and before acknowledgement. Keep the native entry. Repair storage, retrieve/save the same result and continue the original flow.
- Completion fails: first save the authorised result and duplicate-prevention state durably. Fail the host completion service, restart, then retry only that unfinished step. Even after native acknowledgement, the receipt must block another authorisation.
Disable these controls in shipping builds. Keep original flow/order identity and count financial creations separately from HTTP attempts. Concurrent duplicate tests need their own approved backend procedure; sequential replay does not prove concurrency behaviour.
For missing-state or replay-expiry tests, use an isolated test store or injected clock. Never edit a live journal. Preserve available identifiers through the approved channel and keep a new charge blocked until the named owner reconciles the original state.