Initial Call to Cardinal and Response - iOS - V 2.2.3

Step 4 - Setup the Initial Call to Cardinal


Calling cardinal session setup will begin the communication process with Cardinal to ensure your user's experience is seamless, by authenticating your credentials (serverJwt) and completing the data collection process. By the time they are ready to checkout, all necessary pre-processing will be completed.Use the code snippet below for completing the cardinal session setup

The following function call must be placed in your Checkout ViewController.

 Objective-C
NSString *jwtString = @"INSERT_YOUR_JWT_HERE";

[session setupWithJWT:jwtString 
		  didComplete:^(NSString * _Nonnull consumerSessionId){
    //
    // You may have your Submit button disabled on page load. Once you are setup
    // for CCA, you may then enable it. This will prevent users from submitting
    // their order before CCA is ready.
    //
} didValidate:^(CardinalResponse * _Nonnull validateResponse) {
   	// Handle failed setup
    // If there was an error with setup, cardinal will call this function with
    // validate response and empty serverJWT
}];
 Swift
let jwtString = "INSERT_YOUR_JWT_HERE"

session.setup(jwtString: jwtString, completed: { (consumerSessionId: String) in
    //
    // You may have your Submit button disabled on page load. Once you are setup
    // for CCA, you may then enable it. This will prevent users from submitting
    // their order before CCA is ready.
    //
}) { (validateResponse: CardinalResponse) in
    // Handle failed setup
    // If there was an error with setup, cardinal will call this function with
    // validate response and empty serverJWT
}
If you already have the credit card number and just need to pass it to Cardinal, you can pass it in cardinal session setup.It is ideal in a flow where the consumer has already entered their payment information.
 Objective-C : Cardinal Set up with Account Number
NSString *accountNumberString = @"1234567890123456";
NSString *jwtString = @"INSERT_YOUR_JWT_HERE";

[session setupWithJWT:jwtString 
		accountNumber:accountNumberString 
		  didComplete:^(NSString * _Nonnull consumerSessionId) {
    //
    // You may have your Submit button disabled on page load. Once you are setup
    // for CCA, you may then enable it. This will prevent users from submitting
    // their order before CCA is ready.
    //
} didValidate:^(CardinalResponse * _Nonnull validateResponse) {
   	// Handle failed setup
    // If there was an error with setup, cardinal will call this function with
    // validate response and empty serverJWT        
}];
 Swift : Cardinal Setup with AccountNumber
let accountNumberString = "1234567890123456"
let jwtString = "INSERT_YOUR_JWT_HERE"

session.setup(jwtString: jwtString, 
				account: accountNumberString, 
			  completed: { (consumerSessionId: String) in
    //
    // You may have your Submit button disabled on page load. Once you are setup
    // for CCA, you may then enable it. This will prevent users from submitting
    // their order before CCA is ready.
    //
}) { (validateResponse: CardinalResponse) in
    // Handle failed setup
    // If there was an error with setup, cardinal will call this function with
    // validate response and empty serverJWT
}