Secure Fields Overview

SecureFields JS Overview

SecureFields JS is a hosted field (payment, PII) solution that helps developers provide additional security to a merchant’s website. They are plug-in fields in your platform's "end-user" interface that provide an easy way to securely implement data collection without needing to pass through your systems. SecureFields JS fields are customizable, secure, input elements. When a user enters secure data in these fields, the data is converted into a token/s. The token/s can be used to send the sensitive data to the specified destination.

If you are looking for specific commands or options, please see the reference to the developer API specs provided from within your partner portal

Advantages of using SecureFields JS

Instantly create customized forms that adhere to PCI and other PII requirements. Our servers intercept the sensitive data before it hits your servers and replaces it with aliased version, while securing the original data in our vault.

The following example shows a rendered payments form using the SecureFields JS to serve the card holder name, card number, expiration date and CVV fields.

Before you begin

You will need your public and private keys from your partner console account. You can also use OAuth credentials if you are a registered partner with Platform.

Implementing SecureField JS

1. Add SecureFields JS to your checkout page

There are two ways to load SecureFields JS

Option #1 - To add SecureFields JS to your checkout page, include our JavaScript library in your host page:

Option #2 - Alternatively, to load only the SecureField JS library without the web components, include the following JavaScript library in your host page:

Then copy the following checkout form into the checkout page:

This will create a very simple (and unstyled) payment form. However, the payment form will not yet contain the fields nor will it be functional. It must first be configured before it can successfully tokenize your payment methods.

2. Initialization

Once the host form is on the page, the fields are initialized with the SecureFields JS module.

Place the below snippet in a new script tag on the bottom of your checkout page, swapping out the example environment key with your own.

Capturing cardholder's billing address fields

There are two ways to capture address fields and send to Platform

  1. Capture address fields within the secure fields (refer here for sample)

  2. Capture address fields outside of the secure fields, in your own form and pass these address fields via createCard (refer here for sample)

2a. Capture address fields within the secure fields

2b. Capture address fields outside of secure fields, in your own form and you can pass the address info via createCard

In this scenario, you will capture the address fields in your own form and provide those values in the form.createCard function as shown below

Following sections are only applicable if you're tokenizing card data for payments. For general PII information, please refer to Using tokens .

3. Tokenize payment details

Depending on your account configuration, your tokenized card info can be made available as global or merchant specific.

Note from the example code above that SecureFields JS doesn’t automatically hook into any form events. Instead, you must explicitly tell it when you want to send the collected card data for tokenization.

As shown in the example above, the most straightforward approach is to create a form onSubmit handler or an element eventListener that serves as a trigger to delegate to SecureFields JS createCard() method. This method will in turn return the tokenized card object that you can safely store within your system.

When automatic Network Tokenization is activated on your account, any PAN data associated with it will automatically use a token provided by the card brand network.

4. Executing an auth transaction

After the SecureFields JS tokenizes your payment method, it is up to you to execute the actual transaction from your backend server environment. This is necessary because the browser is not a secure environment and should never contain your access secret (which is required to invoke the transactional portion of our API).

When the checkout form is submitted, extract the token parameter and use it to execute an auth and capture using the direct APIs:

The above call will authorize a payment method to be charged a specific amount and return an authorization id. No funds are taken with an auth – a follow-up capture transaction is required to actually move the funds.

5. Executing a capture transaction

To capture the amount, you must next call the capture API endpoint

the amount and currency_code are optional fields within the capture call if a partial capture is desired.

At this point, you should be able to see the posted transactions via the merchant's transactions page available via your partner portal.

6. Refund the transaction

To refund the amount, void or reverse the transaction you must make next call

Implementing CSS for secure fields

To customize the appearance of secure fields in your payment form, you can add CSS to style them according to your needs. Here's a sample CSS snippet:

SecureField JS with OAuth token

Load Platform library

We recommend using npm to install Platform, as shown in the following example. However, it is also possible to integrate Platform without npm.

Install payengine library from npm public registry:

To use SecureField JS with an OAuth token, you must implement an endpoint on your server that retrieves a Merchant Session Token. This token allows SecureField JS to process payments securely.

Create a function that calls your server’s new endpoint (/session/token) to retrieve the Merchant Session Token:

Once the payengine library is loaded and configured with fetchAccessToken, you can initialize the SecureField JS

Creating a Merchant Session Token

To interact with SecureField JS, you must obtain a short-lived Merchant Session Token. This requires calling the Platform API with your OAuth access token.

1. Implement a server-side endpoint

Your server should expose an endpoint (/session/token) that requests a Merchant Session Token from Platform using an OAuth access token:

Last updated