Last Updated: 23 August 2024 | Change Log

iOS SDK


Set your views to take your customer's card details in your iOS application.

Getting our SDK

To get our iOS SDK we recommend that you use Cocoapods.

Once you've installed and configured your project to use Cocoapods, add the following line to your projects Podfile to add our SDK to your project.

pod 'AccessCheckoutSDK'

Here is a link to our Access checkout iOS SDK on Cocoapods:

and here's a link to our Access Checkout iOS SDK GitHub repository.

Import

You must import the Access checkout module to have access to all the classes, methods and functions needed to create your form and generate a sessionState.

Here is an example of how you would import the Access checkout module into your project.

import AccessCheckoutSDK

After importing the Access checkout module, we recommend you extend your ViewController with our UIViewController.

class ViewController: UIViewController 
   ...

Extending your ViewController class with our UIViewController gives you access to all the classes you'll need to set and style your view.

Referencing your views

In your storyboard, add the PANView, ExpiryDateView and CVVView UI components to your ViewController subclass.

You then need to link the referencing outlets panView, expiryDateView and cvvView to their respective views in your ViewController.

class ViewController: UIViewController {

    @IBOutlet weak var panView: PANView!
    @IBOutlet weak var expiryDateView: ExpiryDateView!
    @IBOutlet weak var cvvView: CVVView!
    ...
ViewControllerOutletDescription
PANViewpanViewThe unique view identifier for your customer's card number
ExpiryDateViewexpiryDateViewThe unique view identifier for your customer's card expiry date
CVVViewcvvViewThe unique view identifier for your customer's card cvv number

Override viewDidLoad()

We recommend that you create an override viewDidLoad() function, which is used to instantiate the AccessCheckoutCard object. You can then pass the CardView's to start allowing your customers to enter their card details.

card stores the current state of the form that your customer is using to enter their details.

Then you can instantiate the AccessCheckoutCardValidator class with the cardConfiguration rules in the cardConfiguration.json file. You may use the supplied card configuration rules or supply your own rules based on your requirements.

override func viewDidLoad() {

    let card = AccessCheckoutCard(panView: panView, expiryDateView: expiryDateView, cvvView: cvvView)
    card.cardDelegate = self
    if let url = Bundle.main.url(forResource: "cardConfiguration", withExtension: "json") {
        card.cardValidator = AccessCheckoutCardValidator(cardConfiguration: CardConfiguration(fromURL: url))
    }
    self.card = card
FunctionDescription
cardDelegateHandles the events on the card views, checking the validity of your customer's card details that are entered in the view.
cardValidatorGets and checks the card validation rules. Uses the rules from the configuration file to determine the validity of your customer's card details.
Warning

The validation does not check if your customer's card details are correct. The validator only checks the formatting of the entered details.

Validation Rules

The table below shows the rules that our SDK uses to validate your customer's card details. Get our validation rules here.

BrandpanStartpanEndpanLengthcvvLength
visa4049163
visa413600413600133
visa444509444509133
visa444550444550133
visa450603450603133
visa450617450617133
visa450628450628133
visa450636450636133
visa450640450640133
visa450662450662133
visa463100463100133
visa476142476142133
visa476143476143133
visa492901492901133
visa492920492920133
visa492923492923133
visa492928492928133
visa492937492937133
visa492939492939133
visa492960492960133
mastercard2227163
mastercard5059163
mastercard6767163
amex3434154
amex3737154

Next steps


Create sessionState