> ## 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.

# PrimerPaymentMethodSelectionScope

> API reference for the payment method selection scope

`PrimerPaymentMethodSelectionScope` manages the payment method list, selection, and vaulted payment methods.

## Declaration

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

## Properties

### State

| Property                       | Type                                             | Description                       |
| ------------------------------ | ------------------------------------------------ | --------------------------------- |
| `state`                        | `AsyncStream<PrimerPaymentMethodSelectionState>` | Stream of selection state changes |
| `dismissalMechanism`           | `[DismissalMechanism]`                           | Supported dismissal methods       |
| `selectedVaultedPaymentMethod` | `VaultedPaymentMethod?`                          | Currently selected vaulted method |

### Customization

| Property            | Type                                     | Description                                                                           |
| ------------------- | ---------------------------------------- | ------------------------------------------------------------------------------------- |
| `screen`            | `PaymentMethodSelectionScreenComponent?` | Full screen replacement. Signature: `(PrimerPaymentMethodSelectionScope) -> any View` |
| `paymentMethodItem` | `PaymentMethodItemComponent?`            | Custom payment method row. Signature: `(CheckoutPaymentMethod) -> any View`           |
| `categoryHeader`    | `CategoryHeaderComponent?`               | Custom section header. Signature: `(String) -> any View`                              |
| `emptyStateView`    | `Component?`                             | Shown when no methods are available                                                   |

## Methods

| Method                                             | Description                          |
| -------------------------------------------------- | ------------------------------------ |
| `onPaymentMethodSelected(paymentMethod:)`          | Select a payment method to proceed   |
| `cancel()`                                         | Cancel the selection                 |
| `payWithVaultedPaymentMethod()`                    | Pay with the selected vaulted method |
| `payWithVaultedPaymentMethodAndCvv(_ cvv: String)` | Pay with vaulted method using CVV    |
| `updateCvvInput(_ cvv: String)`                    | Update CVV input for vaulted method  |
| `showAllVaultedPaymentMethods()`                   | Expand the vaulted methods list      |
| `showOtherWaysToPay()`                             | Show additional payment methods      |

## PrimerPaymentMethodSelectionState

```swift theme={"dark"}
public struct PrimerPaymentMethodSelectionState {
  var paymentMethods: [CheckoutPaymentMethod]
  var isLoading: Bool
  var selectedPaymentMethod: CheckoutPaymentMethod?
  var searchQuery: String
  var filteredPaymentMethods: [CheckoutPaymentMethod]
  var error: String?
  var selectedVaultedPaymentMethod: VaultedPaymentMethod?
  var isVaultPaymentLoading: Bool
  var requiresCvvInput: Bool
  var cvvInput: String
  var isCvvValid: Bool
  var cvvError: String?
  var isPaymentMethodsExpanded: Bool
}
```

| Property                 | Type                      | Description                             |
| ------------------------ | ------------------------- | --------------------------------------- |
| `paymentMethods`         | `[CheckoutPaymentMethod]` | All available payment methods           |
| `isLoading`              | `Bool`                    | Loading state                           |
| `selectedPaymentMethod`  | `CheckoutPaymentMethod?`  | Currently selected method               |
| `filteredPaymentMethods` | `[CheckoutPaymentMethod]` | Methods matching search query           |
| `error`                  | `String?`                 | Error message                           |
| `requiresCvvInput`       | `Bool`                    | Whether selected vault method needs CVV |
| `isCvvValid`             | `Bool`                    | CVV validation state                    |

## See also

<CardGroup cols={2}>
  <Card title="Display saved methods" icon="vault" href="/checkout/primer-checkout/guides-and-recipes/display-saved-payment-methods">
    Work with vaulted payment methods
  </Card>

  <Card title="Layout customization" icon="wand-magic-sparkles" href="/checkout/primer-checkout/build-your-ui/layout-customization">
    Customize the checkout layout
  </Card>
</CardGroup>
