Skip to main content
Primer Checkout iOS SDK is currently in beta (v3.0.0-beta.8). The API is subject to change before the stable release.
PrimerCheckoutState is a public, Equatable enum that represents the current state of the checkout flow. It captures both the lifecycle of the session (initializing, ready) and its outcome (success, failure, dismissed). Your onCompletion closure on PrimerCheckout or on the .primerCheckoutSession(_:theme:onCompletion:) modifier receives the outcome states .success, .failure and .dismissed. To follow the lifecycle states .initializing and .ready, read PrimerCheckoutSession.phase. .success and .dismissed end the session and are delivered at most once. .failure depends on when it happens: once the checkout is ready, a failed payment attempt does not end the session — the SDK shows its error screen, offers a retry, and your closure is called again with the outcome of each further attempt. An initialization failure (before the checkout becomes ready) ends an inline PrimerCheckoutSession. PrimerCheckout keeps its initialization error view open with a Retry button, so a later outcome can still arrive. With uiOptions.isErrorScreenEnabled set to false, the SDK shows no error view and your app decides what to show. PrimerCheckoutPresenter closes its sheet on the failure instead.
Do not treat a .failure after the checkout is ready as the end of the session. If you tear down your checkout UI on it, a customer who retries after a decline and then succeeds will never reach your success handling. Tear down on .success and .dismissed. On an inline PrimerCheckoutSession, also tear down on a .failure that arrives before the session first becomes ready.
On iOS, a single PrimerCheckoutState enum covers what the Android SDK splits across PrimerCheckoutState (lifecycle) and PrimerCheckoutEvent (outcomes). The .initializing and .ready cases mirror the lifecycle; .success, .failure, and .dismissed mirror the outcome events delivered to onCompletion.

Definition

States

.ready associated values

To read the client session, use PrimerCheckoutSession.clientSession. It is @Published and becomes non-nil as soon as the checkout is ready:
refresh() renews clientSession, and cancel() sets it back to nil. The value is a snapshot. A client-session update during checkout, such as a surcharge or a billing address, does not update it.
This requires the inline integration. PrimerCheckout — the managed modal — renders the SDK’s own screens and exposes no session object, so the client session is not reachable from it.

.failure associated values

Lifecycle

A checkout session progresses from the lifecycle states to an outcome. .success and .dismissed end it. A .failure ends it only when initialization fails on an inline PrimerCheckoutSession, or when PrimerCheckoutPresenter closes its sheet with the error screen off:
.success and .dismissed are delivered at most once per session. .failure is delivered once per failed attempt. A failure before .ready ends an inline PrimerCheckoutSession. With the error screen off, any failure ends a PrimerCheckoutPresenter checkout. The lifecycle states .initializing and .ready are never passed to onCompletion.

Handling completion

Pass an onCompletion closure when you present checkout. It receives the outcome states — .success, .failure, or .dismissed — and may be called more than once if a payment attempt fails and the customer retries.
onCompletion only delivers outcome states, but a switch on PrimerCheckoutState must still be exhaustive. Cover the lifecycle cases .initializing and .ready with a default: case. @unknown default: does not cover them: it matches only cases added in a future version, so the compiler still warns that the switch is not exhaustive.

PaymentResult

PaymentResult is the value carried by .success. It is a public, Sendable, Equatable struct describing the completed payment.

PaymentStatus

PaymentStatus is a public, Sendable enum describing the final status of a payment.
Always include a default: (or @unknown default:) case when switching on PaymentStatus to handle future additions.

Handling the result

Use the .success payload to read the payment details and route your UI:
For a full integration walkthrough, see Handle payment result.

PrimerClientSession

The resolved client session, carried by .ready and published on PrimerCheckoutSession.clientSession.
Every property is optional because the client session itself is merchant-configured — a session created without line items has none. Read them defensively rather than assuming a shape.

PrimerLineItem

taxCode and taxAmount are per line item. Do not read the order’s total tax from them — a three-item order reports each item’s own tax, and the values will not sum to a field you can find elsewhere on the session unless your client session was configured that way.

PrimerOrder

PrimerCustomer

PrimerAddress

PrimerClientSession.PaymentMethod

A Codable, Equatable struct nested in PrimerClientSession, so name it as PrimerClientSession.PaymentMethod.

PrimerFee

See also

PrimerCheckout

Present checkout and receive the final state through onCompletion.

PrimerError

Error details carried by the .failure state.

Handle payment result

Route your UI based on the checkout outcome.

PrimerCheckoutSession

Drive the inline checkout lifecycle from your own layout.