Skip to main content
Primer Checkout iOS SDK is currently in beta (v3.0.0-beta.1). The API is subject to change before the stable release.
PaymentMethodsDefaults is a public enum (used as a namespace) providing the pre-built @ViewBuilder content that PrimerPaymentMethods renders when you omit a slot. Use these helpers inside your own slots to mix custom and default content, or as a reference for the default look and feel.
@available(iOS 15.0, *)
public enum PaymentMethodsDefaults
Each helper is the default value for the matching PrimerPaymentMethods slot. The component falls back to PaymentMethodsDefaults.header($0), PaymentMethodsDefaults.method($0, onSelect: $1), and PaymentMethodsDefaults.emptyState($0) when those slots are not supplied.

Builders

BuilderDescription
header(_:)Default “Choose payment method” header styled with the current theme
method(_:onSelect:)Payment method row with icon, name, optional surcharge, and selection action
emptyState(_:)Message displayed when no payment methods are available
public static func header(_ session: PrimerSelectionSession) -> PaymentMethodsHeaderContent
Renders the section title using the theme’s typography and color tokens, with the header accessibility trait applied.
ParameterTypeDescription
sessionPrimerSelectionSessionThe active selection session. Accepted to match the slot closure signature; the default header is static.
The session parameter exists only so this helper matches the header slot’s closure signature — the default header does not read from it.

method

public static func method(
    _ method: CheckoutPaymentMethod,
    onSelect: @escaping () -> Void
) -> PaymentMethodRowContent
Renders a tappable row for a single payment method, including its icon, display name, and any surcharge.
ParameterTypeDescription
methodCheckoutPaymentMethodThe payment method data to display
onSelect@escaping () -> VoidCallback invoked when the row is tapped. PrimerPaymentMethods wires this to session.select(method).

emptyState

public static func emptyState(_ session: PrimerSelectionSession) -> PaymentMethodsEmptyContent
Rendered automatically by PrimerPaymentMethods when session.state.paymentMethods is empty.
ParameterTypeDescription
sessionPrimerSelectionSessionThe active selection session. Accepted to match the slot closure signature; the default empty state is static.

Return types

Each builder returns a concrete public view type so it can serve as a @ViewBuilder default argument. You can use these types directly when composing your own layouts.
TypeReturned byDescription
PaymentMethodsHeaderContentheader(_:)The default section header view
PaymentMethodRowContentmethod(_:onSelect:)A single default payment method row
PaymentMethodsEmptyContentemptyState(_:)The default empty-state view
@available(iOS 15.0, *)
public struct PaymentMethodsHeaderContent: View

@available(iOS 15.0, *)
public struct PaymentMethodRowContent: View

@available(iOS 15.0, *)
public struct PaymentMethodsEmptyContent: View

Using defaults inside custom slots

Reuse a default builder for one part of the list while customizing another. Here the default header and empty state are kept, but each row is replaced with a branded row:
import SwiftUI
import PrimerSDK

struct CustomPaymentMethodsView: View {
    var body: some View {
        PrimerPaymentMethods(
            method: { method, onSelect in
                Button(action: onSelect) {
                    HStack {
                        if let icon = method.icon {
                            Image(uiImage: icon)
                                .resizable()
                                .scaledToFit()
                                .frame(width: 24, height: 24)
                        }
                        Text(method.name)
                        Spacer()
                        if let surcharge = method.formattedSurcharge {
                            Text(surcharge)
                                .foregroundColor(.secondary)
                        }
                    }
                    .padding()
                }
            }
        )
    }
}
Because the header and emptyState slots are omitted, PrimerPaymentMethods falls back to PaymentMethodsDefaults.header and PaymentMethodsDefaults.emptyState. You can also call a default builder explicitly — for example, to render the default row while wrapping it in your own container:
PrimerPaymentMethods(
    method: { method, onSelect in
        PaymentMethodsDefaults.method(method, onSelect: onSelect)
            .padding(.horizontal)
            .background(Color(.secondarySystemBackground))
            .cornerRadius(12)
    }
)
The header and emptyState slots pass you the PrimerSelectionSession, so you can branch on session.state to show custom content while still falling back to a default builder when appropriate.

See also

PrimerPaymentMethods

The slot-based payment method list these defaults power.

PrimerSelectionSession

Session that exposes the available methods and the select action.

VaultedPaymentMethods

Saved payment methods and their own default sub-components.

CardFormDefaults

The equivalent default sub-components for the card form.