**Last updated**: 30 October 2025 | [**Change log**](/products/checkout/ios/changelog/) # CVC validation Validate your customer's CVC before processing it. Warning The validation does not check if your customer's CVC are correct. The validation only checks the format of the entered CVC. ## Get started Before you begin, ensure: * You have added the `AccessCheckoutSDK` to your project as a Cocoapods dependency * You have added an `import AccessCheckoutSDK` at the top of your swift file The key components for this integration are: * A reference to your `AccessCheckoutUITextField` for the CVC. * An `AccessCheckoutCvcOnlyValidationDelegate` designed to receive validation events * An instance of `CvcOnlyValidationConfig` containing all the information required for the initialization of the validation flow, including a reference to the CVC UI component to enable validation for * An `AccessCheckoutClient` responsible for initializing the validation flow. Full sample integration You can see an example of the CVC validation integration [here](https://github.com/Worldpay/access-checkout-ios/tree/master/AccessCheckoutDemo). ## Reference your UI component You must reference your UI component for CVC, as this is required for CVC validation. Instructions can be found [here](/products/checkout/ios/cvc-only#reference-your-ui-components). ## Implement the validation listener 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. br ```swift 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 } } ``` br ### Function and parameter descriptions | 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. | ## Initialize the `AccessCheckoutClient` and validation Recommendation 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](/products/checkout/ios/cvc-only#initialize-the-accesscheckoutclient). After implementing the `AccessCheckoutCvcOnlyValidationDelegate`, initialize validation for your views by creating a`CvcOnlyValidationConfig` using the builder and passing it to the `initialiseValidation` method of `AccessCheckoutClient`. ```swift 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) } } } ``` br **Next steps** [Create a CVC session](/products/checkout/ios/cvc-only)