A Cardinal Mobile SDK is available for integrating Payer Authentication services into
mobile applications running on the Android platform. Since this Android SDK only works
with 3-D Secure 2.x transactions, you must provide functionality to open a WebView to
handle any 3-D Secure 1.0 transactions that occur.
Update 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.If your project uses Progurad, add the lines shown below to therepositories { ... maven { url "https://cardinalcommerceprod.jfrog.io/artifactory/android" credentials { username Artifactory username password Artifactory user API Key } } } dependencies { ... //Cardinal Mobile SDK implementation 2.5-1 }
proguard-rules.pro
file.
-keep class com.cardinalcommerce.dependencies.internal.bouncycastle.** -keep class com.cardinalcommerce.dependencies.internal.nimbusds.**
Configure the Android SDK
Get the instance of the cardinal object by
Cardinal.getInstance()
. It is
recommended to 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); }
Method | Description | Default Values |
---|---|---|
setEnableDFSync (boolean enableDFSync) | On setting true, onSetupCompleted is called after device
data collected is sent to the server. | False |
setEnableQuickAuth (boolean enableQuickAuth) | Sets enable quick auth false. | False |
setEnvironment(Setting up Cardinal 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 UI 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 UI types that the device supports for displaying
specific challenge user interfaces within the SDK. | CardinalUiType.BOTH |
Set Up the Initial Call
Calling
Cardinal.init()
begins the communication process with Cardinal,
authenticates your credentials (server JWT), and completes the data collection
process. By the time the customer is ready to check out, all necessary
pre-processing is complete. Use 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 the Running Payer Authentication in SDK section for next steps.