API reference
Consumer wallet reference for Android and iOS. Android uses com.wollette; Swift uses WolletteApp. Merchant APIs are in the POS API reference. Methods wait for completion (suspend / async) and throw WolletteException / WolletteError unless noted. Every protected operation can also throw non-retryable DEVICE_COMPROMISED.
Error kinds are written in Android form; the iOS case is the camel-case equivalent (VALIDATION → .validation). Types are on the Types page.
Entry point
class WolletteSdk(context: Context, config: WolletteConfig)
val onboarding: Onboarding
val walletOnboarding: WalletOnboarding
val profile: Profile
val wollette: Wallet
val payments: Payments
suspend fun login(activity: Activity)
suspend fun applySession(accessToken: String, authorizationId: String, expirySeconds: Int)
suspend fun setRegistrationToken(token: String, provider: ApiContextProvider? = null)
suspend fun clear()
companion object {
fun completeLogin(uri: Uri?)
}init(config: WolletteConfig) throws
let onboarding: any Onboarding
let walletOnboarding: any WalletOnboarding
let profile: any Profile
let wollette: any Wallet
let payments: any Payments
let consumerPayments: ConsumerPaymentPreparation
@MainActor func login() async throws
@MainActor func startWalletOnboarding(presenting: UIViewController, provider: any ApiContextProvider) async throws -> WalletOnboardingProgress
@MainActor func resumeWalletRegistration(presenting: UIViewController, provider: any ApiContextProvider) async throws -> WalletOnboardingProgress
@MainActor func addWalletAccount(presenting: UIViewController, provider: any ApiContextProvider) async throws -> WalletOnboardingProgress
@MainActor func resumePendingWalletRegistration(presenting: UIViewController, provider: any ApiContextProvider) async throws -> WalletOnboardingProgress
func applySession(accessToken: String, authorizationId: String, expirySeconds: Int) async throws
func setRegistrationToken(_ token: String, provider: (any ApiContextProvider)? = nil) async throws
func clear() async throwsThe constructor throws VALIDATION if apiBaseUrl is not HTTPS or requestTimeoutMillis is not positive. Keep one instance; services cannot be constructed directly.
login
Opens the hosted login page (Chrome Custom Tab / ASWebAuthenticationSession), exchanges the callback for tokens and stores the session. Requires loginBaseUrl and redirectUri. Throws CANCELLED if the user dismisses the page. On iOS, a newer login or session replacement invalidates an unfinished login with VALIDATION; only the current attempt may save. On Android, login, applySession and clear share a lock on one instance, so later calls wait while login is pending. Tokens are never returned. Success does not imply push or tap-to-pay readiness.
iOS: cancelling the calling Task throws CancellationError.
The hosted-login configuration requires loginBaseUrl and a registered redirectUri. Android accepts the foreground Activity; Swift login() is @MainActor. User dismissal is CANCELLED / .cancelled; native coroutine/Task cancellation remains cancellation. Login does not create the consumer device association. See the Android and iOS starter flows.
applySession
Stores a host-managed consumer session. expirySeconds is the remaining lifetime at the time of the call. Your app owns renewal even if a login service is configured. Blank inputs or non-positive lifetime produce VALIDATION; malformed JWT structure/payload produces INVALID_RESPONSE; disallowed consumer/delegation claims produce UNAUTHORIZED. The parser checks claims, not the JWT signature. Does not open a browser or return tokens. If the consumer identity changes, previous form/recovery storage and native consumer payment keys are cleared. Stop the separate iOS Bluetooth client before switching. Handle cleanup failures. In-flight calls for the previous session fail with non-retryable VALIDATION.
setRegistrationToken
Stores the FCM token, then syncs the device association when a session exists. No session: success without HTTP, provider not called. Session with no provider or an invalid first context: VALIDATION, token kept, no HTTP. The read and the create/update use distinct contexts. Blank token: VALIDATION.
clear
On success, deletes the stored session, pending wallet operation and wallet-form storage. Both platforms delete native consumer payment keys; Android also disarms NFC. Your app stops the separate iOS Bluetooth client. No API call. Developer keys, local device identity, in-memory FCM token and registration OTP state remain. Cleanup may stop on a storage error; see Sign out and switch consumers.
completeLogin (Android)
For hosts whose own activity receives the redirect. Does not wait. Prefer the intent filter on LoginRedirectActivity.
Hosted wallet presentation (iOS)
All four wrappers present the SDK-owned WebView from a visible UIViewController:
| iOS entry point | Android equivalent |
|---|---|
startWalletOnboarding | walletOnboarding.start(activity, provider) |
resumeWalletRegistration | walletOnboarding.resumeRegistration(activity, provider) |
addWalletAccount | walletOnboarding.addAccount(activity, provider) |
resumePendingWalletRegistration | walletOnboarding.resumePendingRegistration(activity, provider) |
See WalletOnboarding below.
ApiContext and ApiContextProvider
data class ApiContext(developerId: String, nonce: String, signature: String)
fun interface ApiContextProvider { suspend fun nextContext(): ApiContext }struct ApiContext: Sendable, Equatable {
let developerId: String
let nonce: String
let signature: String
}
protocol ApiContextProvider: Sendable {
func nextContext() async throws -> ApiContext
}One developer proof per Wollette API HTTP attempt. nextContext is called once per attempt, including the retry after a 401 refresh, and never for the login service's /tokens or /refresh. toString() / description omit the signature. Rules: Developer authentication.
Onboarding
Consumer registration by phone OTP. All methods take a provider except state and clearRegistration.
| Method | Returns | Behaviour | Errors |
|---|---|---|---|
state | RegistrationState | Current step: Idle, OtpRequested(phone), OtpVerified(phone). Memory only; process death resets it. Android: not suspend. iOS: async getter | — |
checkPhone(phone, provider) | Availability | Whether the number is free. Does not start an OTP session | VALIDATION, NETWORK, UNAUTHORIZED, SERVER, INVALID_RESPONSE |
requestOtp(phone, provider) | — | Sends an SMS OTP and stores the phone in memory. Replaces any previous session | VALIDATION, NETWORK, UNAUTHORIZED, OTP_COOLDOWN, SERVER, INVALID_RESPONSE |
resendOtp(provider) | — | Sends another OTP for the stored phone. Clears a previously verified code | REGISTRATION_STATE, NETWORK, UNAUTHORIZED, OTP_COOLDOWN, SERVER, INVALID_RESPONSE |
verifyOtp(code, provider) | — | Confirms a 6-digit code and stores it for createUser | VALIDATION, REGISTRATION_STATE, NETWORK, UNAUTHORIZED, OTP_INVALID, SERVER, INVALID_RESPONSE |
checkEmail(email, provider) | Availability | Email must be non-blank. Does not change the OTP session | VALIDATION, NETWORK, UNAUTHORIZED, SERVER, INVALID_RESPONSE |
checkUsername(username, provider) | Availability | Username must be non-blank. Does not change the OTP session | VALIDATION, NETWORK, UNAUTHORIZED, SERVER, INVALID_RESPONSE |
createUser(request, provider) | CreateUserResult | Creates the consumer. Requires a requested and verified OTP. Attaches device name and a local serial number. Address required unless appType is NATIVE_WOLLETTE. Clears the session on success | VALIDATION, REGISTRATION_STATE, NETWORK, UNAUTHORIZED, SERVER, INVALID_RESPONSE |
clearRegistration() | — | Drops the in-memory session. No API call. Does not throw | — |
Onboarding.createUser
| Contract | Behaviour |
|---|---|
| Before calling | Request and verify the phone OTP on the same SDK instance |
| Request | CreateUserRequest; use approved terms, gender, locale and address-area IDs |
| Address | Required for THIRD_PARTY; only NATIVE_WOLLETTE may omit it; a supplied address is validated |
| Returns | Consumer id and fullyRegistered; neither creates a sign-in session nor confirms wallet activation |
| Success side effect | Clears the in-memory registration session |
| Lost response | Determine whether the consumer exists through the approved onboarding/support process before submitting again |
| Continue | Sign in, then activate |
The SDK does not provide reference-data lookup methods. Your host obtains valid IDs through the core reference-data reads for the approved environment; variables such as termsId are app inputs, not literal test values.
WalletOnboarding
interface WalletOnboarding {
suspend fun pendingProgress(provider: ApiContextProvider): WalletOnboardingProgress?
suspend fun resumePendingRegistration(activity: Activity, provider: ApiContextProvider): WalletOnboardingProgress
suspend fun resumePendingRegistration(webView: WalletOnboardingWebView, provider: ApiContextProvider): WalletOnboardingProgress
suspend fun addAccount(activity: Activity, provider: ApiContextProvider): WalletOnboardingProgress
suspend fun addAccount(webView: WalletAccountLinkingWebView, provider: ApiContextProvider): WalletOnboardingProgress
suspend fun progress(provider: ApiContextProvider): WalletOnboardingProgress
suspend fun registrationStatus(provider: ApiContextProvider): WalletGriffinState
suspend fun start(activity: Activity, provider: ApiContextProvider): WalletOnboardingProgress
suspend fun start(webView: WalletOnboardingWebView, provider: ApiContextProvider): WalletOnboardingProgress
suspend fun resumeRegistration(activity: Activity, provider: ApiContextProvider): WalletOnboardingProgress
suspend fun resumeRegistration(webView: WalletOnboardingWebView, provider: ApiContextProvider): WalletOnboardingProgress
}protocol WalletOnboarding: Sendable {
func pendingProgress(provider: any ApiContextProvider) async throws -> WalletOnboardingProgress?
func resumePendingRegistration(webView: any WalletOnboardingWebView, provider: any ApiContextProvider) async throws -> WalletOnboardingProgress
func addAccount(webView: any WalletAccountLinkingWebView, provider: any ApiContextProvider) async throws -> WalletOnboardingProgress
func progress(provider: any ApiContextProvider) async throws -> WalletOnboardingProgress
func registrationStatus(provider: any ApiContextProvider) async throws -> WalletGriffinState
func start(webView: any WalletOnboardingWebView, provider: any ApiContextProvider) async throws -> WalletOnboardingProgress
func resumeRegistration(webView: any WalletOnboardingWebView, provider: any ApiContextProvider) async throws -> WalletOnboardingProgress
}
// SDK-owned presentation lives on WolletteSDK:
// startWalletOnboarding, resumeWalletRegistration, addWalletAccount,
// and resumePendingWalletRegistration (each takes presenting:provider:)| Method | Behaviour |
|---|---|
pendingProgress | Checks server state for the saved AIS target. Returns null/nil and clears a completed or invalid record; null/nil does not prove general activation is complete |
resumePendingRegistration | Continues the saved target without new AIS. With no saved record, returns Complete without starting a flow. Check general progress separately |
addAccount | Starts new AIS authorisation, requires the new consent ID from the trusted callback, and continues for that target. An existing-account match can return Complete; refresh the linked-account list |
progress | Reads general AIS, latest Griffin registration, PIS and account state. Check pending recovery first; an older active account can already satisfy general progress |
registrationStatus | Reads the latest Griffin registration regardless of AIS or PIS state. No registration: mode START, null id and status. Accepted: mode ACCEPTED |
start | Chooses the first incomplete step, opens its form, confirms with the API after the callback, creates the BaaS account before PIS if needed, continues through confirmed Griffin states in the same call. Returns Complete, Needs(step) or Griffin(state) |
resumeRegistration | Same state machine as start, intended for continuation after a restart, a saved draft or a pending result |
All wallet-onboarding operations require a session and provider. Methods that open forms also require access to the fixed development form origin. Custom addAccount presentation requires WalletAccountLinkingWebView. See Custom WebView adapter. A callback that leaves server state unchanged for about 30 seconds returns Needs or Griffin. Closing the SDK-owned WebView throws CANCELLED; a failed message throws ONBOARDING_FAILED; a Griffin saved message closes the SDK-owned form, reads progress once and returns that progress without polling or opening the next form. The result can be Needs, Griffin with the current server-derived mode, or Complete. The public custom-adapter interface does not expose the built-in draft-saved signal; see adapter limits. Concurrent start calls on one instance are serialised. Android: the SDK-owned path throws VALIDATION if the device WebView lacks document-start script injection or the web message listener.
Wallet (sdk.wollette)
| Method | Returns | Behaviour | Errors |
|---|---|---|---|
retrieve(provider) | WalletAccount | First BaaS account from the API. Empty list throws WALLET_NOT_READY. A returned account does not prove PIS is complete. Safe to retry | UNAUTHORIZED, NETWORK, SERVER, INVALID_RESPONSE, WALLET_NOT_READY, STORAGE |
linkedAccounts(provider) | List<LinkedAccount> | Linked CURRENT bank accounts from AIS consents. Empty list is valid. Safe to retry | UNAUTHORIZED, NETWORK, SERVER, INVALID_RESPONSE, STORAGE |
topUp(accountId, amount, provider) | WalletTransfer | Bank account → wallet. Requires a completed PIS consent for the account. Your app opens the returned authorizationUrl when present | VALIDATION, UNAUTHORIZED, NETWORK, SERVER, INVALID_RESPONSE, STORAGE |
payOut(accountId, amount, provider) | WalletTransfer | Wallet → bank account. Requires account number and sort code | VALIDATION, UNAUTHORIZED, NETWORK, SERVER, INVALID_RESPONSE, WALLET_NOT_READY, STORAGE |
reconcileTopUp(paymentId, provider) | TopUpStatus | One reconciliation request for a top-up. Safe to retry | Shared request errors: VALIDATION, UNAUTHORIZED, NETWORK, SERVER, INVALID_RESPONSE, STORAGE |
awaitTopUpCompletion(paymentId, provider) | TopUpStatus | Reconciles every 2 seconds until succeeded, declined or expired. After 180 seconds throws retryable SERVER. Fresh proof per poll | Errors from reconciliation; retryable SERVER on timeout; task/coroutine cancellation can propagate |
updateBalanceControlSettings(settings, provider) | — | Replaces auto top-up and minimum balance together. Null minimum clears it. Resolves the wallet first | VALIDATION, UNAUTHORIZED, NETWORK, SERVER, INVALID_RESPONSE, WALLET_NOT_READY, STORAGE, DEVICE_COMPROMISED |
transactions | WalletTransactions | Transaction history service | — |
Reconciliation uses the shared authenticated request/error path. Invalid proofs and session replacement can produce VALIDATION; response decoding can produce INVALID_RESPONSE. Protected calls can also produce DEVICE_COMPROMISED. Use kind and retryable rather than treating an error table as an exhaustive list of host-provider or cancellation errors.
Wallet.retrieve
Read the current consumer's first BaaS wallet account.
suspend fun retrieve(provider: ApiContextProvider): WalletAccountfunc retrieve(provider: any ApiContextProvider) async throws -> WalletAccount| Contract | Behaviour |
|---|---|
| Required input | Fresh developer proof from provider, plus an active consumer session |
| Device/activation prerequisites | No FCM/device-association requirement for this read. A returned account is not proof of completed activation |
| Returned value | WalletAccount; response fields, including balance, can be absent |
| Empty account list | WALLET_NOT_READY / .walletNotReady |
| Side effects | Authenticated GET and SDK-owned token refresh where applicable; no activation or payment initiation |
| Retry | Read is marked safe; use retryable for eligible network/429/5xx failures. Host-owned sessions require host renewal |
| Other failures | Developer-proof/session validation, storage, decoding, device-integrity and transport failures; native cancellation and provider errors can propagate |
The Consumer starter apps call this after hosted login. See wallet reads for linked accounts, pagination and optional money fields.
Wallet.topUp
| Contract | Behaviour |
|---|---|
accountId | The linked bank account's LinkedAccount.id, not the BaaS WalletAccount.id |
| Other inputs | Active consumer session, provider and positive finite amount; money policy still needs backend confirmation |
| Account state | Matching completed PIS consent |
| Returns | WalletTransfer.id, optional status and optional authorizationUrl |
| Host action | Save the returned ID and open any authorisation URL in the system browser |
| Confirm result | reconcileTopUp for one check, or awaitTopUpCompletion for polling |
| Retry boundary | Do not automatically repeat initiation; a lost response can leave an uncertain transfer |
| Insufficient funds | The specific PIS HTTP 401 rejection is non-retryable VALIDATION, not UNAUTHORIZED; see error handling |
Wallet.payOut
| Contract | Behaviour |
|---|---|
accountId | The selected linked bank account's ID |
| Other inputs | Active consumer session, provider and positive finite amount |
| Account details | Account number and sort code must be available |
| Returns | WalletTransfer; its presence alone does not establish settlement |
| Host action | Record returned identity/status and use the approved backend outcome/reconciliation process |
| Retry boundary | Do not automatically repeat initiation; reconcileTopUp is not a pay-out status method |
The transfer guide shows both calls. Required units, rounding/precision and accepted currencies belong to the confirmed backend contract.
WalletTransactions.list
suspend fun list(from: Date, to: Date, startingAfter: String? = null, provider: ApiContextProvider): TransactionPagefunc list(from: Date, to: Date, startingAfter: String?, provider: any ApiContextProvider) async throws -> TransactionPage
func list(from: Date, to: Date, provider: any ApiContextProvider) async throws -> TransactionPage // first pageOne page of wallet transactions. from and to are inclusive. VALIDATION if from is after to or startingAfter is not a non-negative integer. Safe to retry. Resolving an empty wallet-account list throws WALLET_NOT_READY. Errors: VALIDATION, UNAUTHORIZED, NETWORK, SERVER, INVALID_RESPONSE, WALLET_NOT_READY, STORAGE.
Profile (sdk.profile)
| Method | Returns | Behaviour | Errors |
|---|---|---|---|
retrieve(provider) | UserProfile | Consumer and account details. Safe to retry | UNAUTHORIZED, NETWORK, SERVER, INVALID_RESPONSE, STORAGE, DEVICE_COMPROMISED |
update(changes, provider) | — | Reads the current consumer, preserves version and unedited fields, sends a full update. Empty change set or blank string is VALIDATION. Not safe to auto-retry | VALIDATION, UNAUTHORIZED, NETWORK, SERVER, INVALID_RESPONSE, STORAGE, DEVICE_COMPROMISED |
changePassword(oldPassword, newPassword, otp, provider) | — | Verifies the 6-digit OTP, then submits the change. Success invalidates the session (Android also clears payment keys and NFC) | VALIDATION, OTP_INVALID, UNAUTHORIZED, NETWORK, SERVER, INVALID_RESPONSE, STORAGE, DEVICE_COMPROMISED |
Profile.update
Supply at least one allowed field in ProfileChanges. Omitted/null fields mean unchanged. The SDK reads the current consumer and version, preserves other fields and sends a full update. It is not safe to automatically repeat a mutation after a lost response; re-read the profile before deciding what remains to change. See profile settings.
Profile.changePassword
Supply non-blank old/new passwords and the required six-digit OTP. The SDK verifies that OTP and submits the change. Success invalidates the session; Android also clears payment keys and NFC. The OTP request/acquisition contract still needs Wollette confirmation. Handle the documented password-change flow and subsequent sign-in explicitly.
Payments (sdk.payments)
| Method | Platform | Behaviour |
|---|---|---|
pay(accountId, provider) | Android | Prepares tap to pay for a linked account: device association, payment keys, arms the HCE service. Requires session, HCE, NFC on, completed PIS consent, and an FCM token (or an existing association). VALIDATION otherwise. Errors: VALIDATION, UNAUTHORIZED, NETWORK, SERVER, INVALID_RESPONSE, STORAGE |
pay(accountId:provider:) | iOS | Throws .validation. No HCE on iOS |
stop() | Android | Disarms immediately, invalidates in-flight pay calls, does not throw or wait |
stop() | iOS | No-op |
LoginRedirectActivity (Android)
Library activity that completes login. Merge an exported intent filter into your app manifest. tools:replace overrides the library's exported=false; the app callback, SDK URI and hosted-login registration must match:
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools">
<application>
<activity android:name="com.wollette.LoginRedirectActivity"
android:exported="true" tools:replace="android:exported">
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />
<data android:scheme="myapp" android:host="wollette-callback" />
</intent-filter>
</activity>
</application>
</manifest>Consumer Bluetooth (iOS)
Retain AppleBlePaymentClient for the foreground payment screen:
func exchange(
accountId: String,
profile: BleGattProfile,
provider: any ConsumerBlePayloadProvider,
minimumRSSI: Int = -65,
discoveryMillis: Int = 2_000,
timeoutMillis: Int = 40_000,
onStage: @escaping @Sendable (BleTransferStage) -> Void = { _ in }
) async throws
func stop() asyncexchange returns Void: success means transferred, not authorised. It allows one active exchange per client. stop cancels and waits for its current task. The legacy payments.stop() is unrelated.
Construct BackendConsumerBlePayloadProvider(preparation: sdk.consumerPayments, provider: provider) and use .wollettePaymentV1. The concrete provider resolves the trusted POS key, prepares the payer and encrypts the envelope. Ordinary missing/expired/unbound account keys are provisioned once within the same exchange. Unknown mutations require explicit recovery; an expired device key requires separate maintenance.
Consumer payer preparation (iOS)
Obtain the preparation actor from sdk.consumerPayments; it has no public initializer.
func payer(
accountId: String,
provider: any ApiContextProvider
) async throws -> ConsumerPaymentPayer
func replaceAccountKey(
accountId: String,
provider: any ApiContextProvider,
recoverUnknownOutcome: Bool = false
) async throws -> ConsumerPaymentKeyInfopayer requires the current device/account association, matching completed PIS consent and a bound account key. It does not create/rotate that key. Keep the returned inner payer native and out of logs.
replaceAccountKey replaces server key material. A pending marker survives unknown response, cancellation or storage failure. recoverUnknownOutcome: true explicitly authorises another replacement, not retrieval of the lost key. This mutation disables automatic HTTP 401 refresh/replay; that does not change the ordinary policy for other consumer reads.
Types, validation and error families are described under Types, Validation and Errors. The consumer payment guide shows the screen lifecycle.