This document serves as a guide for the integrator of Ravelin’s iOS 3DS SDK, providing details on how the SDK should be configured and integrated into an iOS application.
Ravelin’s 3DS iOS SDK v3.1 requires iOS 15 or later; v3.0.0 supports iOS 12 or later. The development language used is Swift version 5. The SDK can be used with Objective-C, provided that appropriate bridging is implemented in the host application.
The iOS SDK follows semantic versioning - The version can be described as MAJOR.MINOR.PATCH, where:
The current release is v3.1.0. Minimum iOS is 15. v3.0.0 is the last release for apps that deploy below iOS 15. v3.0 is a major line with breaking API changes from v2.x — see Upgrading from v2.x.
Recommended upgrade path: merchants on v2.0.x or v3.0.0 should upgrade to v3.1.0 when the app deployment target is iOS 15 or later.
| Phase | Policy |
|---|---|
| v3.1.0 available | v3.1.0 is the recommended release for new integrations and for upgrades from v2.0.x and v3.0.0. Requires iOS 15 |
| v2.x maintenance | Until July 2027, v2.x receives security-fix-only patches on request; no new features |
| v2.x end of life | After July 2027, no further v2.x releases; merchants must be on v3.0.0 or later |
Internal security-fix backports for exceptional cases are handled through your Ravelin account team. Version details are not published in merchant documentation.
v3.0 requires integration code changes. The main differences:
| Area | v2.x | v3.0 |
|---|---|---|
| SDK construction | ThreeDS2SDK(configParameters:…) | ThreeDS2SDK() then initialize(…) |
| Init completion | ((Bool) -> Void)? | (Result<Void, R3DS2Error>) -> Void |
locale parameter | Present (ignored by SDK) | Removed |
| UI customization | Single UiCustomization? | UiCustomizationMap? (.DEFAULT / .DARK / .MONOCHROME) |
| Dark-mode colors | setDarkTextColor, setDarkBackgroundColor, etc. | Removed — use separate map entries per theme |
| Init metadata failure | Could complete with success == false | Result.failure(.sdkRuntime(…)) with explicit message |
Threading: completion handlers for initialize(…) and createTransaction(…) are not called on the main queue. Dispatch to the main queue before updating UI, or use the async throws overloads on iOS 13+ (which resume on the main actor).
iOS 13+: optional async throws overloads are available for initialize(…), createTransaction(…), and doChallenge(…).
See the v3.0 migration guide for the full checklist, and Initialization / UI Customization for updated examples.
The Ravelin 3D-Secure SDK is built and tested according to the following supporting EMV 3D-Secure documentation. Therefore, this guide should be used in conjunction with the following specifications (n.b. access requires authentication on the EMVCo website):
This section provides technical details on how to integrate the 3DS SDK into the host application.
Though the SDK utilizes UIKit, it is possible to integrate this into an app using SwiftUI.
Integration options include:
To assist with integration, simple demo apps can be supplied; these consist of:
In a Package.swift manifest, the iOS 15+ requirement is:
.package(url: "git@github.com:unravelin/ravelin-3ds-sdk-ios-xcframework-distribution.git", .upToNextMinor(from: "3.1.0"))
Install CocoaPods following the official instructions.
Add Ravelin3DS to the host app’s Podfile. Use ~> 3.1.0 when the app deployment target is iOS 15 or later. Use ~> 3.0.0 when the app must deploy below iOS 15.
pod 'Ravelin3DS', '~> 3.1.0', :source => 'https://github.com/unravelin/Specs.git'
pod install.v3.0.0 introduced two link models. Both remain supported on v3.1.0 and later 3.1 releases. Choose based on your build pipeline and security requirements.
The published XCFramework includes mergeable library metadata (MERGEABLE_LIBRARY=YES on the device slice). That metadata does not force merging — your host app build settings determine the runtime link model.
Same integration as v2.0.1 — simplest path for most merchants upgrading from v2.x.
Ravelin3DS.xcframework in your app target as today.MERGED_BINARY_TYPE on the app target.getWarnings(), and confirm results before go-live.Runtime: SDK loads as a separate dyld image (like v2.0.1).
Optional. Requires Xcode 15+.
MERGED_BINARY_TYPE) to manual or automatic.Ravelin3DS target in your project.manual: ensure Ravelin3DS is in Link Binary With Libraries.getWarnings(), and confirm results before go-live.Runtime: In Release builds, the SDK is merged into your app executable rather than loaded as a separate framework image.
In Debug builds, mergeable dependencies may still behave as dynamic frameworks. Validate getWarnings() on a Release device build for either option.
| Dynamic (Option A) | Mergeable (Option B) | |
|---|---|---|
| Support | Supported | Supported |
| v2 migration effort | API only — same embed workflow | API + app build settings |
| Xcode | Same as v2.x | 15+; MERGED_BINARY_TYPE on app |
| SDK load model | Separate dyld image | Merged into app executable (Release) |
App baseline SW02 (APP-INTEGRITY-CHECK) | Runs when enabled | Runs when enabled |
| DYLD / hooking SW02 | Runs | Runs |
Upgrading to v3.0.0 or v3.1.0 without merge settings does not keep you on v2.0.1 — you get v3 APIs with dynamic loading (Option A). Staying on v2.0.1 requires keeping the v2.0.1 dependency version.
SW02 (SDK integrity) can be raised when the SDK detects reverse-engineering tooling, hooking, or — when APP-INTEGRITY-CHECK=baseline is enabled — a change to the host app executable since the baseline was established. SDK Mach-O __TEXT.__text hash verification is not performed. APP-INTEGRITY-CHECK defaults to disabled; use APP-INTEGRITY-TRUSTED-INSTALL=N for non–App Store debug builds.
getWarnings() on your chosen link model before go-live.The published XCFramework contains the framework binary. Debug symbols are a separate device dSYM, sent by Ravelin on request for the SDK version you linked.
Dynamic embedded framework. Add the dSYM to the app archive when you want Ravelin3DS frames symbolicated in App Store Connect. Until you do, upload can report that symbols for Ravelin3DS.framework were missing. The upload still succeeds, and Organizer shows raw addresses for those frames. Crashlytics, Sentry, and similar tools can take the same dSYM later, including for a build already shipped. App Store Connect applies it to archives that contain the dSYM at upload.
Ravelin3DS.framework.dSYM.zip for your SDK version from Ravelin.dwarfdump --uuid Ravelin3DS.framework.dSYM
dwarfdump --uuid path/to/Ravelin3DS.framework/Ravelin3DS
$(SRCROOT)/Vendor/Ravelin3DS.framework.dSYM under Input Files and $(DWARF_DSYM_FOLDER_PATH)/Ravelin3DS.framework.dSYM under Output Files:if [ "${ACTION}" = "install" ]; then
rsync -a "${SRCROOT}/Vendor/Ravelin3DS.framework.dSYM" "${DWARF_DSYM_FOLDER_PATH}/"
fi
The phase runs for archive installs. The dSYM is for crash symbolication of that SDK version. Keep it out of public source control.
Mergeable. A Release build merges the SDK into the app executable. The app dSYM from that archive covers those frames. Do not add the framework dSYM.
There are three primary security goals:
An API key is available for use with the SDK. Add it to ConfigParameters and pass those parameters to initialize(…) on your ThreeDS2SDK instance.
The Ravelin 3DS SDK aims to provide an authentication service for payment transactions which involve different Card schemes. Each card scheme provides public keys for device data encryption, root/mediator keys to verify signed certificates which arrive from the ACS, and the Card scheme logos. In order to comply with the PCI 3DS SDK 1.1v requirements these values cannot be bundled with the SDK. In order to protect this information the Ravelin 3DS SDK fetches this information from a remote host over a secured TLS link protected by an API token. The metadata downloaded from the host is stored in encrypted storage.
The following is a list of card schemes that the Ravelin 3DS SDK is certified with:
| Card Scheme | Directory Server ID |
|---|---|
| Visa | A000000003 |
| Mastercard | A000000004 |
| JCB (Japan Credit Bureau) | A000000065 |
| CB (Cartes Bancaires) | A000000042 |
| Diners Club/Discover | A000000152 |
| Amex (American Express) | A000000025 |
| UnionPay | A000000333 |
| Eftpos | A000000384 |
Pass an appropriate Directory Server ID value, as directoryServerID, when calling createTransaction(directoryServerID:messageVersion:) during Authentication with an argument matching a value from the
table above.
The 3DS SDK uses the listed external dependencies which are integrated directly into the SDK; there is no requirement to include these dependencies in any app using the 3DS SDK.
Here you can find a list of these dependencies:
| Name | Usage | Website | License | Version |
|---|---|---|---|---|
| JOSESwift | a framework supporting the JOSE standards | https://github.com/airsidemobile/JOSESwift | Apache | 2.4.0 |
The EMVCo 3DS Specification requires the communication between the 3DS SDK and the ACS to be done through HTTPS, but there’s no such requirement when downloading the Payment System and Issuer logo images that the SDK displays in the challenge screens. These URLs are provided as parameters by the ACS in the CRes and it’s expected that they will be HTTPS URLs.
If, however, an insecure HTTP URL is provided, the images will not be downloaded due to Apple’s default policies on insecure network connections. For more information on this, please visit the relevant Apple documentation.
Device Information parameters can be set as restricted, which will in turn make the SDK not collect them.
Pass through ConfigParameters. A list of device info parameters and their corresponding IDs can be found in the EMV® 3-D Secure SDK—Device Information Data Version 1.7 documentation.
R3DS2Error.invalidInput is thrown if a passed ID doesn’t correspond to any predefined device info parameter.
ConfigParametersBy using ConfigParameters.addParam(...), with the following arguments:
paramType: .restrictedDeviceParameters
paramValue: Comma-separated list of device info parameter IDs.
Example:
let configParameters = ConfigParameters()
do {
try configParameters.addParam(paramType: .restrictedDeviceParameters,
paramValue: "C001,C002,C003,I001,I002")
} catch let error {
errorHandler(error.localizedDescription)
}
If your app uses Universal App Links for Out-of-Band return on protocol version 2.3.1, declare support at initialization so the SDK sends the correct oobAppURLInd value in OOB CReqs:
try configParameters.addParam(paramType: .oobUniversalAppLinkSupported, paramValue: "true")
When omitted, the SDK defaults to "false" (oobAppURLInd = 03). See Requestor App URL and Out-of-Band (OOB) authentication.
This section describes which iOS Permissions should be granted.
| Permission | Mandatory | Description |
|---|---|---|
Location | No | Used during the device info collection process for better risk calculation. Request permission from the user before creating a transaction. |
The SDK API complies with the API defined by the EMVCo 3DS SDK Specification. This section describes how the SDK can be used to perform 3DS Authentication of payment / non-payment transactions.
Please refer to the iOS 3DS SDK Interface.
The SDK exposes EMVCo-style type names as Swift typealiases. In integration examples below, the most common names are:
| Name | Underlying type | Usage |
|---|---|---|
ThreeDS2SDK | R3DS2ServiceSDK | Concrete class — use in app code (let sdk = ThreeDS2SDK()) |
ThreeDS2Service | R3DS2Service | Protocol implemented by ThreeDS2SDK |
ConfigParameters | R3DS2ConfigParameters | SDK configuration |
Transaction | R3DS2Transaction | Per-checkout transaction |
Warning | R3DS2Warning | Initialization security warning |
R3DS2Error | — | All SDK errors (see SDK Error Handling) |
ThreeDS2Exception | R3DS2Error | Legacy alias — prefer R3DS2Error in new code |
Set an API key by adding a value for publishableApiKey to a ConfigParameters object.
let configParameters = ConfigParameters()
do {
try configParameters.addParam(paramType: .publishableApiKey, paramValue: "xxxx...")
} catch {
// handle InvalidInput
}
Create an uninitialized SDK instance, then call initialize(…):
let sdk = ThreeDS2SDK()
do {
try sdk.initialize(configParameters: configParameters, uiCustomization: uiCustomizationMap) { result in
DispatchQueue.main.async {
switch result {
case .success:
// SDK ready — safe to call getSDKVersion(), createTransaction(), etc.
case .failure(let error):
// Async failure — typically metadata/operability (.sdkRuntime)
}
}
}
} catch {
// Synchronous failure — invalid config or SDKAlreadyInitialized
}
| Function Argument | Description |
|---|---|
configParameters | Instance of ConfigParameters |
uiCustomization | Instance of UiCustomizationMap, or a single UiCustomization (wrapped as .DEFAULT) |
completion | Escaping closure with Result<Void, R3DS2Error>. Not called on the main queue. |
Synchronous vs asynchronous errors:
| When | How it surfaces |
|---|---|
| Invalid config (e.g. missing PAK) | Thrown synchronously from initialize(…) on the caller’s thread |
| Second init while already initialized | Thrown synchronously — .sdkAlreadyInitialized |
| Metadata download or operability check fails | Delivered in completion — .sdkRuntime(message:) |
If SDK version metadata or required scheme data (configured via the RIDS parameter) cannot be obtained, initialization completes with .sdkRuntime and a descriptive message.
Swift concurrency (iOS 13+):
let sdk = ThreeDS2SDK()
do {
try await sdk.initialize(configParameters: configParameters, uiCustomization: uiCustomizationMap)
// Safe to update UI when called from the main actor
} catch {
// handle error
}
Each ThreeDS2SDK instance should be used serially — do not call initialize, createTransaction, or cleanup concurrently on the same instance.
During initialization, security checks are performed and device information collected. These parameters will be part of Authentication and will be provided to the ACS via 3DS Server for risk analysis. For more details, refer to Security Features.
The EMV 3DS protocol defines an API for challenge flow UI Customization. This includes text color, fonts, background color, etc. A list of all available methods can be found in Section 4.5 of the 3DS SDK Specification.
Pass a theme map (UiCustomizationMap) at initialization. The SDK selects the active entry when the challenge screen is shown, based on the device appearance (light, dark, or grayscale accessibility), and refreshes when traits change.
| Key | When used |
|---|---|
.DEFAULT | Light mode |
.DARK | Dark mode |
.MONOCHROME | Grayscale accessibility mode (falls back to .DEFAULT if not set) |
Each UiCustomization instance holds one color set. Configure separate instances for each appearance mode:
let defaultUi = UiCustomization()
let defaultToolbar = ToolbarCustomization()
try defaultToolbar.setHeaderText(headerText: "Secure Checkout")
try defaultToolbar.setBackgroundColor(hexColorCode: "#EC6C2D")
defaultUi.setToolbarCustomization(toolbarCustomization: defaultToolbar)
let darkUi = UiCustomization()
let darkToolbar = ToolbarCustomization()
try darkToolbar.setHeaderText(headerText: "Secure Checkout")
try darkToolbar.setBackgroundColor(hexColorCode: "#1E293B")
darkUi.setToolbarCustomization(toolbarCustomization: darkToolbar)
let uiCustomizationMap: UiCustomizationMap = [
.DEFAULT: defaultUi,
.DARK: darkUi
]
If you only need one theme, pass a single UiCustomization to initialize(…) — the SDK wraps it as .DEFAULT.
SDK-owned challenge chrome (toolbar defaults, cancel confirmation, whitelist buttons) is loaded from the SDK string catalog. English is included in the XCFramework. Override text via ToolbarCustomization setters when needed. ACS challenge content is unchanged.
For more detailed information, refer to Section 4.5 in the 3DS SDK Specification.
After security checks are performed, the SDK provides the outcome as a list of Warning objects. To obtain the result of these checks, call getWarnings() on your initialized SDK instance.
do {
let sdkWarnings = try sdk.getWarnings()
} catch R3DS2Error.sdkNotInitialized {
// SDK not initialized
} catch {
// other errors
}
Each Warning exposes getID(), getMessage(), and getSeverity() (.LOW, .MEDIUM, or .HIGH). It’s up to the integrator to decide what to do with this information. The resulting warnings are also provided as part of Device Info in the Authentication process. For more details, please refer to Security Warnings.
The 3DS Authentication flow starts with the Authentication Request that is sent to the 3DS Server, where an AReq is created, forwarded to the relevant DS and further forwarded to the relevant ACS. The ACS then evaluates the data in the AReq and responds with an ARes back to the DS, which comes back to the 3DS Requestor Environment via the 3DS Server.
The SDK generates authentication parameters that should be used to build the Authentication Request. All these parameters should be sent to the 3DS Server. These are made available in the Transaction object.
To obtain an instance of Transaction, call createTransaction(…) on your SDK instance:
/// Synchronous — throws R3DS2Error on failure.
func createTransaction(directoryServerID: String, messageVersion: String?) throws -> Transaction
/// Asynchronous — completion is not called on the main queue.
func createTransaction(
directoryServerID directoryServerId: String,
messageVersion: String?,
completion: @escaping (Result<Transaction, R3DS2Error>) -> Void
)
Returns a Result asynchronously, after attempting to recover from any errors where possible. The completion handler is not called on the main queue.
sdk.createTransaction(directoryServerID: "A000000003", messageVersion: "2.2.0") { result in
DispatchQueue.main.async {
switch result {
case .success(let transaction):
// handle success
case .failure(let error):
// handle failure
}
}
}
On iOS 13+, try await sdk.createTransaction(directoryServerID:messageVersion:) resumes on the main actor.
| Function Argument | Description |
|---|---|
directoryServerID | The Directory Server ID is a Registered Application Provider Identifier (RID) that is unique to the Payment System. |
messageVersion | 3DS Protocol Version to be used (‘2.2.0’ or ‘2.3.1’). If this value is nil, the highest version supported (‘2.3.1’) will be used. N.B. SDK v2.0.0 or above is required to support protocol version 2.3.1 See Supported Protocols |
After the Transaction object has been created, AuthenticationRequestParameters can be obtained by calling Transaction.getAuthenticationRequestParameters().
do {
let transactionParameters = try transaction.getAuthenticationRequestParameters()
} catch let error as R3DS2Error {
// handle SDK error
} catch {
// ...
}
All available AuthenticationRequestParameters are defined in Chapter 4.12 in the EMVCo 3DS SDK Specification.
While the Authentication Request is ongoing, a Processing Screen supplied by the SDK will be shown. To get a reference to the associated ProgressDialog object, use Transaction.getProgressView().
A requirement from the 3DS Specification is that this processing screen should be shown for a minimum of two seconds, regardless of authentication response time or result.
v3.0 adds optional async throws overloads that resume on the main actor:
try await sdk.initialize(configParameters: config, uiCustomization: map)
let transaction = try await sdk.createTransaction(
directoryServerID: "A000000004",
messageVersion: "2.2.0"
)
let result = try await transaction.doChallenge(
challengeParameters: challengeParams,
timeOut: 5,
challengeView: challengeView
)
doChallenge returns a ChallengeResult (R3DS2ChallengeResult) for terminal outcomes (.completed, .cancelled, .timedOut, .protocolError, .runtimeError). Synchronous validation failures are still thrown as R3DS2Error. The callback-based ChallengeStatusReceiver API remains available and unchanged.
These operations are not cancelable. Use completion-based overloads when you need background-queue delivery.
The messageVersion parameter value is determined by the protocol version. In order to determine the appropriate protocol version, several factors must be considered:
For example, the version API may return versionRecommendation equal to 2.3.1 while the current
version of the application supports only 2.2.0. In that case, the integrator should use 2.2.0 as the
protocol version for the authentication request.
Another example: The application supports both 2.2.0 and 2.3.1 protocols while the version API
recommendation is to use 2.2.0 because the Card scheme or the issuer doesn’t yet support 2.3.1.
If the ACS assesses a transaction as high-risk, it forces the challenge flow onto it. In case of Challenge, the 3DS Requestor calls Transaction.doChallenge(...) and the SDK takes over the Challenge process.
do {
try transaction.doChallenge(challengeParameters: challengeParameters,
challengeStatusReceiver: challengeStatusReceiver,
timeOut: 5,
challengeView: challengeView)
} catch let error as R3DS2Error {
// handle SDK error
}
| Function Argument | Description |
|---|---|
challengeParameters | Instance of ChallengeParameters, created with values from the Authentication Response. |
challengeStatusReceiver | Callback object that implements ChallengeStatusReceiver. Through this the application will be notified about the challenge result. The SDK holds a weak reference to this object. |
timeOut | Timeout interval (in minutes) within which the challenge process must be completed. The minimum value is defined to be 5 minutes. |
challengeView | An implementation of ChallengeView, providing a view controller onto which the challenge flow will be presented. The SDK holds a weak reference to this view controller. |
Once a Challenge has been started, any calls to Transaction.doChallenge(...) or Transaction.close() will result in an R3DS2Error.sdkRuntime, however the challenge flow will not be interrupted.
Starting with protocol version 2.2.0, the 3DS Requestor App can be opened from another authentication application during an Out-of-Band challenge to indicate that OOB authentication has completed. Provide your requestor app URL via ChallengeParameters.setThreeDSRequestorAppURL(_:).
The value is optional. It should be a fully qualified URL or a Universal App Link.
For native OOB (acsUiType = 04) and HTML OOB (acsUiType = 06) challenges, when the cardholder returns to the Requestor App after completing authentication in the OOB app, the SDK automatically submits a CReq with the OOB Continuation Indicator set to automatic (oobContinue = 02 on 2.3.1). This only happens after the Requestor App has actually entered the background (for example, when the cardholder switched to the OOB app). Transient inactive states such as Control Center or the notification shade do not trigger auto-continue.
Manual Continue still submits a CReq with oobContinue = 01 when the cardholder taps the continue button without leaving the app.
oobAppURLInd)On protocol version 2.3.1, the SDK includes oobAppURLInd in OOB continuation CReqs to declare whether the Requestor App supports Universal App Links for OOB return. Configure this at initialization:
try configParameters.addParam(paramType: .oobUniversalAppLinkSupported, paramValue: "true")
oobUniversalAppLinkSupported | oobAppURLInd in CReq (2.3.1 only) | Meaning |
|---|---|---|
omitted or "false" (default) | 03 | Universal App Link not supported by the Requestor App |
"true" | 01 | Universal App Link supported |
On protocol version 2.2.0, oobAppURLInd is not sent. The parameter name matches the Android SDK (oobUniversalAppLinkSupported) for cross-platform parity.
Set oobUniversalAppLinkSupported to "true" when your app uses Universal App Links for OOB return and your EMVCo or scheme test configuration expects oobAppURLInd = 01.
If the SDK cannot open the OOB authentication app (missing URL, scheme not registered, or user cancellation), it submits a continuation CReq with oobAppStatus = 01. HTML OOB challenges use the same continuation path as native OOB in this case — the CReq does not include challengeHTMLDataEntry.
After invoking Transaction.doChallenge(...), the challenge flow starts and the SDK takes control of the UI. It will get control back when any of the callback methods from ChallengeStatusReceiver are invoked:
final class MyChallengeReceiver: ChallengeStatusReceiver {
func completed(completionEvent: CompletionEvent) {
// Handle successful or unsuccessful completion of challenge flow
}
func cancelled() {
// Handle challenge canceled by the user
}
func timedout() {
// Handle challenge timeout
}
func protocolError(protocolErrorEvent: ProtocolErrorEvent) {
// Handle protocol error that has been sent by the ACS
}
func runtimeError(runtimeErrorEvent: RuntimeErrorEvent) {
// Handle error that has occurred in the SDK at runtime
}
}
When any of these are invoked, the Challenge is considered as finished. As a result, the SDK dismisses the Challenge screen, closes the transaction, cleans up resources and returns control back to the host application.
After the 3DS Authentication is finished, the 3DS Requestor should close the Transaction by calling Transaction.close() in order to clear references and avoid memory leaks. When the authentication is done with the Challenge flow, the SDK handles this.
Similarly, in order to free up resources used by the SDK, call sdk.cleanup(). Once cleanup completes, the instance is in the same state as a newly created ThreeDS2SDK and can be used again, however you’ll need to go through initialization again. Create a new Transaction object after initializing the service.
This section covers SDK errors and their meaning. All errors are surfaced as R3DS2Error. ThreeDS2Exception is a legacy type alias for the same enum.
The EMVCo 3DS SDK specification defines four error categories. In Swift these map to R3DS2Error cases:
| EMVCo category | R3DS2Error case | When it occurs |
|---|---|---|
| Invalid input | .invalidInput(message:) | Invalid data provided to the SDK (e.g. missing PAK, unsupported protocol version) |
| SDK already initialized | .sdkAlreadyInitialized | initialize(…) called on an already initialized instance |
| SDK not initialized | .sdkNotInitialized | SDK method called before successful initialization |
| SDK runtime error | .sdkRuntime(message:) | Internal SDK error, including metadata/operability failures delivered via init completion |
Handling errors:
do {
try sdk.initialize(configParameters: config, uiCustomization: map) { result in
switch result {
case .success:
break
case .failure(let error):
switch error {
case .invalidInput(let message):
break
case .sdkAlreadyInitialized:
break
case .sdkNotInitialized:
break
case .sdkRuntime(let message):
break
}
}
}
} catch let error as R3DS2Error {
// synchronous validation failure (invalid config, already initialized)
}
Synchronous methods such as getWarnings() and createTransaction(…) throw R3DS2Error directly. Completion handlers deliver failures as Result.failure(R3DS2Error).
This section goes into detail about the security aspects concerning the SDK and its integration.
The SDK implements a number of security functions that are defined in the EMVCo 3DS SDK Specification and in PCI 3DS SDK Security Standard.
During Initialization, the SDK performs a number of required security checks. These checks may result in warnings that are available to the host application. It’s up to you to act upon these warnings - The SDK will continue to operate as normal should you decide to, for example, ignore them.
For v3.0.0 and v3.1.0, choose a link model and verify getWarnings() on a physical Release build.
Below is a list of the possible warnings:
| Code | Severity | Description |
|---|---|---|
SW01 | HIGH | Jailbroken device. |
SW02 | HIGH | The SDK has been tampered with. |
SW03 | HIGH | An emulator is being used to run the Application. |
SW04 | MEDIUM | Debugger is attached. |
SW05 | HIGH | Unsupported OS Version. |
The SDK uses several cryptographic methods to secure the communication and transfer of data.
Device Data collected during initialization is sent to the 3DS Server, which forwards it to the DS and ACS. In order to secure the transmission, the SDK encrypts that data with the DS Public Key in JWE format. The encrypted data can be retrieved by calling AuthenticationRequestParameters.getDeviceData().
After the DS receives this encrypted data, it decrypts it and sends it to the ACS. Using data transferred in the Authentication, the 3DS SDK and ACS exchange keys using the Diffie-Hellman protocol - This establishes the secure channel that is used during the challenge flow.
The Ephemeral Key used for the key exchange is generated by the SDK. It can be retrieved in JWK format by invoking AuthenticationRequestParameters.getSDKEphemeralPublicKey(). This key should be sent in the Authentication Request to the 3DS Server together with the other parameters.
// Setup SDK Authentication Request Parameters
let authRequestParams = try transaction.getAuthenticationRequestParameters()
let encryptedDeviceInfo = authRequestParams.getDeviceData()
let sdkTransactionId = authRequestParams.getSDKTransactionID()
let sdkEphemeralPublicKey = authRequestParams.getSDKEphemeralPublicKey()
let sdkReferenceNumber = authRequestParams.getSDKReferenceNumber()
let sdkAppID = authRequestParams.getSDKAppID()
The SDK and dependencies only make use of cryptographic functions provided as part of the OS, specifically based upon the CommonCrypto library.
Complying with Encryption Export Regulations.
A complete definition for the 3DS SDK interface.
ThreeDS2SDK is the concrete class merchants use in application code. It conforms to the ThreeDS2Service protocol defined below.
// initialize
sdk = ThreeDS2SDK()
sdk.initialize(configParameters, uiCustomizationMap)
warnings = sdk.getWarnings()
evaluate warnings
// authentication
transaction = sdk.createTransaction(...)
authenticationRequestParameters = transaction.getAuthenticationRequestParameters()
authenticationResponse = make AuthenticationRequest with authenticationRequestParameters
// challenge
if authenticationResponse.challengeRequired
build challengeParameters from authenticationResponse
transaction.doChallenge(challengeParameters,challengeStatusReceiver)
// handle challenge completion event
challengeStatusReceiver receives an async event:
completed
cancelled
timedout
error
// cleanup
transaction.close()
sdk.cleanup()
public protocol ThreeDS2Service {
/// Creates an uninitialized 3DS SDK instance.
init()
/// Initializes the 3DS SDK instance asynchronously.
///
/// - Parameters:
/// - configParameters: Configuration information that shall be used during initialization.
/// - uiCustomization: A map of UI customizations keyed by mode (DEFAULT, DARK, MONOCHROME).
/// - completion: Escaping closure invoked with the initialization result.
/// - Throws: InvalidInput, SDKAlreadyInitialized (synchronous, on caller's thread).
///
/// The completion handler is not called on the main queue.
func initialize(
configParameters: R3DS2ConfigParameters,
uiCustomization: UiCustomizationMap?,
completion: @escaping (Result<Void, R3DS2Error>) -> Void
) throws
/// Initializes using a single DEFAULT customization (convenience overload).
func initialize(
configParameters: R3DS2ConfigParameters,
uiCustomization: UiCustomization?,
completion: @escaping (Result<Void, R3DS2Error>) -> Void
) throws
/// Initializes using Swift concurrency (iOS 13+). Resumes on the main actor.
@available(iOS 13.0, *)
func initialize(
configParameters: R3DS2ConfigParameters,
uiCustomization: UiCustomizationMap?
) async throws
/// Returns the warnings produced by the 3DS SDK during initialization.
///
/// - Returns: Returns an Array of warnings produced by the 3DS SDK during initialization.
/// - Throws: SDKNotInitialized.
func getWarnings() throws -> [R3DS2Warning]
/// Returns the version of the 3DS SDK that is integrated with the 3DS Requestor App.
///
/// - Returns: returns (as a string) the version of the 3DS SDK that is integrated with the 3DS
/// Requestor App.
/// - Throws: SDKNotInitialized, SDKRuntime
func getSDKVersion() throws -> String
/// Synchronous transaction creation.
func createTransaction(directoryServerID: String, messageVersion: String?) throws -> R3DS2Transaction
/// Asynchronous transaction creation. Completion is not called on the main queue.
func createTransaction(directoryServerID directoryServerId: String, messageVersion: String?, completion: @escaping (Result<R3DS2Transaction, R3DS2Error>) -> Void)
/// Creates a transaction using Swift concurrency (iOS 13+). Resumes on the main actor.
@available(iOS 13.0, *)
func createTransaction(directoryServerID: String, messageVersion: String?) async throws -> R3DS2Transaction
/// Frees up resources that are used by the 3DS Requestor App until it is closed.
///
/// - Throws: SDKNotInitialized
func cleanup() throws
}
The 3DS Requestor App creates an instance of ThreeDS2Service with init(), then calls initialize(…) with configuration parameters and a UI customization map.
The following tasks are performed during initialization:
Depending on the 3DS Requestor App implementation, a ThreeDS2Service instance is created either during 3DS Requestor App startup as a background task or when a transaction is initiated.
Once initialized, state is maintained until the cleanup method is called.
The getWarnings method returns any warnings produced by the 3DS SDK during initialization.
The getSDKVersion method returns the version of the 3DS SDK that is integrated with the 3DS Requestor App.
The createTransaction method creates an instance of Transaction through which the 3DS Requestor App gets the data that is required to perform the transaction. The 3DS Requestor App calls the createTransaction method for each transaction that is to be processed. When the createTransaction method is called:
R3DS2Error.invalidInput. If the messageVersion parameter is empty or nil, the highest protocol version that the 3DS SDK supports is used. If a challenge flow is triggered for the transaction, the 3DS SDK uses the same protocol version during the challenge process.The cleanup method frees up resources that are used by the 3DS SDK.
Implements the Transaction interface and holds parameters that the 3DS Server requires to create AReq messages and to perform the Challenge Flow.
public protocol Transaction {
/// Returns device and 3DS SDK information to the 3DS Requestor App.
///
/// - Returns: Returns an AuthenticationRequestParameters object that contains device information and 3DS SDK information.
/// - Throws: SDKRuntime.
func getAuthenticationRequestParameters() throws -> AuthenticationRequestParameters
/// Initiates the challenge process.
///
/// - Parameters:
/// - challengeParameters: ACS details required by the 3DS SDK to conduct the challenge
/// process during the transaction.
/// - challengeStatusReceiver: Callback object for notifying the 3DS Requestor App about the
/// challenge status.
/// - timeOut: Timeout interval (in minutes) within which the challenge process must be
/// completed. The minimum timeout interval shall be 5 minutes.
/// - challengeView: implementation of ChallengeView providing a UIViewController
/// - Throws: InvalidInput or SDKRuntime.
func doChallenge(challengeParameters: ChallengeParameters,
challengeStatusReceiver: ChallengeStatusReceiver,
timeOut: Int,
challengeView: ChallengeView) throws
/// Initiates the challenge process using Swift concurrency (iOS 13+).
/// Returns ChallengeResult on the main actor for terminal outcomes.
@available(iOS 13.0, *)
func doChallenge(challengeParameters: ChallengeParameters,
timeOut: Int,
challengeView: ChallengeView) async throws -> ChallengeResult
/// Returns an instance of Progress View (processing screen) that the 3DS Requestor App uses.
///
/// - Returns: Returns a ProgressDialog object.
func getProgressView() -> ProgressDialog
/// Cleans up resources that are held by the Transaction object.
/// - Throws: SDKRuntime.
func close() throws
}
When the 3DS Requestor App calls the getAuthenticationRequestParameters method, the 3DS SDK encrypts the device information that it collects during initialization, and sends this information, along with the SDK information, to the 3DS Requestor App. The Requestor App includes this information in its message to the 3DS Server.
The 3DS SDK encrypts the device information by using the DS public key. This key is identified based on the directoryServerID that is passed to the createTransaction method. The 3DS SDK can use A128CBC-HS256 or A128GCM as the encryption algorithm. Refer to 3DS SDK Encryption to DS in EMV 3DS Protocol Specification.
The 3DS SDK generates an ephemeral key pair that is required for subsequent communication with the ACS if a challenge must be applied. For more information, refer to ACS Secure Channel in EMVCo 3DS SDK Specification
If the ARes that is returned indicates that the challenge flow must be applied, the 3DS Requestor App calls the doChallenge method with the required input parameters.
When the doChallenge method is called, control of the app is passed to the 3DS SDK and the SDK initiates the challenge process:
For more information about the algorithms used for validation, and the CEKs, refer to the 3DS SDK Secure Channel Set-Up in EMV 3DS Protocol Specification.
The 3DS SDK displays the challenge to the Cardholder. The following steps shall take place during the challenge process. The SDK will:
If the time taken by the challenge process exceeds the timeout value passed by the 3DS Requestor App (minimum of 5 minutes), the 3DS SDK shall:
The getProgressView method shall return an instance of ProgressDialog associated with a ProgressView; both the view and the association are managed by the SDK. The 3DS Requestor App uses the ProgressDialog.
The close method is called to clean up resources that are held by the Transaction object. Note: This method is required to be called only when the doChallenge method is not called in the transaction. The following are some examples of scenarios in which the close method is called:
N.B. An instance of ConfigParameters is used to pass a number of parameters to the SDK. The options for these parameters are provided in sample code
/// Represents additional configuration parameters that can be passed to the 3DS SDK during initialization.
public protocol ConfigParameters {
func addParam(group: String?, paramName: String, paramValue: String?) throws
func getParamValue(group: String?, paramName: String) throws -> String
func removeParam(group: String?, paramName: String) throws -> String
func addParam(paramType: ConfigParamType, paramValue: String?) throws
func getParamValue(paramType: ConfigParamType) throws -> String
func removeParam(paramType: ConfigParamType) throws -> String
}
public enum ConfigParamType {
case metaDataHost
case publishableApiKey
case errorReportHost
case errorApiKey
case restrictedDeviceParameters
case registeredApplicationProviderIdentifiers
case oobUniversalAppLinkSupported
}
ConfigParamType | Value | Default | Description |
|---|---|---|---|
oobUniversalAppLinkSupported | "true" or "false" | "false" | On 2.3.1 OOB CReqs, sets oobAppURLInd to 01 (supported) or 03 (not supported). Omitted on 2.2.0. |
/// Customization for SDK UI in default, dark, or grayscale accessibility mode.
public enum UiCustomizationType {
case DEFAULT
case DARK
case MONOCHROME
}
/// Maps a UI mode to its customization.
public typealias UiCustomizationMap = [UiCustomizationType: UiCustomization]
/// Provides the functionality required for 3DS SDK UI customization.
public protocol UiCustomization {
func setButtonCustomization(_ buttonCustomization: ButtonCustomization, _ buttonType: ButtonType) throws
func setButtonCustomization(_ buttonCustomization: ButtonCustomization, _ buttonType: String) throws
func setToolbarCustomization(_ toolbarCustomization: ToolbarCustomization) throws
func setLabelCustomization(_ labelCustomization: LabelCustomization) throws
func setTextBoxCustomization(_ textBoxCustomization: TextBoxCustomization) throws
func getButtonCustomization(_ buttonType: ButtonType) throws -> ButtonCustomization
func getButtonCustomization(_ buttonType: String) throws -> ButtonCustomization
func getToolbarCustomization() throws -> ToolbarCustomization
func getLabelCustomization() throws -> LabelCustomization
func getTextBoxCustomization() throws -> TextBoxCustomization
}
/// Each UiCustomization holds one color set. Provide separate instances per theme in UiCustomizationMap.
/// Provides methods to pass UI customization parameters to the 3DS SDK.
public protocol Customization {
func setTextFontName(_ fontName: String) throws
func setTextColor(_ hexColorCode: String) throws
func setTextFontSize(_ fontSize: Int) throws
func getTextFontName() -> String
func getTextColor() -> String
func getTextFontSize() -> Int
}
public enum ButtonType {
case SUBMIT
case CONTINUE
case NEXT
case CANCEL
case RESEND
}
public protocol ButtonCustomization: Customization {
func setBackgroundColor(_ hexColorCode: String) throws
func setCornerRadius(_ cornerRadius: Int) throws
func setBorderWidth(_ borderWidth: Int) throws
func setBorderColor(_ hexColorCode: String) throws
func getBackgroundColor() -> String
func getCornerRadius() -> Int
func getBorderWidth() -> Int
func getBorderColor() -> String
}
public protocol ToolbarCustomization: Customization {
func setBackgroundColor(_ hexColorCode: String) throws
func setHeaderText(_ headerText: String) throws
func getBackgroundColor() -> String
func getHeaderText() -> String
}
public protocol LabelCustomization: Customization {
func setHeadingTextColor(_ hexColorCode: String) throws
func setHeadingTextFontName(_ fontName: String) throws
func setHeadingTextFontSize(_ fontSize: Int) throws
func getHeadingTextColor() -> String
func getHeadingTextFontName() -> String
func getHeadingTextFontSize() -> Int
}
public protocol TextBoxCustomization: Customization {
func setBorderWidth(_ borderWidth: Int) throws
func setBorderColor(_ hexColorCode: String) throws
func setCornerRadius(_ cornerRadius: Int) throws
func getBorderWidth() -> Int
func getBorderColor() -> String
func getCornerRadius() -> Int
}
Warning (R3DS2Warning) represents a warning produced by the 3DS SDK while performing security checks during initialization.
public class Warning {
func getID() -> String
func getMessage() -> String
func getSeverity() -> Severity
}
/// Severity levels of warnings produced by the 3DS SDK while conducting security checks during initialization.
/// - LOW: A low-severity warning
/// - MEDIUM: A medium-severity warning
/// - HIGH: A high-severity warning
public enum Severity {
case LOW
case MEDIUM
case HIGH
}
Parameters that the Requestor App passes to the 3DS Server when creating the AReq
public protocol AuthenticationRequestParameters {
func getDeviceData() -> String
func getSDKTransactionID() -> String
func getSDKAppID() -> String
func getSDKReferenceNumber() -> String
func getSDKEphemeralPublicKey() -> String
func getMessageVersion() -> String
}
Parameters that are required to conduct the challenge process; it is mandatory to set values for these parameters.
public protocol ChallengeParameters {
func set3DSServerTransactionID(_ transactionID: String)
func setAcsTransactionID(_ transactionID: String)
func setAcsRefNumber(_ refNumber: String)
func setAcsSignedContent(_ signedContent: String)
func setThreeDSRequestorAppURL (_ threeDSRequestorAppURL : String)
func get3DSServerTransactionID() -> String
func getAcsTransactionID() -> String
func getAcsRefNumber() -> String
func getAcsSignedContent() -> String
func getThreeDSRequestorAppURL() -> String
}
A callback object that implements the ChallengeStatusReceiver interface to receive challenge status notifications from the 3DS SDK at the end of the challenge process. Depending on the result of the challenge process, the 3DS Requestor App may display a message or redirect the cardholder to a screen in the app.
public protocol ChallengeStatusReceiver {
func completed(completionEvent: CompletionEvent)
func cancelled()
func timedout()
func protocolError(protocolErrorEvent: ProtocolErrorEvent)
func runtimeError(runtimeErrorEvent: RuntimeErrorEvent)
}
Protocol defining functions to control the progress view.
public protocol ProgressDialog {
/// Start the progress dialog
func start()
/// Stop the progress dialog
/// As required by the 3DS specification, after a call to stop() the progress dialog indicator will continue until it has been displayed for a minimum of 2 seconds.
func stop()
}
public protocol CompletionEvent {
func getSDKTransactionID() -> String
func getTransactionStatus() -> String
}
public protocol ErrorMessage {
func getTransactionID() -> String
func getErrorCode() -> String
func getErrorDescription() -> String
func getErrorDetails() -> String
}
public protocol ProtocolErrorEvent {
func getErrorMessage() -> ErrorMessage
func getSDKTransactionID() -> String
}
public protocol RuntimeErrorEvent {
func getErrorCode() -> String?
func getErrorMessage() -> String
}
/// Errors produced by the SDK, and interaction with it.
///
/// `ThreeDS2Exception` is a type alias for `R3DS2Error`.
public enum R3DS2Error: Error, Equatable {
case invalidInput(message: String)
case sdkAlreadyInitialized
case sdkNotInitialized
case sdkRuntime(message: String)
}
/// Terminal outcome of async `doChallenge` (iOS 13+).
public enum ChallengeResult {
case completed(CompletionEvent)
case cancelled
case timedOut
case protocolError(ProtocolErrorEvent)
case runtimeError(RuntimeErrorEvent)
}
Major release — breaking API changes from v2.x. See Upgrading from v2.x.
ThreeDS2SDK() then initialize(…) with Result<Void, R3DS2Error>UiCustomizationMap for appearance-aware challenge theming (.DEFAULT, .DARK, .MONOCHROME); dual-color setDark* APIs removedasync throws APIs for initialize, createTransaction, and doChallenge (iOS 13+).sdkRuntime errors when metadata or operability checks fail at initializationoobAppStatus on open failures, and config-driven oobAppURLInd via oobUniversalAppLinkSupportedinit and configure (removed in v3.0 — use ThreeDS2SDK() + initialize(…))Was this page helpful?