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

# PrimerAchScope

> API reference for the ACH scope

`PrimerAchScope` manages the ACH multi-step payment flow: user details collection, bank account collection, and mandate acceptance.

## Declaration

```swift theme={"dark"}
@MainActor
public protocol PrimerAchScope: PrimerPaymentMethodScope where State == PrimerAchState
```

## Properties

| Property                      | Type                          | Description                                   |
| ----------------------------- | ----------------------------- | --------------------------------------------- |
| `state`                       | `AsyncStream<PrimerAchState>` | Stream of ACH state changes                   |
| `presentationContext`         | `PresentationContext`         | `.direct` or `.fromPaymentSelection`          |
| `dismissalMechanism`          | `[DismissalMechanism]`        | Supported dismissal methods                   |
| `bankCollectorViewController` | `UIViewController?`           | Bank collection view controller for embedding |

### Customization

| Property            | Type                  | Description                                                            |
| ------------------- | --------------------- | ---------------------------------------------------------------------- |
| `screen`            | `AchScreenComponent?` | Full screen replacement. Signature: `(any PrimerAchScope) -> any View` |
| `userDetailsScreen` | `AchScreenComponent?` | User details step replacement                                          |
| `mandateScreen`     | `AchScreenComponent?` | Mandate step replacement                                               |
| `submitButton`      | `AchButtonComponent?` | Custom submit button. Signature: `(any PrimerAchScope) -> any View`    |

## Methods

| Method                                | Description                                       |
| ------------------------------------- | ------------------------------------------------- |
| `updateFirstName(_ value: String)`    | Update first name                                 |
| `updateLastName(_ value: String)`     | Update last name                                  |
| `updateEmailAddress(_ value: String)` | Update email address                              |
| `submitUserDetails()`                 | Submit user details to proceed to bank collection |
| `acceptMandate()`                     | Accept the ACH mandate                            |
| `declineMandate()`                    | Decline the mandate                               |
| `onBack()`                            | Navigate back                                     |
| `cancel()`                            | Cancel the ACH flow                               |

## PrimerAchState

```swift theme={"dark"}
public struct PrimerAchState: Equatable {
  public enum Step: Equatable {
    case loading
    case userDetailsCollection
    case bankAccountCollection
    case mandateAcceptance
    case processing
  }

  var step: Step
  var userDetails: UserDetails
  var fieldValidation: FieldValidation?
  var mandateText: String?
  var isSubmitEnabled: Bool
}
```

### Flow

```mermaid theme={"dark"}
stateDiagram-v2
    [*] --> loading
    loading --> userDetailsCollection
    userDetailsCollection --> bankAccountCollection
    bankAccountCollection --> mandateAcceptance
    mandateAcceptance --> processing
    processing --> [*]
```

### UserDetails

```swift theme={"dark"}
public struct UserDetails: Equatable {
  let firstName: String
  let lastName: String
  let emailAddress: String
}
```

### FieldValidation

```swift theme={"dark"}
public struct FieldValidation: Equatable {
  let firstNameError: String?
  let lastNameError: String?
  let emailError: String?
  var hasErrors: Bool
}
```

| Property          | Type               | Description                        |
| ----------------- | ------------------ | ---------------------------------- |
| `step`            | `Step`             | Current step in the flow           |
| `userDetails`     | `UserDetails`      | Collected user details             |
| `fieldValidation` | `FieldValidation?` | Validation errors for user details |
| `mandateText`     | `String?`          | ACH mandate text for acceptance    |
| `isSubmitEnabled` | `Bool`             | Whether submit is allowed          |

## See also

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