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

# deleteVaultedPaymentMethod

This async method allows you to delete a vaulted payment method by providing its ID as an argument for the `customerId` attached to the [client session](/api-reference/v2.4/api-reference/client-session-api/create-a-client-session#body-customer-id).

```swift SWIFT theme={"dark"}
public func deleteVaultedPaymentMethod(id: String, completion: @escaping (_ error: Error?) -> Void)
```

## Parameters

<Expandable title="Properties" defaultOpen>
  <ResponseField name="vaultedPaymentMethodId" type="String" required>
    The `id` of a `PrimerHeadlessUniversalCheckout.VaultedPaymentMethod` previously retrieved with [fetchVaultedPaymentMethods](/sdk/ios/v2.x.x/primer-headless-checkout/vault-manager/fetchVaultedPaymentMethods).
  </ResponseField>
</Expandable>

## Returns

The `deleteVaultedPaymentMethod` method performs the deletion operation and returns an error in case of failure, or nil in case of success.

<Expandable title="Return Values" defaultOpen>
  <ResponseField name="completion">
    Completion will be called when the deletion has been completed.
  </ResponseField>

  <ResponseField name="error" type="Error">
    <Expandable title="Errors" defaultOpen>
      <ResponseField name="invalidVaultedPaymentMethodId" type="PrimerError">
        An error that will be thrown in case the you provide a vaulted payment method that doesn't exist.
      </ResponseField>
    </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 {
      // Handle the error
    }
  }

  func deleteVaultedPaymentMethod(with id: String) {
    // 👇 Call deleteVaultedPaymentMethod and pass one of the vaulted payment methods'
    // id (retrieved with fetchVaultedPaymentMethods)
    self.vaultManager.deleteVaultedPaymentMethod(id: id, completion: { error in
      if let error = error {
        // Handle the error
      } else {
        // Vaulted payment method was deleted successfully
      }
    })
  }
}
```
