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.
| Field | Meaning |
|---|---|
| status | completed, authorized, pending, failed or canceled (table below) |
| closedBy | customer: 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 |
| errorCode | Why the payment did not complete. Set when the status is failed |
| transactionID | The Praxis transaction ID, when a transaction exists. Use it to find the payment on your server |
| traceID | The Praxis trace ID, for support requests |
| amount, currency | The amount the transaction recorded, in major units, and its ISO 4217 code. Nil without a transaction |
| paymentMethod | The key of the payment method that paid, for example "Credit Card" |
| intent | deposit or withdrawal. Nil when the cashier closed before the session was read |
| withdrawalStatus | The Praxis status of a withdrawal (section 13). Nil for a deposit |
| orderID | Your order id of the session, as your server sent it to Praxis |
| cardBrand | The card brand name of the transaction, for example "Visa". Never a card number or any part of one |
| Status | Meaning | What your app does |
|---|---|---|
| completed | The payment was approved | Show success; credit the customer from the server notification |
| authorized | The card was authorized and not charged yet (for example a zero-amount authorization) | As completed, for an authorization |
| pending | The payment is still processing, or a withdrawal request was accepted and waits to be paid out | Tell the customer it is in progress; the final status reaches your server later |
| failed | The payment did not go through | Read errorCode and show your own message |
| canceled | The customer closed the cashier before paying | Nothing 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."
}
}| Code | Raw value | Money taken? | What your app can do |
|---|---|---|---|
| .declined | declined | No | Ask for another card |
| .cardInvalid | card_invalid | No | Ask 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 |
| .cardNotAccepted | card_not_accepted | No | Try again later |
| .network | network | Maybe | Check the final status on your server |
| .sessionExpired | session_expired | No | Create a new session |
| .serverError | server_error | Maybe | Check the final status on your server |
| .validationFailed | validation_failed | No | Check the amount and the session settings; a withdrawal's preset amount must not be above the balance |
| .noPaymentMethod | no_payment_method | No | No payment method is available for this session and currency |
| .unexpectedResponse | unexpected_response | Maybe | Check the final status; update the SDK |
| .unknown | unknown | Maybe | Check the final status on your server |
| .sessionUnavailable | session_unavailable | No | The cashier could not read the session when it opened. Create a new session |
| .invalidToken | invalid_token | No | The token was empty; nothing was sent. Pass the token your server got |
| .transactionCanceled | transaction_canceled | No | The payment was cancelled. The customer may pay again |
| .paymentMethodUnavailable | payment_method_unavailable | No | The 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 |
| .walletUnavailable | wallet_unavailable | No | Apple Pay gave no token, or the wallet payment cannot be sent. Nothing was sent. Offer the card instead |
| .configurationError | configuration_error | No | The 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 |
| .unsupportedSessionType | unsupported_session_type | No | Never sent. It exists so your switch statements compile |
| .contactEncryptionUnavailable | contact_encryption_unavailable | No | Never 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.
Updated about 8 hours ago
Did this page help you?