Configure NFC and Bluetooth
Guides

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:

TransportConsumerPOSSetup before exchangeEvidence
NFCPhysical Android device with HCE and NFC, API 24+Physical Android NFC readerActivated wallet, selected linked account, association/payment keys; merchant session, original terminal, usable key, NFC and BAAS capabilitiesImplemented roles; full device/payment acceptance pending
Bluetooth LEPhysical 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 keysFull 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

PlatformNFCBluetooth
Android POSCurrent foreground Activity; NFC available and enabled. Permission is declared by the libraryLibrary 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.

Kotlin
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 PosPayerSource implementations 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:

OperationAPI used by the reviewed adapter
POS creates a payment sessionPOST merchant-branch-pos/{posId}/payment-sessions
Consumer resolves the POS public keyGET merchant-branch-pos/{posId}/public-keys?paymentSessionId=...
POS closes the sessionDELETE 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

  1. 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.
  2. 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.
  3. On POS enable the foreground reader.
  4. Confirm the consumer is ready and the POS is waiting, then present the devices. A data-exchanged stage proves transfer only.
  5. 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.
  6. 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

  1. 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.
  2. Configure the shared v1 GATT profile, BackendPosBleSessionProvider on POS and the concrete consumer payload provider on the iPhone, following the examples above and consumer setup.
  3. Enable radio/permissions. The implemented Android POS role is a peripheral: request applicable Android 12+ BLUETOOTH_ADVERTISE/BLUETOOTH_CONNECT runtime permissions; this role adds no scan/location permission. The checkout's geographic location input is separate. The consumer iPhone needs its Bluetooth usage description.
  4. 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.
  5. 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.
  6. 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

SymptomCheck and actionExpected result
No Bluetooth discoveryForeground screens, matching profile/adapters, radio, role-specific permissions and backend session creationOne suitable POS appears; otherwise capture sanitised device/phase evidence
Several terminalsSeparate nearby devices and explicitly retryOne eligible terminal; no automatic strongest-signal selection
Permission deniedExplain the needed permission and let the user correct system settingsThe next explicit attempt can acquire
Exchange failedCancel acquisition and inspect the retained operationAcknowledge only an abandoned never-submitted attempt; submitted work uses recovery
Details transferred, no final resultInspect the POS request/journal and recover the same operationDefinitive 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:

InputRequired detail
Owner and environmentNamed operator/contact, approved API environment and SDK/host versions
Accounts and devicesTest consumer/merchant, original terminal context and approved physical device pair
Order and moneyUnique host flow, eligible original payment for refunds, exact amount/currency under the confirmed money policy
Outcome controlDocumented fixture or fault-control name, how to activate it and how to reset it
Expected observationsExact expected status, retained journal phase, host order/result state and financial creation count
Evidence and escalationSafe 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 stateAction with approved fixture/controlExpected SDK stateExpected host handling
Ready paymentRun one approved successful paymentAUTHORIZED, retained until safe acknowledgementSave result, complete once, retain receipt; one financial creation
Controlled rejectionRun the designated decline fixtureConfigured DECLINED, BLOCKED or FAILED; definitive result retainedSave outcome, acknowledge safely, offer an explicit new choice
Delayed resultSubmit once and recover the known requestPENDING_AUTHORIZATION / TIMED_OUT; still outstandingKeep order incomplete and use GET recovery
Lost initiation responseLet the request reach the server, drop its response, restart and explicitly recoverUnknown submitted operation; exact saved replay retains body/signature/IDRestore original flow; verify one financial creation despite repeated HTTP attempts
Pending/result at process exitKill after journal write and restart with the same contextRetained snapshot/cached result or same-request GETRestore host receipt; no second authorisation
Host result-save failureInject storage failure before acknowledgementNative definitive result stays retainedRepair storage, save the same result; no new initiation
Host completion failure after acknowledgementFail completion after a durable receipt, then restartJournal may be clear; host receipt remainsRetry completion only, preserving the authorised request
Full or partial refundUse an eligible original request and approved amount in a distinct refund flowRetained refund result; same recovery rulesEnforce remaining refundable amount and prevent duplicate refund
Lost/corrupt host or SDK recordUse an isolated test fault and preserve correlation dataBlock unsafe fresh initiationNamed operations owner reconciles original order/request
Unknown submission beyond replay windowUse an approved clock/storage harnessRECOVERY_WINDOW_EXPIRED; journal retainedReconcile externally; known request IDs may still use GET
Interrupted activationInterrupt approved AIS/Griffin/PIS and restore sessionInspect saved target before general progressResume 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:

Shell
./android/gradlew -p android :wollette-sdk-pos:testDebugUnitTest --tests 'com.wollette.pos.PosPaymentsTest'
ScenarioKotlin method in PosPaymentsTest
Cached authorisationauthorizedResultIsCachedUntilHostAcknowledgesCompletion
Lost response/recreationlostResponseRequiresExplicitExactReplayAfterRecreation
Pending known requestknownPendingRequestUsesGetOnlyAndPreservesAuthorization
Server status mappingallServerStatusesAreReturnedWithoutDeclineCollapsing
Expired replayreplayWindowCannotOutliveServerIdempotency
Cancellation after dispatchcancellationAfterDispatchRetainsUnknownOperation
Native result-store failurepostResponseStorageFailureReportsUnknownWithoutLosingMarker
Full/partial refund fieldsrefundPayloadAndSignaturePreserveOriginalAndPayerFields

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.