Implementation examples
Node.js
The Components integration handles frictionless and challenge 3D Secure authentication flows, including the data exchange between your front end and the issuer's Access Control Server (ACS).
Follow the instructions on this page if your integration uses the /payments or /payments/details endpoint, and Checkout API 49 or later. If you are using Checkout API 46 or earlier, follow instructions in the 3D Secure 2 integration guide for v46 or earlier.
This guide is for integrations using Web Component v6.0.0 or later. For earlier versions, use the guide for Earlier versions.
If your integration uses the /sessions endpoint, you do not need additional configuration for 3D Secure.
To handle native 3D Secure 2 authentication:
- Get additional shopper details in your payment form.
- Make a payment request, including additional shopper details.
- Handle the 3D Secure 2 action to perform the authentication flow.
- Submit the authentication result.
- Show the payment result.
Requirements
This page assumes that you have already either:
- Built a Card Component integration.
- Built your own UI for collecting shopper's card details.
A strict CSP for your website can prevent native 3D Secure 2 challenges from being loaded on your website. You can use the redirect flow if you do not want to adjust your CSP.
If you are using 3D Secure for PSD2 compliance, read our comprehensive PSD2 SCA guide.
Collect additional shopper details in your payment form
For higher authentication rates, we strongly recommend that you collect the shopper's email address, cardholder name, billing address, and IP address for payments with 3D Secure authentication.
Make a payment
From your server, make a /payments request, specifying:
Your next steps depend on if the /payments response contains an action
object.
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 show 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 front end. 2. Use the Component to perform the authentication flow. 3. Submit the authentication result. |
redirect | The payment is routed to the 3D Secure 2 redirect flow. |
1. Pass the action object to your front end. 2. Use handleAction to handle the redirect. 3. Confirm the redirect result. |
The following example shows a /payments response with action.type
: threeDS2
Handle the 3D Secure 2 action
If your integration uses the Card Component to collect the shopper's card details, also use it to handle the 3D Secure 2 action on the same page.
If you built your own UI for collecting the shopper's card details or want to render 3D Secure authentication on a different page than the payment, create a new 3D Secure 2 Component.
Handle Component errors
When an error occurs, Component calls the onError
handler.
For errors that happen during the 3D Secure 2 authentication, you do not need to stop the payment flow because the shopper can continue.
Submit the authentication result
-
Get the
state.data
from theonAdditionalDetails
event, and pass it your server. -
From your server, make a POST /payments/details request, specifying:
details
: Thestate.data.details
from theonAdditionalDetails
event.
The /payments/details response has a
resultCode
. You need it to show the payment result. -
Pass the
resultCode
you received in the /payments/details to theactions.resolve()
object in theonAdditionalDetails
event. -
Depending on the
resultCode
, handle the payment flow with theonPaymentCompleted
oronPaymentFailed
event.
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.