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! ...
ViewController | Outlet | Description |
---|---|---|
PANView | panView | The unique view identifier for your customer's card number |
ExpiryDateView | expiryDateView | The unique view identifier for your customer's card expiry date |
CVVView | cvvView | The 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
Function | Description |
---|---|
cardDelegate | Handles the events on the card views, checking the validity of your customer's card details that are entered in the view. |
cardValidator | Gets and checks the card validation rules. Uses the rules from the configuration file to determine the validity of your customer's card details. |
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.
Brand | panStart | panEnd | panLength | cvvLength |
---|---|---|---|---|
visa | 40 | 49 | 16 | 3 |
visa | 413600 | 413600 | 13 | 3 |
visa | 444509 | 444509 | 13 | 3 |
visa | 444550 | 444550 | 13 | 3 |
visa | 450603 | 450603 | 13 | 3 |
visa | 450617 | 450617 | 13 | 3 |
visa | 450628 | 450628 | 13 | 3 |
visa | 450636 | 450636 | 13 | 3 |
visa | 450640 | 450640 | 13 | 3 |
visa | 450662 | 450662 | 13 | 3 |
visa | 463100 | 463100 | 13 | 3 |
visa | 476142 | 476142 | 13 | 3 |
visa | 476143 | 476143 | 13 | 3 |
visa | 492901 | 492901 | 13 | 3 |
visa | 492920 | 492920 | 13 | 3 |
visa | 492923 | 492923 | 13 | 3 |
visa | 492928 | 492928 | 13 | 3 |
visa | 492937 | 492937 | 13 | 3 |
visa | 492939 | 492939 | 13 | 3 |
visa | 492960 | 492960 | 13 | 3 |
mastercard | 22 | 27 | 16 | 3 |
mastercard | 50 | 59 | 16 | 3 |
mastercard | 67 | 67 | 16 | 3 |
amex | 34 | 34 | 15 | 4 |
amex | 37 | 37 | 15 | 4 |
Next steps