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

# provide

This method allows you get a new instance of `StripeAchUserDetailsComponent` to initiate Stripe ACH payments.

```swift SWIFT theme={"dark"}
public func provide<PrimerHeadlessAchComponent>(paymentMethodType: String) throws -> PrimerHeadlessAchComponent?
        where PrimerCollectableData: Any, PrimerHeadlessStep: Any
```

## Parameters

**Parameters**

**paymentMethodType** `String` *required*

A unique string identifier for the payment method. Supported payment methods for current client session are returned in [primerHeadlessUniversalCheckoutDidLoadAvailablePaymentMethods](https://primer.io/docs/sdk/ios/v2.x.x/primer-headless-checkout/delegates/PrimerHeadlessUniversalCheckoutDelegate.md#primerheadlessuniversalcheckoutdidloadavailablepaymentmethods) delegate method.

## Type parameters

**Type Parameters**

**PrimerHeadlessAchComponent** `PrimerCollectableData, PrimerHeadlessStep` *required*

The type of the `PrimerHeadlessAchComponent` implementation to
return.

**Supported types**

<table>
  <tr>
    <th>Type</th>
    <th>paymentMethodType</th>
  </tr>

  <tr>
    <td>
      [StripeAchUserDetailsComponent](#param-stripe-ach-user-details-component)
    </td>

    <td>
      [STRIPE\_ACH](https://primer.io/docs/sdk/ios/v2.x.x/primer-headless-checkout/ach-headless-manager/provide.md)
    </td>
  </tr>
</table>

## Returns

An instance of the passed generic type, which could be any of the following available components:

**Common API**

**PrimerHeadlessAchComponent** `Implemented by all components`

**Methods and Properties**

**start**

Initialize the component by calling the start function. This method should be called only once.

**submit**

Call `submit` function in order to process collected data and move component to next state.

**errorDelegate** `PrimerHeadlessErrorableDelegate`

Error delegate will be triggered every time an error is thrown in the process.

```swift SWIFT theme={"dark"}
  func didReceiveError(error: PrimerError)
```

**Supported types**

**StripeAchUserDetailsComponent** `PrimerHeadlessAchComponent where Data == ACHUserDetailsCollectableData, Step == ACHUserDetailsStep`

**API**

**updateCollectedData(collectableData: ACHUserDetailsCollectableData)**

Update component with collected data by passing an enum representing collectable data. This method can be called at any point, even if you have only partially collected data.
To validate the partially collected data, you can refer to the [validationDelegate](#param-validation-delegate) and receive the validation status when it's updated.

In case of ACH, the Data will be of type `ACHUserDetailsCollectableData`.

**enum ACHUserDetailsCollectableData**

**firstName**

Enum member representing the customer's first name.

**Properties**

**value** `String`

The string value for the customer's first name.

**lastName**

Enum member representing the customer's last name.

**Properties**

**value** `String`

The string value for the customer's last name.

**emailAddress**

Enum member representing the customer's email address.

**Properties**

**value** `String`

The string value for the customer's email address.

Example:

```swift SWIFT theme={"dark"}
func updateCollectedData(collectableData: ACHUserDetailsCollectableData)
```

**stepDelegate** `PrimerHeadlessStepDelegate`

Whenever [start](#param-start) or [submit](#param-submit) methods are called, `stepDelegate` will trigger the next step in
case the call to the mentioned method was successful.

In the case of `STRIPE_ACH`, the steps will be of type&#x20;
`ACHUserDetailsStep`.

`ACHUserDetailsStep` is an enum holding different output data for
specific steps.

**enum ACHUserDetailsStep**

**retrievedUserDetails(\_ details: ACHUserDetails)**

Enum member representing the retrieved user details.

**Properties**

**details** `ACHUserDetails`

The retrieved user details of type `ACHUserDetails`&#x20;
previously sent on client session creation.

**Properties**

**firstName** `String`

The first name previously sent on client session creation.

**lastName** `String`

The last name previously sent on client session creation.

**emailAddress** `String`

The email address previously sent on client session creation.

**didCollectUserDetails**

Enum member representing the event of collected user details.

Example:

```swift SWIFT theme={"dark"}
func didReceiveStep(step: PrimerHeadlessStep) {
    guard let step = step as? ACHUserDetailsStep else { return }
    switch step {
    case .retrievedUserDetails(let userDetails):
    case .didCollectUserDetails:
    }
}
```

**validationDelegate** `PrimerHeadlessValidatableDelegate`

Validation delegate will be triggered every time collected data is updated.

```swift SWIFT theme={"dark"}
func didUpdate(validationStatus: PrimerValidationStatus, for data: PrimerCollectableData?)
```

In the case of `STRIPE_ACH`, the data will be of type&#x20;
`ACHUserDetailsCollectableData`.

**PrimerValidationStatus** `Enum`

`PrimerValidationStatus` is an enum that represents the different validation statuses in the Primer SDK. It helps to communicate the state of validation for a particular process, providing clear categorization of validation states.

**enum PrimerValidationStatus**

**validating** `ACHUserDetailsCollectableData`

Enum case representing the ongoing validation state.
This indicates that the validation process is currently in progress.

**valid** `ACHUserDetailsCollectableData`

Enum case representing a successful validation state.
This indicates that the validation process has completed successfully and the data is valid.

**invalid** `ACHUserDetailsCollectableData`

Enum case representing an unsuccessful validation state due to validation errors.
This indicates that the validation process has completed but has found one or more errors in the data.

**Associated Value**

**errors** `[PrimerValidationError]`

An array of `PrimerValidationError` representing the specific validation errors found.

**error** `ACHUserDetailsCollectableData`

Enum case representing an error state due to an unexpected issue.
This indicates that an unexpected error has occurred during the validation process.

**Associated Value**

**error** `PrimerError`

A `PrimerError` representing the unexpected error that occurred.

```swift SWIFT theme={"dark"}
func didUpdate(validationStatus: PrimerValidationStatus, for data: PrimerCollectableData?) {
    guard let data = data as? ACHUserDetailsCollectableData else { return }
    switch validationStatus {
    case .validating:
    case .valid:
    case .invalid(errors: let errors):
    case .error(error: let error):
    }
}
```

## Example

> [!NOTE]
>
> Although the component focuses on collecting user details pertaining to ACH,
> it also kicks off the tokenization and payment processes. Because of this,
> it should be kept in memory until the checkout is completed.
>
> Ensure that the screen implementing this component is not dismissed until the payment
> is finished, as the component returned by the manager is optional. As a result,
> having a weak reference to it will stop the entire payment flow if the screen is dismissed prematurely.

```swift SWIFT theme={"dark"}
do {
    manager = PrimerHeadlessUniversalCheckout.AchManager()
    stripeAchComponent = try manager.provide(paymentMethodType: "STRIPE_ACH")
} catch {
    // Catch errors here
}
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.