SDK Reference

The public methods, parameters and types of the iOS SDK.

This page lists the public methods, parameters and types of the Praxis iOS SDK. For step-by-step instructions, see Accept payments in your iOS app.

Status, closed-by, withdrawal status, step, intent, error code and error category values are structs with static values, not enums, so new values do not break your build. Always keep a default branch when you switch over them.

Presentation

CashierView

A SwiftUI view that shows the Cashier.

// The predefined template over a session the view makes and closes
CashierView(
    token: String,
    environment: CashierEnvironment,
    configuration: CashierConfiguration = CashierConfiguration(),
    onResult: @escaping @MainActor (CashierResult) -> Void
)

// Your layout over a session the view makes and closes
CashierView(token:environment:configuration:onResult:layout:)

// The predefined template, or your layout, over a session your app holds and closes
CashierView(session: CashierSession)
CashierView(session: CashierSession, layout: () -> Content)
ParameterDescriptionFormatRequired
tokenThe session token your server got from the Cashier Payment Request (session.auth_token). An empty token shows an error and ends with invalid_token.StringYes
environmentThe Praxis environment: .sandbox or .live.CashierEnvironmentYes
configurationFeatures, behavior, theme, texts, hooks and payment handler. Default: CashierConfiguration().CashierConfigurationNo
onResultCalled once, on the main actor, when the Cashier closes.(CashierResult) -> VoidYes
layoutYour layout from Cashier blocks and containers. Default: Cashier.AmountFirstLayout().@ViewBuilder () -> ContentNo
sessionA session your app holds. The view starts it when it appears and never closes it.CashierSessionYes, in the session initializers

CashierView is generic over its layout: a stored property needs the full type, for example CashierView<Cashier.AmountFirstLayout>.

cashierSheet modifier

Presents the Cashier full height over a view, with the SDK's own sheet chrome.

.cashierSheet(
    isPresented: Binding<Bool>,
    token: String,
    environment: CashierEnvironment,
    configuration: CashierConfiguration = CashierConfiguration(),
    onResult: @escaping @MainActor (CashierResult) -> Void
)

.cashierSheet(isPresented:token:environment:configuration:onResult:layout:)
ParameterDescriptionFormatRequired
isPresentedWhether the Cashier shows. The SDK turns it to false when the customer closes the Cashier. Setting it to false closes the session.Binding<Bool>Yes
token, environment, configuration, onResult, layoutAs for CashierView.

CashierViewController

A UIViewController that shows the Cashier in UIKit.

CashierViewController(
    token: String,
    environment: CashierEnvironment,
    configuration: CashierConfiguration = CashierConfiguration(),
    slots: CashierSlots = CashierSlots(),
    onResult: @escaping @MainActor (CashierResult) -> Void
)

CashierViewController(session: CashierSession, slots: CashierSlots = CashierSlots())
CashierViewController(session: CashierSession, @ViewBuilder layout: @escaping () -> Content)
ParameterDescriptionFormatRequired
slotsYour header, footer, hidden blocks and inserted views. See Customization. Default: CashierSlots() (no slots).CashierSlotsNo
sessionA session your app holds and closes.CashierSessionYes, in the session initializers
layoutYour SwiftUI layout.@ViewBuilder () -> ContentYes, in the layout initializer
Other parametersAs for CashierView.

The controller exposes session (CashierSession). Storyboards are not supported. Present it modally or push it. A controller that made its session closes it when it is dismissed or removed from its parent. While a payment runs, a presented controller refuses the swipe down, and a pushed one hides its back button and turns off swipe-back.

CashierScope

Connects your own views to a session: it puts the session and the resolved theme into the SwiftUI environment and starts the session when it first appears. CashierView, .cashierSheet and CashierViewController wrap your layout in a scope for you.

CashierScope(session) {
    // your layout
}

Environment

CashierEnvironment

The Praxis environment the Cashier talks to. The SDK has the service addresses of each environment built in. It holds no key or secret.

CashierView(token: token, environment: .sandbox) { result in … }
ValueDescription
.sandboxThe Praxis sandbox, for development and testing.
.liveThe Praxis live environment.

Use the environment your server created the session in.

When Praxis gives you another domain for your sessions, build the environment from it:

ValueDescription
try .sandbox(domain: "cashier-test.example.com")The Praxis sandbox on that domain.
try .live(domain: "pay.example.com")The Praxis live environment on that domain.

A domain that is not a bare host name (no scheme, path or port) throws invalidDomain.

Configuration

CashierConfiguration

CashierConfiguration(
    features: CashierFeatures = .default,
    theme: CashierTheme = CashierTheme(),
    header: CashierHeaderOptions = CashierHeaderOptions(),
    amount: CashierAmountOptions = CashierAmountOptions(),
    paymentMethods: CashierPaymentMethodOptions = CashierPaymentMethodOptions(),
    card: CashierCardOptions = CashierCardOptions(),
    promotions: CashierPromotionOptions = CashierPromotionOptions(),
    billingFields: CashierBillingFields = CashierBillingFields(),
    result: CashierResultOptions = CashierResultOptions(),
    footer: CashierFooterLinks = CashierFooterLinks(),
    texts: CashierTexts = CashierTexts(),
    hooks: CashierHooks = CashierHooks(),
    paymentHandler: CashierPaymentHandler = .praxis,
    returnsAfterResult: Bool = false,
    presetAmountEditable: Bool = false
)
ParameterDescriptionFormatRequired
featuresThe parts of the Cashier that are on. Default: .default (the recommended set).CashierFeaturesNo
themeColors, font, button shape, appearance, field labels.CashierThemeNo
headerBalance, Deposit / Withdraw tabs, back and close buttons.CashierHeaderOptionsNo
amountCurrency format, currency mode, quick amounts.CashierAmountOptionsNo
paymentMethodsHow payment methods show, and field prefill.CashierPaymentMethodOptionsNo
cardCardholder name prefill and lock.CashierCardOptionsNo
promotionsThe promotion block. Default: none.CashierPromotionOptionsNo
billingFieldsEditable, read-only or hidden, per billing field.CashierBillingFieldsNo
resultThe details on the result screen.CashierResultOptionsNo
footerSupport and policy links. Default: none, so no footer.CashierFooterLinksNo
textsTexts that win over the server texts, and the main button texts.CashierTextsNo
hooksEvents, live amount, method filter, field rules.CashierHooksNo
paymentHandler.praxis or .custom { … }. Default: .praxis.CashierPaymentHandlerNo
returnsAfterResultEnds the Cashier as soon as a result arrives that opens no provider page. Default: false.BoolNo
presetAmountEditableThe customer can change an amount the session came with. Needs .editableAmount; a zero-amount authorization stays fixed. Default: false.BoolNo

Details: Configuration and Settings.

CashierFeatures

An option set. .default is the recommended set; start from it and remove what you do not want.

ValueDescription
.editableAmountThe customer can enter or change the amount when the session has none. A session amount stays fixed unless presetAmountEditable is true.
.amountLimitsMethod limits are fetched and enforced.
.currencyChangeThe customer can change the currency.
.savedInstrumentsSaved cards and accounts.
.applePayApple Pay, as its own method and as the switch in the card method. It shows only when Praxis sends Apple Pay settings for the session, the device can pay, and your app's Apple Pay capability lists that merchant ID.

CashierHeaderOptions

CashierHeaderOptions(
    balance: Visibility = .mainPages,
    paymentType: Visibility = .mainPages,
    showsBackButton: Bool = false,
    closeButton: CloseButton = .visible
)
ParameterDescriptionFormatRequired
balanceWhere the balance shows. Default: .mainPages..hidden, .mainPages, .allPagesNo
paymentTypeWhere the Deposit / Withdraw tabs show. Default: .mainPages..hidden, .mainPages, .allPagesNo
showsBackButtonA back button on the first page; a tap sends cashier_back_button. Default: false.BoolNo
closeButtonThe close button. Default: .visible..visible, .hiddenNo

CashierAmountOptions

CashierAmountOptions(
    currencyFormat: CurrencyFormat = .isoCode,
    currencyMode: CurrencyMode = .paymentCurrency,
    quickAmounts: CashierQuickAmounts = CashierQuickAmounts()
)
ParameterDescriptionFormatRequired
currencyFormat€10 or EUR 10. Default: .isoCode..symbol, .isoCodeNo
currencyModeAmounts in the payment currency, or in the account's base currency. Default: .paymentCurrency..paymentCurrency, .baseCurrencyNo
quickAmountsThe quick amount buttons. Default: none.CashierQuickAmountsNo

CashierQuickAmounts

CashierQuickAmounts(lists: [List] = [], basedOnLastDeposit: Bool = false)

CashierQuickAmounts.List(
    amounts: [Choice],                 // .amount(Decimal) or .maximum
    currency: String? = nil,
    paymentMethod: String? = nil,
    intent: CashierIntent = .deposit,
    startingAmount: Decimal? = nil
)
ParameterDescriptionFormatRequired
listsButton lists; the first match for the method and currency is used. Default: [].[CashierQuickAmounts.List]No
basedOnLastDepositBuilds deposit buttons from the customer's last deposit. Default: false.BoolNo
List.amountsThe buttons, in order.[CashierQuickAmounts.Choice]Yes
List.currencyISO 4217 code; nil for any currency.String?No
List.paymentMethodMethod key; nil for any method.String?No
List.intent.deposit or .withdrawal. Default: .deposit.CashierIntentNo
List.startingAmountThe amount the Cashier starts with when the session has no amount and the customer no previous deposit. Must be 0 or more. Default: nil.Decimal?No

No lists and basedOnLastDeposit false means quick amounts are off. Rules: Amount and quick amounts.

CashierPaymentMethodOptions

CashierPaymentMethodOptions(
    lastUsedFirst: Bool = false,
    showsLimits: Bool = true,
    fees: FeeVisibility = .always,
    showsCardExpiry: Bool = false,
    allowsRemoval: Bool = false,
    prefillsFields: Bool = true
)
ParameterDescriptionFormatRequired
lastUsedFirstThe last used method first. Default: false.BoolNo
showsLimitsLimits text on method rows. Default: true.BoolNo
feesFee text on method rows. Default: .always..always, .ifNotZero, .hiddenNo
showsCardExpiryExpiry date on every saved card; off, an expired card shows expired alone. Default: false.BoolNo
allowsRemovalThe customer can remove saved cards and accounts. Default: false.BoolNo
prefillsFieldsFills method fields from the profile. Default: true.BoolNo

CashierCardOptions

CashierCardOptions(prefillsCardholderName: Bool = false, locksCardholderName: Bool = false)
ParameterDescriptionFormatRequired
prefillsCardholderNameFills the cardholder name with the customer's name. Default: false.BoolNo
locksCardholderNameLocks the cardholder name and the billing name. Use with prefillsCardholderName. Default: false.BoolNo

CashierPromotionOptions

CashierPromotionOptions(style: Style? = nil)
ParameterDescriptionFormatRequired
style.bonusList, .codeField, or nil for no promotions. Default: nil.CashierPromotionOptions.Style?No

CashierBillingFields

CashierBillingFields(country:name:email:phone:postalCode:state:city:address:countries:)

Each field parameter is .editable (default), .readOnly or .hidden. countries (CashierCountryList) sets the countries the country sheet offers and which come first; by default, every country in alphabetical order. Details: Billing fields.

CashierResultOptions

CashierResultOptions(
    showsDeclineReason: Bool = true,
    showsDate: Bool = false,
    showsFee: Bool = false,
    showsTotal: Bool = false,
    showsBonus: Bool = false,
    showsPaymentInstrument: Bool = false,
    showsBillingDescriptor: Bool = false
)

Each value shows one detail on the result screen. Details: Result screen.

CashierFooterLinks

CashierFooterLinks(
    supportWebsite: URL? = nil,
    supportEmail: String? = nil,
    supportPhone: String? = nil,
    privacyPolicy: URL? = nil,
    termsOfService: URL? = nil
)

The footer shows when at least one link is set. URLs must be https. Details: Footer links.

CashierTheme and CashierTexts

Every parameter, color role, text style and text key is listed in Customization.

CashierTheme(brandColorLight:brandColorDark:brandTextColorLight:brandTextColorDark:fontName:buttonShape:appearance:fieldLabelStyle:roleColors:cornerRadius:)
CashierTheme(brand: Color, brandText: Color? = nil)

CashierTexts(_ texts: [CashierTexts.Key: String] = [:], depositButton: String? = nil, withdrawalButton: String? = nil)
CashierTexts(byLanguage: [String: [CashierTexts.Key: String]], depositButton: String? = nil, withdrawalButton: String? = nil)

CashierHooks

CashierHooks(
    onEvent: (@MainActor @Sendable (CashierEvent) -> Void)? = nil,
    onAmountChange: (@MainActor @Sendable (CashierAmountUpdate) -> Void)? = nil,
    methodFilter: (@MainActor @Sendable ([CashierMethodInfo]) async -> [String])? = nil,
    fieldRules: [CashierFieldRule] = [],
    skippedFieldChecks: [String: Set<String>] = [:],
    fieldAdjustments: [CashierFieldAdjustment] = []
)
ParameterDescriptionFormatRequired
onEventEach event, in order.(CashierEvent) -> VoidNo
onAmountChangeThe live amount.(CashierAmountUpdate) -> VoidNo
methodFilterReturns the method ids to show, in order. Cannot add methods.([CashierMethodInfo]) async -> [String]No
fieldRulesExtra field checks.[CashierFieldRule]No
skippedFieldChecksPer method key, field names whose checks are off.[String: Set<String>]No
fieldAdjustmentsHide, require or prefill fields.[CashierFieldAdjustment]No

All hooks run on the main actor. Details: Events & Hooks.

CashierFieldRule

CashierFieldRule(field: String, methods: Set<String>? = nil, pattern: String? = nil,
                 minimumLength: Int? = nil, isRequired: Bool = false, errorTextKey: CashierTexts.Key? = nil)
ParameterDescriptionFormatRequired
fieldThe field name as Praxis sends it, for example zip.StringYes
methodsThe method keys the rule applies to. Default: nil (every method).Set<String>?No
patternA regular expression the value must match. An invalid pattern is ignored.String?No
minimumLengthThe least number of characters.Int?No
isRequiredThe field must hold a value. Default: false.BoolNo
errorTextKeyThe text key of the message.CashierTexts.Key?No

CashierFieldAdjustment

MethodDescription
.hide(field:method:)Hides a field of a method.
.require(field:method:)Makes a field of a method required.
.defaultValue(_:field:method:)Gives a field of a method a start value.

CashierPaymentHandler

ValueDescription
.praxisThe SDK sends the payment to Praxis. The default.
.custom(_:)Your async code gets a CashierPaymentRequest and returns a CashierPaymentOutcome. It runs on the main actor, once per final tap, with a 130-second limit.

CashierPaymentRequest: amount (Decimal), currency (String), originAmount (Decimal?, the base-currency amount of a cross-currency payment), paymentMethod (String), paymentMethodType (String?, "cc" for a card method, nil otherwise), termsAccepted (Bool), hasPromotionCode (Bool), payload (CashierPaymentPayload, sealed; its only method is submitToPraxis()).

CashierPaymentOutcome: the outcome of submitToPraxis(), .notSubmitted, or .finished(_ status: CashierResult.Status, transactionID: String? = nil). Details: Payment Handler.

Session

CashierSession

One payment session. @Observable and @MainActor. Creating it does no network work; it starts when a CashierScope (or CashierView) first appears, or when you call start().

CashierSession(
    token: String,
    environment: CashierEnvironment,
    configuration: CashierConfiguration = CashierConfiguration(),
    onResult: @escaping @MainActor (CashierResult) -> Void = { _ in }
)
MemberDescription
snapshotThe read-only CashierSnapshot.
start()Starts the session. Called for you by the scope.
close()Closes the Cashier and calls onResult once with closedBy .code: .canceled before a payment, .pending while one runs. A closed session cannot start again.
next()Does what the main button does now.
back()Shows the page before in Cashier.Pages. Does nothing on the first page, outside the form, while a payment runs, or after close(); snapshot.canGoBack says when it moves.
setAmount(_ amount: Decimal)Sets the amount, in major units. Ignored when the amount is locked.
selectCurrency(_ code: String)Picks a currency from snapshot.currencies.
selectMethod(id: String)Selects a method from snapshot.methods.
selectBonus(id: String?)Selects an offered bonus, or none with nil.
applyPromotionCode()Applies the code typed in the promotion code field.
setTermsAccepted(_ accepted: Bool)Ticks or unticks the terms box.

Commands that do not apply in the current state are ignored.

CashierSnapshot

PropertyDescriptionFormat
stepThe part of the Cashier the customer is on.CashierStep
isBusyStarting, paying or checking the status.Bool
canPayThe main button pays now and is enabled.Bool
canContinueThe main button continues to another section and is enabled.Bool
canGoBackGoing back works now: back() moves. False on the first page, on a single page, while a payment runs, during 3-D Secure and after a result.Bool
amountThe amount to pay, in major units. Nil before the session starts.Decimal?
currencyThe ISO 4217 code of amount.String?
currenciesThe currencies the customer can pick.[String]
intentThe intent of the active tab.CashierIntent
paymentMethodThe selected method.CashierMethodInfo?
methodsThe methods the customer can pick: server order, then saved rows.[CashierMethodInfo]
termsRequiredThe terms must be accepted before paying.Bool
termsAcceptedThe terms box is ticked.Bool
bonusThe selected bonus.CashierBonusInfo?
bonusesThe offered bonuses.[CashierBonusInfo]
feeThe fee of the selected method.Decimal?
totalThe total to pay (on a withdrawal: what the customer receives).Decimal?
resultThe result, once the payment ended. While the Cashier is still open, result.closedBy is .sdk.CashierResult?
amountLimitsThe selected method's smallest and largest amount, for example for a Max button. Nil with no method, when .amountLimits is off, or when the method has no limit for the currency. On a withdrawal the maximum is capped by the balance.CashierAmountLimits?
languageThe session language your server set, for example "en". The Cashier shows its texts in it, which can differ from the app's language. Nil before the session starts.String?
isRightToLeftThe session language reads right to left (he, ar). CashierView and CashierScope then mirror the Cashier; with CashierSessionScope, set the layout direction of your views from it.Bool

CashierStep

ValueDescription
.loadingThe Cashier is starting, or a tab is loading.
.amountThe amount section: amount, currency and method.
.detailsThe method details section.
.billingThe billing section.
.resultThe payment is processing, needs a decision, or ended.
.errorAn error screen shows.

CashierIntent

ValueDescription
.depositThe customer pays in. Authorization sessions report a deposit.
.withdrawalThe customer withdraws.

CashierMethodInfo

PropertyDescriptionFormat
idThe method key, or saved-<n> for a saved card or account.String
nameThe method title, or an SDK name for a saved row (no digits).String
typeThe method type, for example cc.String?
logoURLThe method logo.URL?
isSavedThe row is a saved card or account.Bool
isInMaintenanceThe method cannot pay now.Bool

CashierBonusInfo

PropertyDescriptionFormat
idThe bonus id.String
titleThe bonus title.String

CashierSlotContext

What slot content reads from @Environment(\.cashierSlotContext): snapshot, back(), close(), next(). See Customization.

Results

CashierResult

PropertyDescriptionFormat
statusHow the Cashier ended.CashierResult.Status
closedByWho closed it.CashierResult.ClosedBy
errorCodeWhy the payment failed. Set only for .failed.CashierErrorCode?
transactionIDThe Praxis transaction ID.String?
traceIDThe Praxis trace ID, for support.String?
amountThe transaction amount, in major units. Nil without a transaction.Decimal?
currencyThe ISO 4217 code of amount.String?
paymentMethodThe Praxis name of the payment method that paid.String?
orderIDYour order_id.String?
cardBrandThe card brand, for example Visa.String?
intent.deposit or .withdrawal.CashierIntent?
withdrawalStatusThe Praxis status of a withdrawal. Nil for a deposit, a withdrawal without a transaction, or a status the SDK does not list.CashierResult.WithdrawalStatus?

CashierResult.Status

CaseDescription
.completedThe payment was approved.
.authorizedThe card was authorized and not charged yet.
.pendingStill processing, or a withdrawal request waits to be paid out.
.failedThe payment did not go through.
.canceledThe Cashier closed before a payment started.

CashierResult.ClosedBy

CaseDescription
.customerThe customer tapped close or a button under the result.
.codeYour app closed the Cashier: it called close() on the session or the slot context, dismissed the CashierView or CashierViewController that made the session, or set the .cashierSheet binding to false.
.sdkThe SDK ended the session, for example with returnsAfterResult.

CashierResult.WithdrawalStatus

.approved, .authorized, .requested, .requestedPayout, .partialPayout, .pending, .pendingAsync, .initialized, .verification, .declined, .error, .canceled. Meanings: Results & Error Codes.

Errors

CashierErrorCode

CaseRaw valueCategory
.declineddeclinedpayment
.cardInvalidcard_invalidpayment
.cardNotAcceptedcard_not_acceptedpayment
.transactionCanceledtransaction_canceledpayment
.noPaymentMethodno_payment_methodpayment
.walletUnavailablewallet_unavailablepayment
.networknetworknetwork
.sessionExpiredsession_expiredsession
.sessionUnavailablesession_unavailablesession
.invalidTokeninvalid_tokensession
.validationFailedvalidation_failedvalidation
.serverErrorserver_errorserver
.unexpectedResponseunexpected_responseserver
.unknownunknownserver
.configurationErrorconfiguration_errorconfiguration
.paymentMethodUnavailablepayment_method_unavailableconfiguration

errorCode.category is one of .session, .network, .server, .validation, .configuration, .payment; category.rawValue gives it as text for analytics. CashierErrorCode(rawValue:) makes a code from a logged value; prefer the static values. What each code means and what to do: Results & Error Codes.

Events

CashierEvent

PropertyDescriptionFormat
nameThe event. Every name is listed in Events & Hooks.CashierEvent.Name
paymentMethodThe type of the selected method, for example cc for cards (the same as CashierMethodInfo.type).String?
methodKeysEmpty on cashier_loaded; nil on every other event.[String]?
actionTypeThe action type of the payment answer, for example redirect or await.String?
statusThe transaction status.String?
errorCodeOn transaction_failed and cashier_loading_failed: the same code as the result.CashierErrorCode?
cardBrandThe card brand in lower case, for example visa.String?
isValidThe validity of the card or method fields.Bool?
amount, currencyThe amount (major units) and currency.Decimal?, String?
traceIDThe Praxis trace ID.String?
ignoredNameOn configuration_value_ignored: the value that was ignored.String?
reasonOn layout_incomplete: requiredBlock (a required block is missing), duplicateSealed (two card blocks on screen at once) or presentation (blocks are outside Cashier.Pages, so only the amount section opens).String?
missingOn layout_incomplete: the blocks your layout must draw and does not, for example ["cashier.mainButton", "cashier.terms"], or a left-out card input such as cashier.cardField.expiry. Empty when the reason is presentation.[String]?
intentThe intent of the tab the customer is on. Nil on initSession, initApp, createPaymentPage, createResultPage, layout_incomplete, configuration_value_ignored and terms_accepted_by_code.CashierIntent?
secondaryIntentsThe session's other intents.[CashierIntent]?

Event names and when each is sent: Events & Hooks.

CashierAmountUpdate

PropertyDescriptionFormat
amountThe amount, in the account's base currency.Decimal
totalChargeThe amount to charge in currency.Decimal?
displayAmountThe amount in currency, an included fee taken out (withdrawal: what leaves the balance).Decimal?
feeThe fee in currency.Decimal?
totalThe total to pay (withdrawal: what the customer receives).Decimal?
currencyThe payment currency.String

When the customer sees only the base currency and the method charges in another currency, displayAmount, fee and total are in the method's currency while currency stays the base currency.

Slots

Slot methods

Methods of Cashier.AmountFirstLayout and Cashier.OnePageLayout. Add them to the template and pass it as the last closure of CashierView or .cashierSheet.

.cashierHeader { /* your view */ }
.cashierFooter { /* your view */ }
.cashierHide(_ block: HideableBlock)
.cashierInsert(before anchor: CashierAnchor) { /* your view */ }
.cashierInsert(after anchor: CashierAnchor) { /* your view */ }

CashierSlots

The UIKit form of the slot methods, passed to CashierViewController.

MethodDescription
setHeader(_:)Replaces the header with your UIView.
setFooter(_:)Replaces the footer with your UIView.
hide(_:)Hides a HideableBlock.
insert(before:_:), insert(after:_:)Adds your UIView before or after a CashierAnchor.

HideableBlock

.header, .footer, .quickAmounts, .promotions.

CashierAnchor

.header, .amount, .quickAmounts, .promotions, .selectedMethod, .amountChangeNote, .totalToPay, .terms, .mainButton, .footer, .stepTitle, .cardForm, .savedCardCode, .walletSwitch, .methodFields, .bankPicker, .saveCardNote, .billingForm, .result.

Where each block shows and what each slot can do: Customization.

Theme helpers

CashierResolvedTheme

Read it with @Environment(\.cashierResolvedTheme) inside the Cashier.

MemberDescriptionFormat
color(_:)The color of a CashierTheme.Role.Color
cornerRadiusThe corner radius of buttons and cards.CGFloat
spacing(_:)A step of the spacing scale, .s2 to .s40.CGFloat
font(_:)The font of a TextStyle.Font

cashierFont(_:)

.cashierFont(_ style: CashierResolvedTheme.TextStyle)

Sets the font, letter spacing and line height of a Cashier text style on your text, following Dynamic Type. Spacing steps and text styles are listed in Customization.

Layout

Cashier.AmountFirstLayout

The predefined template. CashierView, .cashierSheet and CashierViewController use it when you pass no layout. Up to three pages: the amount and the method, the method details, and billing. Pages a payment does not need are skipped.

Cashier.AmountFirstLayout()

Cashier.OnePageLayout

The second pre-built layout: the same blocks on one page. The main button always pays.

Cashier.OnePageLayout()

Both layouts take the slot methods (see Slots).

Cashier.Pages

Your own pages, in your own order. The main button runs the checks of the page and shows the next page; on the last page that shows, it pays. While the Cashier loads, processes or shows a result or an error, the outcome page shows instead.

Cashier.Pages(
    @Cashier.PagesBuilder pages: () -> YourPages,
    @ViewBuilder bottom: () -> Bottom,         // optional
    @ViewBuilder outcome: () -> OutcomePage    // optional; default Cashier.Outcome()
)
ParameterDescriptionFormatRequired
pagesThe Cashier.Pages, in the order the customer goes through them. Write them one after the other; an if or a switch around a page is not supported (use cashierPageShown(when:)).@Cashier.PagesBuilder () -> YourPagesYes
bottomThe pinned bottom area of the pages that have none of their own, usually the main button.@ViewBuilder () -> BottomNo
outcomeThe page for loading, processing, results and errors. Default: Cashier.Outcome().@ViewBuilder () -> OutcomePageNo

Every block of your layout must be inside Cashier.Pages. Blocks outside it give layout_incomplete with the reason presentation. How the pages, their checks and the required blocks work: Blocks & Containers.

Cashier.Page

One page of Cashier.Pages. A page opens the sections of its checks; the last page that shows also opens every section no earlier page opened. Each page is drawn only while it shows.

Cashier.Page(
    _ title: String,
    validates checks: Cashier.PageCheck...,    // optional
    @ViewBuilder content: () -> Content,
    @ViewBuilder bottom: () -> Bottom,         // optional
    @ViewBuilder footer: () -> Footer          // optional; needs bottom
)
ParameterDescriptionFormatRequired
titleThe page's title, in the customer's language. VoiceOver reads it when the page shows; your views read it from @Environment(\.cashierPage). With an empty title, VoiceOver moves to the top of the page and a Cashier.StepTitle on it takes the focus.StringYes
checksWhat the main button checks before the customer may leave the page. None by default.Cashier.PageCheck...No
contentThe page's content. It scrolls.@ViewBuilder () -> ContentYes
bottomThe page's pinned bottom area, in place of the bottom of Cashier.Pages.@ViewBuilder () -> BottomNo
footerWhat shows under the bottom area, for example Cashier.Footer(). On a page that scrolls as a whole, it shows once the customer scrolls to the end; on a page whose content scrolls, it stays pinned under the bottom area.@ViewBuilder () -> FooterNo

cashierPageScrolling(_:)

Sets how a Cashier.Page scrolls.

Cashier.Page(…) { … }
    .cashierPageScrolling(_ scrolling: Cashier.PageScrolling)

Cashier.PageScrolling values:

ValueDescription
.wholePageThe content and the bottom area scroll as one page. The bottom area sticks to the bottom of the screen until its own place scrolls into view, and the footer follows it. The default.
.contentOnlyOnly the content scrolls. A Cashier.Header at the top of the content stays pinned, and the bottom area and the footer stay pinned at the bottom.

cashierPageShown(when:)

Shows a Cashier.Page only while a rule returns true. Cashier.Pages asks again whenever the payment changes: the method, the amount, the currency. A hidden page is skipped by the main button and by back; when the page the customer is on hides, the page before it shows.

Cashier.Page(…) { … }
    .cashierPageShown(when isShown: @escaping @MainActor @Sendable (Cashier.PageEligibility) -> Bool)

Cashier.Page(…) { … }
    .cashierPageShown(_ isShown: Bool)         // a decision your app makes itself

Cashier.PageEligibility, what the rule reads:

MemberDescriptionFormat
isNeededThe payment needs this page now: it runs one check the payment needs, or no check at all. For example, a billing page is not needed when the payment has no billing field.Bool
needs(_:)The payment needs this check now. The method, the amount and the terms are always needed.(Cashier.PageCheck) -> Bool
snapshotThe Cashier's state now.CashierSnapshot
Cashier.Page("", validates: .billing) { Cashier.BillingForm() }
    .cashierPageShown { page in page.isNeeded }

Cashier.PageCheck

A check a page runs before the customer may leave it. Pass it to validates: of Cashier.Page.

ValueThe main button lets the customer leave the page whenSection it opensBlock the page draws
.methodA method is chosen and its details have loaded. The button stays disabled until then.AmountNone
.amountThe amount and the currency are set, payable and inside the limits. The button stays disabled until then.AmountNone
.methodDetailsThe card, the saved card code, the method fields or the bank are valid. A tap shows every error of the page instead.Method detailsCashier.MethodDetails or the single detail blocks
.billingThe billing fields are valid. A tap shows every error of the page instead.BillingCashier.BillingForm
.termsThe terms box is ticked when it is required. A tap shows the terms error instead.NoneCashier.Terms

rawValue (and description) gives the check as text, for logs.

Cashier.PageContext

The page the customer is on, for any view inside a Cashier.Page. Read it with @Environment(\.cashierPage). Positions count only the pages that show, so "step 2 of 3" stays right when a rule hides a page.

@Environment(\.cashierPage) private var page
MemberDescriptionFormat
indexThe page's place among the pages that show, from 0.Int
countThe number of pages that show.Int
isFirstThe customer is on the first page that shows.Bool
isLastThe customer is on the last page that shows, the one whose main button pays.Bool
titleThe page's title, as you gave it to Cashier.Page.String
back()Shows the page before, as the header's back button and CashierSession.back() do. Returns false on the first page, outside Cashier.Pages or while a payment runs.() -> Bool

Outside Cashier.Pages, the value is one page whose back() does nothing.

cashierPagesStyle(_:)

Sets how the pages of Cashier.Pages inside a view move from one to the next.

Cashier.Pages { … }
    .cashierPagesStyle(_ style: CashierPagesStyle)

CashierPagesStyle values:

ValueDescription
.inPlaceThe pages show one at a time in the Cashier's page: a swipe from the leading edge goes back, and a new page slides in. The default.
.inPlace(swipe:transition:)The same, with your swipe and transition. Defaults: swipe: .back, transition: .slide.
CashierPagesStyle.SwipeDescription
.backA swipe from the leading edge goes back. The default.
.backAndForwardA swipe from the leading edge goes back; a swipe from the trailing edge continues, as the main button does (its checks run first). It never pays: on the last page only the main button pays.
.disabledNo swipe: the main button and back only.
CashierPagesStyle.TransitionDescription
.slideThe new page slides in from the side it comes from, following the layout direction. It fades under Reduce Motion. The default.
.fadeThe new page fades in.
.immediateThe new page shows at once.
.cashierPagesStyle(.inPlace(swipe: .backAndForward, transition: .fade))

Blocks

The Cashier blocks (Cashier.Amount(), Cashier.MainButton(), …) and the required-block rule are listed in Blocks & Containers.

Appendix: text keys

Every text key of the Cashier, as the static property on CashierTexts.Key and the key string. Texts with {{…}} contain placeholders.

Swift nameText key
.addAdd
.add_promotion_codeadd_promotion_code
.addressaddress
.addYourCardaddYourCard
.agree_with_terms_of_serviceAgree with terms of service
.all_Payment_MethodsAll Payment Methods
.allPaymentMethodsallPaymentMethods
.amountAmount
.amount_creditedamount_credited
.amountFirstExchangeRateamountFirstExchangeRate
.appearsOnStatementAsappearsOnStatementAs
.applyApply
.are_you_sure_you_want_to_removeAre you sure you want to remove
.authorizeAuthorize
.backback
.back_to_siteBack to site
.background_Exchange_ConfirmationBackground Exchange Confirmation
.betweenbetween
.billing_addressBilling address
.billingInformationbillingInformation
.bonus_not_supportedbonus_not_supported
.bonus_unlockedbonus_unlocked
.bonus_unlocked_capitalBonus_unlocked
.bonuses_not_available_messagebonuses_not_available_message
.bonusReceivedbonusReceived
.cancelCancel
.cancel_pending_withdrawalscancel_pending_withdrawals
.cancel_requestcancel_request
.cancel_withdrawalcancel_withdrawal
.cancel_withdrawal_credited_messagecancel_withdrawal_credited_message
.cancel_withdrawal_request_titlecancel_withdrawal_request_title
.cannotBeBlankcannotBeBlank
.cardHolderNamecardHolderName
.cardNotAcceptedcardNotAccepted
.cardNumbercardNumber
.cardNumberLabelcardNumberLabel
.change_currencyChange currency
.change_payment_methodChange payment method
.choose_another_methodChoose another method
.choose_provider_cardChoose {{provider}} card
.choose_bonusChoose bonus
.choose_different_methodchoose_different_method
.chooseanothermethodchooseanothermethod
.citycity
.closeclose
.confirmConfirm
.contact_detailsContact details
.contact_SupportContact Support
.continueContinue
.continue_without_bonuscontinue_without_bonus
.copiedCopied!
.copyCopy
.countrycountry
.credited_backcredited_back
.cryptoCrypto
.currencyCurrency
.customer_support_emailcustomer_support_email
.customer_support_link_textcustomer_support_link_text
.customer_support_phonecustomer_support_phone
.customer_support_urlcustomer_support_url
.customerNamecustomerName
.cvcLabelcvcLabel
.datedate
.debit_or_credit_cardDebit or credit card
.depositdeposit
.deposit_feesdeposit_fees
.dismissdismiss
.dod_error_textdod_error_text
.dod_textdod_text
.dod_urldod_url
.dod_url_textdod_url_text
.download_PDFDownload PDF
.downloadedDownloaded
.emailemail
.emailIsNotValidemailIsNotValid
.ending_inending in
.enter_valid_card_numberEnter valid card number
.enter_valid_dateEnter valid date
.enter_valid_nameEnter valid name
.enter_promotion_codeenter_promotion_code
.enterSecurityCodeForCardenterSecurityCodeForCard
.exchange_rate_may_varyexchange_rate_may_vary
.expiredexpired
.expiresexpires
.expiryDateexpiryDate
.failed_to_removeFailed to remove
.feeFee
.fiatFiat
.field_invalidField invalid
.final_amount_may_vary_byFinal amount may vary by
.fromfrom
.from_capitalFrom
.get_Payment_DetailsGet Payment Details
.get_full_bonus_justget_full_bonus_just
.go_back_capitalGo back
.go_backgo-back
.helpHelp
.higher_deposit_neededhigher_deposit_needed
.higher_deposit_needed_messagehigher_deposit_needed_message
.higher_withdrawal_needed_messagehigher_withdrawal_needed_message
.hourshours
.iacceptiaccept
.idontacceptidontaccept
.if_no_the_transaction_will_be_processed_without_additional_conversionIf no, the transaction will be processed without additional conversion.
.included_feeincluded_fee
.incorrect_valueIncorrect value
.insufficient_balanceInsufficient balance
.invalidInputFormatinvalidInputFormat
.invalidValueinvalidValue
.limitslimits
.maintenance_available_inmaintenance_available_in
.maintenance_not_available_until_datemaintenance_not_available_until_date
.maintenance_not_available_until_daymaintenance_not_available_until_day
.maintenance_now_availablemaintenance_now_available
.maintenance_refresh_to_usemaintenance_refresh_to_use
.makeAnotherPaymentmakeAnotherPayment
.maxMax
.maximummaximum
.maximum_amount_limit_messagemaximum_amount_limit_message
.maximum_deposit_limitmaximum_deposit_limit
.maximum_withdrawal_limitmaximum_withdrawal_limit
.maximumLengthmaximumLength
.min_depositMin. deposit
.minimumminimum
.minimum_depositMinimum deposit
.minimum_deposit_for_bonusminimum_deposit_for_bonus
.minimum_deposit_requiredminimum_deposit_required
.minimum_withdrawal_requiredminimum_withdrawal_required
.minimumLengthminimumLength
.minuteminute
.minutesminutes
.moremore
.nameOnCardnameOnCard
.need_helpNeed help?
.newClosednewClosed
.newContinuenewContinue
.no_available_payment_methodsNo available payment methods
.no_saved_cardsNo saved cards
.no_bonusno_bonus
.no_feeno_fee
.no_feesno_fees
.no_pending_withdrawalsno_pending_withdrawals
.noCountryFoundnoCountryFound
.noCountryFoundSubtitlenoCountryFoundSubtitle
.noOptionsnoOptions
.noOptionsAvailablenoOptionsAvailable
.noRegionFoundnoRegionFound
.noRegionFoundSubtitlenoRegionFoundSubtitle
.partialApprovalBonusWarningpartialApprovalBonusWarning
.partialApprovalRequestedAmountpartialApprovalRequestedAmount
.partialApprovalSubtitlepartialApprovalSubtitle
.partialApprovalSuccessDescriptionpartialApprovalSuccessDescription
.partialApprovalSuccessTitlepartialApprovalSuccessTitle
.partialApprovalTimerPrefixpartialApprovalTimerPrefix
.partialApprovalTimerSuffixpartialApprovalTimerSuffix
.partialApprovalTitlepartialApprovalTitle
.partialApprovalYouCanDepositpartialApprovalYouCanDeposit
.payment_detailspayment details
.payment_details_capitalPayment details
.payment_method_capitalPayment method
.payment_method_unavailablePayment method unavailable
.payment_summaryPayment summary
.paymentDetailspaymentDetails
.payments_are_unavailable_in_the_selected_currencyPayments are unavailable in the selected currency
.phonephone
.phoneIsNotValidphoneIsNotValid
.pick_another_methodpick_another_method
.please_contact_customer_supportPlease contact customer support
.please_do_not_close_this_windowPlease do not close this window
.pleaseEnterPayoutpleaseEnterPayout
.plusplus
.postalCodepostalCode
.powerSlideEnterAmountpowerSlideEnterAmount
.powerSlideMyAccountpowerSlideMyAccount
.privacy_PolicyPrivacy Policy
.protected_with_pciprotected_with_pci
.provinceprovince
.recently_usedrecently_used
.regionCoderegionCode
.removeRemove
.remove_payment_methodRemove payment method
.removedremoved
.searchSearch
.searchCountrysearchCountry
.searchPhoneCodesearchPhoneCode
.secondsecond
.secondsseconds
.securityCodesecurityCode
.select_bankSelect bank
.select_countrySelect country
.select_region_codeSelect region code
.select_payment_methodselect_payment_method
.show_moreShow more
.showLessshowLess
.showMoreshowMore
.stateState
.temporarily_unavailabletemporarily_unavailable
.terms_of_ServiceTerms of Service
.terms_conditions_link_textterms_conditions_link_text
.terms_conditions_urlterms_conditions_url
.the_fee_isthe_fee_is
.toto
.to_pay_now_use_another_payment_methodto_pay_now_use_another_payment_method
.token_provider_is_not_availableToken provider is not available
.total_addtotal_add
.total_to_paytotal_to_pay
.traceIdtraceId
.try_another_cardTry another card
.tryAgaintryAgain
.unsuccessful_transactionunsuccessful_transaction
.unsuccessful_transaction_apmunsuccessful_transaction_apm
.unsuccessful_transaction_obunsuccessful_transaction_ob
.up_toup to
.we_will_save_your_cardwe_will_save_your_card
.withdrawwithdraw
.withdrawal_cancelled_successwithdrawal_cancelled_success
.withdrawal_feeswithdrawal_fees
.withdrawal_requestswithdrawal_requests
.withdrawal_request_acceptedwithdrawal-request-accepted
.withdrawal_request_messagewithdrawal-request-message
.you_addyou_add
.you_payyou_pay
.you_pay_inyou_pay_in
.you_receiveyou_receive
.you_receive_inyou_receive_in
.you_withdrawyou_withdraw
.youll_get_fundsyoull_get_funds
.your_transaction_is_processingYour transaction is processing.
.requestAcceptedrequestAccepted
.transaction_successfulTransaction successful
.transactionAuthorizedtransactionAuthorized
.your_transaction_failedYour transaction failed
.your_transaction_has_been_canceledYour transaction has been canceled
.your_transaction_is_pendingYour transaction is pending
.select_currency_to_pay_inselect_currency_to_pay_in
.footerPanoramicfooterPanoramic
.invalidIbanFormatinvalidIbanFormat
.invalidBicFormatinvalidBicFormat
.entrada_inv_lida_corrijaEntrada inválida, corrija
.can_t_get_session_informationCan't get session information
.token_is_invalidToken is invalid
.if_you_require_assistance_or_technical_support_please_contact_customer_supportIf you require assistance or technical support, please contact customer support.
.somethingWentWrongsomethingWentWrong
.do_you_accept_potential_conversion_charges_to_increase_the_chances_of_completing_the_transaction_successfullyDo you accept potential conversion charges to increase the chances of completing the transaction successfully?
.additional_currency_conversion_may_be_applied_to_complete_the_transaction_successfullyAdditional currency conversion may be applied to complete the transaction successfully.
.this_card_cannot_be_accepted_Please_consider_using_another_card_or_trying_a_different_payment_methodThis card cannot be accepted. Please consider using another card or trying a different payment method.
.tryAnotherMethodTexttryAnotherMethodText
.payment_method_not_availablePayment method not available.
.please_contact_your_site_administratorPlease contact your site administrator.
.session_expiredSession expired
.your_session_has_expired_Please_try_again_by_starting_overYour session has expired. Please try again by starting over.
.something_went_wrongSomething went wrong.
.please_contact_your_system_administrator_Code_101Please contact your system administrator (Code: 101)
.please_try_again_with_lower_amountPlease try again with lower amount.
.apologies_it_appears_that_you_don_t_have_any_payment_details_registered_to_use_for_withdrawal_requestApologies, it appears that you don't have any payment details registered to use for withdrawal request
.sdk_deposit_limit_alertsdk_deposit_limit_alert
.sdk_clear_searchsdk_clear_search
.sdk_fee_infosdk_fee_info
.sdk_wallet_transaction_failedsdk_wallet_transaction_failed (on the Apple Pay sheet for a declined payment with a message; default: Transaction failed. {{error_message}})
.sdk_wallet_payment_declinedsdk_wallet_payment_declined (declined, no message; default: "Payment declined. Please choose another card.")
.sdk_wallet_something_went_wrongsdk_wallet_something_went_wrong (on the Apple Pay sheet for other errors; default: Something went wrong. {{error_message}})
.sdk_wallet_no_processorsdk_wallet_no_processor (on the Apple Pay sheet when the card cannot be used; when you do not set it, sdk_wallet_no_gateways shows)
.sdk_wallet_no_gatewayssdk_wallet_no_gateways (on the Apple Pay sheet when the card cannot be used and sdk_wallet_no_processor is not set)
.sdk_bank_file_bank_namesdk_bank_file_bank_name
.sdk_saved_cardsdk_saved_card
.sdk_saved_accountsdk_saved_account
.sdk_pix_key_type_labelsdk_pix_key_type_label
.sdk_pix_bank_code_labelsdk_pix_bank_code_label
.sdk_pix_bank_branch_labelsdk_pix_bank_branch_label
.sdk_pix_bank_account_labelsdk_pix_bank_account_label
.sdk_pix_bank_account_digit_labelsdk_pix_bank_account_digit_label
.sdk_pix_bank_account_type_labelsdk_pix_bank_account_type_label
.insufficient_funds_for_amount_deposit_Try_a_lower_amountInsufficient funds for {{amount}} deposit. Try a lower amount.
.sdk_cvv_showsdk_cvv_show
.sdk_cvv_hidesdk_cvv_hide

What's next


Did this page help you?