Perform a validation process on the provided additional payment method data
for a given vaultedPaymentMethodId
.
12345
func validate( vaultedPaymentMethodId: String, vaultedPaymentMethodAdditionalData: PrimerVaultedPaymentMethodAdditionalData, completion: @escaping (_ errors: [Error]?) -> Void)
swift
copy
Parameters
vaultedPaymentMethodId
StringRequiredThe id
of a PrimerHeadlessUniversalCheckout.VaultedPaymentMethod
previously retrieved with fetchVaultedPaymentMethods.
vaultedPaymentMethodAdditionalData
PrimerVaultedPaymentMethodAdditionalDataRequireddirect subclasses
Properties
cvv
StringRequiredReturns
The validate
method performs validation operation for the given vaultedPaymentMethodId
and vaultedPaymentMethodAdditionalData
.
The completion handler will either return an array of errors, or nil
if validation is successful.
The errors returned can be cast to PrimerError
or PrimerValidationError
.
Completion will be called when the validation has been completed and the result is available.
errors
Array<Error>invalidVaultedPaymentMethodId
PrimerErrorinvalidCvv
PrimerValidationErrorExample
123456789101112131415161718192021222324252627282930
import UIKitimport 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 { // Handler the error } } func validateCVV(_ cvv: String, forVaultedPaymentMethodWithId id: String) { let vaultedCardAdditionalData = PrimerVaultedCardAdditionalData(cvv: cvv) // 👇 Call validate self.vaultManager.validate(vaultedPaymentMethodId: id, vaultedPaymentMethodAdditionalData: vaultedCardAdditionalData, completion: { errors in if let errors = errors { // Handle validation errors } }) }}
swift
copy