Our 3D Secure 2 Component handles the 3D Secure 2 device fingerprinting and challenge flows, including the data exchange between your front end and the issuer's Access Control Server (ACS).
When adding native 3D Secure 2 authentication to your integration:
- Collect additional parameters in your payment form.
- Provide additional parameters when making a payment request.
- Use the Action Component to perform the authentication flow.
- If the payment was routed to 3D Secure 2 redirect flow, use the Redirect Component.
Use v4.10.2 or later of iOS Components to trigger the native 3D Secure 2 flow and ensure best performance. We recommend you always use the latest Components version.
Before you begin
Before starting your integration, make sure that you have integrated our Card Component, or built your own UI for collecting shopper's card details.
Collect additional parameters in your payment form
For higher authentication rates, we strongly recommend that you collect the cardholder name for payments with 3D Secure authentication.
To collect the cardholder name using our Card Component, specify the following when adding the Card Component:
showsHolderNameField
: true
let configuration = CardComponent.Configuration(showsHolderNameField: true)
let component = CardComponent(paymentMethod: paymentMethod,
apiContext: apiContext,
configuration: configuration)
component.delegate = self
self.cardComponent = component
present(component.viewController, animated: true)
We also recommend that you collect the shopper billing address in advance in your payment form. Deliver this parameter to your backend when making a payment as it is required by the card schemes.
Make a payment
From your server, make a /payments request, specifying:
To increase the likelihood of achieving a frictionless flow and higher authorisation rates, we recommend that you send additional parameters if you have the data available. Do not send placeholder data in the live environment.
For channel
iOS, we recommend including these additional parameters: billingAddress
, shopperEmail
and shopperIP
.
Your next steps depend on whether the /payments response contains an action
object, and on the action.type
. Choose your API version:
Use the Action Component
Use the
AdyenActionComponent
to perform the 3D Secure 2 authentication flows, and receive the information that you need to submit in your next API request.
-
Create and persist an instance of
AdyenActionComponent
.let component = AdyenActionComponent(apiContext: apiContext, configuration: configuration) component.delegate = self component.presentationDelegate = presentationDelegate self.adyenActionComponent = component component.configuration.threeDS.requestorAppURL = URL(string: "https://{yourapp.com}/adyen3ds2")
-
Pass the
action
object from the /payments or /payments/details response.let action = try JSONDecoder().decode(Action.self, from: actionData) adyenActionComponent.handle(action)
-
After completing authentication, the Component invokes
didSubmit
( /payments) ordidProvide
( /payments/details). Pass thedata.details
object to your server.func didSubmit(_ data: ActionComponentData, from component: ActionComponent) // For /payments func didProvide(_ data: ActionComponentData, from component: ActionComponent) // For /payments/details
In case an error occurs on the app, the Component invokes the
didFail
method from theActionComponentDelegate
. Dismiss the Component's view controller and display an error message.func didFail(with error: Error, from component: ActionComponent)
Handling 3D Secure redirect
If you get action: redirect, the Component must handle the redirect. Implement the following:
-
You must inform the
AdyenActionComponent
when the shopper returns to your app. To do this, implement the following in your UIApplicationDelegate:func application(_ app: UIApplication, open url: URL, options: [UIApplicationOpenURLOptionsKey: Any] = [:]) -> Bool { RedirectComponent.applicationDidOpen(from: url) return true }
-
After
AdyenActionComponent
completes the authentication, it invokes thedidProvide
method from the ActionComponentDelegate. Get the contents ofdata
and pass this to your server.func didProvide(_ data: ActionComponentData, from component: ActionComponent)
In case an error occurs on the app, the Component invokes the
didFail
method from theActionComponentDelegate
. Dismiss the Component's view controller and display an error message.func didFail(with error: Error, from component: ActionComponent)
Customizing the UI for 3D Secure 2
The Component inherits your app's theme to ensure the UI of the challenge flow fits your app's look and feel. For more UI customizations, use the customization options provided in the
appearanceConfiguration
property.
For more information on iOS Components classes, refer to our Reference documentation.
Present the payment result
Use theĀ resultCode from the /payments or /payments/details response to present the payment result to your shopper. You will also receive the outcome of the payment asynchronously in a webhook.
For card payments, you can receive the following resultCode
values:
resultCode | Description | Action to take |
---|---|---|
Authorised | The payment was successful. | Inform the shopper that the payment has been successful. If you are using manual capture, you also need to capture the payment. |
Cancelled | The shopper cancelled the payment. | Ask the shopper if they want to continue with the order, or ask them to select a different payment method. |
Error | There was an error when the payment was being processed. For more information, check the
refusalReason
field. |
Inform the shopper that there was an error processing their payment. |
Refused | The payment was refused. For more information, check the
refusalReason
field. |
Ask the shopper to try the payment again using a different payment method. |
Test and go live
Use our test card numbers to test how your integration handles different 3D Secure authentication scenarios.
Troubleshooting
If native 3D Secure 2 is not triggered, check that:
- Your Component version is 4.10.2 or later
paymentMethod.threeDS2SdkVersion
is populated and sent in payment requestchannel
is set to iOSauthenticationData.threeDSRequestData.nativeThreeDS
is set to preferred if you use Checkout API v69 or later ORadditionalData.allow3DS2
is set to true if you use Checkout API v68 or earlier