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
| Parameter | Type | Default | Description |
|---|---|---|---|
header | (PrimerSelectionSession) -> Header | PaymentMethodsDefaults.header($0) | Slot for the section header rendered above the list. Receives the PrimerSelectionSession. |
method | (CheckoutPaymentMethod, @escaping () -> Void) -> Method | PaymentMethodsDefaults.method($0, onSelect: $1) | Slot rendered once per available method. Receives the CheckoutPaymentMethod and an onSelect closure to invoke when the row is tapped. |
emptyState | (PrimerSelectionSession) -> Empty | PaymentMethodsDefaults.emptyState($0) | Slot shown when no payment methods are available. Receives the PrimerSelectionSession. |
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.
PrimerSelectionSession is present in the environment (the view is used outside .primerCheckoutSession(_:)), nothing is rendered.
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
| Property | Type | Description |
|---|---|---|
id | String | Unique identifier for this payment method instance. |
type | String | The payment method type identifier (e.g., "PAYMENT_CARD", "PAYPAL", "APPLE_PAY"). |
name | String | Human-readable display name for the payment method. |
icon | UIImage? | Icon image to display for this payment method. |
surcharge | Int? | Surcharge amount in minor currency units (e.g., cents), if applicable. |
hasUnknownSurcharge | Bool | Indicates whether the surcharge amount is unknown (e.g., varies by card network). |
formattedSurcharge | String? | Pre-formatted surcharge string for display (e.g., "+ $0.50"). |
backgroundColor | UIColor? | Custom background color for the payment method button. |
buttonText | String? | Custom button text from display metadata (e.g., "Pay with Klarna"). |
textColor | UIColor? | Custom text color for the payment method button. |
borderColor | UIColor? | Custom border color for the payment method button. |
borderWidth | CGFloat? | Custom border width for the payment method button. |
cornerRadius | CGFloat? | Custom corner radius for the payment method button. |
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.