> ## Documentation Index
> Fetch the complete documentation index at: https://primer.io/docs/llms.txt
> Use this file to discover all available pages before exploring further.

# PrimerCheckoutScope

> API reference for the top-level checkout scope protocol

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

## Declaration

```swift theme={"dark"}
@MainActor
public protocol PrimerCheckoutScope: AnyObject
```

## Properties

### State

| Property                 | Type                                | Description                                          |
| ------------------------ | ----------------------------------- | ---------------------------------------------------- |
| `state`                  | `AsyncStream<PrimerCheckoutState>`  | Stream of checkout state changes                     |
| `paymentMethodSelection` | `PrimerPaymentMethodSelectionScope` | Access to the payment method selection scope         |
| `paymentHandling`        | `PrimerPaymentHandling`             | Current payment handling mode (`.auto` or `.manual`) |

### Customization

| Property       | Type                  | Description                                             |
| -------------- | --------------------- | ------------------------------------------------------- |
| `container`    | `ContainerComponent?` | Wraps all checkout content. Receives a content closure. |
| `splashScreen` | `Component?`          | Shown during initialization                             |
| `loading`      | `Component?`          | Shown during payment processing                         |
| `errorScreen`  | `ErrorComponent?`     | Shown on error. Receives error message.                 |

## Methods

### getPaymentMethodScope

Access a specific payment method scope:

```swift theme={"dark"}
// 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

```swift theme={"dark"}
// 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:

```swift theme={"dark"}
func onDismiss()
```

## PrimerCheckoutState

| Case            | Associated values                        | Description           |
| --------------- | ---------------------------------------- | --------------------- |
| `.initializing` | —                                        | Loading configuration |
| `.ready`        | `totalAmount: Int, currencyCode: String` | Ready for interaction |
| `.success`      | `PaymentResult`                          | Payment completed     |
| `.failure`      | `PrimerError`                            | Payment failed        |
| `.dismissed`    | —                                        | Checkout dismissed    |

## See also

<CardGroup cols={2}>
  <Card title="Scopes overview" icon="diagram-project" href="/sdk/ios-checkout/v3.0.0-beta/configuration/scopes-overview">
    Scope hierarchy and access patterns
  </Card>

  <Card title="State and events" icon="bolt" href="/sdk/ios-checkout/v3.0.0-beta/configuration/state-events">
    State observation patterns
  </Card>
</CardGroup>
