Perform a validation process on the provided additionalData for a given vaultedPaymentMethodId.

1234
suspend fun validate(  vaultedPaymentMethodId: String,  additionalData: PrimerVaultedPaymentMethodAdditionalData): Result<List<PrimerValidationError>>
kotlin
copy

Parameters

The id of a PrimerVaultedPaymentMethod previously retrieved with fetchVaultedPaymentMethods.

additionalData
PrimerVaultedPaymentMethodAdditionalDataRequired
direct subclasses
Properties
cvv
StringRequired
CVV value associated with the vaulted card.

Returns

The validate method performs validation operation for the given vaultedPaymentMethodId and additionalData. 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 validation. This allows you to handle different scenarios based on the result.

In case of successful operation result, SDK will return:

Properties
errorId
StringRequired
A unique error identifier.
description
StringRequired
A error description.
diagnosticsId
StringRequired
A unique diagnostics id for the given error.
If the returned list is empty after performing a validation process, it indicates that the data has passed the validation successfully. On the other hand, if the validation process encounters any issues or errors, the result object will contain a list of PrimerValidationError objects. These objects represent specific validation errors or issues associated with the payment method data.

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.

Example

Refer to the following example for fetching vaulted payment methods.

For example, by utilizing the validate function, you can validate the CVV collected from the user by passing PrimerVaultedCardAdditionalData(cvv: ...) as the additionalData parameter.

12345678910111213
private fun validateVaultedPaymentMethodAdditionalData(  vaultedPaymentMethodId: String,  additionalData: PrimerVaultedPaymentMethodAdditionalData) {  // 👇 validate additional data by calling suspend function within the scope  scope.launch {    vaultManager.validate(vaultedPaymentMethodId, additionalData).onSuccess { errors ->      // enable 'Pay' button in case errors list is empty...    }.onFailure { throwable ->      // handle error    }  }}
kotlin
copy