Search

Are you looking for test card numbers?

Would you like to contact support?

Custom card fields

Use our Secured Fields Component to build your own card input fields.

If you want more UI freedom in building your own input fields for card payments, you can customize card fields with the Secured Fields Component instead. You can collect raw card data if you are PCI Level 1 or 2 certified. Otherwise, you need to integrate our Secured Fields Component to securely collect and encrypt the shopper's card details.

This guide assumes that you've already completed your server-side integration with our online payments API. If you haven't yet, check the Components page for integration steps.

Collect shopper's card details with Secured Fields Component

When the shopper enters their card details on your website, the Component collects the data, and then creates an encrypted version that you can safely transmit when you make the payment.

If you are using a standalone implementation of Secured Fields, we recommend to use the Secured Fields Component instead.

Older versions will still be supported, but newer functionality will be released on the Secured Fields Component.

See sample code

Check out Secured Fields Component on GitHub.

To add the Secured Fields Component to your payments form, you'll need to:

  1. Make sure that you have already added the Components JavaScript file and the required configuration on your payments page.

  2. Create a DOM element for Secured Fields:

    <div id="securedfields">
        <label>
            <span>Card number:</span>
            <span data-cse="encryptedCardNumber"></span>
        </label>
        <label>
            <span>Expiry date:</span>
            <span data-cse="encryptedExpiryDate"></span>
        </label>
        <label>
            <span>CVV/CVC:</span>
            <span data-cse="encryptedSecurityCode"></span>
        </label>
    </div>
  3. Create an instance of the Secured Fields component, and mount it. You can also include additional configuration properties. For more information, see Configuring the Component.

    const sf = checkout.create('securedfields').mount('#securedfields');
  4. The Component will trigger onChange event when the card brand changes and whenever the Secured Fields form becomes valid or invalid. When onChange callback is triggered and state.isValid is true, get the encrypted values from state.data. You'll use these data to make the payment.

     {
       type: "scheme",
       encryptedCardNumber: "adyenjs_0_1_18$MT6ppy0FAMVMLH...",
       encryptedExpiryMonth: "adyenjs_0_1_18$MT6ppy0FAMVMLH...",
       encryptedExpiryYear: "adyenjs_0_1_18$MT6ppy0FAMVMLH...",
       encryptedSecurityCode: "adyenjs_0_1_18$MT6ppy0FAMVMLH..."
     }

Next, continue to make a payment request from your server.

Configuring the Component

When instantiating the Secured Fields Component, you can optionally specify:

  • ariaLabels: Specify aria attributes for the input fields for web accessibility. If not specified, default labels will be applied.
  • autoFocus: Automatically shift the focus from date field to the CVC field. Defaults to true.
  • groupTypes: Defaults to ['mc','visa','amex']. Configure supported card types to facilitate brand detection used in the onBrand callback. See list of available card brands. If a shopper enters a card type not specified in the GroupTypes configuration, the onBrand callback will not be invoked.
  • placeholders: Specify the sample values you want to appear for card detail input fields. If not specified, default placeholders will be applied.
  • styles: Set a style object to customize the input fields. See Styling Secured Fields for a list of supported properties. If not specified, default styles will be applied.
  • type: Defaults to card. Set this to a specific card brand to limit the PAN that secured fields will accept as valid. If set to a single brand, the 'groupTypes' property will be ignored. See list of available card brands.
  • Additional Secured Fields callbacks.
const sf = checkout.create('securedfields', {
    // Optional
    type: 'card',
    groupTypes: ['mc', 'visa', 'amex', 'bcmc', 'maestro'],
    styles: {
        error: {
            color: 'red'
        },
        validated: {
            color: 'green',
        },
        placeholder: {
            color: '#d8d8d8'
        }
    },
    placeholders: {
        encryptedCardNumber: '9999 9999 9999 9999',
        encryptedExpiryDate: 'mm/yy',
        encryptedSecurityCode: '1234'
    },
    ariaLabels: {
        lang: 'en-GB',
        encryptedCardNumber: {
            label: 'Credit or debit card number field'
        }
    },
    // Events
    onChange: function() {},
    onValid : function() {},
    onLoad: function() {},
    onConfigSuccess: function() {},
    onFieldValid : function() {},
    onBrand: function() {},
    onError: function() {},
    onFocus: function() {},
    onBinValue: function(bin) {}
}).mount('#securedfields');

Default styles, placeholders, and labels

If you don't provide configuration for styles, placeholders, and labels, the Component will use the following default properties.

{
    styles: {
            base: {
                color: "#001b2b",
                fontSize: "16px",
                fontWeight: "400"
            },
            placeholder: {
                color: "#90a2bd",
                fontWeight: "200"
            },
            error: {
                color: "#001b2b"
            }
    },
    placeholders: {
        encryptedCardNumber: "1111 2222 3333 4444",
        encryptedExpiryDate: "MM/YY",
        encryptedSecurityCode: "1234"
    },
    ariaLabels: {
        lang: "en-GB",
        encryptedCardNumber: {
            label: "Credit or debit card number",
            iframeTitle: "Iframe for secured card data input field"
        },
        encryptedExpiryDate: {
            label: "Credit or debit card expiration date",
            iframeTitle: "Iframe for secured card data input field"
        },
        encryptedSecurityCode: {
            label: "Iframe for secured card data input field"
        }
    }
}

Events

The Secured Fields Component will trigger events depending on shopper action. Implement callbacks to handle events and use these to customize your shopper's experience when specific events occur.

For more information on what each callback object contains, see Secured Fields callbacks.

  • onChange: Called when the shopper enters data in the card input fields. Here you have the option to override your main Adyen Checkout configuration.
  • onValid: Called when all fields are valid.
  • onLoad: Called once all the Secured Fields have been created but are not yet ready to use.
  • onConfigSuccess: Called once the Secured Fields are ready to use.
  • onFieldValid: Called when a specific field is validated and encrypted or becomes invalid.
  • onBrand: Called once we detect the card brand.
  • onError: Called when in case of an invalid card number, invalid expiry date, or incomplete field. Called again when errors are cleared.
  • onFocus: Called when a field gains or loses focus.
  • onBinValue: Provides the BIN Number of the card (up to 6 digits), called as the user types in the PAN.

Next steps