Last updated: 30 October 2025 | Change log
Validate your customer's CVC before processing it.
The validation does not check if your customer's CVC are correct. The validation only checks the format of the entered CVC.
Before you begin, ensure:
- You have added the 
AccessCheckoutSDKto your project as a Cocoapods dependency - You have added an 
import AccessCheckoutSDKat the top of your swift file 
The key components for this integration are:
- A reference to your 
AccessCheckoutUITextFieldfor the CVC. - An 
AccessCheckoutCvcOnlyValidationDelegatedesigned to receive validation events - An instance of 
CvcOnlyValidationConfigcontaining all the information required for the initialization of the validation flow, including a reference to the CVC UI component to enable validation for - An 
AccessCheckoutClientresponsible for initializing the validation flow. 
You can see an example of the CVC validation integration here.
You must reference your UI component for CVC, as this is required for CVC validation. Instructions can be found here.
To receive validation events as your customer enters their CVC details, you are required to create your own implementation of the AccessCheckoutCvcOnlyValidationDelegate protocol. Each function of this protocol is optional, giving you the flexibility to listen only to the events that are relevant to your application.
extension ViewController: AccessCheckoutCvcOnlyValidationDelegate {
  // This event handler is notified when the CVC becomes valid or invalid
    func cvcValidChanged(isValid: Bool) {
      // You might want to change the text color
        cvcAccessCheckoutView.textColor = isValid ? nil : UIColor.red
        
        if !valid {
            // You might want to disable a submit button which would normally be clicked on when all fields are valid
            submitButton.isEnabled = false
        }
    }
    // This event handler is notified when CVC is valid
    func validationSuccess() {
        // You might want to enable a submit button when the CVC is valid
        submitButton.isEnabled = true
   }
}| Method | Description | 
|---|---|
cvcValidChanged | This method is called with the validity of the CVC field. isValid indicates whether the field is in a valid or invalid state. | 
validationSuccess | This method is called when the CVC field is in a valid state. You typically use this to enable the submit button. | 
We highly recommend to do this in the viewDidLoad() handler of your UIViewController.
You must first initialize the AccessCheckoutClient using the AccessCheckoutClientBuilder, providing your accessBaseUrl and checkoutId. Instructions can be found here.
After implementing the AccessCheckoutCvcOnlyValidationDelegate, initialize validation for your views by creating aCvcOnlyValidationConfig using the builder and passing it to the initialiseValidation method of AccessCheckoutClient.
import AccessCheckoutSDK
class MyViewController: UIViewController {
    private let accessBaseUrl = "TARGET_BASE_URL"
    private let checkoutId = "YOUR_CHECKOUT_ID"
    @IBOutlet weak var cvcAccessCheckoutView: AccessCheckoutUITextField!
    override func viewDidLoad() {
        super.viewDidLoad()
        // other fields omitted
        do {
            // Initialize the AccessCheckoutClient
            let accessCheckoutClient = try AccessCheckoutClientBuilder()
                .accessBaseUrl(accessBaseUrl)
                .checkoutId(checkoutId)
                .build()
            // Create the validation configuration
            let validationConfig = try CvcOnlyValidationConfig.builder()
                .cvc(cvcAccessCheckoutView)
                .validationDelegate(self)
                .build()
            // Initialize validation using the client
            accessCheckoutClient.initialiseValidation(validationConfig)
        } catch {
            // Handle initialization error (e.g., log or show alert)
        }
    }
}
Next steps