PrimerPaymentMethods is the SwiftUI view that renders the list of available payment methods. It is composed from three @ViewBuilder slots — a header, a per-method method row, and an emptyState — and resolves its PrimerSelectionSession from the environment supplied by the .primerCheckoutSession(_:) modifier.
Each slot defaults to the matching helper on PaymentMethodsDefaults, so calling PrimerPaymentMethods() with no arguments renders the SDK’s built-in UI. Override any one slot to customize that part of the list while keeping the defaults for the rest.
PrimerPaymentMethods is available on iOS 15.0 and later (@available(iOS 15.0, *)).Signature
Parameters
Default behavior
By defaultPrimerPaymentMethods arranges its slots in a vertical stack:
- Renders the default header.
- When
session.state.paymentMethodsis non-empty, renders one default row per method. Each row’s tap triggerssession.select(paymentMethod), starting that method’s flow. - When
session.state.paymentMethodsis empty, renders the default empty state.
PrimerPaymentMethods applies the spacing between its slots itself, so the spacing stays the same when you override a slot. primerSpaceMedium (12pt by default) separates the header from the list of methods, or from the empty state when there are no methods. primerSpaceSmall (8pt by default) separates the method rows. You can change both through SpacingOverrides in PrimerCheckoutTheme.
PrimerPaymentMethods renders nothing while no PrimerSelectionSession is in the environment. This happens while the checkout session is still initializing, and when the view is used outside .primerCheckoutSession(_:). The list appears once session.phase reaches .ready.
Wire the view hierarchy with
.primerCheckoutSession(_:). PrimerPaymentMethods reads its session from the environment — you do not pass the session into the view directly.CheckoutPaymentMethod
CheckoutPaymentMethod describes a single payment method available for selection. It contains the method’s display information and optional custom styling. The method slot receives one instance per available method, and selecting a method is also surfaced through session.state.selectedPaymentMethod.
Properties
CheckoutPaymentMethod equality compares only id, type, name, surcharge, hasUnknownSurcharge, formattedSurcharge and backgroundColor. Background colors are compared in both light and dark mode. The display-only properties icon, buttonText, textColor, borderColor, borderWidth and cornerRadius are ignored, so a change to them alone does not make two methods unequal.Customization
Custom method row
Override themethod slot to render your own row. The slot receives the CheckoutPaymentMethod and an onSelect closure — call onSelect when the user taps your row to start that method’s flow.
Custom empty state
Override theemptyState slot to control what appears when no methods are available. The slot receives the PrimerSelectionSession so you can read selection state if needed.
Custom header
Override theheader slot to replace the default section title.
See also
PrimerSelectionSession
The observable session that drives the method list and selection.
PaymentMethodsDefaults
Default slot bodies used by PrimerPaymentMethods.
PrimerVaultedPaymentMethods
Render and select saved (vaulted) payment methods.
PrimerCardForm
The slot-based card entry composable.