**Last updated**: 30 October 2025 | [**Change log**](/products/checkout/ios/changelog/) # Create `sessionState` Create a `sessionState` by sending your customer's card details. ### `sessionState` A `sessionState` is a unique identifier for your customer's card details, generated by the SDK. ## Create an `AccessCheckoutClient` instance The `AccessCheckoutDiscovery` component provides the entry point to our SDK, it also provides the single `discover()` function. This function may be called anywhere in your application lifecycle. ``` let accessCheckoutDiscovery = AccessCheckoutDiscovery(baseUrl: ) accessCheckoutDiscovery.discover(urlSession: URLSession.shared) { self.accessCheckoutClient = AccessCheckoutClient(discovery: accessCheckoutDiscovery, merchantIdentifier: ) } ``` | Methods | Descriptions | | --- | --- | | `` | For testing use : `https://try.access.worldpay.com/`For live use : `https://access.worldpay.com/` | | `` | Your unique merchant ID. | Ensure the Access Checkout URL has been added to your App's Transport Security Settings. For testing use : `https://try.access.worldpay.com/`For live use : `https://access.worldpay.com/` ## Implement `CardDelegate` Implementing your `ViewController` with our `CardDelegate` notifies you of the validity of your customer's card details. Here is an example of how you would implement your `MyViewController` with our `CardDelegate` class. ``` extension ViewController: CardDelegate { ... } ``` Inside the implementation above, you can set the behavior of your form based on the result of the validation. In the example below, when the details that your customers has entered in the views are valid, the submit button becomes enabled. The example also uses the rules to determine the brand of your customer's card, which can be used to update a UI component. ``` ... func cardView(_ cardView: CardView, isValid valid: Bool) { // Update your UI with the validation result cardView.isValid(valid: valid) // Check for card validity to enable submission if let valid = card?.isValid() { submitButton.isEnabled = valid } } func didChangeCardBrand(_ cardBrand: CardConfiguration.CardBrand?) { // Update any card brand on the panView if let imageUrl = cardBrand?.imageUrl { // Load the brand image here... } else { // Clear brand image here... } } ... ``` The validation rules and both `SVG` and `PNG` versions of your customer's card band icons are stored in the same [JSON file](https://access.worldpay.com/access-checkout/cardConfiguration.json). ## Submitting Form and getting `sessionState` When your customer's card details are valid, and they select the submit button, you must invoke the `func submit()` function. Invoking this function sends your customer's card details and potentially respond with a `sessionState`. ``` func submitCard(pan: PAN, month: ExpiryMonth, year: ExpiryYear, cvv: CVV) { accessCheckoutClient?.createSession(pan: pan, expiryMonth: expiryMonth, expiryYear: expiryYear, cvv: cvv) { result in DispatchQueue.main.async { switch result { case .success(let session): // Session is returned here case .failure(let error): // Error handling if let accessCheckoutClientError = error as? AccessCheckoutClientError { switch accessCheckoutClientError { case .bodyDoesNotMatchSchema(_, let validationErrors): // Handle validation errors default: break } } else { // handle other errors } } } } } ``` The function above sends your customer's card number(`pan`), card expiry month and year and card cvv. The function then perform another validation check on your customer's card details, as well as checking your `` and any other provided information. If there is an error, our SDK returns an error containing the `errorName`, `message` and a `validationErrors`, detailing the reason an error was returned. If successful a `sessionState` is returned instead, you must use the `sessionState` to create a [verified token](/products/verified-tokens/v2/create-verified-token#create-a-verified-token-request). ### Create a Verified token Once you've received a `sessionState` you must create a [verified token](/products/verified-tokens/v2/create-verified-token#create-a-verified-token-request) to [take a payment](/products/card-payments/v6/authorize-a-payment#authorize-a-payment). **Next steps** [Verified token](/products/verified-tokens/v2/create-verified-token)