PrimerVaultedPaymentMethods renders the customer’s saved (vaulted) payment methods as a list, composed from three slots: a header, a per-method row, and a submit button. Tapping a row selects that method; the submit button pays with the currently selected vaulted method.
The view resolves its PrimerSelectionSession from the environment. Selection, deletion, and CVV recapture are all driven through that session — PrimerVaultedPaymentMethods only composes the UI.
This view reads its session from the environment injected by the
.primerCheckoutSession(_:onCompletion:) modifier. Place it inside a view hierarchy that applies that modifier. When no session is present it renders an empty placeholder.PrimerVaultedPaymentMethods
| Parameter | Type | Default | Description |
|---|---|---|---|
header | (PrimerSelectionSession) -> AnyView | VaultedPaymentMethodsDefaults.header($0) | Header shown above the list. Receives the session so custom headers can read state or trigger session actions. |
item | (VaultedMethod, _ isSelected: Bool, _ onSelect: @escaping () -> Void) -> AnyView | VaultedPaymentMethodsDefaults.item(...) | Row for each vaulted method. Receives the method, whether it is currently selected, and a callback to select it. |
submitButton | (_ isLoading: Bool, _ isEnabled: Bool, _ onSubmit: @escaping () -> Void) -> AnyView | VaultedPaymentMethodsDefaults.submitButton(...) | Submit button below the list. Receives loading state, enabled state, and a callback that pays with the selected method. |
Slots are type-erased to
AnyView rather than using opaque return types. The three-argument item and submitButton builders hit Swift’s generic-default inference limits, so this view trades the opaque-return ergonomics of PrimerCardForm for guaranteed composition. Wrap any custom slot content in AnyView.VaultedMethod typealias
VaultedMethod is a convenience alias for PrimerHeadlessUniversalCheckout.VaultedPaymentMethod, the model passed to the item slot.
| Property | Type | Description |
|---|---|---|
id | String | Unique identifier for this vaulted method. Use it to drive selection and deletion. |
paymentMethodType | String | Payment method type (e.g. "PAYMENT_CARD", "PAYPAL"). |
paymentInstrumentType | PaymentInstrumentType | Type of payment instrument (e.g. card, bank account). |
paymentInstrumentData | Response.Body.Tokenization.PaymentInstrumentData | Detailed instrument data: card network, masked digits, expiry, external payer info, BIN data. |
analyticsId | String | Identifier used for analytics tracking. |
Usage
The default slots produce a complete, themed vaulted list — no slot arguments are required:Customizing slots
Provide any combination of slots; omitted slots fall back to their defaults. Custom content must be wrapped inAnyView.
Driving selection, deletion, and CVV
PrimerVaultedPaymentMethods delegates all behavior to PrimerSelectionSession. Read vaultedPaymentMethods and call the session methods directly from custom slots.
| Member | Signature | Description |
|---|---|---|
vaultedPaymentMethods | var vaultedPaymentMethods: [PrimerHeadlessUniversalCheckout.VaultedPaymentMethod] { get } | Saved methods for the current customer, loaded once during checkout initialization. Empty while loading or when none exist. |
selectVaulted(_:) | func selectVaulted(_ method: PrimerHeadlessUniversalCheckout.VaultedPaymentMethod) | Marks a vaulted method as selected so a subsequent submit targets it. Backing the item slot’s onSelect. |
delete(_:) | func delete(_ method: PrimerHeadlessUniversalCheckout.VaultedPaymentMethod) | Routes to the delete-confirmation screen for a vaulted method. |
showAll() | func showAll() | Navigates to the full list of saved payment methods. |
updateCvvInput(_:) | func updateCvvInput(_ cvv: String) | Updates and validates the CVV during CVV recapture, driving state.cvvInput, state.isCvvValid, and state.cvvError. |
session.state (PrimerPaymentMethodSelectionState):
| Property | Type | Description |
|---|---|---|
selectedVaultedPaymentMethod | PrimerHeadlessUniversalCheckout.VaultedPaymentMethod? | The currently selected vaulted method, or nil. Compare its id to highlight the selected row. |
isVaultPaymentLoading | Bool | true while a vaulted payment is in flight. Backs the submit slot’s isLoading. |
requiresCvvInput | Bool | true when the selected card requires CVV recapture before submitting. |
cvvInput | String | The CVV value entered during recapture. |
isCvvValid | Bool | true when the entered CVV passes validation. |
cvvError | String? | CVV validation error message, if any. |
CVV recapture is handled by the SDK and is not a customizable slot. When the selected vaulted card requires a CVV, the view inserts a managed CVV field between the rows and the submit button, wired to
updateCvvInput(_:). The submit button stays disabled until a method is selected and — when CVV recapture is required — until a valid CVV is entered.VaultedPaymentMethodsDefaults
The default slot content. BecausePrimerVaultedPaymentMethods erases its slots to AnyView, these helpers return some View. Compose them inside custom slots to keep the default look while overriding only part of the layout.
| Method | Description |
|---|---|
header(_:) | Default section header (“All saved payment methods”). The session argument is accepted only to match the slot signature; the header is static. |
item(_:isSelected:onSelect:) | Default vaulted method row with brand icon, label, and a selection checkmark. |
submitButton(isLoading:isEnabled:onSubmit:) | Default pay button. Shows a progress spinner while isLoading and dims while disabled. |
cvvInput(_:) | SDK-managed CVV recapture field, shown only when session.state.requiresCvvInput is true. Rendered automatically by the view — not a slot you pass in. |
unavailable() | Empty placeholder rendered when no PrimerSelectionSession is available in the environment. |
See also
PrimerSelectionSession
Selection, deletion, and CVV actions for payment methods and vaulted methods.
PrimerPaymentMethods
Slot-based list of available (non-vaulted) payment methods.
PaymentMethodsDefaults
Default slot content for the payment methods list.
PrimerCardForm
Slot-based card entry form for new cards.