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.
PrimerCardFormSession is the observable session for the card payment form. It publishes the current PrimerCardFormState and exposes field update methods, co-badge network selection, and submission controls. The session is created by the SDK and injected into every PrimerCardForm slot closure. Read state to render your UI and call the session’s methods to mutate the form.
You never instantiate PrimerCardFormSession yourself. Each PrimerCardForm slot (cardDetails, billingAddress, submitButton) receives the session as a closure parameter. Observe it with @ObservedObject.

Accessing the session

The session is passed to each PrimerCardForm slot. Capture it and observe state to drive your UI:
To observe state changes inside a custom subview, mark the captured session as @ObservedObject:

Property

Methods

Field update methods

Each setter forwards a raw string to the form. The session re-validates and re-publishes state after every update. Updating the card number triggers network detection and may populate state.availableNetworks and state.binData.

Network selection

Lifecycle

When wiring custom TextFields, drive each field with the matching update* method and read back the current value from session.state.data so the form stays the single source of truth.

PrimerCardFormState

The complete state of the card payment form: configuration, current field values, validation errors, loading and validity flags, co-badge network selection, and surcharge information.

Properties

Convenience properties

Helper methods

Validation errors surface in fieldErrors after the form evaluates a field. Use isValid to gate the submit button and errorMessage(for:) to display per-field messages. See ValidationResult.

CardFormConfiguration

Declares which fields the card form requires.
The static CardFormConfiguration.default requires [.cardNumber, .expiryDate, .cvv, .cardholderName] with no billing fields.

FormData

Type-safe container for field values keyed by PrimerInputElementType. Subscript access returns an empty string for unset fields.

FieldError

A validation error for a specific form field.

PrimerInputElementType

The field identifier used throughout PrimerCardFormState (in configuration, data, and fieldErrors).

See also

PrimerCardForm

The card form component and its customizable slots.

Card field components

Prebuilt field views from CardFormDefaults.

ValidationResult

Field validation model and error handling.

PrimerCountry

Country model for billing address selection.