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

Delete a vaulted payment method for the `customerId` attached to the [client session](/api-reference/v2.4/api-reference/client-session-api/create-a-client-session) by id.
You can get the id from any instance of `PrimerVaultedPaymentMethod` returned by [fetchVaultedPaymentMethods](/sdk/android/v2.x.x/primer-headless-checkout/vault-manager/fetchVaultedPaymentMethods).

```kotlin KOTLIN theme={"dark"}
suspend fun deleteVaultedPaymentMethod(vaultedPaymentMethodId: String): Result<Unit>
```

## Parameters

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

## Returns

The `deleteVaultedPaymentMethod` method performs the deletion of vaulted payment method and returns a result object of
type [Result](https://kotlinlang.org/api-reference/latest/jvm/stdlib/kotlin/-result/).

The Result class represents the outcome of the operation, indicating `success` or `failure`.

By inspecting the returned Result object, you can determine the success or failure of the deletion of the vaulted payment method.
This allows you to handle different scenarios based on the result.

<Expandable title="Results" defaultOpen>
  <ResponseField name="success">
    In case of successful operation result, SDK will return `Unit`.
  </ResponseField>

  <ResponseField name="failure">
    In case of unsuccessful operation result, as part of `Result` object SDK will return:

    <Expandable title="Exceptions" defaultOpen>
      <ResponseField name="InvalidVaultedPaymentMethodIdException">
        In case the id passed does not match any payment method previously retrieved by [fetchVaultedPaymentMethods](/sdk/android/v2.x.x/primer-headless-checkout/vault-manager/fetchVaultedPaymentMethods).
      </ResponseField>

      <ResponseField name="VaultManagerDeleteException">
        If an error occurs while deleting the vaulted payment method.
      </ResponseField>

      <ResponseField name="IOException">
        if an I/O error occurs during the API request.
      </ResponseField>
    </Expandable>
  </ResponseField>
</Expandable>

## Example

Refer to the following example for [fetching](/sdk/android/v2.x.x/primer-headless-checkout/vault-manager/fetchVaultedPaymentMethods#example) vaulted payment methods.

```kotlin KOTLIN theme={"dark"}
private fun deleteVaultedPaymentMethod(vaultedPaymentMethodId: String) {
  // 👇 delete vaulted payment method by calling suspend function within the scope
  scope.launch {
    vaultManager.deleteVaultedPaymentMethod(vaultedPaymentMethodId).onSuccess {
      // display success message to the user, remove vaulted payment method from the list...
    }.onFailure { throwable ->
      // handle error
    }
  }
}
```
