Skip to main content
PrimerCheckoutScope is the top-level scope providing access to checkout state, payment method scopes, and screen-level customization.

Declaration

@MainActor
public protocol PrimerCheckoutScope: AnyObject

Properties

State

PropertyTypeDescription
stateAsyncStream<PrimerCheckoutState>Stream of checkout state changes
paymentMethodSelectionPrimerPaymentMethodSelectionScopeAccess to the payment method selection scope
paymentHandlingPrimerPaymentHandlingCurrent payment handling mode (.auto or .manual)

Customization

PropertyTypeDescription
containerContainerComponent?Wraps all checkout content. Receives a content closure.
splashScreenComponent?Shown during initialization
loadingComponent?Shown during payment processing
errorScreenErrorComponent?Shown on error. Receives error message.

Methods

getPaymentMethodScope

Access a specific payment method scope:
// By scope type
func getPaymentMethodScope<T: PrimerPaymentMethodScope>(_ scopeType: T.Type) -> T?

// By payment method type enum
func getPaymentMethodScope<T: PrimerPaymentMethodScope>(for methodType: PrimerPaymentMethodType) -> T?

// By payment method type string
func getPaymentMethodScope<T: PrimerPaymentMethodScope>(for paymentMethodType: String) -> T?

Examples

// Get card form scope
let cardScope: PrimerCardFormScope? = checkoutScope.getPaymentMethodScope(PrimerCardFormScope.self)

// Get Apple Pay scope by enum
let applePayScope: PrimerApplePayScope? = checkoutScope.getPaymentMethodScope(for: .applePay)

// Get PayPal scope by string
let paypalScope: PrimerPayPalScope? = checkoutScope.getPaymentMethodScope(for: "PAYPAL")

onDismiss

Programmatically dismiss the checkout:
func onDismiss()

PrimerCheckoutState

CaseAssociated valuesDescription
.initializingLoading configuration
.readytotalAmount: Int, currencyCode: StringReady for interaction
.successPaymentResultPayment completed
.failurePrimerErrorPayment failed
.dismissedCheckout dismissed

See also

Scopes overview

Scope hierarchy and access patterns

State and events

State observation patterns