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

# fetchVaultedPaymentMethods

Get an array of `PrimerHeadlessUniversalCheckout.VaultedPaymentMethod` for the `customerId` attached to the [client session](/api-reference/v2.4/api-reference/client-session-api/create-a-client-session#body-customer-id).
Build your own UI to display, manage and perform payments with them.

<Warning>
  The list of vaulted payment methods is not affected by the checkout builder's conditions.

  For example, if you configured the checkout builder to not show `Paypal` with the current client session, but `Paypal` was vaulted previously, `fetchVaultedPaymentMethods` will still return it.

  <b>
    The mentioned issue will be addressed and resolved in an upcoming release,
    improving the overall functionality of the Vault Manager.
  </b>
</Warning>

```swift SWIFT theme={"dark"}
func fetchVaultedPaymentMethods(
    completion: @escaping (_ vaultedPaymentMethods: [PrimerHeadlessUniversalCheckout.VaultedPaymentMethod]?, _ error: Error?) -> Void
)
```

## Returns

The `fetchVaultedPaymentMethods` method fetches the vaulted payment methods for the `customerId` attached to the [client session](/api-reference/v2.4/api-reference/client-session-api/create-a-client-session#body-customer-id)
and returns an array of `PrimerHeadlessUniversalCheckout.VaultedPaymentMethod` in case of success, or an error in case of failure.

<Expandable title="Return Values" defaultOpen>
  <ResponseField name="completion">
    Completion will be called when the operation has been completed and the result is available.

    <Expandable title="Parameters" defaultOpen>
      <ResponseField name="vaultedPaymentMethods" type="Array<PrimerHeadlessUniversalCheckout.VaultedPaymentMethod>">
        <Expandable title="PrimerHeadlessUniversalCheckout.VaultedPaymentMethod" defaultOpen>
          <ResponseField name="id" type="String" required>
            A *temporary* identifier for the `PrimerHeadlessUniversalCheckout.VaultedPaymentMethod` previously retrieved
            with [fetchVaultedPaymentMethods](/sdk/ios/v2.x.x/primer-headless-checkout/vault-manager/fetchVaultedPaymentMethods).

            You can use `id` to [deleteVaultedPaymentMethod](/sdk/ios/v2.x.x/primer-headless-checkout/vault-manager/deleteVaultedPaymentMethod),
            [validate](/sdk/ios/v2.x.x/primer-headless-checkout/vault-manager/validate) its additional data, or [start](/sdk/ios/v2.x.x/primer-headless-checkout/vault-manager/startPaymentFlow) a payment flow.

            ℹ️ This id changes with each call to [fetchVaultedPaymentMethods](/sdk/ios/v2.x.x/primer-headless-checkout/vault-manager/fetchVaultedPaymentMethods).
          </ResponseField>

          <ResponseField name="analyticsId" type="String" required>
            An identifier for the vaulted payment method that doesn't change across calls to [fetchVaultedPaymentMethods](/sdk/ios/v2.x.x/primer-headless-checkout/vault-manager/fetchVaultedPaymentMethods).
          </ResponseField>

          <ResponseField name="paymentInstrumentType" type="String" required>
            The type of the payment instrument associated to the vaulted payment method.
          </ResponseField>

          <ResponseField name="paymentMethodType" type="String" required>
            A unique string identifier for the vaulted payment method.
          </ResponseField>

          <ResponseField name="paymentInstrumentData" type="PaymentInstrumentData" required>
            Data associated to the payment instrument. You can use this information to display the vaulted payment method in your UI.

            <Expandable title="Parameters" defaultOpen>
              <ResponseField name="paymentMethodConfigId" type="String" />

              <ResponseField name="paymentMethodType" type="String" />

              <ResponseField name="sessionInfo" type="SessionInfo" />

              <ResponseField name="first6Digits" type="String" />

              <ResponseField name="last4Digits" type="String" />

              <ResponseField name="accountNumberLast4Digits" type="String" />

              <ResponseField name="expirationMonth" type="String" />

              <ResponseField name="expirationYear" type="String" />

              <ResponseField name="cardholderName" type="String" />

              <ResponseField name="network" type="String" />

              <ResponseField name="isNetworkTokenized" type="String" />

              <ResponseField name="binData" type="BinData" />

              <ResponseField name="threeDSecureAuthentication" type="ThreeDS.AuthenticationDetails" />

              <ResponseField name="paypalBillingAgreementId" type="String" />

              <ResponseField name="externalPayerInfo" type="ExternalPayerInfo" />

              <ResponseField name="shippingAddress" type="ShippingAddress" />

              <ResponseField name="klarnaCustomerToken" type="String" />

              <ResponseField name="sessionData" type="SessionData" />

              <ResponseField name="bankName" type="String" />
            </Expandable>
          </ResponseField>

          <ResponseField name="threeDSecureAuthentication" type="ThreeDSAuthenticationData" />
        </Expandable>
      </ResponseField>

      <ResponseField name="error" type="Error" optional />
    </Expandable>
  </ResponseField>
</Expandable>

## Example

```swift SWIFT theme={"dark"}

import UIKit
import PrimerSDK

class MerchantHeadlesVaultManagerViewController: UIViewController {

  var vaultManager = PrimerHeadlessUniversalCheckout.VaultManager()

  override func viewDidLoad() {
    super.viewDidLoad()

    do {
      // Before you configure your vault manager you must have started
      // PrimerHeadlessUniversalCheckout with a client token.
      try self.vaultManager.configure()

    } catch {
      // Handler the error
    }
  }

  func fetchVaultedPaymentMethods() {
    // 👇 Call fetchVaultedPaymentMethods
    self.vaultManager.fetchVaultedPaymentMethods { vaultedPaymentMethods, err in
      if let err = err {
        // Handle the error

      } else if let vaultedPaymentMethods = vaultedPaymentMethods {
        // Populate your UI with the vaulted payment methods
      }
    }
  }
}
```
