PrimerCountry carries the ISO code, display name, flag emoji, and dial code, and is surfaced through PrimerCardFormState.selectedCountry once the buyer selects a country.
PrimerCountry is a public struct conforming to Equatable and Identifiable, where id is the ISO code. The stable identifier makes it safe to use directly in SwiftUI List and ForEach.
Definition
Properties
PrimerCountry requires iOS 15.0+, matching the minimum deployment target for the Checkout Components framework.Initializer
Reading the selected country
When billing address collection is enabled, the buyer’s chosen country is exposed on the card form state. ObservePrimerCardFormSession and read state.selectedCountry:
Updating the selected country
To set the billing country programmatically, callupdateCountryCode(_:) on the card form session with an ISO 3166-1 alpha-2 code. When the code is a supported country code with a dial-code entry, the session resolves state.selectedCountry into a full PrimerCountry. Otherwise, state.selectedCountry keeps its previous value. The codes BQ, BV, CW, EH, HM, SX, TF and UM have no dial-code entry. The buyer can pick them in the country picker, but state.selectedCountry keeps its previous value:
Equatable behavior
TwoPrimerCountry values are equal when all four properties (code, name, flag, dialCode) match. This makes PrimerCountry safe to compare when diffing card form state in Equatable-driven SwiftUI views.
See also
PrimerCardFormSession
Observe the card form state and update the billing country.
Validation
Field-level validation errors (
FieldError) for billing address inputs.