No momento, esta página não está disponível em português
Online-payment icon

3D Secure 2 Component

Add native 3D Secure 2 authentication to your integration.

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:

  1. Collect additional parameters in your payment form.
  2. Provide additional parameters when making a payment request.
  3. Use the Action Component to perform the authentication flow.
  4. 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:

Parameter name Required Description
paymentMethod -white_check_mark- If using the Card Component, pass the data.paymentMethod object from the didSubmit event from your client app. If submitting raw card data, refer to Raw card data for the fields that you need to pass.
paymentMethod.holderName Required for Visa The cardholder's name.
paymentMethod.threeDS2SdkVersion -white_check_mark- Required to trigger in-app native. See how to get the SDK version.
channel -white_check_mark- Set to iOS.
authenticationData.threeDSRequestData.nativeThreeDS -white_check_mark- Set to preferred. Indicates that your payment page can handle 3D Secure 2 transactions natively.
returnUrl -white_check_mark- In case of a 3D Secure 2 redirect flow, this is the URL where the shopper will be redirected back to after completing authentication. Use the custom URL for your app, for example, my-app://adyen. For more information on setting custom URL schemes, refer to the Apple Developer documentation.
billingAddress The cardholder's billing address.
shopperEmail Required for Visa The cardholder's email address. shopperEmail or a phone number is required for Visa.
threeDS2requestData.homePhone
threeDS2RequestData.workPhone
threeDS2RequestData.mobilePhone
Required for Visa A phone number for the shopper, include one of these fields. shopperEmail or a phone number is required for Visa.

Get the SDK version

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, shopperEmailand shopperIP.

Your next steps depend on whether the /payments response contains an action object, and on the action.type. Choose your API version:

action.type Description Next steps
No action object The transaction was either exempted or out-of-scope for 3D Secure 2 authentication. Use the resultCode to present the payment result to your shopper.
threeDS2 The payment qualifies for 3D Secure 2, and will go through the authentication flow. 1. Pass the action object to your client app to perform the authentication flow.
2. Submit the challenge result.
redirect The payment is routed to the 3D Secure 2 redirect flow.
1. Pass the action object to your client app
2. Handle the redirect result.

The following example shows a /payments response with action.type: threeDS2

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.

  1. 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")
  2. Pass the action object from the /payments or /payments/details response.

    let action = try JSONDecoder().decode(Action.self, from: actionData)
    adyenActionComponent.handle(action)
  3. After completing authentication, the Component invokes didSubmit ( /payments) or didProvide ( /payments/details). Pass the data.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 the ActionComponentDelegate. Dismiss the Component's view controller and display an error message.

    func didFail(with error: Error, from component: ActionComponent)
  1. From your server, make a /payments/details request, specifying:
    • details: The data.details from the didProvide method from your client app.

Your next steps depend on whether the /payments/details response contains an action object.

If you receive an action object, store the action.paymentData on your server - you'll need this when making a /payments/details request later.

action.type Description Next steps
No action object The 3D Secure 2 authentication process is completed. Use the resultCode from the /payments response to present the payment result to your shopper.
Any action object redirect, threeDS2 1. Pass the action object to your client app.
2. Do step 2 again.

Handling 3D Secure redirect

If you get action: redirect, the Component must handle the redirect. Implement the following:

  1. 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
    }
  2. After AdyenActionComponent completes the authentication, it invokes the didProvide method from the ActionComponentDelegate. Get the contents of data 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 the ActionComponentDelegate. 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 request
  • channel is set to iOS
  • authenticationData.threeDSRequestData.nativeThreeDS is set to preferred if you use Checkout API v69 or later OR additionalData.allow3DS2 is set to true if you use Checkout API v68 or earlier

See also