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.
Once the application is opened, the SDK is initialized and warnings are retrieved from the SDK. In case of any warnings being present, 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 text fields. 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.
To present the integration steps in the correct order, the Netcetera iOS 3DS SDK Demo Application is configured to work with the Netcetera requestor backend, which is an internal component not included in the 3DS SDK product. The communication protocol between the merchant application and the PSP is proprietary and specific to the PSP backend, falling outside the scope of our Netcetera 3DS SDK products.
For our use case, we utilize the backend for:
- Versioning: Obtaining the Directory Server ID and the latest supported 3DS Protocol Version for the involved card number.
- Authentication: Managing the authentication step of the 3DS authentication flow.
Appropriate adjustments to the application are necessary for it to function correctly and process transactions.
App architecture
The Netcetera Demo Merchant 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 screensInitialViewPresenter
- contains the logic for the screen presentationInitializationUseCase
- defines the methods used for the initialization of the SDK and verification of its warningsInitializationUseCaseImplementation
- 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 Netcetera Demo Merchant 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 to opt in 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 Netcetera Demo Merchant Application uses CocoaPods integration.
SDK Usage
At the start of the Netcetera Demo Merchant Application, the 3DS SDK is initialized in InitializationUseCaseImplementation
. For the initialization to be successful, a valid API 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 integrator to decide what to do with these warnings. An example is displayed bellow:
Prior to the creation of the transaction, the SDK utilizes the versioning request. The versioning request is used to get the directoryServerID for the given card number, as well as the highestCommonSupportedVersion value, if LATEST_VERSION is selected for the message version. The versioning response contains additional data that can be useful for an integrating app. For more information on versioning, refer to the Netcetera 3DS Server SaaS documentation page.
The logic for creating the transaction, the versioning request and the authentication request 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 EnvironmentParamsProviderLogic
.
The images used in the Netcetera Demo Merchant Application can be found in Assets.xcassets
.