Delete a vaulted payment method for the customerId
attached to the client session by id.
You can get the id from any instance of PrimerVaultedPaymentMethod
returned by fetchVaultedPaymentMethods.
1
suspend fun deleteVaultedPaymentMethod(vaultedPaymentMethodId: String): Result<Unit>
Parameters
The id
of a PrimerVaultedPaymentMethod
previously retrieved with fetchVaultedPaymentMethods.
Returns
The deleteVaultedPaymentMethod
method performs the deletion of vaulted payment method and returns a result object of
type 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.
In case of successful operation result, SDK will return Unit
.
In case of unsuccessful operation result, as part of Result
object SDK will return:
In case the id passed does not match any payment method previously retrieved by fetchVaultedPaymentMethods.
If an error occurs while deleting the vaulted payment method.
if an I/O error occurs during the API request.
Example
Refer to the following example for fetching vaulted payment methods.
12345678910
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 } }}