Initial Call to Cardinal and Response - Android

Step 3 - Set Up the Initial Call to Cardinal


Calling Cardinal.init() 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.init()

Java
cardinal = Cardinal.getInstance();
String serverJwt = "INSERT_YOUR_JWT_HERE";
cardinal.init(serverJwt ,
new CardinalInitService() {
    /**
    * You may have your Submit button disabled on page load. Once you are set up
    * for CCA, you may then enable it. This will prevent users from submitting
    * their order before CCA is ready.
    */
    @Override
    public void onSetupCompleted(String consumerSessionId) {
 
    }
    /**
    * If there was an error with set up, Cardinal will call this function with
    * validate response and empty serverJWT
    * @param validateResponse
    * @param serverJwt will be an empty
    */
    @Override
    public void onValidated(ValidateResponse validateResponse, String serverJwt) {
 
    }
});
Kotlin
cardinal = Cardinal.getInstance()
val serverJwt = "INSERT_YOUR_JWT_HERE"
cardinal.init(serverJwt, object: CardinalInitService {
	/**
	* You may have your Submit button disabled on page load. Once you are set up
    * for CCA, you may then enable it. This will prevent users from submitting
    * their order before CCA is ready.
    */
	
	override fun onSetupCompleted(consumerSessionId: String) {
	
	}

    /**
    * If there was an error with setup, cardinal will call this function with
    * validate response and empty serverJWT
    * @param validateResponse
    * @param serverJwt will be an empty
    */
	override fun onValidated(validateResponse: ValidateResponse, serverJwt: String?) {

	}
})

The following feature is deprecated as of 2.2.4

If you already have the credit card number and just need to pass it to Cardinal, you can pass it in Cardinal.init(). This makes it ideal in a flow where the consumer has already entered their payment information.

Cardinal.init with accountNumber - Java
cardinal = Cardinal.getInstance();
String serverJwt = "INSERT_YOUR_JWT_HERE";
String accountNumber = "INSERT_YOUR_ACCOUNT_NUMBER" //minimum of 6 digits of the account number (credit Card number) 
cardinal.init(serverJwt , accountNumber
new CardinalInitService() {
    /**
    * 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.
    */
    @Override
    public void onSetupCompleted(String consumerSessionId) {
 
    }
    /**
    * If there was an error with setup, cardinal will call this function with
    * validate response and empty serverJWT
    * @param validateResponse
    * @param serverJwt will be an empty
    */
    @Override
    public void onValidated(ValidateResponse validateResponse, String serverJwt) {
 
    }
});
Cardinal.init with accountNumber - Kotlin
cardinal = Cardinal.getInstance()
val serverJwt = "INSERT_YOUR_JWT_HERE"
val accountNumber = "INSERT_YOUR_ACCOUNT_NUMBER" //minimum of 6 digits of the account number (credit Card number) 
cardinal.init(serverJwt, accountNumber, object : CardinalInitService {
    /**
    * 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.
    */
    override fun onSetupCompleted(consumerSessionId: String) {

    }

    /**
    * If there was an error with setup, cardinal will call this function with
    * validate response and empty serverJWT
    * @param validateResponse
    * @param serverJwt will be an empty
    */

    override fun onValidated(validateResponse: ValidateResponse, serverJwt: String?) {

    }
})