Configuration & Customization
Configuration, theme, texts, slots, events, hooks and the payment handler.
This page covers everything you can change in the Cashier: configuration options and features (§1), settings, theme, texts and slots (§2), events and hooks (§3), and the payment handler (§4).
1. Configuration
1.1 CashierConfiguration
CashierConfigurationPass a CashierConfiguration when you show the Cashier. Every Cashier setting of the app is set here, in code: the look, the header, the amount and quick amounts, how payment methods show, promotions, billing fields, the result screen and the footer links.
The SDK does not read the Cashier settings you made for your web Cashier in the Praxis Backoffice (Theme Editor). So your app can look and behave differently from your web Cashier, and it changes only when you release a new app version.
Every option has a default, so CashierConfiguration() gives a working Cashier.
let configuration = CashierConfiguration(
theme: CashierTheme(brandColorLight: "#006FFF", buttonShape: .pill),
header: CashierHeaderOptions(balance: .hidden),
amount: CashierAmountOptions(
quickAmounts: CashierQuickAmounts(lists: [
.init(amounts: [.amount(20), .amount(50), .amount(100)], currency: "EUR")
])
),
promotions: CashierPromotionOptions(style: .codeField),
texts: CashierTexts(depositButton: "Top up")
)
CashierView(token: token, environment: cashierEnvironment, configuration: configuration) { result in
handle(result)
}CashierConfiguration has 15 options:
| Option | What it sets | Section |
|---|---|---|
features | Which parts of the Cashier are on | §2.2 |
header | Balance, Deposit / Withdraw tabs, back and close buttons | §2.3.1 |
amount | Currency format, currency mode, quick amounts | §2.3.2 |
paymentMethods | Method order, limits, fees, saved card expiry, removal, field prefill | §2.3.3 |
card | Cardholder name prefill and lock | §2.3.4 |
promotions | Bonus list or promotion code field | §2.3.5 |
billingFields | Editable, read-only or hidden, per billing field | §2.3.6 |
result | The details on the result screen | §2.3.7 |
footer | Support and policy links | §2.3.8 |
returnsAfterResult | Your app shows the result instead of the Cashier | §2.3.9 |
presetAmountEditable | The customer can change an amount the session came with | §2.3.10 |
theme | Colors, font, button shape, appearance, field labels | §2.5 |
texts | Any text, and the main button text | §2.8 |
hooks | Events, live amount, method filter, field rules | §3 |
paymentHandler | Your code before the payment is sent to Praxis | §4 |
Each one, with its format and default, is also listed in the SDK Reference.
1.2 Features
CashierFeatures turns parts of the Cashier on or off. The SDK fetches data only for features that are on: a feature that is off costs no network request and shows nothing. Your payment setup at Praxis still decides what shows when a feature is on, for example the methods and their limits.
What each feature does when it is on or off is listed in §2.2. Quick amounts and promotions are not features: they are on when you set them up in amount (§2.3.2) and promotions (§2.3.5).
.default is the recommended set. Start from .default and remove the features you do not want, as below.
// Fixed amount: the amount cannot change and no limits are fetched
let configuration = CashierConfiguration(
features: CashierFeatures.default.subtracting([.editableAmount, .amountLimits]))1.3 While a payment runs
From the moment the customer pays until the result shows, the Cashier hides its close button and refuses a swipe down, so one tap cannot abandon the payment. This applies to .cashierSheet, CashierViewController, and a sheet you present yourself around CashierView.
While the payment processes, the Cashier keeps asking Praxis for its status until the session expires; it then ends with .pending. If your app needs an earlier way out, dismiss the Cashier, or call close() on a CashierSession you hold. The result is then .pending, because the payment may still complete. Check its final status on your server.
1.4 Provider and 3-D Secure pages
3-D Secure challenges and payment provider pages open inside the Cashier, in a web view the SDK owns, and return to the Cashier on their own. There is nothing to configure in the app; your server sets the app_return_url when it creates the session, and your app registers it to bring the customer back from bank apps. See 3-D Secure and provider pages.
1.5 Holding the session yourself
CashierView(token:environment:...) makes and closes its own session. To read the Cashier state from elsewhere in your app, or to drive it from your own controls, create a CashierSession and pass it in. Your app then closes it.
let session = CashierSession(token: token, environment: cashierEnvironment,
configuration: configuration) { result in handle(result) }
CashierView(session: session) // the ready-made cashier
// CashierViewController(session: session) // UIKit
// Elsewhere
let snapshot = session.snapshot // read-only state, see SDK reference
session.close() // ends with .canceled, or .pending while a payment runsCashierSession is @Observable: SwiftUI views that read snapshot redraw when it changes. A closed session cannot start again; create a new one with a new token.
2. Customization
2.1 Overview
Everything you can customize is set in code, in one place: the CashierConfiguration you pass when you show the Cashier, plus slots on the predefined template. Nothing is customized by subclassing or registering types.
| Area | What you can change | Set with | Section |
|---|---|---|---|
| Features | Which parts of the Cashier are on | CashierConfiguration.features | §2.2 |
| Header | Balance, Deposit / Withdraw tabs, back and close buttons | CashierConfiguration.header (CashierHeaderOptions) | §2.3.1 |
| Amount | Currency format, currency mode, quick amount buttons | CashierConfiguration.amount (CashierAmountOptions) | §2.3.2 |
| Payment methods | Last used method first, limits, fees, saved card expiry, removal, field prefill | CashierConfiguration.paymentMethods (CashierPaymentMethodOptions) | §2.3.3 |
| Card | Cardholder name prefill and lock | CashierConfiguration.card (CashierCardOptions) | §2.3.4 |
| Promotions | Bonus list or promotion code field | CashierConfiguration.promotions (CashierPromotionOptions) | §2.3.5 |
| Billing fields | Editable, read-only or hidden, per field | CashierConfiguration.billingFields (CashierBillingFields) | §2.3.6 |
| Result screen | Which payment details show | CashierConfiguration.result (CashierResultOptions) | §2.3.7 |
| Footer | Support and policy links | CashierConfiguration.footer (CashierFooterLinks) | §2.3.8 |
| Return after the result | Your app shows the result | CashierConfiguration.returnsAfterResult | §2.3.9 |
| Editable session amount | The customer can change an amount the session came with | CashierConfiguration.presetAmountEditable | §2.3.10 |
| Slots | Your header and footer, hidden blocks, your views between blocks | .cashierHeader, .cashierFooter, .cashierHide, .cashierInsert; CashierSlots in UIKit | §2.4 |
| Theme | Brand colors, text color on brand, font, button shape, corner radius, appearance, field labels | CashierConfiguration.theme (CashierTheme) | §2.5 |
| Color roles | Any of 42 colors the Cashier draws with | CashierTheme.roleColors | §2.6 |
| Your views in the theme | Colors, spacing, fonts and radius for your own views | cashierResolvedTheme, .cashierFont(_:) | §2.7 |
| Texts | Any text, for every language or per language; the deposit and withdrawal button text | CashierConfiguration.texts (CashierTexts) | §2.8 |
| Fields and methods | Extra field checks, hidden or required fields, default values, method order | CashierConfiguration.hooks (CashierHooks) | §2.9 |
| Payment | Your code before the Praxis submit | CashierConfiguration.paymentHandler | §2.10 |
| Layout | The order of blocks, one page or several | Your own layout | Layouts & Examples |
All of them combine in one configuration:
let configuration = CashierConfiguration(
theme: CashierTheme(
brandColorLight: "#0F768A",
brandColorDark: "#3FB6CC",
fontName: "Lora",
buttonShape: .pill,
appearance: .system,
fieldLabelStyle: .floatingLabel,
roleColors: [.screenBackground: Color("AppBackground")]
),
header: CashierHeaderOptions(balance: .allPages, showsBackButton: true),
amount: CashierAmountOptions(
currencyFormat: .symbol,
quickAmounts: CashierQuickAmounts(lists: [
.init(amounts: [.amount(20), .amount(50), .amount(100), .maximum],
currency: "EUR", startingAmount: 50)
])
),
paymentMethods: CashierPaymentMethodOptions(lastUsedFirst: true, fees: .ifNotZero, allowsRemoval: true),
card: CashierCardOptions(prefillsCardholderName: true, locksCardholderName: true),
promotions: CashierPromotionOptions(style: .bonusList),
billingFields: CashierBillingFields(country: .readOnly, phone: .hidden),
result: CashierResultOptions(showsDate: true, showsTotal: true, showsPaymentInstrument: true),
footer: CashierFooterLinks(
supportEmail: "[email protected]",
termsOfService: URL(string: "https://merchant.example/terms")
),
texts: CashierTexts([.agree_with_terms_of_service: "I accept the terms"], depositButton: "Deposit now"),
hooks: CashierHooks(fieldRules: [CashierFieldRule(field: "zip", minimumLength: 4)])
)
CashierView(token: token, environment: cashierEnvironment, configuration: configuration, onResult: handle) {
Cashier.AmountFirstLayout()
.cashierHeader { BrandHeader() }
}Every value has a default, listed with it. The defaults are the same as the web Cashier's defaults, with one exception: the close button shows by default. A value the SDK cannot use is ignored, its default applies, and the event configuration_value_ignored is sent once.
All customization follows one rule: card data and customer data never reach your app. See §2.11.
2.2 Features
CashierConfiguration.features (CashierFeatures, an option set). Default: .default, the recommended set. The SDK fetches data only for features that are on, and your payment setup at Praxis still decides what shows.
| Feature | When on | When off |
|---|---|---|
.editableAmount | The customer can enter or change the amount when the session has none. A session amount stays fixed unless presetAmountEditable is true (§2.3.10). | The session amount shows as fixed text. |
.amountLimits | The method limits for the currency are fetched and enforced; amounts outside them are blocked. | No limits are fetched; Praxis checks the amount when the customer pays. |
.currencyChange | The customer can change the payment currency. | The currency stays the starting currency. |
.savedInstruments | Saved cards and saved accounts. The customer can remove them when paymentMethods.allowsRemoval is true. | Saved rows are hidden and nothing can be removed. |
.applePay | Apple Pay, as its own method and as the switch in the card method. It shows only when Praxis sends Apple Pay settings for the session, the device can pay, and your app's Apple Pay capability lists that merchant ID. | Apple Pay methods are left out and the card method shows no switch. |
let features = CashierFeatures.default.subtracting(.currencyChange)Quick amounts and promotions are switched on by their settings, not by a feature: see §2.3.2 and §2.3.5.
2.3 Settings
Each group below is one option of CashierConfiguration. Every parameter has a default, so set only the values you want to change:
CashierConfiguration(header: CashierHeaderOptions(balance: .hidden)) // everything else keeps its default2.3.1 Header
CashierConfiguration.header (CashierHeaderOptions). The header is the bar at the top of every page.
| Parameter | Description | Format | Required |
|---|---|---|---|
balance | Where the customer's balance shows: .hidden (never), .mainPages (on the amount page only) or .allPages (on every page with the header, except the result screens). Default: .mainPages. | CashierHeaderOptions.Visibility | No |
paymentType | Where the Deposit / Withdraw tabs show, with the same values as balance. A session with one transaction type shows one tab that names it. A session that allows both shows both, and the customer can switch until they try to pay. Default: .mainPages. | CashierHeaderOptions.Visibility | No |
showsBackButton | true shows a back button on the first page. A tap sends the event cashier_back_button and the Cashier stays open, so your app can react, for example by closing it. Later pages always have a back button. Default: false. | Bool | No |
closeButton | .visible shows the close button; .hidden never shows it. While a payment runs, the close button is hidden whatever this value. Default: .visible. | CashierHeaderOptions.CloseButton | No |
The web Cashier hides the close button by default. The app shows it by default, because a full-screen Cashier needs a way out. If you hide it, give the customer another way out, for example a swipe down on.cashierSheet, your own navigation, or a close button in your own header slot (§2.4) that callsclose().
2.3.2 Amount and quick amounts
CashierConfiguration.amount (CashierAmountOptions).
| Parameter | Description | Format | Required |
|---|---|---|---|
currencyFormat | How amounts show the currency: .symbol (€10) or .isoCode (EUR 10). Default: .isoCode. | .symbol or .isoCode | No |
currencyMode | Which currency amounts show in: .paymentCurrency, the currency the customer pays in, or .baseCurrency, the base currency of the customer's account, with the payment currency hidden. Default: .paymentCurrency. | .paymentCurrency or .baseCurrency | No |
quickAmounts | The quick amount buttons under the amount. Default: no buttons. | CashierQuickAmounts | No |
Quick amounts. Quick amount buttons let the customer pick a common amount with one tap. Give one or more lists of buttons, or build the buttons from the customer's last deposit.
CashierQuickAmounts:
| Parameter | Description | Format | Required |
|---|---|---|---|
lists | Your button lists. The Cashier picks one list for the session, as described below. Default: []. | [CashierQuickAmounts.List] | No |
basedOnLastDeposit | true builds the buttons of a deposit from the customer's last deposit instead: up to five amounts, from the last deposit (at least 20) up to the method maximum. A customer with no previous deposit gets 20, 50, 100, 200 and 500, those up to the method maximum. No buttons show when the method has no maximum. When the last deposit is in another currency or below the method minimum, your lists apply instead. Default: false. | Bool | No |
CashierQuickAmounts.List:
| Parameter | Description | Format | Required |
|---|---|---|---|
amounts | The buttons, in order: .amount(_:) for a fixed amount, or .maximum for a Max button set to the method maximum. Amounts must not be negative. | [CashierQuickAmounts.Choice] | Yes |
currency | The currency the list is for, as an ISO 4217 code. nil means any currency. Default: nil. | String? | No |
paymentMethod | The payment method the list is for, as the method key Praxis sends (the paymentMethod of CashierPaymentRequest). nil means any method. Default: nil. | String? | No |
intent | The transaction type the list is for: .deposit or .withdrawal. Default: .deposit. | CashierIntent | No |
startingAmount | The amount the Cashier starts with, used only when the session has no amount and the customer has no previous deposit. Only a list with no paymentMethod and a matching currency applies, because no method is selected yet when the Cashier opens. Must be 0 or more. Default: nil. | Decimal? | No |
Which list is used. For the session's transaction type, the Cashier takes the first list that matches, in this order:
- The list for the selected payment method and the currency.
- A list for any method, with the currency.
- A list for the selected method, with any currency.
A list with neither a method nor a currency is never used. Buttons outside the method limits are left out. When no list matches, no buttons show.
let quickAmounts = CashierQuickAmounts(lists: [
// Deposits in EUR: four buttons, starting at 50
.init(amounts: [.amount(20), .amount(50), .amount(100), .maximum], currency: "EUR", startingAmount: 50),
// Withdrawals in EUR
.init(amounts: [.amount(50), .amount(100), .amount(200)], currency: "EUR", intent: .withdrawal),
// Deposits in USD
.init(amounts: [.amount(25), .amount(50), .amount(100)], currency: "USD")
])
let configuration = CashierConfiguration(amount: CashierAmountOptions(quickAmounts: quickAmounts))
Quick amounts are off when you set no lists andbasedOnLastDepositisfalse, which is the default. No buttons show. The customer's last deposit still starts the amount when the session has none.Quick amount buttons do not show while the amount is locked: with a session amount (unless
presetAmountEditableistrue), or with.editableAmountoff. To hide the buttons in one layout only, use.cashierHide(.quickAmounts)(§2.4).
2.3.3 Payment methods
CashierConfiguration.paymentMethods (CashierPaymentMethodOptions). Which methods the customer can use is set at Praxis; these values decide how they show.
| Parameter | Description | Format | Required |
|---|---|---|---|
lastUsedFirst | true starts the method list with the method the customer used last. Default: false. | Bool | No |
showsLimits | true shows the minimum and maximum amount on each method row. This changes the text only; the .amountLimits feature decides whether limits are enforced. Default: true. | Bool | No |
fees | How method fees show: .always, .ifNotZero (only when the fee is more than zero) or .hidden. Default: .always. | CashierPaymentMethodOptions.FeeVisibility | No |
showsCardExpiry | true shows the expiry date of saved cards: on the selected method, in the method list (with expires MM/YY while the customer manages saved cards), in the retry list and in the wallet card list of a withdrawal. false shows no date; an expired card still shows expired. Default: false. | Bool | No |
allowsRemoval | true lets the customer remove a saved card or saved account. The Cashier always asks before it removes one. Needs the .savedInstruments feature. Default: false. | Bool | No |
prefillsFields | true fills method fields from the customer profile. false leaves them empty; a saved template or a default value from Praxis still fills them. Default: true. | Bool | No |
2.3.4 Card
CashierConfiguration.card (CashierCardOptions).
| Parameter | Description | Format | Required |
|---|---|---|---|
prefillsCardholderName | true fills the cardholder name with the customer's name from the session. Default: false. | Bool | No |
locksCardholderName | true stops the customer from changing the cardholder name. Use it with prefillsCardholderName: true; without a prefill the field stays empty and locked. It also locks the name field of the billing form. Default: false. | Bool | No |
2.3.5 Promotions
CashierConfiguration.promotions (CashierPromotionOptions). Which bonuses and promotion codes are valid is set at Praxis.
| Parameter | Description | Format | Required |
|---|---|---|---|
style | .bonusList shows the bonuses Praxis offers for the session, for the customer to pick from. .codeField shows a field where the customer types a promotion code. nil shows no promotion block. Default: nil. | CashierPromotionOptions.Style? | No |
Withstylenil, promotions are off completely: no bonus or code block shows, no bonus data is read, and no code is sent with the payment. To hide the block in one layout only, use.cashierHide(.promotions)(§2.4).
2.3.6 Billing fields
CashierConfiguration.billingFields (CashierBillingFields). The billing fields show when the payment method needs billing data. Each field takes one of three values:
.editable: the customer can fill in or change the field..readOnly: the field shows the value from the customer profile, and the customer cannot change it, unless the value has an error: the field then becomes editable so the customer can fix it..hidden: the field does not show.
| Parameter | Field | Default |
|---|---|---|
country | Country | .editable |
name | Customer name | .editable |
email | .editable | |
phone | Phone | .editable |
postalCode | Postal code | .editable |
state | State | .editable |
city | City | .editable |
address | Address | .editable |
let billingFields = CashierBillingFields(country: .readOnly, email: .readOnly, phone: .hidden)To add checks to a field or make it required, use CashierHooks (§2.9).
2.3.7 Result screen
CashierConfiguration.result (CashierResultOptions). The details the result screen shows after a payment.
| Parameter | Description | Format | Required |
|---|---|---|---|
showsDeclineReason | Shows why a payment was declined. Default: true. | Bool | No |
showsDate | Shows the date and time of the payment. Default: false. | Bool | No |
showsFee | Shows the fee. Default: false. | Bool | No |
showsTotal | Shows the total amount. Default: false. | Bool | No |
showsBonus | Shows the bonus the customer received. Default: false. | Bool | No |
showsPaymentInstrument | Shows the card or account used, masked. Default: false. | Bool | No |
showsBillingDescriptor | Shows the billing descriptor: the name the payment has on the customer's statement. Default: false. | Bool | No |
With returnsAfterResult true (§2.3.9), the result screen does not show, so these values have no effect.
2.3.8 Footer links
CashierConfiguration.footer (CashierFooterLinks). The footer under the first page shows your support contacts and policy links. It shows when at least one link is set.
| Parameter | Description | Format | Required |
|---|---|---|---|
supportWebsite | Your support page. Must be https. Default: nil (no link). | URL? | No |
supportEmail | Your support email address. Default: nil (no link). | String? | No |
supportPhone | Your support phone number, for example "+357 22 000000". Default: nil (no link). | String? | No |
privacyPolicy | Your privacy policy. Must be https. Default: nil (no link). | URL? | No |
termsOfService | Your terms of service. Must be https. Default: nil (no link). | URL? | No |
To show your own footer instead, use .cashierFooter { … } (§2.4).
2.3.9 Return after the result
| Parameter | Description | Format | Required |
|---|---|---|---|
returnsAfterResult | true ends the Cashier as soon as a payment result arrives that opens no provider page, and calls onResult with closedBy .sdk. The SDK's result, bank details, partial approval and pending screens are skipped, so you show your own. Default: false. | Bool | No |
2.3.10 Editable session amount
When your server creates the session with an amount, the Cashier shows that amount as fixed text. Set presetAmountEditable to let the customer change it.
| Parameter | Description | Format | Required |
|---|---|---|---|
presetAmountEditable | true shows the session amount prefilled and lets the customer change it, within the method limits when .amountLimits is on. false shows it as fixed text. Needs the .editableAmount feature. A zero-amount card authorization always stays fixed. Has no effect when the session has no amount. Default: false. | Bool | No |
let configuration = CashierConfiguration(presetAmountEditable: true)2.4 Slots
Slots change the predefined template without writing your own layout. They are methods of Cashier.AmountFirstLayout and Cashier.OnePageLayout: add them to the template and pass it as the last closure of CashierView or .cashierSheet. In UIKit, use CashierSlots (§2.4.4).
| Method | Parameters | Effect |
|---|---|---|
.cashierHeader { … } | Your view | Replaces the header on every page. |
.cashierFooter { … } | Your view | Replaces the footer under the first page. |
.cashierHide(_:) | HideableBlock | Hides a block. |
.cashierInsert(before:_:) | CashierAnchor, your view | Adds your view before a block. |
.cashierInsert(after:_:) | CashierAnchor, your view | Adds your view after a block. |
CashierView(token: token, environment: cashierEnvironment, onResult: handle) {
Cashier.AmountFirstLayout()
.cashierHeader { BrandHeader() }
.cashierFooter { Text("Payments are processed by Praxis").cashierFont(.small) }
.cashierHide(.quickAmounts)
.cashierInsert(before: .mainButton) { SecurityNote() }
.cashierInsert(after: .selectedMethod) { LoyaltyHint() }
}2.4.1 Blocks you can hide: HideableBlock
HideableBlockOnly blocks without legal or payment meaning can be hidden.
| Value | Hides |
|---|---|
.header | The header: back and close buttons, the Deposit / Withdraw tabs, the balance. Give the customer a way to close and go back if you hide it, and do not hide it in sessions with more than one intent. |
.footer | The footer under the first page. |
.quickAmounts | The quick amount buttons. |
.promotions | The bonus list and the promotion code field. To turn promotions off completely, including the data request, leave promotions.style nil instead (§2.3.5). |
2.4.2 Where you can insert: CashierAnchor
CashierAnchorInserted content sits between blocks, in its own clipped container, and shows only while its anchor block shows. Several inserts at the same anchor show in the order you wrote them. Content is never placed inside a block.
| Anchor | Page | Block |
|---|---|---|
.header | Every page | The header |
.amount | Amount | The amount, currency and limits |
.quickAmounts | Amount | The quick amount buttons |
.promotions | Amount | The bonus list or the promotion code, whichever shows |
.selectedMethod | Amount | The selected payment method |
.amountChangeNote | Amount | The note when the method changes the amount |
.totalToPay | Amount | The fee and the total |
.terms | Amount; details and billing during a decline recovery | The terms box |
.mainButton | Every page | The main button |
.footer | Amount | The footer |
.stepTitle | Details, billing | The page title |
.cardForm | Details | The card fields |
.savedCardCode | Details | The saved card CVV field |
.walletSwitch | Details | The card or Apple Pay switch |
.methodFields | Details | The fields of a non-card method |
.bankPicker | Details | The bank list of a bank wire |
.saveCardNote | Details | The note that a new card is saved |
.billingForm | Billing | The billing and contact fields |
.result | Result | The result of the payment |
2.4.3 What slot content can read: CashierSlotContext
CashierSlotContextSlot content does not get the CashierSession. It reads @Environment(\.cashierSlotContext), which is nil outside slot content:
| Member | Description |
|---|---|
snapshot | The read-only CashierSnapshot: step, amount, currency, selected method, total, result and more. Never card or personal data. |
back() | Goes back one page. Ignored on the first page or while a payment runs. |
close() | Closes the Cashier. onResult is called with closedBy .code. |
next() | Does what the main button does now. Ignored when the button is disabled. |
struct BrandHeader: View {
@Environment(\.cashierSlotContext) private var cashier
@Environment(\.cashierResolvedTheme) private var theme
var body: some View {
HStack {
if let cashier, cashier.snapshot.step != .amount {
Button("Back") { cashier.back() }
}
Spacer()
Image("logo")
Spacer()
Button("Close") { cashier?.close() }
}
.foregroundStyle(theme.color(.headerIcon))
.padding(theme.spacing(.s16))
}
}
Inside slot content,@Environment(CashierSession.self)is nil. A non-optional read of it there stops the app at run time.
2.4.4 Slots in UIKit: CashierSlots
CashierSlotsPass CashierSlots to CashierViewController(token:environment:configuration:slots:onResult:) or CashierViewController(session:slots:). Your views are UIViews.
| Method | Effect |
|---|---|
setHeader(_:) | Replaces the header. |
setFooter(_:) | Replaces the footer. |
hide(_:) | Hides a HideableBlock. |
insert(before:_:) | Adds your view before a CashierAnchor. |
insert(after:_:) | Adds your view after a CashierAnchor. |
var slots = CashierSlots()
slots.setHeader { BrandHeaderView() }
slots.hide(.quickAmounts)
slots.insert(after: .selectedMethod) { LoyaltyHintView() }
let cashier = CashierViewController(token: token, environment: cashierEnvironment, slots: slots) { result in
handle(result)
}2.5 Theme
CashierConfiguration.theme (CashierTheme). The Cashier takes its look from two sources; the later one wins, value by value:
- Built-in defaults.
- Your
CashierThemevalues that are notnil.roleColorsandcornerRadiuswin over the palette and the button shape.
The theme is not read from the Praxis Backoffice, so the loading screen already has your look.
| Parameter | Description | Format | Required |
|---|---|---|---|
brandColorLight | The brand color in light appearance, as hex: # and 3, 4, 6 or 8 digits (for example "#0F768A"). The Cashier builds its whole palette from it: main button, links, selected states, quick amounts. Default: nil (#0F768A). | String? | No |
brandColorDark | The brand color in dark appearance, as hex. It is not taken from brandColorLight: with .dark or .system, set it too, or use CashierTheme(brand:brandText:). Default: nil (#0F758A). | String? | No |
brandTextColorLight | The text color on the main button and the selected quick amount in light appearance, as hex. Default: nil (#F2F2F2). | String? | No |
brandTextColorDark | The same in dark appearance. Default: nil (#F2F2F2). | String? | No |
fontName | The family or PostScript name of a font your app has registered. nil or "default" uses the system font. A font the app does not have falls back to the system font: serif or monospace for the web Cashier's serif and monospace fonts, sans-serif otherwise. The SDK never downloads fonts. Sizes and weights do not change. Default: nil (the system font). | String? | No |
buttonShape | The corner style of the main button and of the parts that follow it (method card, field groups, dialogs, bonus cards): .rounded (8 pt), .sharp (0 pt) or .pill (20 pt). Default: nil (.rounded). | CashierTheme.ButtonShape? | No |
cornerRadius | A corner radius in points for the same parts. Wins over buttonShape. Must be 0 or more. Default: nil. | CGFloat? | No |
appearance | .light, .dark or .system. With .system, the Cashier reads the device setting when it opens and keeps it while it is open. Default: nil (.light). | CashierTheme.Appearance? | No |
fieldLabelStyle | How method and billing fields show labels: .topLabel (label above the field), .floatingLabel (label inside the field) or .noLabel (each field group is one box with thin dividers). Default: nil (.topLabel). | CashierTheme.FieldLabelStyle? | No |
roleColors | Colors for single roles. See §2.6. Default: [:]. | [CashierTheme.Role: Color] | No |
One brand color for both appearances. CashierTheme(brand:brandText:) takes SwiftUI colors. A color from your asset catalog that changes with the appearance gives its light value to light appearance and its dark value to dark appearance:
let theme = CashierTheme(brand: Color("BrandBlue"), brandText: .white)All properties of CashierTheme are var, so you can also change a theme after creating it:
var theme = CashierTheme(brand: Color("BrandBlue"))
theme.buttonShape = .pill
theme.fieldLabelStyle = .floatingLabel
Not customizable: spacing and type sizes. Text sizes follow the customer's Dynamic Type setting.
An invalid hex color or a negativecornerRadiusis ignored and reported once withconfiguration_value_ignored;ignoredNamenames the field.
2.6 Color roles
CashierTheme.Role names each color the Cashier draws with. A role you set in roleColors replaces the palette color of that role, in both appearances. Use a color from your asset catalog to give different light and dark values.
| Role | Used for |
|---|---|
.screenBackground | The screen background |
.sheetSurface | Sheet surfaces |
.dialogSurface | Dialog surfaces |
.fieldBackground | Input backgrounds |
.highContrast | Terms text, checkbox border and fill, currency selector, text cursor |
.onAccentConstant | Checkbox tick and the spinner on the main button |
.accent | The brand color: main button, selected pill, links |
.accentPressed | The main button while pressed |
.onAccent | Text on the main button and the selected pill |
.accentSoft | Quick amount pills, the exchange icon background |
.pillPressed | A quick amount pill while pressed |
.cardSurface | Method card, picker rows, bonus cards |
.selectedRow | The selected picker row, the currency row |
.closeButtonFill | The sheet close button |
.radioFill | The currency row radio button |
.pendingIconCircle | The circle behind the pending result icon |
.headerDivider | The line under the header |
.disabledFill | A disabled button |
.divider | Dividers |
.fieldBorder | Field borders |
.grabber | The sheet grabber |
.placeholderText | Placeholders |
.appliedButtonDisabled | The disabled Apply label of the promotion code |
.inputBorder | The promotion code input border |
.secondaryText | Subtitles and the footer |
.disabledText | Disabled button text |
.headerIcon | Header back and close icons |
.noteText | The amount change note |
.headerText | Header tab, balance and step subtitle |
.mutedText | Bonus descriptions and the result help link |
.primaryText | The amount, titles and body text |
.strongText | Field text, banner text, dialog text, the result title |
.error | Limit text, field errors, the decline reason |
.errorSoft | The circle behind the declined result icon |
.success | "No fees" and an unlocked bonus |
.warning | The maintenance warning |
.warningSoft | The maintenance warning background |
.termsError | The terms box and text in the error state |
.cardFieldBorder | The card field group border |
.backdrop | The backdrop behind sheets and dialogs |
.sheetShadow | The sheet shadow |
.dialogShadow | The dialog shadow |
let theme = CashierTheme(
brandColorLight: "#0F768A",
roleColors: [
.screenBackground: Color("AppBackground"),
.primaryText: Color("AppText"),
.error: .red
]
)
Check contrast when you set text and background roles. The Cashier does not adjust colors you set.
2.7 The theme in your own views
Inside the Cashier, your slot content and your own layout views can draw with the resolved theme: your values over the defaults. Read @Environment(\.cashierResolvedTheme) (CashierResolvedTheme). Outside the Cashier it holds the default theme.
| Member | Returns | Description |
|---|---|---|
color(_:) | Color | The color of a role (§2.6). |
cornerRadius | CGFloat | The corner radius from buttonShape or your cornerRadius. |
spacing(_:) | CGFloat | A step of the spacing scale. |
font(_:) | Font | The font of a text style. Follows Dynamic Type only with a font your app registered. |
For text, prefer the view modifier .cashierFont(_:): it sets the font, letter spacing and line height of the style and follows Dynamic Type with every font, as the Cashier's own text does.
struct LoyaltyHint: View {
@Environment(\.cashierResolvedTheme) private var theme
var body: some View {
Text("You earn points with this deposit")
.cashierFont(.caption)
.foregroundStyle(theme.color(.secondaryText))
.padding(theme.spacing(.s12))
.background(theme.color(.cardSurface), in: RoundedRectangle(cornerRadius: theme.cornerRadius))
}
}Spacing steps (CashierResolvedTheme.Spacing):
| Step | Points | Step | Points |
|---|---|---|---|
.s2 | 2 | .s20 | 20 |
.s4 | 4 | .s22 | 22 |
.s8 | 8 | .s24 | 24 (the gap between blocks on the first page) |
.s10 | 10 | .s25 | 25 |
.s12 | 12 | .s32 | 32 |
.s16 | 16 (the side inset of every screen) | .s40 | 40 |
.s17 | 17 |
Text styles (CashierResolvedTheme.TextStyle), sizes at the default Dynamic Type size:
| Style | Size and weight | Used for |
|---|---|---|
.amount | 48 pt, semibold | The amount |
.stepTitle | 24 pt, semibold | Page titles |
.resultTitle | 22 pt, semibold | Result titles |
.button | 16 pt, semibold | Buttons |
.methodTitle | 16 pt, semibold | Method titles |
.bonusTitle | 16 pt, semibold | Bonus titles |
.promoLink | 16 pt, medium | The promotion code link |
.body | 16 pt, regular | Body text and fields |
.resultRow | 16 pt, regular | Result detail rows |
.badge | 14 pt, heavy | Bonus badges |
.label | 14 pt, semibold | Labels, the header tab |
.totalAmount | 14 pt, semibold | The total to pay |
.dialogLink | 14 pt, medium | Dialog text buttons |
.caption | 14 pt, regular | Captions |
.captionLoose | 14 pt, regular | Captions with looser line spacing |
.terms | 14 pt, regular | Terms text |
.dialogText | 14 pt, regular | Dialog text |
.subtitle | 14 pt, regular | Subtitles |
.small | 12 pt, regular | Small text |
.footerLink | 12 pt, regular | Footer links |
2.8 Texts
Every text the Cashier shows comes from the texts set for your application at Praxis, in the session language. The keys are the same as the Praxis web Cashier's translation keys, plus a few SDK keys that start with sdk_. Replace any text with CashierConfiguration.texts (CashierTexts).
| Initializer | Description |
|---|---|
CashierTexts(_:depositButton:withdrawalButton:) | Your texts for every language: [CashierTexts.Key: String]. |
CashierTexts(byLanguage:depositButton:withdrawalButton:) | Your texts per language: [String: [CashierTexts.Key: String]], where the language code is matched exactly with the session language (for example "de"). |
// The same text in every language
let texts = CashierTexts([
.deposit: "Deposit now",
.agree_with_terms_of_service: "I accept the terms"
])
// Per language
let localized = CashierTexts(byLanguage: [
"en": [.deposit: "Deposit now"],
"de": [.deposit: "Jetzt einzahlen"]
])Which text wins: a CashierTexts holds either texts for every language (CashierTexts(_:)) or texts per language (CashierTexts(byLanguage:)). Your text wins over the server text. With byLanguage, a session language you did not list uses the server text. A key with no text anywhere shows the key itself.
Main button text. depositButton and withdrawalButton replace the Deposit / Withdraw text of the main button: on the amount page and on the final pay button (on a one-page layout, always). A bank wire still shows Get Payment Details, a card authorization shows Authorize, and Continue on the details page is unchanged. A value equal to a known text key shows that key's text; an empty value means the standard text. They win over the texts for that button in every language. For a different button text per language, set the deposit and withdraw keys with CashierTexts(byLanguage:) instead.
| Parameter | Description | Format | Required |
|---|---|---|---|
depositButton | The main button text of a deposit. Default: nil (the standard text). | String? | No |
withdrawalButton | The main button text of a withdrawal. Default: nil (the standard text). | String? | No |
let texts = CashierTexts(depositButton: "Top up", withdrawalButton: "Cash out")Placeholders. Some texts contain placeholders such as {{amount}}, which the Cashier fills in. Keep them in your text.
Keys. Each key has a static property on CashierTexts.Key, named after the key, for example Agree with terms of service is .agree_with_terms_of_service and Payment details is .payment_details_capital. Look up the exact name in the appendix. Every key the Cashier knows has a static property. CashierTexts.Key(rawValue:) takes the key text verbatim, but a key the Cashier does not know is ignored and reported once with configuration_value_ignored.
Texts are shown as they are. Never put card data, customer data or server text into your texts.
2.9 Fields and methods
These parameters are part of CashierHooks, passed in CashierConfiguration.hooks. They are described with examples in §3.5.
| Parameter | Description | Format | Required |
|---|---|---|---|
methodFilter | Keeps and reorders payment methods: return the ids to show, in order. Cannot add methods. | ([CashierMethodInfo]) async -> [String] | No |
fieldRules | Extra checks on method and billing fields: pattern (regular expression), minimumLength, isRequired, and errorTextKey for the message. Limit to methods with methods. | [CashierFieldRule] | No |
skippedFieldChecks | Per method key, field names whose checks are turned off. | [String: Set<String>] | No |
fieldAdjustments | .hide(field:method:), .require(field:method:), .defaultValue(_:field:method:). | [CashierFieldAdjustment] | No |
Field names are the names Praxis sends for a method's fields, for example account_number or zip. Your code never sees what the customer types.
2.10 Payment handler
CashierConfiguration.paymentHandler: .praxis (default) or .custom { request in … } to run your own code, for example a risk check, before the payment is sent to Praxis. See §4.
2.11 What your app cannot change
These limits keep card data out of your app and minimize your PCI DSS scope.
| Your app cannot | Why |
|---|---|
| Read or send card numbers, CVVs, card tokens, contact data, billing values or field values. | They never leave the SDK. |
| Charge through your own payment provider. | A Payment Handler gets amounts, flags and a sealed payload only. |
| Replace a block that captures or shows personal data: card form, saved card code, method fields, billing form, bank details. | These blocks are sealed. You can place them, and hide them where hiding is allowed, but not rebuild them. |
| Hide the amount, selected method, total, terms or main button. | They carry legal or payment meaning. |
Read the CashierSession from slot content. | Slot content gets CashierSlotContext only. |
| See which saved card or account a saved row is. | A saved row has the id saved-<n> and an SDK name; its label, masked number and last digits stay in the SDK. |
Show your own text inside SDK screens other than through CashierTexts. | Every text the Cashier shows comes from texts. |
| Change spacing or type sizes. | Neither is part of CashierTheme. |
3. Events and hooks
3.1 CashierHooks
CashierHooksPut your code in CashierHooks and pass it in CashierConfiguration(hooks:). Every hook runs on the main actor.
let hooks = CashierHooks(
onEvent: { event in analytics.track(event.name.rawValue, traceID: event.traceID) },
onAmountChange: { update in
if let total = update.total ?? update.totalCharge { cartView.show(total, update.currency) }
},
methodFilter: { methods in methods.filter { !$0.isInMaintenance }.map(\.id) },
fieldRules: [CashierFieldRule(field: "zip", minimumLength: 4)]
)
let configuration = CashierConfiguration(hooks: hooks)| Hook | Description |
|---|---|
onEvent | Each CashierEvent, in order (§3.2). |
onAmountChange | The live amount (§3.3). |
methodFilter | Keeps and reorders payment methods (§3.4). |
fieldRules | Extra checks on fields (§3.5). |
skippedFieldChecks | Field checks to turn off, per method key (§3.5). |
fieldAdjustments | Hide a field, make it required, or give it a start value (§3.5). |
3.2 Events
Event names are the web Payment Page SDK names, so you can track the app and the web the same way. A few events exist only in the SDK: layout_incomplete, configuration_value_ignored and terms_accepted_by_code. Read the name with event.name.rawValue.
| Name | Raw value | When |
|---|---|---|
initSession | initSession | The session was read. |
initApp | initApp | The Cashier was set up. |
cashierLoaded | cashier_loaded | The Cashier is ready. |
paymentMethodSelected | payment_method_selected | A method was selected. |
createPaymentPage | createPaymentPage | The form of the selected method is ready. |
hostedPaymentFieldsLoaded | hosted_payment_fields_loaded | The card fields showed. |
hostedFieldsValid / hostedFieldsInvalid | hpf_form_valid / hpf_form_invalid | The card fields became valid or invalid. |
methodFieldsLoaded | apm_fields_loaded | The method fields showed. |
methodFieldsValid / methodFieldsInvalid | apm_form_valid / apm_form_invalid | The method fields became valid or invalid. |
submit | cashier_submit | The payment was handed off. |
transactionAttempted | transaction_attempted | The payment answer arrived and is OK. |
redirection | redirection | A provider page opened. |
transaction | transaction | A transaction status arrived. |
thankYouPageLoaded | thank_you_page_loaded | The final result showed. |
createResultPage | createResultPage | The result page was made. |
transactionFailed | transaction_failed | The payment ended on an error. |
loadingFailed | cashier_loading_failed | The Cashier could not load, or ended on an error screen. |
layoutIncomplete | layout_incomplete | Your layout leaves out a block the payment needs. See Required blocks. |
configurationValueIgnored | configuration_value_ignored | A configuration value you set was ignored, for example an invalid color, a negative amount or a URL that is not https. ignoredName names the field. |
termsAcceptedByCode | terms_accepted_by_code | Your app ticked the terms box. |
backButton | cashier_back_button | The customer tapped the header back button on the first page. This button shows only when header.showsBackButton is true. The Cashier stays open, so your app can react, for example by closing it. |
walletNotPresented | wallet_not_presented | The Apple Pay sheet could not open, so Apple Pay is hidden for the rest of the session. Most often your app's Apple Pay capability does not contain the merchant ID Praxis gave you; a debug build also prints a console warning that names it. |
There is no event for a step change (read CashierSnapshot.step), no click event and no per-field event.
Event fields. Every field of CashierEvent, with its format, is listed in the SDK Reference. Events carry the method type, action type, status, error code, card brand, validity, amount and currency, trace ID, the ignored value name, the layout_incomplete reason and the intents; a field is nil when the event does not use it. cashier_loaded always carries currency (the account's base currency, else the session currency) and amount (the session amount, nil when there is none). The two withdrawal error pages send transaction_failed, not cashier_loading_failed.
Deposits and withdrawals. event.intent is the intent of the tab the customer is on (.deposit or .withdrawal), so you can track withdrawals apart from deposits. A card authorization session reports a deposit. secondaryIntents is set on cashier_loaded and cashier_loading_failed in sessions that offer more than one intent.
3.3 Live amount
onAmountChange gets a CashierAmountUpdate while the amount section shows an amount: first when it shows, then each time the amount, charge, display amount, fee, total or currency changes. On a withdrawal, displayAmount is what leaves the balance and total is what the customer receives. When the customer sees only the base currency and the method charges in another currency, displayAmount, fee and total are in the method's currency while currency stays the base currency.
Every field of CashierAmountUpdate is listed in the SDK Reference.
3.4 Method filter
methodFilter gets the methods the picker would offer ([CashierMethodInfo]) and returns the ids to keep, in the order to show. It can remove and reorder methods, but not add one. Unknown ids are ignored. A saved card or account has the opaque id saved-<n>.
If your filter returns no id from the list it got, the Cashier shows its error screen and ends with theconfiguration_errorcode.
3.5 Field rules and adjustments
Field names are the names Praxis sends for a method's fields, for example account_number or zip.
let hooks = CashierHooks(
fieldRules: [
CashierFieldRule(field: "account_number", methods: ["example_wallet"], pattern: "^[0-9]+$", minimumLength: 6)
],
skippedFieldChecks: ["example_wallet": ["address"]],
fieldAdjustments: [
.hide(field: "state", method: "example_wallet"),
.require(field: "phone", method: "example_wallet"),
.defaultValue("GB", field: "country", method: "example_wallet")
]
)| Type | Description |
|---|---|
CashierFieldRule(field:methods:pattern:minimumLength:isRequired:errorTextKey:) | Adds a check to a method or billing field: a regular expression, a minimum length, or a required value. methods nil means every method. errorTextKey picks the message from CashierTexts. |
skippedFieldChecks | [method key: Set<field name>]: turns off the checks of the named fields. |
CashierFieldAdjustment | .hide(field:method:), .require(field:method:), .defaultValue(_:field:method:). |
The SDK applies these inside. Your code never sees what the customer types.
3.6 What never reaches your code
Events and hooks never carry card numbers, CVVs, card tokens, customer data (name, email, phone, address), field values, server messages or the session token.
4. Payment handler
4.1 Overview
By default, CashierPaymentHandler.praxis sends the payment to Praxis and the SDK does everything. To step in, for example for your own risk check, pass a .custom handler:
let configuration = CashierConfiguration(paymentHandler: .custom { request in
guard await myRiskCheck(amount: request.amount, currency: request.currency) else {
return .notSubmitted
}
return await request.payload.submitToPraxis()
})4.2 What the handler gets
The handler runs once per tap on the final button, after every check passed and after the card is protected. It gets a CashierPaymentRequest:
| Property | Description | Format |
|---|---|---|
amount, currency | The amount (major units; crypto in the minor units the payment sends) and currency of the payment. | Decimal, String |
originAmount | The amount the customer entered in the base currency, for a cross-currency payment; nil otherwise. | Decimal? |
paymentMethod | The method key. | String |
paymentMethodType | "cc" for a card method; nil for other methods. | String? |
termsAccepted | Whether the terms were accepted. | Bool |
hasPromotionCode | Whether a promotion code is sent. Never the code itself. | Bool |
payload | Everything else, sealed. | CashierPaymentPayload |
The payload cannot be read, printed or inspected. The only thing it can do is submitToPraxis(), which sends it to Praxis exactly as the default handler does.
4.3 What the handler returns
| Return | What the Cashier does |
|---|---|
The outcome of request.payload.submitToPraxis() | Continues as with the default handler: processing, provider page, result. |
.notSubmitted | Nothing was sent. The button stops being busy and the customer stays on the page. |
.finished(_:transactionID:) | Your code finished the payment another way. The Cashier shows the result for that status (title and icon only). The transaction ID reaches CashierResult.transactionID. |
Payments finished outside PraxisWhen your handler returns
.finished, Praxis did not process the payment, so no Payment Notification follows for it. Confirm and reconcile such payments in the system that finished them, before you credit the customer. Every payment sent withsubmitToPraxis()is confirmed by the Payment Notification as usual.
4.4 Rules
- Once.
submitToPraxis()sends at most once. A second call returns.notSubmittedand sends nothing. - Timeout. The handler has 130 seconds. After that the Cashier treats the payment as sent with its answer lost: it shows the processing screen and reads the payment result. A later
submitToPraxis()sends nothing. - Close.
CashierSession.close()cancels the handler and closes the payload. - Main actor. The handler runs on the main actor.
A handler cannot charge through your own payment provider. It never gets the card number, CVV, card token, customer contact data or any field value.
What's next
Updated about 18 hours ago