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.

Core API

ComponentDescription
PrimerCheckoutManaged SwiftUI view that renders the SDK’s default checkout screens
PrimerCheckoutSessionObservable session that owns the checkout lifecycle for composable, inline checkout
PrimerCheckoutStateEnum representing checkout lifecycle states (initializing, ready, success, failure, dismissed)
PrimerCheckoutPresenterUIKit entry point that presents the managed checkout modally with a delegate

Card Form

ComponentDescription
PrimerCardFormCard payment form view with @ViewBuilder slots for card details, billing address, and submit
PrimerCardFormSessionObservable session exposing card-form state, field mutations, and the submit action
CardFormDefaultsPre-built slot bodies and per-field building blocks for custom card form layouts
Card Field ComponentsIndividual field building blocks (cardNumber, expiryDate, cvv, cardholderName, etc.)

Payment Methods

ComponentDescription
PrimerPaymentMethodsPayment method list view with @ViewBuilder slots for header, method row, and empty state
PrimerSelectionSessionObservable session exposing the selection state and selection actions
PaymentMethodsDefaultsPre-built slot bodies for custom payment method layouts
PrimerVaultedPaymentMethodsSaved payment methods view with slots for header, item, and submit

Theming

ComponentDescription
PrimerCheckoutThemeRoot theme container holding all design token override groups
ColorOverridesColor token overrides for light and dark mode
SpacingOverridesSpacing values for padding and margins
TypographyOverridesFont sizes, weights, and line heights
RadiusOverrides / BorderWidthOverrides / SizeOverridesCorner radius, border widths, and component sizes

Common Objects

ComponentDescription
PrimerSettingsSDK configuration (payment handling mode, options)
PrimerErrorError details with diagnostics ID and recovery suggestion
ValidationResultField validation result with error details
PrimerCardNetworkCard network type for co-badged card selection
PrimerCountryCountry data used for billing address selection

Session pattern

The iOS SDK exposes one managed entry point and one composable entry point. Both are built on the same observable PrimerCheckoutSession, which owns the checkout lifecycle: it loads the client session, tracks the lifecycle Phase, and delivers the final PrimerCheckoutState.

Composable (inline)

Hold a PrimerCheckoutSession as a @StateObject, then attach it to your view hierarchy with the .primerCheckoutSession(_:onCompletion:) modifier. The composable views — PrimerCardForm, PrimerPaymentMethods, and PrimerVaultedPaymentMethods — resolve their per-feature session from the SwiftUI environment and expose @ViewBuilder slots you can override.
@StateObject private var session = PrimerCheckoutSession(clientToken: token)

var body: some View {
    ScrollView {
        PrimerCardForm()
        PrimerPaymentMethods()
    }
    .primerCheckoutSession(session) { state in
        handle(state)
    }
}
Each composable view receives its session as a slot parameter so you can read state and call actions from your custom UI:
SessionResolved byExposes
PrimerCheckoutSession.primerCheckoutSession(_:onCompletion:)phase, onBeforePaymentCreate, idempotencyKey
PrimerCardFormSessionPrimerCardForm slotsCard field mutations, submit(), cancel()
PrimerSelectionSessionPrimerPaymentMethods / PrimerVaultedPaymentMethods slotsselect(_:), selectVaulted(_:), delete(_:), cancel()
Sessions are @MainActor ObservableObjects. Observe them with @StateObject (when you own them) or @ObservedObject (when they are passed into a slot), and read their @Published state/phase directly in your views.

Managed (modal)

For a turnkey flow that renders the SDK’s default screens, use PrimerCheckout in SwiftUI, or PrimerCheckoutPresenter from UIKit.
PrimerCheckout(clientToken: token) { state in
    handle(state)
}
PrimerCheckoutPresenter.shared.delegate = self
PrimerCheckoutPresenter.presentCheckout(clientToken: token, from: self)
Start with the managed PrimerCheckout view to get a working checkout quickly, then move to the composable views and @ViewBuilder slots when you need full control over the UI.

See also

PrimerCheckoutSession

Own the checkout lifecycle for inline, composable checkout.

PrimerCheckout

Drop in the managed SwiftUI checkout view.

PrimerCardForm

Build a custom card form with @ViewBuilder slots.

Handle payment result

React to the final PrimerCheckoutState.