> ## 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](https://primer.io/docs/api-reference/v2.4/api-reference/client-session-api/create-a-client-session.md#body-customer-id).

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

## Parameters

**Properties**

**vaultedPaymentMethodId** `String` *required*

The `id` of a `PrimerHeadlessUniversalCheckout.VaultedPaymentMethod` previously retrieved with [fetchVaultedPaymentMethods](https://primer.io/docs/sdk/ios/v2.x.x/primer-headless-checkout/vault-manager/fetchVaultedPaymentMethods.md).

## Returns

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

**Return Values**

**completion**

Completion will be called when the deletion has been completed.

**error** `Error`

**Errors**

**invalidVaultedPaymentMethodId** `PrimerError`

An error that will be thrown in case the you provide a vaulted payment method that doesn't exist.

## 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
      }
    })
  }
}
```


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