MSDK makes it easy to implement native 3D Secure 2 authentication in a mobile application.
NOTE: This guide is specific for the cases when Open Payment Platform (OPP) is not going to be used for some reason. Otherwise, refer to one of the integration types with MSDK.
Mobile SDK provides the following features:
Collecting and encrypting user's device data
Performing security checks
Performing challenge process (including presenting UI and communication with ACS)
Features that are NOT included into the scope of SDK:
Performing authentication request to the 3DS Server
iOSAndroid
Initialize the 3DS service
Initialization phase includes fetching actual config data from the Server, collecting device data and performing security checks. All these actions are done in background thread, so start it whenever you want, it won't affect UI thread. It’s recommended to run initialization on checkout process start or even on application start.
val paymentBrands = listOf("AMEX", "VISA")
OppThreeDSService.getInstance().initialize(
applicationContext,
TransactionMode.LIVE,
paymentBrands)
We also recommend to look through the Customization guide to check advanced features of the MSDK.
Create 3DS transaction
After shopper entered card details and clicked Pay, use 3DS service to create 3DS transaction for the specific payment brand. Store a reference to the transaction, it will be needed later to initiate challenge process.
val protocolVersion = "2.2.0"
val transaction: OppThreeDSTransaction = OppThreeDSService.getInstance().createTransaction("AMEX", protocolVersion)
NOTE: you need to provide valid 3D Secure 2 protocol version when creating transaction. Supported versions are 2.1.0 and 2.2.0.
Send authentication parameters
Getting authRequestParams will encrypt shopper device data and other important information needed for the 3DS Server to authenticate a transaction. It will return JSON string which should be sent to the Server.
E.g. Platform expects it as threeDSecure.deviceInfo parameter in the payment submission request.
let progressView = try transaction.getProgressView()
progressView.show()
// Later, to hide/close:
progressView.close()
ProgressDialog progressDialog = transaction.getProgressView(activity);
progressDialog.show();
// Later, to hide/dismiss:
progressDialog.dismiss();
val progressDialog: ProgressDialog = transaction.getProgressView(activity)
progressDialog.show()
// Later, to hide/dismiss:
progressDialog.dismiss()
Handle authentication response
If card is enrolled for the 3D Secure 2, Server will return 3DS authentication status and client authentication response which is required for the challenge flow.
Depending on status, start challenge or finish the checkout process:
if ([transactionStatus isEqualToString:@"C"]) {
// start the challenge process to complete user authentication
} else {
// authentication is complete
// request payment status
}
if (transactionStatus == "C") {
// start the challenge process to complete user authentication
} else {
// authentication is complete
// request payment status
}
if (transactionStatus.equals("C")) {
// start the challenge process to complete user authentication
} else {
// authentication is complete
// request payment status
}
if (transactionStatus == "C") {
// start the challenge process to complete user authentication
} else {
// authentication is complete
// request payment status
}
Frictionless flow
Frictionless flow means that authentication is done. The payment will be completed or rejected depending on authentication result and system configuration. Request payment status to get the result of the transaction.
Challenge flow
For the challenge flow you will need to pass clientAuthResponse received from the Server to the MSDK and start the challenge.
The SDK will take care of all communication with the ACS while performing the challenge, as well as prompting the shopper as needed for the required input. When the challenge process is complete, control returns to the app in the one of the OppThreeDSChallengeCallback events. See how it can be implemented in the sample code below.