Netcetera iOS 3DS SDK Demo Application

This document provides details about the Netcetera iOS 3DS SDK demo application and how the Netcetera iOS 3DS SDK is integrated in it.

Requestor Application

The Netcetera iOS 3DS SDK demo application is an example application that integrates the Netcetera iOS 3DS SDK. Together with this document, they serve as a guide for an easier integration of the Netcetera iOS 3DS SDK in an application or library.

The demo application simulates a real life payment action. It handles both frictionless and challenge flows.

When you open the application, the SDK is initialized and warnings are retrieved from the SDK. In case of any warning, a warning info screen is displayed. If no warnings are returned the application shows a payment details screen. The payment screen mimics a checkout process with all required payment details. Depending on the provided input (or selected scenario), the application will present the appropriate flow. Users can enter data manually, or select the predefined scenarios which will fill the payment screen values. These are configured for easier testing purposes with our backend. The scenarios can be selected when taping on the "Choose pre-filled data" button. Once all values are filled a transaction is triggered with taping on the "Submit" button.

The demo application is connected to a Netcetera requestor backend server. The server decides whether a frictionless or a challenge flow will be initiated. Note that it works in Netcetera test environment only. Appropriate adjustments will be needed in order to connect to another Requestor backend.

App architecture

The NCA demo application implements the MVP pattern. It uses a ViewController for the UI, a presenter that contains the presentation logic, and use cases which contain the business logic. The application features are divided in groups. Each group contains the corresponding files.

For example, the source/main/initialization folder contains the following files:

  • InitialViewController - contains the methods for presenting the correct screens
  • InitialViewPresenter - contains the logic for the screen presentation
  • InitializationUseCase - defines the methods used for the initialization of the SDK and verification of its warnings
  • InitializationUseCaseImplementation - contains the logic for the initialization of the SDK and verification of its warnings

The same type of structure is implemented in the source/main/paymentDetails group.

With the intent to be used for different use cases, the iOS SDK demo application uses a singleton object of the ThreeDS2Service class. For easier dependency injection, the application implements the Container class from the GirdersSwift framework.

The predefined scenarios screen is implemented with PrefilledDataController. The scenarios model objects are created in the PaymentDetailsScenarios class. These can be easily adjusted with new preferred values.

The handling od user actions on the payment checkout screen is done in the PaymentDetailsPresenter class. The creation of the transaction is triggered by the submitButtonTapped action. The transaction is created based on the screen input.

The authentication request is created in AuthenticationRequestJsonGenerator class. 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 AppApiGateway, while the method which calls this request is located in PaymentDetailsPresenter.

For integration of external libraries, the 3DS demo application uses CocoaPods integration.

SDK Usage

At the start of the Netcetera 3DS iOS demo application, the 3DS SDK is initialized in InitializationUseCaseImplementation. For the initialization to be successful, a valid licence key needs to be configured. An example of such case is displayed below:

Once the SDK has been initialized, you can access the warnings generated during the initialization. This is done in the getWarnings() method of ThreeDS2ServiceSDK object. The method is called by the verifyWarnings method in the InitializationUseCase class. Both the SDK and PCI warnings are returned in the list. It is up to the application or library to decide what to do with these warnings. An example is displayed bellow:

The logic for creating the transaction can be found in PaymentDetailsPresenter. The creation of the transaction starts in the submitButtonTapped function.

If the authentication response requires a challenge, then the doChallenge method is called. This is done in the handleChallengeFlow function of the PaymentDetailsPresenter class.

The configuration of DS public keys and certificates is done in DSsConfiguration.plist. You can use this file as an example, while for implementation guidelines, please refer to the Netcetera iOS 3DS SDK documentation.

The images used in the NCA 3DS demo application can be found in Assets.xcassets.