Getting Started
Last updated
Was this helpful?
Last updated
Was this helpful?
Integrating the library is a straightforward process. You simply need to include the JavaScript file in your application and configure the necessary HTML elements to host the SDK fields. The following steps outline the process:
To begin, include the Firstoken Captures SDK JavaScript file inside the body of your web application.
For reviewing previous versions of Captures SDK JS go to section.
Next, insert the necessary HTML elements within your form application. It is crucial to use specific ID tags for proper rendering of the SDK.
These elements serve as placeholders where the SDK's iframes will be inserted. For optimal data security, we recommend using "div" elements instead of "input" elements. Here is an example:
In the example above, each "div" element has a unique ID corresponding to the type of data it will capture (e.g., card number, cardholder name, expiration date, security code).
cc-number: corresponds to the field where the card number will be received
cc-holder: corresponds to the field where the cardholder's name will be received
cc-expiration-date: corresponds to the field where the expiration date will be received
cc-cvv: corresponds to the field where the security code will be received
To initialize the Firstoken Capture SDK component, you need to call the .create()
method in the JavaScript file and provide the Inbound Route ID (previously created in the Firstoken web portal) as the first argument. Here is an example:
The return value of this call provides information about the current state of the form, including the condition of the fields.
Each field in the form must be initialized using the appropriate code. Here is an example:
By doing this, the Firstoken Capture SDK will create an iframe for each initialized field. The library supports various types of built-in inputs, such as card number, cardholder name, card expiration date, and card security code.
To validate the form fields, you can utilize the following code snippet:
This code allows you to handle input errors and respond to relevant events.
Leverage the capabilities of the Firstoken Captures SDK to capture and handle validation values. The SDK may offer built-in mechanisms or hooks to intercept and process validation values during the submission process.
This function requires the Route Id value to identify the elements created in the form without interfering with other Iframes on the webpage, such as Google Analytics or Google Tag Manager.
The snippet should be placed inside the submit method within your form event listener, as an async function, in order to await the validation response.
To send the form data, you need to define a submit method within your form event listener. Here is an example:
In this method, you can retrieve the serialized form data using the `serializeForm()` function provided by the Firstoken Captures SDK. You can then process the data as needed.
This function requires the Route Id value to identify the elements created in the form without interfering with other Iframes on the webpage, such as Google Analytics or Google Tag Manager.
By following these steps, you can successfully integrate and configure the Firstoken Captures SDK to securely capture data via customizable forms on your website.