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

<Expandable title="Parameters" defaultOpen>
  <ResponseField name="paymentMethodType" type="String" required>
    A unique string identifier for the payment method. Supported payment methods for current client session are returned in [primerHeadlessUniversalCheckoutDidLoadAvailablePaymentMethods](/sdk/ios/v2.x.x/primer-headless-checkout/delegates/PrimerHeadlessUniversalCheckoutDelegate#primerheadlessuniversalcheckoutdidloadavailablepaymentmethods) delegate method.
  </ResponseField>
</Expandable>

## Type parameters

<Expandable title="Type Parameters" defaultOpen>
  <ResponseField name="PrimerHeadlessAchComponent" type="PrimerCollectableData, PrimerHeadlessStep" required>
    <p>
      The type of the <code>PrimerHeadlessAchComponent</code> implementation to
      return.
    </p>

    <Expandable title="Supported types" defaultOpen>
      <table style={{width: "100%", borderCollapse: "collapse", borderSpacing: "0"}}>
        <tr style={{backgroundColor: "#f1f1f1", width: "100%"}}>
          <th style={{padding: "10px", textAlign: "left", width: "100%"}}>Type</th>
          <th style={{padding: "10px", textAlign: "left", width: "100%"}}>paymentMethodType</th>
        </tr>

        <tr style={{width: "100%"}}>
          <td style={{padding: "10px"}}>
            <a style={{color: "#0070f3", fontSize: "14px", textDecoration: "none", fontWeight: "500"}} href={`#param-stripe-ach-user-details-component`}>
              StripeAchUserDetailsComponent
            </a>
          </td>

          <td style={{padding: "10px", width: "100%"}}>
            <a style={{color: "#0070f3", fontSize: "14px", textDecoration: "none", fontWeight: "500"}} href="/sdk/ios/v2.x.x/primer-headless-checkout/ach-headless-manager/provide">
              STRIPE\_ACH
            </a>
          </td>
        </tr>
      </table>
    </Expandable>
  </ResponseField>
</Expandable>

## Returns

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

<Expandable title="Common API" defaultOpen>
  <ResponseField name="PrimerHeadlessAchComponent" type="Implemented by all components">
    <Expandable title="Methods and Properties" defaultOpen>
      <ResponseField name="start">
        Initialize the component by calling the start function. This method should be called only once.
      </ResponseField>

      <ResponseField name="submit">
        Call `submit` function in order to process collected data and move component to next state.
      </ResponseField>

      <ResponseField name="errorDelegate" type="PrimerHeadlessErrorableDelegate">
        Error delegate will be triggered every time an error is thrown in the process.

        ```swift SWIFT theme={"dark"}
          func didReceiveError(error: PrimerError)
        ```
      </ResponseField>
    </Expandable>
  </ResponseField>
</Expandable>

<Expandable title="Supported types" defaultOpen>
  <ResponseField name="StripeAchUserDetailsComponent" type="PrimerHeadlessAchComponent where Data == ACHUserDetailsCollectableData, Step == ACHUserDetailsStep">
    <Expandable title="API" defaultOpen>
      <ResponseField name="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 <a href={`#param-validation-delegate`}>validationDelegate</a> and receive the validation status when it's updated.

        In case of ACH, the Data will be of type <code>ACHUserDetailsCollectableData</code>.

        <Expandable title="enum ACHUserDetailsCollectableData">
          <ResponseField name="firstName">
            Enum member representing the customer's first name.

            <Expandable title="Properties" defaultOpen>
              <ResponseField name="value" type="String">
                The string value for the customer's first name.
              </ResponseField>
            </Expandable>
          </ResponseField>

          <ResponseField name="lastName">
            Enum member representing the customer's last name.

            <Expandable title="Properties" defaultOpen>
              <ResponseField name="value" type="String">
                The string value for the customer's last name.
              </ResponseField>
            </Expandable>
          </ResponseField>

          <ResponseField name="emailAddress">
            Enum member representing the customer's email address.

            <Expandable title="Properties" defaultOpen>
              <ResponseField name="value" type="String">
                The string value for the customer's email address.
              </ResponseField>
            </Expandable>
          </ResponseField>
        </Expandable>

        Example:

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

      <ResponseField name="stepDelegate" type="PrimerHeadlessStepDelegate">
        <p>
          Whenever <span><a href={`#param-start`}>start</a> or <a href={`#param-submit`}>submit</a></span> methods are called, <code>stepDelegate</code> will trigger the next step in
          case the call to the mentioned method was successful.
        </p>

        <p>
          In the case of <code>STRIPE\_ACH</code>, the steps will be of type{" "}
          <code>ACHUserDetailsStep</code>.
        </p>

        <p>
          <code>ACHUserDetailsStep</code> is an enum holding different output data for
          specific steps.
        </p>

        <Expandable title="enum ACHUserDetailsStep">
          <ResponseField name="retrievedUserDetails(_ details: ACHUserDetails)">
            <p>Enum member representing the retrieved user details.</p>

            <Expandable title="Properties" defaultOpen>
              <ResponseField name="details" type="ACHUserDetails">
                <p>
                  The retrieved user details of type <code>ACHUserDetails</code>{" "}
                  previously sent on client session creation.
                </p>

                <Expandable title="Properties" defaultOpen>
                  <ResponseField name="firstName" type="String">
                    <p>The first name previously sent on client session creation.</p>
                  </ResponseField>

                  <ResponseField name="lastName" type="String">
                    <p>The last name previously sent on client session creation.</p>
                  </ResponseField>

                  <ResponseField name="emailAddress" type="String">
                    <p>The email address previously sent on client session creation.</p>
                  </ResponseField>
                </Expandable>
              </ResponseField>
            </Expandable>
          </ResponseField>

          <ResponseField name="didCollectUserDetails">
            Enum member representing the event of collected user details.
          </ResponseField>
        </Expandable>

        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:
            }
        }
        ```
      </ResponseField>

      <ResponseField name="validationDelegate" type="PrimerHeadlessValidatableDelegate">
        <p>Validation delegate will be triggered every time collected data is updated.</p>

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

        <p>
          In the case of <code>STRIPE\_ACH</code>, the data will be of type{" "}
          <code>ACHUserDetailsCollectableData</code>.
        </p>

        <ResponseField name="PrimerValidationStatus" type="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.

          <Expandable title="enum PrimerValidationStatus">
            <ResponseField name="validating" type="ACHUserDetailsCollectableData">
              Enum case representing the ongoing validation state.
              This indicates that the validation process is currently in progress.
            </ResponseField>

            <ResponseField name="valid" type="ACHUserDetailsCollectableData">
              Enum case representing a successful validation state.
              This indicates that the validation process has completed successfully and the data is valid.
            </ResponseField>

            <ResponseField name="invalid" type="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.

              <Expandable title="Associated Value" defaultOpen>
                <ResponseField name="errors" type="[PrimerValidationError]">
                  An array of `PrimerValidationError` representing the specific validation errors found.
                </ResponseField>
              </Expandable>
            </ResponseField>

            <ResponseField name="error" type="ACHUserDetailsCollectableData">
              Enum case representing an error state due to an unexpected issue.
              This indicates that an unexpected error has occurred during the validation process.

              <Expandable title="Associated Value" defaultOpen>
                <ResponseField name="error" type="PrimerError">
                  A `PrimerError` representing the unexpected error that occurred.
                </ResponseField>
              </Expandable>
            </ResponseField>
          </Expandable>
        </ResponseField>
      </ResponseField>

      ```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):
          }
      }
      ```
    </Expandable>
  </ResponseField>
</Expandable>

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

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