Blocks Catalog
Every Cashier block, what it shows by default and how to customize it.
This page is the catalog of the Cashier blocks: what each block shows by default, and how you change it, from theme and texts to drawing the block in your own design (§1 to §9). It ends with the theme and texts as they apply to blocks (§10) and what blocks cannot do (§11). For how to arrange blocks into pages, see Layouts & Examples.
1. Blocks and what you can change
The pictures in §2 to §10 come from the iPhone simulator with test data: Default is what the SDK draws, and Custom (Cashier.Pages) is a cashier drawn by an app with its own pages (see Styled Examples).
1.1 What a block is
A block is one part of the Cashier, such as the amount field, the selected payment method or the main button. Each block is a SwiftUI view in the Cashier namespace, for example Cashier.MainButton(). A block reads what it needs from the session around it and draws nothing when it does not apply, so you can place it without conditions of your own.
Cashier.MainButton() draws the SDK's view. Many blocks also take a closure. The closure gets a context: the block's state, its actions and, where the payment needs one, a sealed SDK part that you place in your view.
Cashier.MainButton() // the SDK's button
Cashier.MainButton { button in // your button, the SDK's rules
MyPrimaryButton(button.state.label, isBusy: button.state.isBusy) {
button.perform()
}
}The context never holds card data or customer data: only flags, the SDK's texts in the session language, and amounts.
1.2 Four kinds of block
| Kind | What you draw | What the SDK keeps | Blocks |
|---|---|---|---|
| Own UI | The whole block, from its state and actions | The rules: every check runs as for the SDK's view | Header, StepTitle, AmountField, SelectedMethod, BonusSection, MainButton, TransactionResult, PartialApproval, ErrorScreen |
| Your frame | The frame around a sealed part: background, border, label, error line, your buttons | The sealed part: card input, field, promotion code input, legal text or total line. You place it; you cannot read it | CardField, MethodField, BillingField, PromoCode, Terms, TotalToPay |
| Data | Your own control, with no SDK block behind it | The values: you read CashierSnapshot and send CashierSession commands | Quick amounts, currency picker, amount limits text, method list |
| SDK only | Nothing inside the block: you place it | The whole view. You change it with configuration, theme and texts | Amount, CurrencyLine, AmountLimitHint, AmountChangeNote, QuickAmounts, Footer, MethodDetails, WalletSwitch, BankPicker, CardForm, SavedCardCode, SaveCardNote, MethodFields, BillingForm, Promotions, Outcome, Loading, Processing, BankDetails, NoMethods |
Every block, whatever its kind, takes its colors and font from your CashierTheme and its texts from the server texts and your CashierTexts (see §10).
1.3 All blocks at a glance
"Template" means the pre-built layouts Cashier.AmountFirstLayout (the predefined template) and Cashier.OnePageLayout. "Own layout" means your own Cashier.Pages. Styled Examples shows four own layouts, from one page to four.
| Block | Kind | Default: what the SDK draws | How to customize | Section |
|---|---|---|---|---|
Header | Own UI | Back, the Deposit / Withdraw tabs, the balance, close | header settings; template: cashierHeader, cashierHide(.header); own layout: Cashier.Header { header in … } | §2.1 |
StepTitle | Own UI | The title of the method details and billing pages | Texts; own layout: Cashier.StepTitle { step in … } | §2.2 |
Footer | SDK only | Your support and policy links under the first page | footer links; template: cashierFooter, cashierHide(.footer) | §2.3 |
AmountField | Own UI | The amount input with the currency sign and code | .editableAmount, presetAmountEditable, amount.currencyFormat; own layout: Cashier.AmountField { field in … } | §3.1 |
Amount | SDK only | AmountField, CurrencyLine and AmountLimitHint together | Place the three blocks one by one to change one of them | §3.1 |
CurrencyLine | SDK only | The currency to pay in and its sheet, or the exchange line | .currencyChange, amount.currencyMode; own layout: your picker from data | §3.2 |
AmountLimitHint | SDK only | The minimum or maximum, when the amount is outside the limits | .amountLimits; own layout: your text from data | §3.3 |
AmountChangeNote | SDK only | A note when the amount to pay differs from the amount typed | Texts, theme | §3.3 |
QuickAmounts | SDK only | Amount pills | amount.quickAmounts; template: cashierHide(.quickAmounts); own layout: your buttons from data | §3.4 |
SelectedMethod | Own UI | The selected method; a tap opens the SDK's method picker | paymentMethods settings, methodFilter; own layout: Cashier.SelectedMethod { method in … } | §4.1 |
| Method list | Data | No block | Your list from snapshot.methods and selectMethod(id:) | §4.2 |
MethodDetails, WalletSwitch, BankPicker | SDK only | The details of the selected method; the card or Apple Pay switch; the bank list of a bank wire | Configuration, theme, texts | §4.3 |
CardField | Your frame | One card input in the SDK's box | Own layout: Cashier.CardField(.number) { field in … }; template: cashierCardField | §5.1 |
SavedCardCode | SDK only | The security code of a saved card | Or Cashier.CardField(.securityCode) { … } | §5.2 |
CardForm, SaveCardNote | SDK only | The card inputs of a new card; the note that the card is saved | card settings, theme, texts; or CardFields | §5.4 |
MethodField | Your frame | One field of the selected method | Own layout: Cashier.MethodField(id) { field in … } | §6.1 |
BillingField | Your frame | One billing field | Own layout: Cashier.BillingField(.phone) { field in … } | §6.2 |
MethodFields, BillingForm | SDK only | All fields of the method; all billing and contact fields | billingFields, paymentMethods.prefillsFields, hooks, fieldLabelStyle | §6.3 |
BonusSection | Own UI | The bonus trigger and the chosen bonus; a tap opens the SDK's chooser | promotions.style .bonusList; own layout: Cashier.BonusSection { bonus in … } | §7.1 |
PromoCode | Your frame | The promotion code link, the code input and the applied code (readable when it is a session bonus) | promotions.style .codeField; own layout: Cashier.PromoCode { promo in … } | §7.2 |
Promotions | SDK only | BonusSection or PromoCode, as promotions.style decides | promotions.style; template: cashierHide(.promotions) | §7.3 |
TotalToPay | Your frame | The total line; a tap opens the payment summary | Own layout: Cashier.TotalToPay { total in … } | §8.1 |
Terms | Your frame | The terms box with its legal text, or the wallet terms text | Texts; own layout: Cashier.Terms { terms in … } | §8.2 |
MainButton | Own UI | Continue, Deposit, Withdraw or the Apple Pay button | depositButton, withdrawalButton, theme; template: cashierMainButton; own layout: Cashier.MainButton { button in … } | §8.3 |
Outcome, Loading, Processing, BankDetails, NoMethods | SDK only | Every screen after the form; the single screens | Theme, texts; wrap Cashier.Outcome() in your frame | §9.1 |
TransactionResult | Own UI | The result: title, icon, amount, details, buttons | result settings; own layout: Cashier.TransactionResult { result in … } | §9.2 |
PartialApproval | Own UI | The partial approval decision with its countdown | Own layout: Cashier.PartialApproval { partial in … } | §9.3 |
ErrorScreen | Own UI | The error screens | Texts, theme; template: cashierErrorScreen; own layout: Cashier.ErrorScreen { error in … } | §9.4 |
1.4 Where you customize a block
There are three places. Use the first one that gives you what you need.
| Where | What you change | Works in |
|---|---|---|
CashierConfiguration | Features, settings, theme and texts. See Configuration & Customization | Every layout |
| Template methods | Your header and footer, hidden blocks, your views between blocks, and your own main button, card fields and error screens | Cashier.AmountFirstLayout() and Cashier.OnePageLayout() |
| Your own layout | Any block with a closure, your views over the session, your own controls from data | Cashier.Pages |
The template methods return the layout with your change. Pass the layout as the last closure of CashierView, .cashierSheet or CashierViewController(session:layout:):
CashierView(token: token, environment: cashierEnvironment, onResult: handle) {
Cashier.AmountFirstLayout()
.cashierHeader { BrandHeader() }
.cashierHide(.quickAmounts)
.cashierInsert(after: .selectedMethod) { LoyaltyHint() }
.cashierMainButton { button in MyMainButton(button: button) }
.cashierCardField { field in MyCardFieldFrame(field: field) }
.cashierErrorScreen { error in MyErrorPage(error: error) }
}| Method | What it does |
|---|---|
cashierHeader(_:) | Replaces the header on every page. Your view reads @Environment(\.cashierSlotContext). |
cashierFooter(_:) | Replaces the footer under the first page. |
cashierHide(_:) | Hides .header, .footer, .quickAmounts or .promotions. |
cashierInsert(before:_:), cashierInsert(after:_:) | Adds your view before or after a block (CashierAnchor). |
cashierMainButton(_:) | Draws the main button with your view, from Cashier.MainButtonContext (§8.3). |
cashierCardField(_:) | Draws each card input with your frame, from Cashier.CardFieldContext (§5.1). |
cashierErrorScreen(_:) | Draws the error screens with your view, from Cashier.ErrorScreenContext (§9.4). |
Inserted views, your header and your footer get CashierSlotContext only: the snapshot and back(), close() and next(). They cannot send other session commands, so controls such as your own quick amounts need your own layout. See Slots.
In your own layout, a view of yours reads the session with @Environment(CashierSession.self). A block with a closure does the rest:
CashierView(session: session) {
Cashier.Pages {
Cashier.Page("Payment") {
Cashier.Header { header in MyHeader(header: header) }
Cashier.AmountField { field in MyAmountField(field: field) }
Cashier.CurrencyLine()
Cashier.AmountLimitHint()
Cashier.SelectedMethod { method in MyMethodRow(method: method) }
Cashier.MethodDetails()
Cashier.BillingForm()
} bottom: {
Cashier.TotalToPay()
Cashier.Terms()
Cashier.MainButton { button in MyMainButton(button: button) }
}
}
}
A block with your content is generic over that content:Cashier.MainButton()is aCashier.MainButton<Never>. Write the type only when you store a block in a property.
1.5 Previews of your own blocks
Build your own block views without a session. Every state has a preview(…) value, and every context a preview(_:…) that wraps the state. The actions run the closures you pass; the texts and amounts are yours.
#Preview {
MyMainButton(button: .preview(.preview(label: "Deposit 50.00 EUR", isBusy: true)))
}
#Preview {
@Previewable @State var accepted = false
MyTerms(terms: .preview(.preview(isAccepted: accepted)) { accepted = $0 })
}In a preview context, the sealed parts (input, legalText) and every sdkView except the main button's are empty placeholders of a field's height. A preview context never pays, sends an event or reaches a session.
2. Header, step title and footer
2.1 Header
Default. The bar at the top of every page: the back button, the Deposit / Withdraw tabs, the balance and the close button.
Customize.
- Settings:
CashierConfiguration.header(CashierHeaderOptions) sets where the balance and the tabs show, the back button on the first page, and the close button. See Header. - Theme: the roles
.headerIcon,.headerTextand.headerDivider. - Template:
.cashierHeader { … }replaces it,.cashierHide(.header)hides it. - Own layout: draw it yourself with
Cashier.Header { header in … }.
struct MyHeader: View {
let header: Cashier.HeaderContext
@Environment(\.cashierText) private var text
var body: some View {
HStack {
if header.state.showsBack {
Button { header.back() } label: { Image(systemName: "chevron.backward") }
.disabled(!header.state.isBackEnabled)
.accessibilityLabel(text(.back))
}
Spacer()
Image("logo")
Spacer()
if header.state.showsClose {
Button { header.close() } label: { Image(systemName: "xmark") }
.accessibilityLabel(text(.close))
}
}
.padding()
}
}
Cashier.Header { header in MyHeader(header: header) }| Name | Type | Description |
|---|---|---|
state.showsBack | Bool | The back button shows. |
state.isBackEnabled | Bool | Back takes a tap now. False while a payment runs on a later page. |
state.showsClose | Bool | The close button shows. |
back() | Bool | Goes back, as the SDK's back button does. Returns false when back does not show or takes no tap now. |
close() | Closes the Cashier, as the SDK's close button does. | |
sdkView | SDKHeaderView | The SDK's own header. |
Do
- Show close whenever
showsCloseis true, and back whenevershowsBackis true. - Keep back visible but disabled when
isBackEnabledis false. - To keep the tabs and the balance and only add your branding, place
header.sdkViewinside your view.
Don't
- Don't draw your own header in a session with both Deposit and Withdraw: the state has no tabs and no balance, so the customer could not switch. Use
header.sdkViewthere.
2.2 Step title
Default. The title of the method details page and the billing page, in the session language. It keeps its own margin to the block under it.
Customize.
- Texts: the title is a server text; replace it with
CashierTexts. - Theme: the text style
.stepTitle. - Own layout:
Cashier.StepTitle { step in … }.
Cashier.StepTitle { step in
Text(step.title.uppercased())
.font(.system(.title2, design: .rounded, weight: .heavy))
.accessibilityAddTraits(.isHeader)
}| Name | Type | Description |
|---|---|---|
title | String | The title, in the session language. |
sdkView | SDKStepTitleView | The SDK's own title. |
Do
- Show
step.title: it follows the session language.
Don't
- Don't put a fixed title of your own in its place: it would not change with the page or the language.
2.3 Footer
Default. Under the first page: your support contacts and policy links, and the logos. It shows when at least one link is set.
Customize.
- Settings:
CashierConfiguration.footer(CashierFooterLinks). See Footer links. - Template:
.cashierFooter { … }replaces it,.cashierHide(.footer)hides it. - Own layout: place
Cashier.Footer()in thefooterof aCashier.Page, or your own view instead.
3. Amount
3.1 Amount field
Default. Cashier.AmountField() is the amount input with the currency sign and code. Cashier.Amount() draws AmountField, CurrencyLine and AmountLimitHint together; the predefined template uses it.
| Default | Custom (Cashier.Pages) |
|---|---|
![]() | ![]() |
Customize.
- Features and settings:
.editableAmount(an input, or the session amount as fixed text),presetAmountEditable,amount.currencyFormatandamount.currencyMode. See Amount and quick amounts. - Theme: the text style
.amount, the role.primaryText. - Own layout: replace
Cashier.Amount()with the three blocks, and draw the field withCashier.AmountField { field in … }. The amount is not card data, so your ownTextFieldcan take it.
struct MyAmountField: View {
let field: Cashier.AmountFieldContext
@FocusState private var isFocused: Bool
var body: some View {
HStack {
TextField(field.state.placeholder, text: Binding(
get: { field.state.text },
set: { field.setText($0) }
))
.keyboardType(.decimalPad)
.focused($isFocused)
.disabled(!field.state.isEditable)
.onChange(of: isFocused) { _, focused in field.setFocused(focused) }
Text(field.state.currencyCode ?? "")
if field.state.isLocked { Image(systemName: "lock") }
}
.font(.system(size: 44, weight: .heavy))
}
}
Cashier.AmountField { field in MyAmountField(field: field) }
Cashier.CurrencyLine()
Cashier.AmountLimitHint()| Name | Type | Description |
|---|---|---|
state.text | String | The amount as the SDK formats it, for example 50.00. Show it in your field. |
state.placeholder | String | The placeholder. |
state.currencyCode | String? | The currency of the amount, for example EUR. Nil before one is chosen. |
state.isLocked | Bool | The amount is fixed for this session. Show it as fixed, for example with a lock. |
state.isEditable | Bool | The amount can change now. False while a payment runs or when it is locked. |
setText(_:) | Bool | Sends what the customer typed, at most 32 characters. The SDK reads it as it reads its own field (separators, decimals, limits). Returns false when the amount cannot change now or the text is too long. |
setFocused(_:) | Tells the SDK your field gained or lost the focus. Leaving it formats the amount and checks the limits. | |
sdkView | SDKAmountFieldView | The SDK's own field. |
Do
- Show
state.text, not a copy of your own: the SDK formats and corrects it. - Call
setFocused(_:)when your field gains and loses the focus. - Keep
CurrencyLineandAmountLimitHintnext to your field, or build them from data (§3.2, §3.3).
Don't
- Don't take input while
isEditableis false. - Don't keep the amount in a state of your own: send each change with
setText(_:)and showstate.text.
3.2 Currency
Default. Cashier.CurrencyLine() is the line under the amount: the currency to pay in, with the currency sheet when the customer can change it, or the exchange line when amounts show in the base currency.
| Default | Custom (Cashier.Pages) |
|---|---|
![]() | ![]() |
Customize.
- Features and settings:
.currencyChange,amount.currencyMode,amount.currencyFormat. - Own layout: build your own currency picker from data.
struct MyCurrencyPicker: View {
@Environment(CashierSession.self) private var cashier
var body: some View {
let snapshot = cashier.snapshot
if snapshot.currencies.count > 1 {
Menu(snapshot.currency ?? "") {
ForEach(snapshot.currencies, id: \.self) { code in
Button(code) { cashier.selectCurrency(code) }
}
}
}
}
}| Name | Type | Description |
|---|---|---|
snapshot.currencies | [String] | The currencies the customer can pick, A to Z. Empty before the session starts. |
snapshot.currency | String? | The currency now. |
selectCurrency(_:) | Picks a currency, as a pick in the currency sheet does. Unknown codes are ignored. |
Do
- Offer only the codes of
snapshot.currencies. - Keep
.methodamong the checks of your amount page in a paged layout: a new currency can change or clear the method.
Don't
- Don't drop
CurrencyLinewithout a look at your sessions: besides the currency it can show the exchange line, which your picker does not.
3.3 Amount limit hint and amount change note
Default. Cashier.AmountLimitHint() shows the minimum or the maximum of the selected method when the amount is outside the limits. Cashier.AmountChangeNote() shows a note when the amount to pay differs from the amount typed. Both draw nothing otherwise.
Customize.
- Features and settings:
.amountLimitsturns limits on or off;paymentMethods.showsLimitsshows them on the method rows. - Texts and theme: the limit texts, the role
.errorfor the limit text and.noteTextfor the note. - Own layout: write your own limits text from
snapshot.amountLimits.
struct MyLimitsText: View {
@Environment(CashierSession.self) private var cashier
var body: some View {
if let limits = cashier.snapshot.amountLimits, let minimum = limits.minimum, let maximum = limits.maximum {
Text("\(minimum.formatted(.currency(code: limits.currency))) – \(maximum.formatted(.currency(code: limits.currency)))")
}
}
}| Name | Type | Description |
|---|---|---|
snapshot.amountLimits | CashierAmountLimits? | The selected method's amount range. Nil with no method, with .amountLimits off, or when the method has no limit for the currency. On a withdrawal, the maximum is capped by the balance. |
minimum, maximum | Decimal? | The smallest and largest amount accepted, in currency. |
currency | String | The currency of the limits. |
Do
- Place the two blocks right under the amount. They take no space when they draw nothing.
Don't
- Don't keep limits of your own: they change with the method, the currency and, on a withdrawal, the balance.
3.4 Quick amounts
Default. Cashier.QuickAmounts() shows amount pills under the amount. No pills show until you set lists or basedOnLastDeposit.
| Default | Custom (Cashier.Pages) |
|---|---|
![]() | ![]() |
Customize.
- Settings:
CashierConfiguration.amount.quickAmounts(CashierQuickAmounts): lists per currency, method and intent, a Max pill, or pills from the last deposit. See Amount and quick amounts. - Theme: the roles
.accentSoftand.pillPressed. - Template:
.cashierHide(.quickAmounts). - Own layout: draw your own buttons from data.
struct MyQuickAmounts: View {
@Environment(CashierSession.self) private var cashier
private let amounts: [Decimal] = [20, 50, 100]
var body: some View {
let snapshot = cashier.snapshot
HStack {
ForEach(amounts, id: \.self) { amount in
MyChip(amount.formatted(), isSelected: snapshot.amount == amount) {
cashier.setAmount(amount)
}
}
if let limits = snapshot.amountLimits, limits.currency == snapshot.currency,
let maximum = limits.maximum {
MyChip("Max", isSelected: snapshot.amount == maximum) {
cashier.setAmount(maximum)
}
}
}
}
}| Name | Type | Description |
|---|---|---|
snapshot.amount | Decimal? | The amount now. Mark the button that equals it. |
snapshot.amountLimits | CashierAmountLimits? | The method's range, for a Max button and to leave out amounts above it. |
setAmount(_:) | Bool | Sets the amount, through the same rules as typing. Returns false when the amount is locked, the amount section is not open or a payment runs. |
Do
- Leave out buttons above
amountLimits.maximum. - Check that
amountLimits.currencyequalssnapshot.currencybefore you use the limits.
Don't
- Don't put your buttons in a template slot: slot content cannot set the amount. Use the
quickAmountssetting there.
4. Payment method
4.1 Selected method
Default. Cashier.SelectedMethod() is a card with the selected payment method. A tap opens the SDK's method picker, which lists the methods and the saved cards and accounts.
Customize.
- Features and settings:
.savedInstruments, andCashierConfiguration.paymentMethods: last used first, limits, fees, saved card expiry, removal. See Payment methods. - Hooks:
methodFilterkeeps and reorders methods. See Method filter. - Theme: the role
.cardSurface, the text style.methodTitle, the corner radius. - Own layout:
Cashier.SelectedMethod { method in … }.
Cashier.SelectedMethod { method in
Button { method.openPicker() } label: {
HStack {
Text(method.state.title).cashierFont(.methodTitle)
Spacer()
if method.state.isChangeable { Image(systemName: "chevron.down") }
}
}
.disabled(!method.state.isChangeable)
}| Name | Type | Description |
|---|---|---|
state.title | String | The method's title, for example Credit Card. |
state.isSaved | Bool | A saved card or account is chosen. Its label shows only in sdkView. |
state.isChangeable | Bool | A tap opens the method picker. |
state.isUnderMaintenance | Bool | Every method is in maintenance. |
openPicker() | Bool | Opens the SDK's method picker. Returns false when the picker takes no tap now. |
sdkView | SDKSelectedMethodView | The SDK's own card. |
Do
- For a saved card or account, show
method.sdkView, or a text of your own such as "Saved card": the card digits are not in the state. - Show a maintenance note when
isUnderMaintenanceis true.
Don't
- Don't offer a change when
isChangeableis false.
4.2 Your own method list
There is no method list block: the SDK's list is the picker that SelectedMethod opens. To show the methods on the page, for example as tiles, build a list from data.
| SDK's method picker | Custom (Cashier.Pages) |
|---|---|
![]() | ![]() |
struct MyMethodList: View {
@Environment(CashierSession.self) private var cashier
var body: some View {
ForEach(cashier.snapshot.methods, id: \.id) { method in
Button {
cashier.selectMethod(id: method.id)
} label: {
HStack {
AsyncImage(url: method.logoURL) { $0.resizable().scaledToFit() } placeholder: { Color.clear }
.frame(width: 32, height: 32)
Text(method.name)
Spacer()
if cashier.snapshot.paymentMethod?.id == method.id { Image(systemName: "checkmark") }
}
}
}
}
}| Name | Type | Description |
|---|---|---|
snapshot.methods | [CashierMethodInfo] | The methods for the current currency, in server order, then the saved cards and accounts. Empty before the list arrives. |
snapshot.paymentMethod | CashierMethodInfo? | The selected method. |
id, name, type, logoURL | The method's id, name, type and logo. A saved row has the id saved-<n> and an SDK name with no digits. | |
isSaved, isInMaintenance | Bool | A saved card or account; a method in maintenance. |
selectMethod(id:) | Selects a method, as a pick in the picker does. Unknown ids and expired saved cards are ignored. A method in maintenance opens its maintenance dialog. |
Do
- Start the session with an amount when the list comes before the amount: the list loads for an amount above 0.
- Mark the method that equals
snapshot.paymentMethod: the SDK can change or clear it after a new amount or currency.
Don't
- Don't keep method ids across sessions:
saved-<n>is a position in this session's list only.
4.3 Method details, wallet switch and bank picker
These blocks are SDK only. Place them; the SDK decides when they show.
| Block | Default |
|---|---|
Cashier.MethodDetails() | The details of the selected method: the card form, the saved card code, the wallet switch, the method fields or the bank picker. |
Cashier.WalletSwitch() | The switch between the card and Apple Pay inside the card method. Needs the .applePay feature. |
Cashier.BankPicker() | The bank choice of a manual bank wire. |
Customize. With configuration, theme and texts only. To draw the card or method inputs in your own frames, place the single blocks instead of MethodDetails: your CardFields (§5), WalletSwitch, MethodFields or your MethodFields (§6), and BankPicker.
Cashier.Page("Details", validates: .methodDetails) {
Cashier.StepTitle()
MyCardFields() // Cashier.CardField { … } for each input
Cashier.WalletSwitch()
Cashier.MethodFields()
Cashier.BankPicker()
}Do
- Place every detail block your methods can need, even if you design for cards only. Each draws nothing when it does not apply.
Don't
- Don't place
MethodDetailsnext to yourCardFields: it draws the card form too, and two card blocks stop the payment.
5. Card
5.1 Card fields
Default. Cashier.CardField(.number) draws one card input in the SDK's box, with its label and error line. The kinds are .number, .expiry, .securityCode and .holder.
| Default | Custom (Cashier.Pages) |
|---|---|
![]() | ![]() |
Customize.
- Theme: the sealed input takes the theme's font and colors:
.fieldBackground,.cardFieldBorder,.primaryText,.placeholderText,.error. - Template:
.cashierCardField { field in … }draws your frame for each input the card form takes. The accepted brands and the protection note stay under your fields. - Own layout:
Cashier.CardField(.number) { field in … }. You draw the label, the border and the error line; the SDK draws the sealed input inside. The card data never leaves it.
struct MyCardField: View {
let field: Cashier.CardFieldContext
var body: some View {
VStack(alignment: .leading) {
Text(field.state.label)
.accessibilityHidden(true) // the sealed input reads the SDK label already
.onTapGesture { field.focus() }
field.input
.padding(.horizontal, 12)
.overlay(RoundedRectangle(cornerRadius: 8).stroke(field.state.issue == nil ? .gray : .red))
if let issue = field.state.issueText {
Text(issue).foregroundStyle(.red)
}
}
}
}
Cashier.CardField(.number) { field in MyCardField(field: field) }
Cashier.CardField(.expiry) { field in MyCardField(field: field) }
Cashier.CardField(.securityCode) { field in MyCardField(field: field) }
Cashier.CardField(.holder) { field in MyCardField(field: field) }| Name | Type | Description |
|---|---|---|
state.kind | Cashier.CardFieldKind | .number, .expiry, .securityCode or .holder. |
state.label | String | The SDK's label. The security code takes the card brand's name for it. |
state.placeholder | String | The SDK's placeholder. |
state.isEmpty | Bool | The input holds nothing. |
state.isValid | Bool | The input holds a valid value. |
state.isFocused | Bool | The input has the focus. |
state.issue | CashierFieldIssue? | .required, .invalid or .brandNotAccepted. Nil when no issue shows. |
state.issueText | String? | The SDK's text for the issue. |
state.brand | CashierCardBrand? | The brand read from the number so far, for example .visa. Number only. |
focus() | Bool | Moves the focus to the input, for a tap on your label. Returns false when the input is not on screen. |
input | CashierSealedInput | The sealed input. Place it inside your frame. |
sdkView | SDKCardFieldView | The SDK's own field: box, label and issue line. |
Do
- Write all four fields. A field the card does not take draws nothing, for example the security code of a payout card.
- Call
focus()when the customer taps your label. - Set the field roles of the theme, so the sealed input matches your frame.
- In your own scroll view, scroll to the first field with an issue after a tap on the disabled main button. The SDK's pages scroll to the card form for you.
Don't
- Don't use
CardFields together withCardForm,SavedCardCodeorMethodDetails. Two inputs of the same kind stop the payment (layout_incomplete, reasonduplicateSealed). - Don't put a view with a gesture on top of
field.input: it blocks the input. Keep your frame around it. - Don't leave an input out. The main button stays disabled, and
layout_incompletenames it, for examplecashier.cardField.securityCode.
While the saved cards load, each field shows the SDK's card loader, one field high, and does not call your closure yet.
5.2 Saved card security code
Default. Cashier.SavedCardCode() is the security code field of a saved card.
Customize. CardFields cover saved cards too: a saved card takes .securityCode, and .holder when it has no known name. With your four CardFields on the page, you need no SavedCardCode.
HStack {
Text("Saved card")
Spacer()
Cashier.CardField(.securityCode) { field in field.input.frame(width: 80) }
}Don't
- Don't put a tap gesture on a whole row that holds the input: put it on your text only.
5.3 Focus and VoiceOver
| Modifier | Description |
|---|---|
cashierFocused(_:equals:) | Ties a CardField to your focus value. Setting the value focuses the input; a tap into the input sets it. Keep the value in @State: @FocusState drops a value that names a card field. |
cashierAnnouncesErrors(_:) | Turns the SDK's VoiceOver announcement of a new card field issue on or off. Turn it off when your UI announces issueText itself. |
enum CardFocus: Hashable { case number, expiry, securityCode }
@State private var focus: CardFocus?
Cashier.CardField(.number) { field in
MyCardField(field: field)
.onChange(of: field.state.isValid) { _, isValid in
if isValid { focus = .expiry } // a complete number moves on to the expiry date
}
}
.cashierFocused($focus, equals: .number)
Cashier.CardField(.expiry) { field in MyCardField(field: field) }
.cashierFocused($focus, equals: .expiry)
Cashier.CardField(.securityCode) { field in MyCardField(field: field) }
.cashierFocused($focus, equals: .securityCode)5.4 Card form and save-card note
Default. Cashier.CardForm() is the group of card inputs for a new card, with the accepted brands and the protection note. Cashier.SaveCardNote() is the note that the new card is saved for later payments.
Customize.
- Settings:
CashierConfiguration.cardprefills and locks the cardholder name. See Card. - Theme and texts: the field roles, the corner radius, the card texts.
- For your own frames, use
CardFields (§5.1) instead ofCardForm.
Do
- Use
CardFormwhen the SDK's look of the card inputs is fine for you: it is the shortest way.
6. Method and billing fields
6.1 Method field
Default. Cashier.MethodField(id) draws one field of the selected method's details, by the field's server name, for example a wallet ID or an account number. It draws nothing while the method details do not show that field.
Customize. Own layout: Cashier.MethodField(id) { field in … } puts your frame around the SDK's field. The SDK's field (input) is sealed and already has its label, its input and its issue line; you add the background, the border, an icon or a required mark.
struct MyFieldFrame<Field: View>: View {
let state: Cashier.FieldState
@ViewBuilder let field: Field
@Environment(\.cashierResolvedTheme) private var theme
var body: some View {
field
.padding(12)
.background(theme.color(.cardSurface), in: RoundedRectangle(cornerRadius: theme.cornerRadius))
.overlay(RoundedRectangle(cornerRadius: theme.cornerRadius)
.stroke(state.hasIssue ? theme.color(.error) : .clear))
}
}
Cashier.MethodField(Cashier.MethodFieldID(rawValue: "account_number")) { field in
MyFieldFrame(state: field.state) { field.input }
}| Name | Type | Description |
|---|---|---|
Cashier.MethodFieldID(rawValue:) | The field's server name, as your integration with Praxis names it. | |
state.isRequired | Bool | The field must be filled. |
state.isEmpty | Bool | The field holds nothing. |
state.hasIssue | Bool | The field shows an issue now. |
input | CashierSealedField | The SDK's field: label, input and issue line. Place it in your frame. |
Do
- Draw every field each of your methods has, or use
Cashier.MethodFields(). OneMethodFieldon screen counts as the method fields for the required-block rule, so the SDK cannot tell you about a field you left out.
Don't
- Don't add your own label or error text: the SDK's field has both.
6.2 Billing field
Default. Cashier.BillingField(kind) draws one billing field. It draws nothing while the billing section does not show the field. The kinds are .fullName, .country, .address, .city, .zip, .state, .phone and .email.
Customize. Own layout: Cashier.BillingField(kind) { field in … }, with the same context as the method field: state (isRequired, isEmpty, hasIssue) and the sealed input.
Cashier.BillingField(.phone) { field in
MyFieldFrame(state: field.state) { field.input }
}The country field opens the SDK's country sheet. You cannot replace the sheet, but you can choose which countries it offers and which come first:
let configuration = CashierConfiguration(
billingFields: CashierBillingFields(
countries: CashierCountryList(preferred: ["DE", "AT", "CH"], allowed: nil) // nil offers every country
)
)Do
- Draw every billing field the billing section can show, or use
Cashier.BillingForm().
Don't
- Don't try to read or fill the values from code. Prefill comes from the session and the configuration.
6.3 Method fields and billing form
Default. Cashier.MethodFields() draws all the extra fields of the selected method. Cashier.BillingForm() draws all the billing and contact fields the payment needs, with its own heading.
Customize.
- Settings:
billingFieldssets each billing field editable, read-only or hidden. See Billing fields.paymentMethods.prefillsFieldsfills method fields from the customer profile. - Hooks:
fieldRules,skippedFieldChecksandfieldAdjustmentsadd checks, hide or require fields, and set default values. See Fields and methods. - Theme:
fieldLabelStyle(label above, floating label or no label), the field roles, the corner radius. - To frame single fields, use
MethodFieldandBillingField(§6.1, §6.2).
7. Promotions
7.1 Bonus section
Default. Cashier.BonusSection() shows the chosen bonus, or a trigger to choose one. A tap opens the SDK's bonus chooser. It shows with promotions.style .bonusList.
Customize.
- Settings:
CashierConfiguration.promotions. See Promotions. - Theme: the role
.cardSurface, the text styles.bonusTitleand.badge. - Template:
.cashierHide(.promotions). - Own layout:
Cashier.BonusSection { bonus in … }. For the full list of bonuses, readsnapshot.bonuses.
struct MyBonusChips: View {
let bonus: Cashier.BonusSectionContext
@Environment(CashierSession.self) private var cashier
@Environment(\.cashierText) private var text
var body: some View {
HStack {
ForEach(cashier.snapshot.bonuses, id: \.id) { item in
MyChip(item.title, isSelected: bonus.state.chosen?.id == item.id) { bonus.choose(item.id) }
}
MyChip(text(.no_bonus), isSelected: bonus.state.chosen == nil) { bonus.choose(nil) }
}
}
}
Cashier.BonusSection { bonus in MyBonusChips(bonus: bonus) }| Name | Type | Description |
|---|---|---|
state.chosen | Cashier.Bonus? | The chosen bonus (id, title, percentage), or nil for none. |
state.showsChooser | Bool | The customer can open the bonus chooser. |
openChooser() | Opens the SDK's bonus chooser. | |
choose(_:) | Chooses a bonus by its id, or none with nil. | |
sdkView | SDKBonusSectionView | The SDK's own section. |
snapshot.bonuses | [CashierBonusInfo] | The bonuses offered for the method and the currency (id, title). |
Do
- Always offer "no bonus".
Don't
- Don't change a bonus title: it is the offer's text.
7.2 Promotion code
Default. Cashier.PromoCode() shows a link to add a promotion code; a tap opens the code input with its Apply button; an applied code shows with its bonus and a remove action. It shows with promotions.style .codeField.
Customize.
- Settings:
CashierConfiguration.promotions. - Theme: the roles
.inputBorderand.appliedButtonDisabled, the text style.promoLink. - Template:
.cashierHide(.promotions). - Own layout:
Cashier.PromoCode { promo in … }. The code input is sealed: you place it while the phase is.open. Once a code is applied,state.appliedCodegives it when it is one of the session's bonuses.
Cashier.PromoCode { promo in
switch promo.state.phase {
case .closed:
Button("Have a promotion code?") { promo.open() }
case .applied:
HStack {
Text(promo.state.appliedCode ?? "Code applied")
Text(promo.state.bonusTitle ?? "")
Button("Remove") { promo.remove() }
}
default: // .open
HStack {
promo.input
Button("Apply") { promo.apply() }
.disabled(!promo.state.canApply)
}
}
}| Name | Type | Description |
|---|---|---|
state.phase | Cashier.PromoCodePhase | .closed, .open or .applied. |
state.canApply | Bool | The input holds a code. |
state.bonusTitle | String? | The title of the bonus the applied code gives. |
state.appliedCode | String? | The applied code when it is one of the session's bonuses, for example "welcome-50". Nil before a code is applied, and for a code that matched no bonus: that code is the customer's own text, sent with the payment for Praxis to check, and stays in the SDK's views. |
open() | Opens the code input. | |
apply() | Bool | Applies the typed code. Returns false while the input is closed or empty. |
remove() | Removes the applied code. | |
input | CashierSealedPromoInput | The sealed code input. The text the customer types never passes through your app. |
sdkView | SDKPromoCodeView | The SDK's own promotion code piece. |
Do
- Handle every phase, with a
defaultcase:PromoCodePhaseis a struct, so a new phase never breaks your build.
Don't
- Don't enable Apply while
canApplyis false.
7.3 Promotions
Default. Cashier.Promotions() draws BonusSection or PromoCode, as promotions.style decides, in one place.
Customize. promotions.style (nil turns promotions off, data request included); template: .cashierHide(.promotions). For your own look, place BonusSection or PromoCode with a closure instead.
Don't
- Don't place
Promotionstogether withBonusSectionorPromoCode: the piece would show twice.
8. Total, terms and main button
8.1 Total to pay
Default. Cashier.TotalToPay() shows the total line with the amounts. A tap opens the payment summary with the fee details.
| Total line | Payment summary |
|---|---|
![]() | ![]() |
Customize.
- Texts and theme: the row labels, the text style
.totalAmount. - Own layout:
Cashier.TotalToPay { total in … }. Your view is a frame: the line with the amounts is the SDK'stotal.sdkView, and only it counts as the total.
Cashier.TotalToPay { total in
HStack {
Button("Details") { total.openSummary() }
Spacer()
total.sdkView
}
}| Name | Type | Description |
|---|---|---|
state.labels | [String] | The labels of the rows, in order, in the session language, for example Total to pay. |
openSummary() | Opens the SDK's payment summary. | |
sdkView | SDKTotalToPayView | The SDK's line with the amounts. Place it fully visible: the payment waits until it shows. |
Do
- Keep the total near the main button, on the page that pays.
Don't
- Don't draw the total from
snapshot.totalin place ofsdkView: the main button stays disabled until the SDK's line shows.
8.2 Terms
Default. Cashier.Terms() shows the terms box: a checkbox and the legal text with its links. For a wallet, it shows the wallet's terms text with no box.
Customize.
- Texts: the terms texts, for example
.agree_with_terms_of_service. - Theme: the roles
.highContrastand.termsError, the text style.terms. - Own layout:
Cashier.Terms { terms in … }. You draw the box; the legal text with its links is sealed (terms.legalText).
Cashier.Terms { terms in
HStack(alignment: .top) {
if terms.state.needsConsent {
MyCheckbox(isOn: terms.state.isAccepted, showsError: terms.state.showsError) {
terms.setAccepted(!terms.state.isAccepted)
}
}
terms.legalText
}
}| Name | Type | Description |
|---|---|---|
state.needsConsent | Bool | The customer must tick a box. False for a wallet's terms text. |
state.isAccepted | Bool | Consent is given. |
state.showsError | Bool | The customer tried to pay without consent. |
setAccepted(_:) | Gives or withdraws consent from your box. Giving consent sends the event terms_accepted_by_code. | |
legalText | CashierSealedLegalText | The legal text with its links. Place it fully visible: it counts as the terms, your box does not. |
sdkView | SDKTermsView | The SDK's own terms: box and text. |
Do
- Place
terms.legalTextalso whenneedsConsentis false. - Call
setAccepted(_:)only from the customer's tap, and show your error state whenshowsErroris true. - Place
Termson the page that checks.terms, or on the last page: the last page shows the terms unless an earlier page checked them.
Don't
- Don't tick the box from code, and don't hide or shrink the legal text.
8.3 Main button
Default. Cashier.MainButton() shows Continue on a page before the last one and Deposit or Withdraw on the page that pays (Authorize for a card authorization, Get Payment Details for a bank wire), or the Apple Pay button when Apple Pay pays. A note can show under it, for example the deposit limit alert.
| Default | Custom (Cashier.Pages) |
|---|---|
![]() | ![]() |
Customize.
- Texts:
CashierTexts(depositButton:withdrawalButton:), or thedepositandwithdrawkeys per language. See Texts. - Theme: the brand colors,
brandTextColorLight/brandTextColorDark,buttonShape,cornerRadius, the text style.button. - Template:
.cashierMainButton { button in … }draws your button everywhere the template shows it. - Own layout:
Cashier.MainButton { button in … }.
struct MyMainButton: View {
let button: Cashier.MainButtonContext
var body: some View {
if let applePay = button.applePay {
applePay // drawn by the SDK
} else {
Button {
button.perform()
} label: {
if button.state.isBusy { ProgressView() } else { Text(button.state.label) }
}
.buttonStyle(MyPillStyle(isEnabled: button.state.isEnabled)) // looks disabled, still takes the tap
}
if let notice = button.state.notice {
Text(notice).font(.footnote)
}
}
}To keep the SDK's button and add views around it, place button.sdkView in your view.
| Name | Type | Description |
|---|---|---|
state.kind | Cashier.MainButtonKind | What a tap does: .continue, .final (pays), .changeCurrency, .applePay or .walletContinue. |
state.label | String | The button text, for example Continue or Deposit 50.00 EUR. |
state.isEnabled | Bool | The button takes taps. |
state.isBusy | Bool | A payment runs: show your busy state. |
state.notice | String? | The note to show under the button, or nil. |
perform() | Bool | Does what a tap on the SDK's button does now. On a disabled button it shows the errors of the page, as the SDK's button does, and returns false. Does nothing for .applePay. |
applePay | CashierSealedApplePayButton? | The Apple Pay button. Not nil only for .applePay: draw it in place of your button. |
sdkView | SDKMainButtonView | The SDK's own button for this state. |
Do
- Show
state.label: it has the right word for the page, the method and your texts. - Draw the disabled look from
isEnabled, but let the tap reachperform(), so the customer sees what is missing. - Keep the main button on every page. It is a required block.
Don't
- Don't call
perform()without the customer's tap. - Don't draw your own Apple Pay button: only
button.applePaycan pay with Apple Pay.
9. Outcome
9.1 Outcome and the single screens
Default. Cashier.Outcome() draws every screen after the form, with the header on top: loading, processing, partial approval, the bank details of a bank wire, the retry and recovery pages after a decline, the pending withdrawals list, the result, the error screens, and the screen shown when no method is available. Cashier.Pages shows it as the outcome page unless you pass your own.
| Processing | Bank details | No methods |
|---|---|---|
![]() | ![]() | ![]() |
| Block | Default |
|---|---|
Cashier.Loading() | The loading screen while the session starts. |
Cashier.Processing() | The wait while the payment status is checked. |
Cashier.BankDetails() | The bank details of a manual bank wire, with copy and download. |
Cashier.NoMethods() | The screen shown when no payment method can pay. |
Cashier.TransactionResult() | The result (§9.2). |
Cashier.PartialApproval() | The partial approval decision (§9.3). |
Cashier.ErrorScreen() | The error screens (§9.4). |
Customize.
- Theme and texts for every screen;
resultsettings for the result screen (Result screen);returnsAfterResult: trueto skip the SDK's result screens and show your own fromonResult(Return after the result). - Own layout: wrap
Cashier.Outcome()in your frame. This keeps every screen:
Cashier.Pages {
…
} outcome: {
VStack(spacing: 0) {
MyBrandBar()
Cashier.Outcome()
}
}- Own layout, your own error screens: show
Cashier.ErrorScreen { … }while the step is.error, andCashier.Outcome()otherwise (§9.4). - Own layout, your own result screen: build the outcome page from the single blocks. Each one draws only on its own screen. Add
Cashier.Header()on top, asCashier.Outcome()does, so the customer can close.
} outcome: {
VStack(spacing: 0) {
Cashier.Header()
Cashier.Loading()
Cashier.Processing()
Cashier.PartialApproval()
Cashier.BankDetails()
Cashier.TransactionResult { result in MyResult(result: result) }
Cashier.ErrorScreen()
Cashier.NoMethods()
}
}
Screens with no single blockThe retry page and the recovery page after a decline, and the list of pending withdrawals, have no block of their own: only
Cashier.Outcome()draws them. An outcome page built from the single blocks shows nothing on those screens. KeepCashier.Outcome()if your methods can decline with a retry offer or you take withdrawals, or usereturnsAfterResultfor your own result screen. See §11.
Don't
- Don't put outcome blocks on a form page: they belong in the outcome page.
- Don't look for a closure on
Loading,Processing,BankDetailsorNoMethods: they are SDK only.
9.2 Transaction result
Default. Cashier.TransactionResult() shows the result: an icon, the title, the amount, the details that result settings turn on (decline reason, date, fee, total, bonus, payment instrument, billing descriptor), and the buttons, such as Try again.
| Default | Custom (Cashier.Pages) |
|---|---|
![]() | ![]() |
Customize.
- Settings:
CashierConfiguration.result(CashierResultOptions). - Texts and theme: the result titles, the roles
.strongText,.errorSoftand.pendingIconCircle, the text styles.resultTitleand.resultRow. - Own layout:
Cashier.TransactionResult { result in … }, in an outcome page of single blocks (§9.1). For the status and the ids, readsnapshot.result.
struct MyResult: View {
let result: Cashier.TransactionResultContext
@Environment(CashierSession.self) private var cashier
var body: some View {
VStack(spacing: 16) {
MyStatusIcon(status: cashier.snapshot.result?.status)
if let title = result.state.title {
Text(title).cashierFont(.resultTitle)
}
if let amount = result.state.amount, let currency = result.state.currency {
Text(amount.formatted(.currency(code: currency)))
}
ForEach(result.state.buttons, id: \.action) { button in
Button(button.label) { result.perform(button.action) }
}
}
}
}| Name | Type | Description |
|---|---|---|
state.title | String? | The title, in the session language. |
state.amount | Decimal? | The amount the screen shows. |
state.currency | String? | The currency of amount. |
state.buttons | [Cashier.ResultButton] | The buttons, in order: each has an action and a label. |
perform(_:) | Does what the SDK's button for the action does: .tryAgain, .goBack, .myAccount, .makeAnotherPayment or .withdrawalGoBack. | |
sdkView | SDKTransactionResultView | The SDK's own result screen, with its details. |
snapshot.result | CashierResult? | The result: status, transactionID, orderID, traceID, paymentMethod, cardBrand, errorCode and more. See Results. |
Do
- Show a different look for pending and failed payments: read
snapshot.result?.status. - Show the buttons the state gives you, with their labels.
- When you need the details the
resultsettings turn on, showresult.sdkView, the SDK's whole result screen, instead: your state does not hold them.
Don't
- Don't credit the customer from the result on screen. Your server waits for the Payment Notification.
9.3 Partial approval
Default. Cashier.PartialApproval() shows the amount the provider approved and the amount asked for, a countdown, and accept and decline buttons. When time runs out, the Cashier declines on its own.
Customize.
- Texts and theme: the
partialApproval…texts. - Own layout:
Cashier.PartialApproval { partial in … }, in an outcome page of single blocks (§9.1).
Cashier.PartialApproval { partial in
let currency = partial.state.currency ?? ""
VStack(spacing: 12) {
Text("\((partial.state.approvedAmount ?? 0).formatted()) of \((partial.state.requestedAmount ?? 0).formatted()) \(currency) approved")
Text("\(partial.state.secondsLeft) s left")
Button("Accept") { partial.accept() }
Button("Decline") { partial.decline() }
}
.disabled(partial.state.isDeciding)
}| Name | Type | Description |
|---|---|---|
state.approvedAmount | Decimal? | The amount the provider approved. |
state.requestedAmount | Decimal? | The amount the customer asked for. |
state.currency | String? | The currency of both amounts. |
state.secondsLeft | Int | The seconds left before the Cashier declines on its own. |
state.isDeciding | Bool | A decision is being sent: accept and decline do nothing now. |
accept() | Accepts the approved amount. | |
decline() | Declines the approved amount. | |
sdkView | SDKPartialApprovalView | The SDK's own screen. |
Do
- Show both amounts and the countdown.
Don't
- Don't accept or decline for the customer.
9.4 Error screen
Default. Cashier.ErrorScreen() shows the error screen of the moment: an icon, a title, a description and, on most screens, "Need help? Contact Support" and "Go back".
state.kind | When | "Go back" |
|---|---|---|
.sessionUnavailable | The session could not be read | No button |
.invalidToken | The session token is empty | No button |
.generic | Any other failure | Back to the first page |
.errorDetails | A failed payment whose answer has error details. title is nil: the details are server text | Back to the first page |
.methodUnavailable | The payment method is not available | Back to the first page |
.code101 | The method's options could not be read | Back to the first page |
.sessionExpired | The session expired | Closes the Cashier |
.amountAboveBalance | The session's withdrawal amount is above the balance | Closes the Cashier |
.cardPayoutUnavailable | A card withdrawal has no saved card and no other method | Closes the Cashier |
.noPayoutAccount | The withdrawal method has no saved account to pay to | Closes the Cashier |
Customize.
- Texts and theme: the error texts, for example
.session_expiredand.go_back, the role colors andbuttonShape. - Template:
.cashierErrorScreen { error in … }draws your view under the header, wherever the template shows an error. - Own layout:
Cashier.ErrorScreen { error in … }, shown while the step is.error:
struct MyOutcome: View {
@Environment(CashierSession.self) private var cashier
var body: some View {
if cashier.snapshot.step == .error {
VStack(spacing: 0) {
Cashier.Header()
Cashier.ErrorScreen { error in MyErrorPage(error: error) }
}
} else {
Cashier.Outcome()
}
}
}
struct MyErrorPage: View {
let error: Cashier.ErrorScreenContext
@Environment(\.cashierText) private var text
var body: some View {
if let title = error.state.title {
VStack(spacing: 12) {
Text(title).font(.title2.bold())
if let message = error.state.message { Text(message) }
if error.state.showsGoBack {
Button(text(.go_back)) { error.goBack() }
if error.state.canContactSupport {
Button(text(.contact_Support)) { error.contactSupport() }
}
}
}
} else {
error.sdkView // .errorDetails: server text, only the SDK draws it
}
}
}Pass MyOutcome() as the outcome of your Cashier.Pages.
| Name | Type | Description |
|---|---|---|
state.kind | Cashier.ErrorScreenKind | Which error shows (table above). |
state.title | String? | The title, in the session language. Nil for .errorDetails. |
state.message | String? | The description under the title, or nil. |
state.showsBackArrow | Bool | The SDK's screen shows a back arrow at the top. It does what goBack() does. |
state.showsGoBack | Bool | The SDK's screen shows "Need help? Contact Support" and "Go back". |
state.canContactSupport | Bool | "Contact Support" opens the session's support website or email. |
goBack() | Does what "Go back" does: back to the first page, or the end of the session. Does nothing on a screen with no way back. | |
contactSupport() | Opens the support website or email. Does nothing when canContactSupport is false. | |
sdkView | SDKErrorScreenView | The SDK's own error screen. |
Do
- Show
error.sdkViewwhentitleis nil. - Take the action labels from
@Environment(\.cashierText):.go_back,.need_helpand.contact_Support. - Offer a way out whenever
showsGoBackorshowsBackArrowis true. - Switch over
state.kindwith adefaultcase:ErrorScreenKindis a struct, so a new kind never breaks your build.
Don't
- Don't build error screens of your own from
snapshot.result?.errorCode: the SDK picks the screen and its way back. - Don't promise "Try again" on
.sessionExpiredor a withdrawal error: going back closes the Cashier there.
10. Theme, texts and appearance
This section covers the theme and texts only as far as they apply to blocks. Every option is described in Configuration & Customization.
10.1 Theme for blocks and sealed parts
Every block the SDK draws, and every sealed part you place in your own frame (card inputs, method and billing fields, the promotion code input, the legal text, the total line), takes its look from CashierTheme: the brand colors, the font, the button shape or corner radius, the field label style and the role colors.
When you draw your own frames, set the roles the sealed parts use, so they match your design:
let theme = CashierTheme(
brandColorLight: "#F5B841",
brandColorDark: "#F5B841",
fontName: "Inter",
buttonShape: .pill,
roleColors: [
.screenBackground: Color("Background"),
.fieldBackground: Color("Field"),
.cardFieldBorder: Color("Field"),
.primaryText: Color("Text"),
.placeholderText: Color("TextMuted"),
.error: Color("Error")
]
)Draw your own views with the same values: read @Environment(\.cashierResolvedTheme) and use .cashierFont(_:) for text. See The theme in your own views.
Spacing and type sizes are not theme values. To change them in a block, draw the block yourself.
10.2 Light and dark
CashierTheme.appearanceis.light,.darkor.system. With.system, the Cashier reads the device setting when it opens and keeps it while it is open.- The SDK draws its blocks and sealed parts with the light or dark palette, your brand colors and your role colors.
CashierView,.cashierSheet,CashierViewControllerandCashierScopeset the color scheme inside them to the Cashier's appearance, your views there included. The rest of your app keeps its own.- A role color is the same in both appearances. For different light and dark values, use a color from your asset catalog, or the brand colors.
10.3 Texts in your own blocks
- The texts in a block's state (labels, issue texts, button labels, titles) come in the session language, which can differ from the app's. Show them as they are.
- For an SDK text in your own view, read
@Environment(\.cashierText):text(.go_back),text(.invalid, field: .expiry). It reads yourCashierTextsfirst, then the server texts. A text with placeholders comes back as its template. - Translate your own words into the session language,
snapshot.language, for example"de". - For
heandar,snapshot.isRightToLeftis true andCashierViewandCashierScopemirror the Cashier, your views inside it included. Amounts and card numbers stay left to right. - Never put card data, customer data or server text into
CashierTexts.
11. What blocks cannot do
The table says what to use instead.
| You cannot | Why | Use instead |
|---|---|---|
| Show a saved card's last digits, brand or expiry date in your own UI, or remove a saved card from your own UI | CashierMethodInfo has no card details, and no command removes a saved method | Show SelectedMethod's sdkView; turn on removal in the SDK's picker with paymentMethods.allowsRemoval |
| Draw your own country picker | The country the customer picks is personal data, and the sheet is the SDK's | Order and limit the sheet with CashierCountryList |
| Show the fee, total paid, decline reason, date, bonus, payment instrument or billing descriptor in your own result screen | Cashier.TransactionResultState holds the title, amount, currency and buttons only | Show result.sdkView with the result settings you need |
| Show the exchange rate on the result screen | No block or state holds it | |
| Draw your own loading, processing or no-methods screen | Loading, Processing and NoMethods take no closure | Theme and texts; wrap Cashier.Outcome() in your frame |
| Draw your own result screen and keep the retry and recovery pages and the pending withdrawals list | Those screens have no block of their own: only Cashier.Outcome() draws them | Keep Cashier.Outcome(), or use returnsAfterResult and show your result screen from onResult |
| Draw your own Deposit / Withdraw tabs or balance | Cashier.HeaderState has neither, and no command switches the intent | Place header.sdkView in your header |
What's next
- Layouts & Examples: where blocks go, one page or several.
- Styled Examples with Cashier.Pages: four cashiers drawn by the app from these blocks, with their code.
- Configuration & Customization: every setting, the theme, the texts and the slots.
- Results, Errors & Troubleshooting
- SDK Reference
Updated about 18 hours ago


















