Top up and pay out
Guides

Top up and pay out

Move money between a linked bank account and the wallet. Both calls require a session and developer proof. The SDK returns transfer data; your app opens any returned authorisation URL. Confirm an uncertain outcome before submitting again.

Top up

Moves money from a linked bank account into the wallet. Requires a completed PIS consent for that account.

val transfer = sdk.wollette.topUp(
    accountId = linkedAccount.id,
    amount = MonetaryAmount(value = 25.0, currencyCode = "GBP"),
    provider = provider,
)
transfer.authorizationUrl?.let { openInBrowser(it) }
  • VALIDATION if the amount is not positive, the account is unknown, or PIS is not ready for that account.
  • Returns WalletTransfer with id, status and an optional authorizationUrl. When present, open it in the system browser so the consumer can authorise the payment.

Insufficient funds

If POST psd/pis/payments returns HTTP 401 with the exact JSON message Insufficient funds, the SDK throws VALIDATION / .validation with statusCode=401 and retryable=false. It does not refresh the session or repeat the request. Show the safe public message and let the consumer make an explicit new choice. Do not route this business rejection to sign-in. Branch on the SDK kind; an HTTP status alone is not enough.

Other 401 responses follow the normal authentication rules. For a lost response or uncertain outcome, use reconciliation before deciding whether another initiation is safe.

Confirm the top-up

A top-up may be pending after the call returns. Reconcile it by the returned transfer/payment ID. These reconciliation methods are for top-ups; they do not confirm a pay-out or a contactless purchase.

One check:

val status = sdk.wollette.reconcileTopUp(transfer.id, provider)

Wait for a terminal state:

val status = sdk.wollette.awaitTopUpCompletion(transfer.id, provider)
when (status.state) {
    TopUpState.SUCCEEDED -> refreshWallet()
    TopUpState.DECLINED -> showDeclined()
    TopUpState.EXPIRED -> showExpired()
    TopUpState.PENDING -> showStillPending()
}

awaitTopUpCompletion calls reconcileTopUp every two seconds, each with a fresh developer proof, and returns on success, decline or expiry. After 180 seconds it throws a retryable SERVER error; call it again or fall back to a single reconcile. reconcileTopUp itself is safe to retry.

State mapping from the API: COMPLETED → succeeded; DECLINED or FAILED → declined; EXPIRED → expired; anything else → pending.

Pay out

Moves money from the wallet to a linked bank account. Requires the account to have an account number and sort code.

val transfer = sdk.wollette.payOut(
    accountId = linkedAccount.id,
    amount = MonetaryAmount(value = 10.0, currencyCode = "GBP"),
    provider = provider,
)

VALIDATION if the amount is not positive or the account details are missing. A returned transfer is not a guarantee that money has settled; show the returned status and confirm the outcome before repeating the payment.

Amount rules

value must be present, finite and greater than zero. accountId must be non-blank. Use the approved currency code; local transfer mapping trims optional code/symbol strings but does not enforce the POS three-letter regex. Confirm units, precision, rounding and accepted currencies with Wollette; see Money values.

Use the confirmed backend model as context for money values. Core rounds that model to two decimal places with HALF_UP; approved transfer units, currencies and provider conversion rules still come from the account contract. Do not apply a multiplication by 100 by assumption.