3DS 2.0 iOS SDK

Integrate the 3D Secure 2.0 SDK into your iOS application.

This is a mobile SDK that you embed into the your iOS application. The SDK is available at https://github.com/Adyen/adyen-3ds2-ios.


Drag Adyen3DS2.framework to the Embedded Binaries section in your general target settings.


Retrieving authentication request parameters

First, create an instance of ADYServiceParameters with the additional data retrieved from your call to /authorise.

Then, instantiate an ADYService with these parameters.

NSDictionary *additionalData = ...; // Retrieved from Adyen.
ADYServiceParameters *serviceParameters = [[ADYServiceParameters alloc] initWithAdditionalData:additionalData];
ADYService *service = [[ADYService alloc] initWithParameters:serviceParameters appearanceConfiguration:nil];

This ADYService is used to create a transaction. From the transaction, you can retrieve the ADYAuthenticationRequestParameters.

NSError *error = nil;
ADYTransaction *transaction = [service createTransactionWithDirectoryServerIdentifier:nil protocolVersion:nil error:&error];
ADYAuthenticationRequestParameters *authenticationRequestParameters = [transaction authenticationRequestParameters];

Use these authentication request parameters in your call to /authorise3ds2.

Keep a reference to your ADYService instance until the transaction is finished.

Performing a challenge

In case a challenge is required, create an instance of ADYChallengeParameters with values from the additional data retrieved from your call to /authorise3ds2.

NSDictionary *additionalData = ...; // Retrieved from Adyen.
ADYChallengeParameters *challengeParameters = [ADYChallengeParameters challengeParametersWithServerTransactionIdentifier:additionalData[@"threeds2.threeDS2ResponseData.threeDSServerTransID"]

Use these challenge parameters to perform the challenge with the transaction you created earlier:

[transaction performChallengeWithParameters:challengeParameters delegate:self];

For the delegate parameter, pass in an instance that conforms to the ADYChallengeStatusDelegate protocol. For this protocol, implement the following methods:

- (void)challengeDidFinishWithCompletion:(ADYChallengeCompletion *)completion;

This method will be invoked when the challenge is completed successfully. The transaction status can be found in the completion object. You'll include this value in your second request to /authorise3ds2.

- (void)challengeDidFailWithError:(NSError *)error;

This method will be invoked when the challenge failed due to an error.

Keep a reference to your ADYService instance until the transaction is finished.

Customizing the UI

The SDK provides some customization options to ensure the UI of the challenge flow fits your app's look and feel. These customization options are available through the ADYAppearanceConfiguration class. To use them, create an instance of ADYAppearanceConfiguration, configure the desired properties and pass it during initialization of the ADYService.

For example, to make the navigation bar and Continue button red:

ADYAppearanceConfiguration *appearanceConfiguration = [ADYAppearanceConfiguration new];
[[appearanceConfiguration navigationBarAppearance] setBackgroundColor:[UIColor redColor]];
[[appearanceConfiguration navigationBarAppearance] setTextColor:[UIColor whiteColor]];
[[appearanceConfiguration continueButtonAppearance] setBackgroundColor:[UIColor redColor]];
[[appearanceConfiguration continueButtonAppearance] setTextColor:[UIColor whiteColor]];
[[appearanceConfiguration continueButtonAppearance] setCornerRadius:3.0f];
ADYService *service = [[ADYService alloc] initWithParameters:nil appearanceConfiguration:appearanceConfiguration];

See also