Consumer contactless payments
Guides

Consumer contactless payments

Present a customer's linked bank account to a WollettePay terminal. Android uses NFC through Host Card Emulation (HCE); iOS uses the foreground Bluetooth LE client. Merchant payment acceptance is covered by the POS SDK.

Android: what the library provides

The library manifest merges the HCE service (PaymentApduService), its NFC permission and the application identifier F2760000850101 into your app. You declare nothing for NFC. The service uses category other, so your app does not need to be the default Tap & pay app.

Requirements for pay

  • A consumer session.
  • A device with HCE and NFC switched on.
  • A linked account with a completed PIS consent.
  • A Firebase token passed in WolletteConfig or setRegistrationToken. The SDK waives this only when an association already exists from an earlier call, and it offers no method to check that, so always supply the token.
  • A fresh developer proof for each request made during arming.

Arm on the pay screen

Kotlin
class PayScreen : Fragment() {
    override fun onResume() {
        super.onResume()
        lifecycleScope.launch {
            try {
                sdk.payments.pay(accountId, provider)
                showReadyToTap()
            } catch (e: WolletteException) {
                showPayError(e)
            }
        }
    }

    override fun onPause() {
        sdk.payments.stop()
        super.onPause()
    }
}

pay creates or updates the device association, fetches or rotates payment keys, and arms the HCE service. It does not open a bank page. It throws VALIDATION if accountId is blank, HCE is missing, NFC is off, PIS is not ready, or there is no token to associate the device.

Disarm when leaving

stop() disarms immediately without waiting for a pending pay request. It prevents an older request from re-arming NFC after the user leaves. Call it in onPause or whenever the pay screen closes.

clear() also disarms HCE and deletes payment keys.

iOS: transfer over Bluetooth

The legacy sdk.payments.pay method still throws validation on iOS. Use AppleBlePaymentClient for Bluetooth.

Before starting, supply a valid consumer session, developer proof provider, current device/account association and completed AIS/PIS setup for the selected account. The POS must have its Bluetooth provider configured, and the session/public-key/close routes must be available in the target environment.

Add NSBluetoothAlwaysUsageDescription to your app's Info.plist:

XML
<key>NSBluetoothAlwaysUsageDescription</key>
<string>Connect to a nearby WollettePay terminal to transfer payment details.</string>

Create and retain one client for the payment screen:

Swift
import WolletteApp
import WolletteShared

let bleClient = AppleBlePaymentClient()
let payloadProvider = BackendConsumerBlePayloadProvider(
    preparation: sdk.consumerPayments,
    provider: provider
)

Start an exchange when the user selects the account for payment:

Swift
try await bleClient.exchange(
    accountId: selectedAccountId,
    profile: .wollettePaymentV1,
    provider: payloadProvider
)
// Payment data transferred. Wait for the financial outcome.

Keep the screen in the foreground. With no suitable terminal, discovery repeats. Multiple suitable terminals stop the attempt with an ambiguity error. Exchange failures require an explicit retry; stronger signal strength does not authenticate a terminal.

The concrete provider sets up or renews an ordinary missing/expired account key once and continues the exchange. Unknown key mutations require explicit recovery. An expired device key needs separate device-key maintenance; replacing the account key will not fix it.

Stop and await cleanup before leaving the screen, switching account or signing out:

Swift
await bleClient.stop()

Backgrounding also cancels the native exchange. sdk.payments.stop() does not stop this separate client. Move stage callbacks to the main actor and ignore events from superseded attempts.

Payment outcome

Android pay returning means NFC is armed. iOS exchange returning means data was transferred. Neither return value establishes authorisation or order completion. A consumer Bluetooth error also does not prove that the POS sent no financial request.

Agree the final-result handoff

Required contractWollette/your backend must supply
DeliverySupported consumer result channel, authentication and subscription/polling rules, if applicable
CorrelationIdentifiers connecting this consumer attempt to the POS request/order
StateMeaning of definitive, delayed and missing results, plus the allowed customer messages
RecoveryRestart/reconnect behaviour and the named escalation route for an unresolved outcome

Until that contract is approved, the local UI can report readiness or transferred details. It cannot infer payment success from NFC arming, Bluetooth exchange or a transport error. reconcileTopUp handles top-ups, not these purchases. The POS recovers its own retained operation through financial recovery.

Compromised devices

PaymentApduService cannot throw to a reader. If a compromise is detected while restoring keys or processing a command, it keeps presentation disabled and answers with a technical APDU response. Your app sees DEVICE_COMPROMISED from pay and other SDK calls, not from the tap. See Device security.

Prepare the payer and reader together

Use the two-device role table to prepare both apps. NFC uses an Android HCE consumer and an approved physical POS reader; the iPhone consumer uses foreground Bluetooth. A simulator build cannot demonstrate the radio exchange.

Check consumer activation/account consent and association separately from merchant session, original terminal and POS key readiness. Keep the consumer payment screen active during exchange and stop its relevant client when leaving. A successful transfer is separate from authorisation and host order completion; the final consumer result channel still needs platform confirmation.