Step 1: Include the library in your project
Before proceeding with the secure-fields implementation, see the SDK Integration overview for detailed instructions on how to properly integrate the SDK into your project. The integration guide provides three flexible methods:- Direct HTML script inclusion
- Dynamic JavaScript injection
- NPM module installation
Step 2: Initialize secure fields with the public key
Get aYuno instance class in your JavaScript application with a valid PUBLIC_API_KEY:
Step 3: Create a customer session and an enrollment payment method object
Create a customer session and a payment method object to use in the setup of your secure fields integration for enrollment. While creating the payment method object, define which one will be available for your customer to enroll (in the case of secure fields, only CARD is available). To verify cards through a zero-value authorization before enrolling a customer, include theverify structure when defining the payment method object for the customer session.
Step 4: Start the enrollment process
Next, you have to create a configuration object. The essential parameters are thecountryCode, which determines the country for which the enrollment process is configured, and customerSession, which refers to the current enrollment’s customer session.
Parameters
Configure the secure fields with the following options:Step 5: Mount the secure-fields
After defining the parameters, define, configure, and mount the secure-fields. For each field, setname and options in secureFields.create.
Configurations:
Once you have set the parameter, you will render the created Secure Field with the
render function by selecting an HTML element using a valid CSS selector (#, ., [data-*]).
Example (three secure-fields):
secureNumber object before creating the vaulted_token and ignore the secureExpiration and secureCvv objects.
After they are mounted, the three secure fields will be shown:
Step 6: Create Vaulted Token
To enroll, create a Vaulted Token:secureFields.generateVaultedTokenWithInformation to receive the full enrollment response. Generate a vaulted token with customer information: