Netcetera Android 3DS SDK Demo Application

This documentation provides details about the use of the Netcetera Android 3DS SDK Demo Application and sample how the Netcetera Android 3DS SDK can be integrated.

Requestor Application

The Netcetera Android 3DS SDK Demo Application represents an example integration of the Netcetera Android 3DS SDK. Along with this documentation, it serves as a guide for an easier integration of the Netcetera Android 3DS SDK in an application or a library.

The demo application simulates a real life payment action. It contains all cases from the frictionless and the challenge flows.

When the application is started, the initial screen is the payment details screen. Depending on the selected scenario, the application will present the appropriate flow.

For presenting the integration steps in proper order, the Netcetera Android 3DS SDK Demo Application is configured to work with Netcetera requestor backend which is an internal component and not available with the 3DS SDK product. The communication protocol between the merchant application and the PSP is proprietary for that particular PSP backend only and out of the scope for our Netcetera 3DS SDK products. For our use-case, we use the backend for:

  • Versioning - Get the latest supported 3DS Protocol Version for the involved card number.
  • Authentication - Process the authentication step of the 3DS authentication flow.

Appropriate adjustments to the application shall be made in order for the application to work and to perform transactions.

App architecture

Regarding the app architecture, the NCA demo application implements simplified version of MVVM pattern. It uses an Activity for the View, a viewmodel that contains the screen logic, and use cases (model) that contain the business logic about the use of the SDK. The application folder structure is organised by features and screen types.

Example structure of a screen implementation, the src/main/.../splash folder contains the following files:

  • SplashActivity.java - contains the view logic of the splash screen.
  • SplashViewModel.java - contains the splash screen logic for interacting between the view and use cases

Example structure of use case, the src/main/.../initialization folder contains the following files:

  • ThreeDSInitialization.java - use case for initialization of ThreeDS2Service
  • InitializationCallback.java - callback for the result of ThreeDSInitialization

The same structure is followed for the other screen implementations and use cases.

Intended to be used by different use cases, the Android SDK demo application uses ThreeDS2Service as singleton instance in a dagger module.

The creation of the transaction in the Android SDK Demo Application is performed by tapping on the Submit button. The predefined scenarios of the frictionless and challenge flows can be found in TransactionModelsRepository. By selecting a scenario in PrefillDataActivity, you select the example which will be shown once you tap on Submit.

The authentication request is created in AuthenticationRequestBuilder. Depending on the response received from the server, the application decides whether or not to opt for a challenge. An example implementation of the authentication request can be found in AuthenticationUseCase, while the method which calls this request is located in CheckoutViewModel.

SDK Usage

The Netcetera Android 3DS SDK is initialized by invoking ThreeDSInitialization in the SplashActivity at the start of the Netcetera 3DS Android Demo Application. For the initialization to be successful, the Netcetera Android 3DS SDK needs to be configured with a valid DS Configuration and a valid licence key. Here is how this is done in the demo application:

Once the SDK has been initialized, you can access the warnings generated during the initialization. This is done by calling the ThreeDS2Service.getWarnings() method. In the example above, the warnings are returned on the initialization callback, but you can ask for them anytime as long as the underlying ThreeDS2Service is initialized.

The creation of transaction and sending of the Authentication Request is performed by tapping on the Submit button on the checkout screen. This logic can be found in CheckoutViewModel.

App URL

Starting with version 2.2.0 of the EMV 3DS Specification Protocol, the application integrating the 3DS SDK can be called (brought to foreground) from another (authentication) application during an OOB challenge flow to indicate completed OOB authentication. The Netcetera demo application provides sample implementation of this feature summarized bellow.

The activity that calls the challenge flow must be open for calls from an outside application for a specific uri - app url. Moreover, this activity should act as a "singleton" so that the instance holding the ongoing challenge flow is brought to foreground (singleTask) instead of launching new activity instance.

Next, this activity needs to update its current intent when new intent is received in order for the Netcetera Android 3DS SDK to detect that it was brought to foreground from another application using the provided app url.

Finally, the application sets the correct app url for the ongoing transaction in the challenge parameters ChallengeParameters.setThreeDSRequestorAppURL(String threeDSRequestorAppURL) used for starting the challenge. The threeDSRequestorAppURL value consists of the scheme and host values declared in the activity manifest configuration and a query parameter transID with the value of the SDK Transaction ID (AuthenticationRequestParameters.getSDKTransactionID()) of the ongoing Transaction. Therefore, considering the aforementioned activity manifest configuration, for a Transaction having SDK Transaction ID of "3800cde2-bba6-11ea-b3de-0242ac130004", the threeDSRequestorAppURL would be equal to https://requestor.netcetera.com?transID=3800cde2-bba6-11ea-b3de-0242ac130004

Proguard configuration

The release build type of the Netcetera Demo Application has set minifyEnabled to true, meaning that during the release task, the source code of the application and its dependencies will go through optimization and obfuscation.

For better tuning which parts of the code are to be optimized and obfuscated, Proguard is used.

Proguard is taken as example configuration as most common measure of simple protection of a given application or library. The same approach should be used when using other similar tools.

Proguard Gradle setup

In the build.gradle these configurations shall be listed in order to be taken into consideration one code optimization is performed.

Logging

As the Netcetera Android 3DS SDK uses SLF4J for logging purposes, one simple configuration is to use SLF4J implementation that is using the Android Logcat. Additionally by providing different configurations for release and debug build type, logging in debug and release builds can be on different level.

Adding logback-android as dependency

To achieve this, first add logback-android logging framework as dependency in build.gradle:

The configuration of logback-android is done via adding logback.xml configuration in the assets directory.

Example Debug configuration for logback-android

Sample configuration for debug builds that will usually be placed in src/debug/assets/. It will log Netcetera Android 3DS SDK info level and above in Android Logcat:

Example Release configuration for logback-android

Sample configuration for release builds that usually will be placed in src/release/assets/. It will not log any Netcetera Android 3DS SDK in Android Logcat: