UIKit entry point for presenting the managed checkout and receiving delegate callbacks
Primer Checkout iOS SDK is currently in beta (v3.0.0-beta.1).
The API is subject to change before the stable release.
PrimerCheckoutPresenter is the UIKit entry point for the managed checkout. It presents the
CheckoutComponents UI from a UIViewController and delivers results through a delegate, acting as a
bridge between UIKit apps and the underlying SwiftUI implementation.
For pure SwiftUI apps, use PrimerCheckout
directly instead of this class. PrimerCheckoutPresenter exists for view-controller based
navigation and Objective-C interoperability.
@available(iOS 15.0, *)@MainActor@objc public final class PrimerCheckoutPresenter: NSObject
The presenter is a @MainActor singleton: call its static methods from the main thread (the
default for UIKit lifecycle callbacks). It is also exposed to Objective-C via @objc.
The shared singleton instance. Use it to assign the delegate. Exposed to Objective-C.
delegate
PrimerCheckoutPresenterDelegate?
The object that receives checkout result and lifecycle callbacks. Held weakly.
isAvailable
Bool
static. true when CheckoutComponents can be presented on the current OS version.
isPresenting
Bool
static. true while a checkout is being presented or is currently on screen.
@objc public static let shared = PrimerCheckoutPresenter()public weak var delegate: PrimerCheckoutPresenterDelegate?@objc public static var isAvailable: Bool@objc public static var isPresenting: Bool
delegate is a weak reference. Retain the object you assign (for example the presenting view
controller) for as long as checkout is on screen, otherwise callbacks will not fire.
presentCheckout has four overloads. They differ only in how much you configure and whether you
supply the presenting view controller yourself. All overloads accept an optional trailing
completion closure that runs once the checkout UI has finished presenting.None of these parameters have Swift defaults. The overloads that omit settings or theme apply the
SDK’s current global PrimerSettings and a default PrimerCheckoutTheme() internally.
If no presenting view controller can be found, the automatic overloads report a
PrimerError through
primerCheckoutPresenterDidFailWithError(_:). Assign the delegate before calling these methods.
The client token for the session. Generate it from your backend with the client session API.
viewController
UIViewController
—
The view controller to present from. Omitted in the automatic-detection overloads.
primerSettings
PrimerSettings
—
Configuration applied to this checkout session. Overloads that omit it use the SDK’s current global PrimerSettings. See PrimerSettings.
primerTheme
PrimerCheckoutTheme
—
Theme configuration for the design tokens. Overloads that omit it use a default PrimerCheckoutTheme().
completion
(() -> Void)?
nil
Optional closure invoked once the checkout UI has finished presenting.
The overloads that take primerSettings or primerTheme are not@objc compatible because of
those Swift-only parameter types. From Objective-C, use the clientToken /
clientToken:from: overloads, or configure settings globally via PrimerSettings.
Optional closure invoked after dismissal completes.
Calling dismiss triggers primerCheckoutPresenterDidDismiss() on the delegate. The checkout also
dismisses itself automatically when a payment succeeds or fails.
Conform to this protocol to receive checkout results and lifecycle events. The result methods are
required; the 3DS lifecycle methods are optional thanks to default implementations in a protocol
extension.
Implement these only if you need to observe the 3-D Secure challenge lifecycle. Each has a default
empty implementation, so you can omit any you do not need.
The success callback delivers a PaymentResult value.
public struct PaymentResult: Sendable, Equatable { public let paymentId: String public let status: PaymentStatus public let token: String? public let redirectUrl: String? public let errorMessage: String? public let amount: Int? public let currencyCode: String? public let paymentMethodType: String?}
PrimerCheckoutPresenter.shared.delegate is weak. Keep the conforming object (here, the view
controller) alive for the duration of checkout so the callbacks are delivered.