Layouts
From the predefined template to your own layout.
This page shows how to build the Cashier: from the predefined template to your own layout (§1), and the blocks and containers a layout is made of (§2).
1. Layouts and examples
1.1 Choose your approach
There are five levels of integration. Start at the top and go down only as far as you need. Every level keeps card and customer data inside the SDK.
| Level | What you write | What you can change | Example |
|---|---|---|---|
| 1. Predefined template | One view | Nothing in the layout. Your configuration (settings, theme, texts) and the payment methods set at Praxis still apply | §1.2.1 |
| 2. Template + configuration | A CashierConfiguration | Features on or off, theme, texts, close button, behavior after the result | §1.2.2 |
| 3. Template + slots | A few slot methods on the template | Your header and footer, hidden blocks, your own views between blocks | §1.2.3 |
| 4. Your own layout | Your pages, built from SDK blocks | The order of blocks, how many pages and what each page checks, your views next to blocks, your outcome page | §1.3 |
| 5. Your own controls | Your views over CashierSnapshot and CashierSession commands | For example your own method list or amount buttons | §1.3.3 |
The building parts are described in §2 Blocks and containers: blocks (Cashier.Amount(), Cashier.SelectedMethod(), …), the container Cashier.Pages with its Cashier.Pages, and the required-block rule.
1.2 Quick integration: the predefined template
The SDK ships two pre-built layouts. Cashier.AmountFirstLayout is the predefined template: CashierView, .cashierSheet and CashierViewController use it when you pass no layout. Cashier.OnePageLayout puts the same blocks on one page (§1.2.4). Both are built only from Cashier.Pages and the public blocks, so you can rebuild either one yourself (§1.3.1, §1.3.4).
The predefined template shows up to three pages. Pages a payment does not need are skipped, for example the billing page when the method needs no billing data.
| Page | Content | Bottom area |
|---|---|---|
| 1. Amount | Header, amount and currency, quick amounts, bonuses, selected payment method, promotion code, amount change note | Total to pay, terms, main button. Footer below |
| 2. Method details | Header, step title, method details (card form, saved card CVV, card or Apple Pay switch, method fields or bank list) | Terms (decline recovery only), save-card note, main button |
| 3. Billing | Header, step title, billing form | Terms (decline recovery only), main button |
After the payment, the template shows processing, 3-D Secure or provider pages, partial approval, decline recovery and result screens.
1.2.1 The predefined template as is
CashierView(token: token, environment: cashierEnvironment) { result in
handle(result)
}The same in a sheet, and in UIKit:
.cashierSheet(isPresented: $showsCashier, token: token, environment: cashierEnvironment) { result in
handle(result)
}
let cashier = CashierViewController(token: token, environment: cashierEnvironment) { result in handle(result) }
present(cashier, animated: true)1.2.2 The template with configuration
Change what the template shows without touching the layout. Turning a feature off, or leaving promotions unset, also stops the SDK from fetching their data.
// A fixed-amount deposit in your brand colors: no amount editing or currency change, no quick amounts or promotions
// (both are off unless you set them up).
let configuration = CashierConfiguration(
features: CashierFeatures.default.subtracting([.editableAmount, .currencyChange]),
theme: CashierTheme(brandColorLight: "#0F768A", brandColorDark: "#3FB6CC", buttonShape: .pill),
header: CashierHeaderOptions(balance: .hidden),
texts: CashierTexts(depositButton: "Deposit now"),
returnsAfterResult: true // close as soon as the result is known and show your own result screen
)
CashierView(token: token, environment: cashierEnvironment, configuration: configuration) { result in
handle(result)
}Which feature or setting controls which part of the template:
| Feature or setting | Blocks it affects |
|---|---|
.editableAmount | AmountField: editable, or the session amount as fixed text |
presetAmountEditable | AmountField: a session amount prefilled and editable instead of fixed text |
.amountLimits | AmountLimitHint, and the amount check |
.currencyChange | CurrencyLine: the currency sheet |
.savedInstruments | Saved cards and accounts in SelectedMethod's picker |
.applePay | Apple Pay in SelectedMethod's picker, and WalletSwitch in the card method |
header | Header: balance, Deposit / Withdraw tabs, back and close buttons |
amount.quickAmounts | QuickAmounts: no buttons unless you set lists or basedOnLastDeposit |
paymentMethods | SelectedMethod's picker: order, limits, fees, card expiry, removal |
promotions.style | Promotions: BonusSection for .bonusList, PromoCode for .codeField, nothing for nil |
billingFields | BillingForm: each field editable, read-only or hidden |
result | TransactionResult (in Outcome): the payment details shown |
footer | Footer: shows when at least one link is set |
All options are listed in Configuration.
1.2.3 The template with slots
Keep the template and add your branding. See Configuration & Customization §2.4 for every slot.
Slots are methods of the template. Pass the template as the last closure of CashierView and add the slots to it:
CashierView(token: token, environment: cashierEnvironment, configuration: configuration, onResult: handle) {
Cashier.AmountFirstLayout()
.cashierHeader { BrandHeader() } // your header on every page
.cashierFooter { Text("Payments are processed by Praxis") } // your footer on the amount page
.cashierHide(.quickAmounts) // hide a block
.cashierInsert(after: .selectedMethod) { LoyaltyHint() } // your view between blocks
}In a sheet, do the same inside .cashierSheet:
.cashierSheet(isPresented: $showsCashier, token: token, environment: cashierEnvironment, onResult: { handle($0) }) {
Cashier.AmountFirstLayout()
.cashierHide(.quickAmounts)
.cashierInsert(after: .selectedMethod) { LoyaltyHint() }
}In UIKit, use CashierSlots (see Configuration & Customization §2.4.4).
Replacing the header
Cashier.Headershows the back and close buttons, the Deposit / Withdraw tabs of a session with both intents, and the balance on a withdrawal. If you replace it, give your header a close button (CashierSlotContext.close()) and, on later pages, a back button (back()). Do not replace it in sessions with more than one intent, or the customer cannot switch tabs.
1.2.4 The one-page layout
Cashier.OnePageLayout shows the amount, the method, the method details and billing on one scrolling page. Its main button always pays: there is no Continue step. It takes the same configuration and slots as the predefined template.
CashierView(token: token, environment: cashierEnvironment, configuration: configuration, onResult: handle) {
Cashier.OnePageLayout()
.cashierHide(.quickAmounts)
}1.3 Your own layout from blocks
Pass your layout as the last closure of CashierView, .cashierSheet, or CashierViewController(session:layout:). Build it with Cashier.Pages: list one Cashier.Page per screen, in the order the customer goes through them. The SDK runs the same payment flow whatever the layout: it decides which sections a payment needs, what each block shows, and when the main button continues or pays. How pages and their checks work is explained in §2.2 and in Styled Examples §1.2.
Rules to keep in mind for every example below:
- Blocks go inside
Cashier.Pages. Put every block in a page, in a bottom area, or in the outcome page. For everything on one screen, use one page. See §1.3.7. - The pages are yours. Use as many pages as you like, in any order. Each page names the checks its main button runs before the customer may leave it (
validates:). A page opens the sections of its checks; the last page that shows opens every section no earlier page opened, and its main button pays. - Hide a page the payment does not need with
.cashierPageShown { page in page.isNeeded }, for example the billing page when the method needs no billing data. Do not putiforswitcharound a page. - Required blocks.
MainButtonon every page; on each page, the blocks of its checks; on the last page that shows, every block no earlier page checked. PutTermsin the bottom area of later pages too: it shows there for the terms step of a decline recovery. See §2.5. - Test every method your account offers with your layout. A missing block disables the main button and sends the
layout_incompleteevent.
1.3.1 Amount first, several pages
The predefined template written out, as a starting point to change. The customer enters the amount, picks the method, then fills in the method details and billing on their own pages.
struct AmountFirstCheckout: View {
var body: some View {
Cashier.Pages {
Cashier.Page("", validates: .method, .amount, .terms) {
Cashier.Header()
Cashier.Amount()
Cashier.QuickAmounts()
Cashier.BonusSection()
Cashier.SelectedMethod()
Cashier.PromoCode()
Cashier.AmountChangeNote()
} bottom: {
Cashier.TotalToPay()
Cashier.Terms()
Cashier.MainButton()
} footer: {
Cashier.Footer()
}
Cashier.Page("", validates: .methodDetails) {
Cashier.Header()
Cashier.StepTitle()
Cashier.MethodDetails()
} bottom: {
Cashier.Terms()
Cashier.SaveCardNote()
Cashier.MainButton()
}
.cashierPageScrolling(.contentOnly)
.cashierPageShown { page in page.isNeeded }
Cashier.Page("", validates: .billing) {
Cashier.Header()
Cashier.StepTitle()
Cashier.BillingForm()
} bottom: {
Cashier.Terms()
Cashier.MainButton()
}
.cashierPageScrolling(.contentOnly)
.cashierPageShown { page in page.isNeeded }
}
}
}
CashierView(token: token, environment: cashierEnvironment, onResult: handle) {
AmountFirstCheckout()
}The details and billing pages show only when the payment needs them. When neither is needed, the first page is the last page that shows, and its main button pays.
The titles are empty, as in the template: VoiceOver then moves to the top of a new page, and StepTitle takes the focus on later pages. If you give titles, give them in the customer's language. VoiceOver reads them, and your views can show them from @Environment(\.cashierPage).
The predefined template also sets spacing and screen margins. In your own layout, add.paddingand stacks as your design needs. Use@Environment(\.cashierResolvedTheme)andtheme.spacing(_:)to match the Cashier's spacing.
1.3.2 Payment method first, several pages
The customer picks the payment method first, then the amount. Only the order of blocks on the first page changes. AmountLimitHint shows the limits of the selected method under the amount.
struct MethodFirstCheckout: View {
var body: some View {
Cashier.Pages {
Cashier.Page("", validates: .method, .amount, .terms) {
Cashier.Header()
Cashier.SelectedMethod() // 1. the method; a tap opens the method picker
Cashier.AmountField() // 2. the amount
Cashier.CurrencyLine()
Cashier.AmountLimitHint() // the limits of the selected method
Cashier.QuickAmounts()
Cashier.AmountChangeNote()
Cashier.Promotions() // 3. the bonus list or the promotion code, as promotions.style decides
} bottom: {
Cashier.TotalToPay()
Cashier.Terms()
Cashier.MainButton()
}
Cashier.Page("", validates: .methodDetails) {
Cashier.Header()
Cashier.StepTitle()
Cashier.MethodDetails()
} bottom: {
Cashier.Terms()
Cashier.SaveCardNote()
Cashier.MainButton()
}
.cashierPageScrolling(.contentOnly)
.cashierPageShown { page in page.isNeeded }
Cashier.Page("", validates: .billing) {
Cashier.Header()
Cashier.StepTitle()
Cashier.BillingForm()
} bottom: {
Cashier.Terms()
Cashier.MainButton()
}
.cashierPageScrolling(.contentOnly)
.cashierPageShown { page in page.isNeeded }
}
}
}You can also give the method a page of its own before the amount: a page that validates .method, then an amount page that validates .amount, .method and .terms. Keep .method on the amount page, because a new currency can change or clear the method.
The method list needs an amountThe Cashier loads the payment methods once an amount above zero and a currency are set. Send
amountwhen you create the session, so the methods are ready when the Cashier opens. The amount is then fixed unless you setpresetAmountEditable: true. Without a session amount, the method picker fills in after the customer enters an amount.
1.3.3 Payment method first, with your own method list
Instead of the selected-method card and its picker, show every method as a list in your own design. Your view reads CashierSnapshot.methods and selects a method with CashierSession.selectMethod(id:). It sees only each method's id, name, type, logo and whether it is saved or in maintenance; saved cards appear as saved-<n> with an SDK name and no card digits.
struct MethodList: View {
@Environment(CashierSession.self) private var cashier
@Environment(\.cashierResolvedTheme) private var theme
var body: some View {
VStack(spacing: theme.spacing(.s8)) {
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).cashierFont(.body)
Spacer()
if cashier.snapshot.paymentMethod?.id == method.id {
Image(systemName: "checkmark")
}
}
.foregroundStyle(theme.color(.primaryText))
}
.disabled(method.isInMaintenance)
}
}
}
}
struct MethodListCheckout: View {
var body: some View {
Cashier.Pages {
Cashier.Page("", validates: .method, .amount, .terms) {
Cashier.Header()
MethodList() // your list
Cashier.Amount()
Cashier.Promotions()
} bottom: {
Cashier.TotalToPay()
Cashier.Terms()
Cashier.MainButton()
}
Cashier.Page("", validates: .methodDetails) {
Cashier.Header()
Cashier.StepTitle()
Cashier.MethodDetails()
} bottom: {
Cashier.Terms()
Cashier.SaveCardNote()
Cashier.MainButton()
}
.cashierPageScrolling(.contentOnly)
.cashierPageShown { page in page.isNeeded }
Cashier.Page("", validates: .billing) {
Cashier.Header()
Cashier.StepTitle()
Cashier.BillingForm()
} bottom: {
Cashier.Terms()
Cashier.MainButton()
}
.cashierPageScrolling(.contentOnly)
.cashierPageShown { page in page.isNeeded }
}
}
}Use the methodFilter hook to remove or reorder methods before they reach the list (see Configuration & Customization §3.4). selectMethod(id:) ignores unknown ids and expired saved cards. A method in maintenance opens its maintenance dialog when it is selected; this example disables it instead.
1.3.4 One-page Cashier
Everything the payment needs on one scrolling page. The main button always pays: there is no Continue step. This is how Cashier.OnePageLayout is built.
struct OnePageCheckout: View {
var body: some View {
Cashier.Pages {
Cashier.Page("") {
Cashier.Header()
Cashier.Amount()
Cashier.QuickAmounts()
Cashier.BonusSection()
Cashier.SelectedMethod()
Cashier.PromoCode()
Cashier.AmountChangeNote()
Cashier.MethodDetails() // card form, saved card CVV, method fields or bank list
Cashier.BillingForm() // shows only when the payment needs billing data
} bottom: {
Cashier.TotalToPay()
Cashier.Terms()
Cashier.SaveCardNote()
Cashier.MainButton()
} footer: {
Cashier.Footer()
}
}
}
}The only page is the last page, so it opens every section the payment needs and its main button pays. It needs no checks. Blocks that do not apply draw nothing, so the page adapts to the selected method: for example, the card form appears when the customer picks a card, and the billing form only when the method needs it.
1.3.5 Express checkout: fixed amount, one page
For a known amount, such as a top-up of a fixed value, combine a short one-page layout with features that lock the amount and skip what you do not need.
let configuration = CashierConfiguration(
features: CashierFeatures.default.subtracting([.editableAmount, .currencyChange])
) // quick amounts and promotions are off by default
CashierView(token: token, environment: cashierEnvironment, configuration: configuration, onResult: handle) {
Cashier.Pages {
Cashier.Page("") {
Cashier.Header()
Cashier.Amount() // the session amount as fixed text
Cashier.SelectedMethod()
Cashier.MethodDetails()
Cashier.BillingForm()
} bottom: {
Cashier.TotalToPay()
Cashier.Terms()
Cashier.MainButton()
}
}
}The amount comes from amount in your server's session request.
1.3.6 Several pages with your own header and result frame
Your own header on the first page, the SDK header on later pages (for the back button), and your branding around the SDK's result screens. The outcome page shows loading, processing, decline recovery, results and errors; wrap Cashier.Outcome rather than replacing it.
struct BrandedCheckout: View {
var body: some View {
Cashier.Pages {
Cashier.Page("", validates: .method, .amount, .terms) {
MyHeader() // reads @Environment(CashierSession.self)
Cashier.Amount()
Cashier.SelectedMethod()
Cashier.Promotions()
} bottom: {
Cashier.TotalToPay()
Cashier.Terms()
Cashier.MainButton()
} footer: {
MyTrustBadges()
}
Cashier.Page("", validates: .methodDetails) {
Cashier.Header()
Cashier.StepTitle()
Cashier.MethodDetails()
} bottom: {
Cashier.Terms()
Cashier.SaveCardNote()
Cashier.MainButton()
}
.cashierPageScrolling(.contentOnly)
.cashierPageShown { page in page.isNeeded }
Cashier.Page("", validates: .billing) {
Cashier.Header()
Cashier.StepTitle()
Cashier.BillingForm()
} bottom: {
Cashier.Terms()
Cashier.MainButton()
}
.cashierPageScrolling(.contentOnly)
.cashierPageShown { page in page.isNeeded }
} outcome: {
VStack(spacing: 0) {
MyBrandBar()
Cashier.Outcome()
}
}
}
}
struct MyHeader: View {
@Environment(CashierSession.self) private var cashier
var body: some View {
HStack {
Image("logo")
Spacer()
Button("Close") { cashier.close() }
}
.padding()
}
}Without an outcome: closure, Cashier.Pages shows Cashier.Outcome().
1.3.7 Keep every block inside Cashier.Pages
Every block must be inside Cashier.Pages: in a page's content, bottom area or footer, in the bottom area of the pages, or in the outcome page. Inside a page, wrap blocks in your own stacks, cards and views as you like. You can also put Cashier.Pages inside your own view, as every example on this page does.
Cashier.Pages tells the SDK how the sections are shown, and it switches to the outcome page for loading, processing, provider pages, results and errors. If you place blocks in your own views outside Cashier.Pages, nothing tells the SDK how the sections are shown. The SDK then opens only the amount section, so the method details and billing never show, and it sends layout_incomplete with the reason presentation.
To show everything on one screen, use one Cashier.Page (§1.3.4).
1.3.8 UIKit
Host any of the layouts above in UIKit with a session you hold:
let session = CashierSession(token: token, environment: cashierEnvironment, configuration: configuration) { result in
handle(result)
}
let cashier = CashierViewController(session: session) {
OnePageCheckout()
}
present(cashier, animated: true)
// Your app closes this session: session.close() when you no longer need it.1.4 Combining layouts with features
A layout decides where blocks go; features and settings decide whether they show. You can keep one layout and change the Cashier per market or per customer group with configuration only:
| Goal | Layout | Configuration |
|---|---|---|
| Full Cashier | AmountFirstLayout | .default |
| Everything on one page | OnePageLayout | .default |
| Returning customers, saved card first | §1.3.2 (method first) | .default |
| Fixed top-up | §1.3.5 | .default minus .editableAmount, .currencyChange; no quick amounts or promotions set |
| No promotions in a market | Any | promotions: CashierPromotionOptions(style: nil) for that market |
| Quick amounts per currency | Any | amount.quickAmounts with one list per currency |
| Card and saved cards only | Any | methodFilter hook keeping card methods and saved-<n> rows |
| Your own result screen | Any | returnsAfterResult: true, then show your screen from onResult |
1.5 Checklist for your own layout
- Every block is inside
Cashier.Pages, and there is noiforswitcharound a page. -
MainButtonis on every page: in the page's bottom area, or in the bottom area of the pages. - Each page draws the blocks of its checks:
MethodDetails(or the single detail blocks) for.methodDetails,BillingFormfor.billing,Termsfor.terms. - The last page that shows draws every block no earlier page checked.
TotalToPayis on the page that opens the amount section. -
Termsis in the bottom area of later pages too, for the terms step of a decline recovery. - A page the payment may not need has
.cashierPageShown { page in page.isNeeded }. - Only one card block (
CardForm,SavedCardCodeorMethodDetails) on screen at a time. -
Cashier.Headerkept, or your header has close and back buttons, in sessions with one intent only. - Tested with every payment method your account offers, with a deposit and a withdrawal if you use both, and with a declined payment that offers a retry.
- No
layout_incompleteevent in your logs while testing.
2. Blocks and containers
2.1 Overview
This section is the reference for blocks, containers and the rules they follow. For complete examples (amount first, payment method first, one page, several pages, express checkout), see §1.
The predefined template is Cashier.AmountFirstLayout; Cashier.OnePageLayout is the second pre-built layout. When slots are not enough, build your own layout from the same blocks: SwiftUI views in the Cashier namespace, such as Cashier.Amount() or Cashier.MainButton(). Each block reads what it needs from the session and draws nothing when it does not apply. Blocks take no data.
Pass your layout to CashierView, .cashierSheet or CashierViewController. Each wraps it in a CashierScope for you.
A payment has up to three sections: the amount (with the payment method), the method details and billing. The session decides which sections a payment needs. The container Cashier.Pages decides how they show. You list your Cashier.Pages, and each page names its checks:
| Check | Section it opens | Blocks the page must draw |
|---|---|---|
.method | Amount | None |
.amount | Amount | None |
.methodDetails | Method details | MethodDetails, or the single detail blocks |
.billing | Billing | BillingForm |
.terms | None | Terms |
A page opens the sections of its checks. The last page that shows also opens every section no earlier page opened, and its main button pays. Blocks of a section that is not open draw nothing. What each check makes the main button wait for is in Styled Examples §1.2.
Cashier.Pages shows Cashier.Outcome for loading, processing, results and errors, unless you pass your own outcome page.
2.2 Several pages
CashierView(session: session) {
Cashier.Pages {
Cashier.Page("", validates: .method, .amount, .terms) {
Cashier.Header()
Cashier.Amount()
Cashier.SelectedMethod()
} bottom: {
Cashier.TotalToPay()
Cashier.Terms()
Cashier.MainButton()
}
Cashier.Page("", validates: .methodDetails) {
Cashier.Header()
Cashier.StepTitle()
Cashier.MethodDetails()
} bottom: {
Cashier.Terms() // shows here only on the terms step of a decline recovery
Cashier.SaveCardNote()
Cashier.MainButton()
}
.cashierPageScrolling(.contentOnly)
.cashierPageShown { page in page.isNeeded }
Cashier.Page("", validates: .billing) {
Cashier.Header()
Cashier.StepTitle()
Cashier.BillingForm()
}
.cashierPageScrolling(.contentOnly)
.cashierPageShown { page in page.isNeeded }
} bottom: {
Cashier.Terms() // for the pages without their own bottom area
Cashier.MainButton()
}
}Each Cashier.Page has:
- A title, in the customer's language. VoiceOver reads it when the page shows. With an empty title, VoiceOver moves to the top of the new page instead, and a
StepTitleon it takes the focus. - Checks (
validates:): what the main button checks before the customer may leave the page. A page with no checks is fine as the last page. - Content, which scrolls.
- A bottom area (optional) that stays pinned above the keyboard. A page without one uses the
bottomofCashier.Pages. - A footer (optional) under the bottom area, for example
Cashier.Footer(). A page with a footer also has its own bottom area.
Write the pages one after the other. An if or a switch around a page is not supported. Use these modifiers on a page instead:
.cashierPageShown { page in page.isNeeded }shows the page only while the rule returns true. The rule runs again whenever the method, the amount or the currency changes.page.isNeededis true when the payment needs one of the page's checks (or the page has none);page.needs(.billing)asks about one check;page.snapshotis the Cashier's state..cashierPageShown(false)hides a page by a decision your app makes itself. A hidden page is skipped by the main button and by back..cashierPageScrolling(.contentOnly)keeps aCashier.Headerat the top of the content pinned while the content scrolls. The default,.wholePage, scrolls the header with the content, and the bottom area sticks to the bottom of the screen until its own place scrolls into view.
More about pages:
- The main button shows the next page that shows. On the last page that shows, it pays. When a payment check fails on the last page, the page that checks it shows again with its errors.
- Back (a swipe from the leading edge, the back button of
Cashier.Header, orCashierSession.back()) shows the page before. - Your views read the page the customer is on with
@Environment(\.cashierPage): its place (index,isFirst,isLast), the number of pages that show (count), itstitleandback(). See Styled Examples §5.2. - A new page slides in. Change the swipe and the transition with
.cashierPagesStyle(_:), for example.cashierPagesStyle(.inPlace(swipe: .backAndForward, transition: .fade)). - Each page is drawn only while it shows. Keep state that must outlive a page in your app or in the session.
2.3 One page
CashierView(session: session) {
Cashier.Pages {
Cashier.Page("") {
Cashier.Header()
Cashier.Amount()
Cashier.BonusSection()
Cashier.SelectedMethod()
Cashier.PromoCode()
Cashier.MethodDetails()
Cashier.BillingForm()
} bottom: {
Cashier.TotalToPay()
Cashier.Terms()
Cashier.MainButton()
}
}
}A single page is the last page: it opens every section the payment needs, and its main button pays.
Blocks outside Cashier.Pages. If you place blocks in your own stack instead, nothing tells the SDK how the sections are shown. The SDK opens only the amount section and sends layout_incomplete with the reason "presentation". Keep every block inside Cashier.Pages; for one screen, use one page.
2.4 Blocks
| Block | What it shows | Section |
|---|---|---|
Header | The title bar, back and close buttons | Every page |
Footer | The footer under the first page | Amount |
Amount | AmountField, CurrencyLine and AmountLimitHint together | Amount |
AmountField | The amount | Amount |
CurrencyLine | The currency, and the currency sheet when it can change | Amount |
AmountLimitHint | The method's lowest and highest amount | Amount |
QuickAmounts | Ready amount buttons | Amount |
Promotions | BonusSection or PromoCode, as promotions.style decides | Amount |
BonusSection | The bonuses the customer can pick | Amount |
PromoCode | The promotion code field | Amount |
SelectedMethod | The selected method and the method picker | Amount |
AmountChangeNote | A note when the method changes the amount | Amount |
TotalToPay | The fee and the total | Amount |
Terms | The terms box | Amount; details and billing during a decline recovery |
MainButton | Continue or Pay | Every page |
StepTitle | The title of a later page | Details, billing |
MethodDetails | The details of the selected method: one of the five blocks below | Details |
CardForm 🔒 | The card fields for a new card | Details |
SavedCardCode 🔒 | The CVV field for a saved card | Details |
WalletSwitch | The switch between the card and Apple Pay | Details |
MethodFields 🔒 | The fields of a non-card method | Details |
BankPicker | The bank list of a bank wire | Details |
SaveCardNote | The note that a new card is saved | Details |
BillingForm 🔒 | Billing and contact fields | Billing |
Outcome | Every screen after the form: loading, processing, retry and recovery pages, results, errors | Outcome |
Loading, Processing, TransactionResult, BankDetails 🔒, PartialApproval, ErrorScreen, NoMethods | The single outcome screens | Outcome |
🔒 Sealed: the block captures or shows card or personal data. You can place it, but you cannot rebuild it, read its values or put content inside it.
What each block shows by default, and how to draw it in your own design, is in the Blocks Catalog.
2.5 Required blocks
Some blocks carry legal or payment meaning. When a section that needs one is open, it must be on screen:
| Needed when | Block |
|---|---|
| Always | MainButton |
| The terms box shows | Terms |
| The total shows | TotalToPay |
| A new card | CardForm (or MethodDetails) |
| A saved card | SavedCardCode (or MethodDetails) |
| The card or Apple Pay switch shows | WalletSwitch (or MethodDetails) |
| The method has fields | MethodFields (or MethodDetails) |
| A bank wire | BankPicker (or MethodDetails) |
| The billing section | BillingForm |
In Cashier.Pages, a page before the last needs MainButton and the blocks of its own checks. The last page that shows needs every block the payment needs, except the blocks of checks an earlier page ran. A block counts only when it draws inside the Cashier.
When a required block is missing, the main button is disabled, no payment is sent, and the SDK sends layout_incomplete with the reason "requiredBlock". The event's missing names the blocks to draw, for example ["cashier.mainButton", "cashier.terms"]. Two card blocks on screen at once (two CardForm, or CardForm with SavedCardCode) give the reason "duplicateSealed" and stop the payment. Blocks outside Cashier.Pages give the reason "presentation" (§1.3.7). The pre-built layouts have every block.
Terms on later pagesIn a layout of several pages, put
Termsin the bottom area of the later pages too. The terms box shows there for the terms step of a decline recovery; without the block, the main button stays disabled on that step.
Test your layout with every payment method your account offers. The SDK checks for common mistakes but cannot catch every misuse.
2.6 Your views next to the blocks
Views inside your layout can read the session and the theme:
struct MyHeader: View {
@Environment(CashierSession.self) private var cashier
@Environment(\.cashierResolvedTheme) private var theme
var body: some View {
Text(cashier.snapshot.amount?.formatted() ?? "")
.foregroundStyle(theme.color(.primaryText))
}
}They can read CashierSession.snapshot, the read-only state of the Cashier, and send its commands, such as next() or selectMethod(id:). The snapshot never holds card data or personal data. Every property and command is listed in the SDK Reference (CashierSession).
What's next
- Integration Guide
- Configuration & Customization
- Blocks Catalog
- Styled Examples with Cashier.Pages: four cashiers drawn by the app, with their code
- Results, Errors & Troubleshooting
- SDK Reference
Updated about 18 hours ago