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.

LevelWhat you writeWhat you can changeExample
1. Predefined templateOne viewNothing in the layout. Your configuration (settings, theme, texts) and the payment methods set at Praxis still apply§1.2.1
2. Template + configurationA CashierConfigurationFeatures on or off, theme, texts, close button, behavior after the result§1.2.2
3. Template + slotsA few slot methods on the templateYour header and footer, hidden blocks, your own views between blocks§1.2.3
4. Your own layoutYour pages, built from SDK blocksThe order of blocks, how many pages and what each page checks, your views next to blocks, your outcome page§1.3
5. Your own controlsYour views over CashierSnapshot and CashierSession commandsFor 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.

PageContentBottom area
1. AmountHeader, amount and currency, quick amounts, bonuses, selected payment method, promotion code, amount change noteTotal to pay, terms, main button. Footer below
2. Method detailsHeader, 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. BillingHeader, step title, billing formTerms (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 settingBlocks it affects
.editableAmountAmountField: editable, or the session amount as fixed text
presetAmountEditableAmountField: a session amount prefilled and editable instead of fixed text
.amountLimitsAmountLimitHint, and the amount check
.currencyChangeCurrencyLine: the currency sheet
.savedInstrumentsSaved cards and accounts in SelectedMethod's picker
.applePayApple Pay in SelectedMethod's picker, and WalletSwitch in the card method
headerHeader: balance, Deposit / Withdraw tabs, back and close buttons
amount.quickAmountsQuickAmounts: no buttons unless you set lists or basedOnLastDeposit
paymentMethodsSelectedMethod's picker: order, limits, fees, card expiry, removal
promotions.stylePromotions: BonusSection for .bonusList, PromoCode for .codeField, nothing for nil
billingFieldsBillingForm: each field editable, read-only or hidden
resultTransactionResult (in Outcome): the payment details shown
footerFooter: 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.Header shows 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 put if or switch around a page.
  • Required blocks. MainButton on every page; on each page, the blocks of its checks; on the last page that shows, every block no earlier page checked. Put Terms in 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_incomplete event.

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 .padding and stacks as your design needs. Use @Environment(\.cashierResolvedTheme) and theme.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 amount

The Cashier loads the payment methods once an amount above zero and a currency are set. Send amount when you create the session, so the methods are ready when the Cashier opens. The amount is then fixed unless you set presetAmountEditable: 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:

GoalLayoutConfiguration
Full CashierAmountFirstLayout.default
Everything on one pageOnePageLayout.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 marketAnypromotions: CashierPromotionOptions(style: nil) for that market
Quick amounts per currencyAnyamount.quickAmounts with one list per currency
Card and saved cards onlyAnymethodFilter hook keeping card methods and saved-<n> rows
Your own result screenAnyreturnsAfterResult: true, then show your screen from onResult

1.5 Checklist for your own layout

  • Every block is inside Cashier.Pages, and there is no if or switch around a page.
  • MainButton is 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, BillingForm for .billing, Terms for .terms.
  • The last page that shows draws every block no earlier page checked. TotalToPay is on the page that opens the amount section.
  • Terms is 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, SavedCardCode or MethodDetails) on screen at a time.
  • Cashier.Header kept, 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_incomplete event 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:

CheckSection it opensBlocks the page must draw
.methodAmountNone
.amountAmountNone
.methodDetailsMethod detailsMethodDetails, or the single detail blocks
.billingBillingBillingForm
.termsNoneTerms

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 StepTitle on 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 bottom of Cashier.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.isNeeded is true when the payment needs one of the page's checks (or the page has none); page.needs(.billing) asks about one check; page.snapshot is 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 a Cashier.Header at 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, or CashierSession.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), its title and back(). 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

BlockWhat it showsSection
HeaderThe title bar, back and close buttonsEvery page
FooterThe footer under the first pageAmount
AmountAmountField, CurrencyLine and AmountLimitHint togetherAmount
AmountFieldThe amountAmount
CurrencyLineThe currency, and the currency sheet when it can changeAmount
AmountLimitHintThe method's lowest and highest amountAmount
QuickAmountsReady amount buttonsAmount
PromotionsBonusSection or PromoCode, as promotions.style decidesAmount
BonusSectionThe bonuses the customer can pickAmount
PromoCodeThe promotion code fieldAmount
SelectedMethodThe selected method and the method pickerAmount
AmountChangeNoteA note when the method changes the amountAmount
TotalToPayThe fee and the totalAmount
TermsThe terms boxAmount; details and billing during a decline recovery
MainButtonContinue or PayEvery page
StepTitleThe title of a later pageDetails, billing
MethodDetailsThe details of the selected method: one of the five blocks belowDetails
CardForm 🔒The card fields for a new cardDetails
SavedCardCode 🔒The CVV field for a saved cardDetails
WalletSwitchThe switch between the card and Apple PayDetails
MethodFields 🔒The fields of a non-card methodDetails
BankPickerThe bank list of a bank wireDetails
SaveCardNoteThe note that a new card is savedDetails
BillingForm 🔒Billing and contact fieldsBilling
OutcomeEvery screen after the form: loading, processing, retry and recovery pages, results, errorsOutcome
Loading, Processing, TransactionResult, BankDetails 🔒, PartialApproval, ErrorScreen, NoMethodsThe single outcome screensOutcome

🔒 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 whenBlock
AlwaysMainButton
The terms box showsTerms
The total showsTotalToPay
A new cardCardForm (or MethodDetails)
A saved cardSavedCardCode (or MethodDetails)
The card or Apple Pay switch showsWalletSwitch (or MethodDetails)
The method has fieldsMethodFields (or MethodDetails)
A bank wireBankPicker (or MethodDetails)
The billing sectionBillingForm

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 pages

In a layout of several pages, put Terms in 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


Did this page help you?