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 eachPrimerCardForm slot. Capture it and observe state to drive your UI:
@ObservedObject:
Property
Methods
Field update methods
Each setter forwards a raw string to the form. The session re-validates and re-publishesstate
after every update. Updating the card number triggers network detection and may populate
state.availableNetworks and state.binData.
Network selection
Lifecycle
PrimerCardFormState
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
CardFormConfiguration.default requires [.cardNumber, .expiryDate, .cvv, .cardholderName]
with no billing fields.
FormData
PrimerInputElementType. Subscript access returns an
empty string for unset fields.
FieldError
PrimerInputElementType
The field identifier used throughoutPrimerCardFormState (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.