6. The result and error codes

The cashier calls onResult once, with a CashierResult. It carries only operational values: never card data, customer data or error text.

FieldMeaning
statuscompleted, authorized, pending, failed or canceled (table below)
closedBycustomer: the close button or a button under the result. code: your app called close(). sdk: the SDK ended the session itself, for example the automatic return after the result
errorCodeWhy the payment did not complete. Set when the status is failed
transactionIDThe Praxis transaction ID, when a transaction exists. Use it to find the payment on your server
traceIDThe Praxis trace ID, for support requests
amount, currencyThe amount the transaction recorded, in major units, and its ISO 4217 code. Nil without a transaction
paymentMethodThe key of the payment method that paid, for example "Credit Card"
intentdeposit or withdrawal. Nil when the cashier closed before the session was read
withdrawalStatusThe Praxis status of a withdrawal (section 13). Nil for a deposit
orderIDYour order id of the session, as your server sent it to Praxis
cardBrandThe card brand name of the transaction, for example "Visa". Never a card number or any part of one
StatusMeaningWhat your app does
completedThe payment was approvedShow success; credit the customer from the server notification
authorizedThe card was authorized and not charged yet (for example a zero-amount authorization)As completed, for an authorization
pendingThe payment is still processing, or a withdrawal request was accepted and waits to be paid outTell the customer it is in progress; the final status reaches your server later
failedThe payment did not go throughRead errorCode and show your own message
canceledThe customer closed the cashier before payingNothing was sent

The statuses, the closed-by values and the error codes are structs with static values, not enums, so new values never break your code. Always keep a default branch.

Error codes

Errors are codes, not text. Your app maps each code to its own message, in its own language.

func message(for code: CashierErrorCode?) -> LocalizedStringResource {
    switch code {
    case .declined: "Your bank declined the payment. Try another card."
    case .cardInvalid: "Check the card details and try again."
    case .network: "Check your connection. If you were charged, the payment will appear shortly."
    case .sessionExpired: "This payment session expired. Please start again."
    default: "The payment did not go through. Please try again."
    }
}
CodeRaw valueMoney taken?What your app can do
.declineddeclinedNoAsk for another card
.cardInvalidcard_invalidNoAsk the customer to check the card. A card typed in the cashier that can be corrected stays on the card form and reports nothing; this code comes from a saved payout card
.cardNotAcceptedcard_not_acceptedNoTry again later
.networknetworkMaybeCheck the final status on your server
.sessionExpiredsession_expiredNoCreate a new session
.serverErrorserver_errorMaybeCheck the final status on your server
.validationFailedvalidation_failedNoCheck the amount and the session settings; a withdrawal's preset amount must not be above the balance
.noPaymentMethodno_payment_methodNoNo payment method is available for this session and currency
.unexpectedResponseunexpected_responseMaybeCheck the final status; update the SDK
.unknownunknownMaybeCheck the final status on your server
.sessionUnavailablesession_unavailableNoThe cashier could not read the session when it opened. Create a new session
.invalidTokeninvalid_tokenNoThe token was empty; nothing was sent. Pass the token your server got
.transactionCanceledtransaction_canceledNoThe payment was cancelled. The customer may pay again
.paymentMethodUnavailablepayment_method_unavailableNoThe selected method could not be shown (an unknown method type, or its options could not load). Nothing was sent. On a withdrawal it also ends the error page of a card withdrawal with no saved card, or of a method with no payout account
.walletUnavailablewallet_unavailableNoApple Pay gave no token, or the wallet payment cannot be sent. Nothing was sent. Offer the card instead
.configurationErrorconfiguration_errorNoThe session was made for the web cashier (create it with channel: ios_sdk), a method needs an SDK this cashier does not have, or your method filter kept no method or failed
.unsupportedSessionTypeunsupported_session_typeNoNever sent. It exists so your switch statements compile
.contactEncryptionUnavailablecontact_encryption_unavailableNoNever sent. It exists so your switch statements compile
  • Each code has a category your app can switch on instead of single codes: session, network, server, validation, configuration and payment.
  • Codes are stable: a released code never changes its meaning. New codes can be added.
  • When the cashier cannot open (an empty token or a session it cannot read), it shows an error screen and, once closed, ends with failed and the code of that screen.
📘

Note

Log errorCode.rawValue and traceID with every failed result. Praxis support finds the payment from the trace ID.

🚧

Important

For every code marked "Maybe", money may have moved. Do not tell the customer the payment failed for good: check the final status on your server.


Did this page help you?