--- title: "Helper functions" description: "Simplify your 3D Secure 2 API implementation with our helper functions." url: "https://docs.adyen.com/checkout-build-your-own-3ds2/checkout-api-helper-functions" source_url: "https://docs.adyen.com/checkout-build-your-own-3ds2/checkout-api-helper-functions.md" canonical: "https://docs.adyen.com/checkout-build-your-own-3ds2/checkout-api-helper-functions" last_modified: "2019-05-27T18:00:00+02:00" language: "en" --- # Helper functions Simplify your 3D Secure 2 API implementation with our helper functions. [View source](/checkout-build-your-own-3ds2/checkout-api-helper-functions.md) Use our helper functions to: * Collect browser info and store data in properties required in the EMVCo specifications. * Perform base64url encoding and decoding. * Create an iframe with an onload event listener for the 3D Secure 2 device fingerprinting and challenge results. * Create a form with a target attribute to send the issuer requests for 3D Secure 2 device fingerprinting and the challenge. * Configure the challenge window size according to the EMVCo specifications. ## Before you begin Before you begin to integrate, make sure you have followed the [Get started with Adyen guide](/get-started-with-adyen) to: * Get an overview of the steps needed to accept live payments. * Create your test account. After you have created your test account: 1. [Get your API Key](/development-resources/api-credentials#generate-api-key). Save a copy as you'll need it for API calls you make to the Adyen payments platform. 2. Install one of our [Libraries](/development-resources/libraries) to connect with the Adyen APIs. For more information on these steps, refer to [Get started with Adyen](/get-started-with-adyen). 3. Read and understand the [API-only integration](/online-payments/build-your-integration/advanced-flow/?platform=Web\&integration=API%20only\&version=71) guide. You should already know how to collect shopper information, either with the [Card component](/payment-methods/cards) or with your [own payment form](/online-payments/build-your-integration/advanced-flow/?platform=Web\&integration=API%20only\&version=71) implementation. 4. Set up your notification URLs. The issuer will send an HTTP POST containing the 3D Secure 2 device fingerprinting process and the challenge result to these URLs. * `YOUR_3DS_METHOD_NOTIFICATION_URL`: Absolute URL to where the issuer can post the result of the 3D Secure device fingerprinting process.  * `YOUR_3DS_NOTIFICATION_URL`: Absolute URL to where the issuer can post a base64url encoded Challenge Response (`CRes`) message, containing the challenge result. 5. Import our helper functions by: * Cloning our repository from  and importing the files into your project.  ```js import collectBrowserInfo from "./browser"; import base64Url from "./base64url"; import createIframe from "./iframe"; import createForm from "./form"; import {validateChallengeWindowSize, getChallengeWindowSize} from "./config.js"; ``` * Or by building the file, hosting it, and then embedding it in your page.  ```xml ``` Add this in your website: ```js window.addEventListener("message", (e) => { if(e.origin === YOUR_HOSTED_DOMAIN_FOR_THE_NOTIFICATION_URLS){ const eventData = e.data; // IdentifyShopper (3DSMethod) response if(eventData.hasOwnProperty('threeDSCompInd')){ // If you haven't already performed the next /payments/details call from your notification URL this // represents a good place to initiate the an API request authorise3DS2RequestAfterIdentifyingShopper(eventData.threeDSCompInd); } // Challenge response if(eventData.hasOwnProperty('transStatus') && eventData.hasOwnProperty('threeDSServerTransID')){ // If you haven't already performed the next /payments/details call from your notification URL this // represents a good place to initiate the an API request authorise3DS2RequestAfterChallenge(eventData.transStatus, eventData.threeDSServerTransID); } // Run code to remove the iframe from the '#threedsContainer' element hideIframe(); } }); ``` ## Testing 3D Secure 2 To test how your integration handles different 3D Secure 2 authentication scenarios, you need to use a card number for the specific flow. When prompted for 3D Secure 2 text challenges, use the following credentials to authenticate: * For native mobile integrations, use password: **1234** * For web and mobile browser integrations, use password: **password** Depending on the [authentication option](/online-payments/3d-secure/#implementation-options), you can receive the following result codes: * **RedirectShopper**: you receive this result code if you are using the [Redirect authentication](/online-payments/3d-secure/redirect-3ds2) flow. * **IdentifyShopper**: you receive this result code if you are using the [Native authentication](/online-payments/3d-secure/native-3ds2/) flow. * **ChallengeShopper**: you receive this result code after you submit the 3D Secure 2 device fingerprinting result in a Native authentication, unless you specify a [frictionless](/online-payments/3d-secure/#frictionless-flow) flow. Depending on your integration, use the following test cards to simulate different authentication flows. | Card Type | Card Number | Expiry Date | Security Code (CVC/CVV/CID) | | ----------------------------- | ------------------- | ----------- | --------------------------- | | American Express | 3714 4963 5398 431 | 03/2030 | 7373 | | Bancontact / Maestro | 6703 4444 4444 4449 | 03/2030 | | | Bancontact / Visa | 4871 0499 9999 9910 | 03/2030 | 737 | | Cartes Bancaires / Visa Debit | 4035 5014 2814 6300 | 03/2030 | 737 | | Cartes Bancaires | 4360 0000 0100 0005 | 03/2030 | 737 | | China UnionPay (Credit) | 6250 9470 0000 0014 | 03/2030 | 123 | | China UnionPay (Debit) | 6250 9460 0000 0016 | 03/2030 | 123 | | Diners | 3056 9309 0259 04 | 03/2030 | 737 | | Discover | 6011 1111 1111 1117 | 03/2030 | 737 | | Maestro | 5000 5500 0000 0029 | 03/2030 | *n/a* | | Mastercard | 5454 5454 5454 5454 | 03/2030 | 737 | | Mastercard Credit | 2222 4000 1000 0008 | 03/2030 | 737 | | Visa | 4917 6100 0000 0000 | 03/2030 | 737 | | Visa Classic | 4166 6766 6766 6746 | 03/2030 | 737 | #### Challenge without fingerprint To test the web-based flow where the device fingerprinting step is skipped (because the issuer's ACS has not configured a `threeDSMethodURL`), and you get a **ChallengeShopper** `resultCode` *immediately* after submitting the payment request, use the following card: | Card Type | Card Number | Expiry Date | Security Code (CVC/CVV/CID) | | --------- | ------------------- | ----------- | --------------------------- | | Visa | 4212 3456 7891 0006 | 03/2030 | 737 | #### Fingerprint without challenge To test the [frictionless flow](/online-payments/3d-secure/#frictionless-flow), in which you perform a fingerprint but no challenge, use the following test card number: | Card number | Expiry Date | Security Code (CVC/CVV/CID) | Authentication scenario | | ------------------- | ----------- | --------------------------- | ---------------------------- | | 5201 2815 0512 9736 | 03/2030 | 737 | Fingerprint but no challenge | #### Native authentication To test authentication scenarios for native mobile (app-based) integrations, use the following test cards: | Card number | Expiry Date | Security Code (CVC/CVV/CID) | Authentication scenario | | ------------------- | ----------- | --------------------------- | --------------------------------------------------------------------------------------------- | | 5201 2855 6567 2311 | 03/2030 | 737 | Basic text authentication | | 5201 2874 9905 2008 | 03/2030 | 737 | Basic single select | | 5201 2815 9233 1633 | 03/2030 | 737 | Basic multi select | | 5201 2888 2269 6974 | 03/2030 | 737 | Basic out-of-band (OOB) authentication | | 5201 2895 0084 3268 | 03/2030 | 737 | HTML out-of-band (OOB) authentication | | 5201 2861 5377 1465 | 03/2030 | 737 | App single select then text authentication | | 4917 6100 0000 0042 | 03/2030 | 737 | Advanced: ACS sends an empty Challenge Response (`CRes`) | | 4917 6100 0000 0067 | 03/2030 | 737 | Advanced: Invalid content in the `acsSignedContent` field in Authentication Response (`ARes`) | | 4917 6100 0000 0059 | 03/2030 | 737 | Advanced: Challenge Response (`CRes`) timeout | #### Technical error To test simulate an error due to a timeout during the 3D Secure 2 authentication on the issuer side, use the following test card: | Card number | Expiry Date | Security Code (CVC/CVV/CID) | Scenario | | ------------------- | ----------- | --------------------------- | --------------------------------------------------------------------------------------------------- | | 5201 2829 9900 5515 | 03/2030 | 737 | Depending on your configuration, the transaction might still proceed to a successful authorization. |