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

# provideBanksComponent

After creating an instance of the `PrimerHeadlessUniversalCheckout.ComponentWithRedirectManager ` you must use one of the compatible provide methods
which will provide the component that can be used to build the flow.
The method <code>provideBanksComponent</code> is backward compatible with older versions of iOS.

```swift SWIFT theme={"dark"}
public func provideBanksComponent(paymentMethodType: String) throws -> any PrimerHeadlessMainComponent
```

## Parameters

<Expandable defaultOpen title="Parameters">
  <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`.
    For Component with redirect manager, the supported payment method is ADYEN\_IDEAL.
  </ResponseField>
</Expandable>

## Returns

An instance conforming to the `PrimerHeadlessMainComponent` protocol.
The `PrimerHeadlessMainComponent` protocol conforms to the PrimerHeadlessCollectDataComponent protocol.

<Expandable title="PrimerHeadlessMainComponent" defaultOpen>
  <Expandable title="PrimerHeadlessCollectDataComponent" defaultOpen>
    <ResponseField name="Data" type="PrimerCollectableData">
      The Data associated type
    </ResponseField>

    <ResponseField name="Step" type="PrimerHeadlessStep">
      The Step associated type
    </ResponseField>

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

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

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

      <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" defaultOpen>
          <ResponseField name="validating">
            Enum case representing the ongoing validation state.
            This indicates that the validation process is currently in progress.
          </ResponseField>

          <ResponseField name="valid">
            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">
            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">
            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>

    <ResponseField name="stepDelegate" type="PrimerHeadlessSteppableDelegate">
      <p>
        <code>BanksStep</code> is a enum class holding different output data for
        specific steps. Whenever <span><a href="#param-submit">submit</a></span>{" "}
        method is 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 ADYEN\_IDEAL, the steps return will be of type{" "}
        <code>BanksStep</code>
      </p>

      <Expandable title="enum BanksStep">
        <ResponseField name="loading">
          Enum member representing the step of loading data for the form redirect component.
        </ResponseField>

        <ResponseField name="banksRetrieved(banks: [IssuingBank])">
          Enum member representing the step of issuing banks retrieved.

          <Expandable title="Properties" defaultOpen>
            <ResponseField name="banks" type="[IssuingBank]">
              The issuing banks array associated with this payment flow.

              <Expandable title="IssuingBank" defaultOpen>
                The `IssuingBank` class provides properties to hold bank details.

                <Expandable title="Properties" defaultOpen>
                  <ResponseField name="id" type="String">
                    The string bank id
                  </ResponseField>

                  <ResponseField name="name" type="String">
                    The bank name string
                  </ResponseField>

                  <ResponseField name="iconUrlStr" type="String">
                    The bank icon url string
                  </ResponseField>

                  <ResponseField name="isDisabled" type="String">
                    Boolean indicating whether the bank is disabled
                  </ResponseField>
                </Expandable>
              </Expandable>
            </ResponseField>
          </Expandable>
        </ResponseField>
      </Expandable>

      ```swift SWIFT theme={"dark"}
        func didReceiveStep(step: PrimerHeadlessStep)
      ```
    </ResponseField>

    <ResponseField name="updateCollectedData(collectableData: Data)">
      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>.

      In case of ADYEN\_IDEAL, the Data will be of type <code>BanksCollectableData</code>

      <Expandable title="enum BanksCollectableData">
        <ResponseField name="bankId">
          Enum member representing the bank id.

          <Expandable title="Properties" defaultOpen>
            <ResponseField name="bankId" type="String">
              The string bank id
            </ResponseField>
          </Expandable>
        </ResponseField>

        <ResponseField name="bankFilterText" type="String">
          Enum member representing the text used for filtering the list of banks by name.

          <Expandable title="Properties" defaultOpen>
            <ResponseField name="text">
              The text used for filtering the list of banks by name.
            </ResponseField>
          </Expandable>
        </ResponseField>
      </Expandable>
    </ResponseField>
  </Expandable>
</Expandable>

## Throws

<Expandable defaultOpen title="Throws">
  <ResponseField name="unsupportedPaymentMethod">
    An error that will be thrown in case the provide method has been called using unsupported `paymentMethodType`.

    <p>
      Supported payment methods for current client session are returned in the `onAvailablePaymentMethodsLoaded` delegate.
    </p>

    Currently, the supported payment method types are:

    <ul>
      <li>ADYEN\_IDEAL</li>
    </ul>
  </ResponseField>

  <ResponseField name="genericError">
    An error that will be thrown in case the provide method fails because of sdk not correctly used.
  </ResponseField>
</Expandable>
