Using the Android SDK

A mobile SDK is available for integrating payer authentication services into mobile applications running on the Android platform.

Updating the Gradle Build Properties

In Android Studio, open the app directory (which can also be labeled Module: app) and open the
build.gradle
file. Edit the Gradle file located in the app directory. Add the contents shown in the example below to the Gradle file.
    
repositories { ... maven { url "https://cardinalcommerceprod.jfrog.io/artifactory/android" credentials { username Artifactory username password Artifactory user API Key } } } java.io.PrintWriter@1497085a dependencies { ... //Cardinal Mobile SDK implementation 2.5-1 }
If your project uses Progurad, add the lines shown below to the
proguard-rules.pro
file.
    
-keep class com.cardinalcommerce.dependencies.internal.bouncycastle.** -keep class com.cardinalcommerce.dependencies.internal.nimbusds.**

Configuring the Android SDK

Get the instance of the Cardinal object by
Cardinal.getInstance()
. Use the default configuration options. See the example below to complete
Cardinal.configure()
.
For more details on configuration, refer to the configuration options table after the example.
    
private Cardinal cardinal = Cardinal.getInstance(); @Override protected void onCreate(Bundle savedInstanceState) { CardinalConfigurationParameters cardinalConfigurationParameters = new CardinalConfigurationParameters(); cardinalConfigurationParameters.setEnvironment(CardinalEnvironment.STAGING); cardinalConfigurationParameters.setTimeout(8000); JSONArray rType = new JSONArray(); rType.put(CardinalRenderType.OTP); rType.put(CardinalRenderType.SINGLE_SELECT); rType.put(CardinalRenderType.MULTI_SELECT); rType.put(CardinalRenderType.OOB); rType.put(CardinalRenderType.HTML); cardinalConfigurationParameters.setRenderType(rType); cardinalConfigurationParameters.setUiType(CardinalUiType.BOTH); UiCustomization yourUICustomizationObject = new UiCustomization(); cardinalConfigurationParameters.setUICustomization(yourUICustomizationObject); cardinal.configure(this,cardinalConfigurationParameters); }
Android Configuration Options
Method
Description
Default Values
setEnableDFSync (boolean enableDFSync)
On setting true, onSetupCompleted is called after the collected device data is sent to the server.
False
setEnableQuickAuth (boolean enableQuickAuth)
Sets enable quick auth false.
False
setEnvironment(Setting up mobile SDK - Android- V 2.1#CardinalEnvironment environment)
Sets the environment to which the SDK must connect.
CardinalEnvironment.
PRODUCTION
setProxyAddress(java.lang. String proxyAddress)
Sets the proxy to which the SDK must connect.
“ “
setRenderType(org.json. JSONArray renderType)
Sets renderLists all user interface types that the device supports for displaying specific challenge user interfaces within the SDK.
JSONArray rType = new JSONArray();
rType.put(Cardinal
RenderType.OTP);
rType.put(Cardinal
RenderType.SINGLE_SELECT);
rType.put(Cardinal
RenderType.MULTI_SELECT);
rType.put(Cardinal
RenderType.OOB);
rType.put(Cardinal
RenderType.HTML);
setTimeout(int timeout)
Sets the maximum amount of time (in milliseconds) for all exchanges.
8000
setUICustomization (UiCustomization UI Customization)
Sets UICustomization
Device Default Values
setUiType(CardinalUiType uiType)
Sets all user interface types that the device supports for displaying specific challenge user interfaces within the SDK.
CardinalUiType.BOTH

Setting Up the Initial Call

Calling
Cardinal.init()
:
  • begins the communication process with Cardinal
  • authenticates your credentials (server JWT)
  • completes the data collection process
By the time the customer is ready to check out, all necessary preprocessing is complete.
Each time a user begins a mobile transaction, Cardinal assigns a unique identifier to the session called a
consumerSessionId
. This
consumerSessionId
ensures that Cardinal matches the correct device data collection results to a request.
Cybersource
calls this session identifier,
payerAuthEnrollService_referenceID
. You must assign the value of the
consumerSessionId
field to the
payerAuthEnrollService_referenceID
field so that
Cybersource
can also track the calls for each user session.
Study the code example shown below for completing the
cardinal.init()
.
Cardinal.init() (Android SDK)
    
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) { } });
See Running Payer Authentication with SDK for the next steps.