Skip to main content
Implement Yuno’s secure-fields checkout in your application by following these steps. Yuno provides a TypeScript library for all available methods.

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:
  1. Direct HTML script inclusion
  2. Dynamic JavaScript injection
  3. NPM module installation
After integrating the SDK, continue with the remaining steps on this page.

Step 2: Initialize secure fields with the public key

In your JavaScript application, create an instance of the Yuno class by providing a valid PUBLIC_API_KEY:
See the credentials page for more information.

Step 3: Start the checkout process

Use the secureFields function and provide the necessary configuration parameters: The essential parameters are the countryCode, which determines the country for which the payment process is configured, and checkoutSession, which refers to the current payment’s checkout session.

Parameters

Configure the secure fields with the following options:
Payments can be customer-initiated (CIT) or merchant-initiated (MIT). See Stored credentials. These steps cover customer-initiated transactions (one-time; no recurrence).

Step 4: Mount the secure-fields

After defining the parameters, define, configure, and mount the secure-fields. For each field, set name and options in secureFields.create. Configurations: Validation behaviour (validationType): Use options.validationType to control when the field is validated: 'on_change' validates as the user types; 'on_blur' validates when the field loses focus; 'on_blur_full' runs full validation on blur. Default: in checkout flows, 'on_blur_full'. Outside checkout flows there is no default — specify validationType if you want validation. If you previously used validateOnBlur: true, migrate to validationType: 'on_blur' or, for full validation on blur, validationType: 'on_blur_full'. 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):

Data available in onChange callback

When the onChange callback is triggered, the data parameter contains:
  • Card IIN Information: Card issuer details including scheme, brand, type, and issuer information
  • Installment Plans: Available installment options for the account if configured
  • Loading States: isCardIINLoading and isInstallmentLoading boolean flags
Below, you can see a GIF showing how you can configure the secure-fields:

Step 5: Generate an OTT (one-time token)

With all user information in hand, start the payment by creating a One-Time Token (OTT) using the function secureFields.generateToken. As it is an asynchronous function, use try/catch to handle triggered errors. When you use a vaulted token with the SDK, all the fraud information from the providers you configured in your card routing is collected and attached to the one-time token; you can add installment information and a security code if the provider requires it.

Generate token parameters

You can also use secureFields.generateTokenWithInformation to receive any additional info the customer gives at checkout, such as installments or document type/number. Create a one-time token with error handling:
Do not pass checkoutSession to generateTokenWithInformation — set it only on the secureFields({ ... }) object. See Payment retry for details.

Step 6: Create the Payment

After receiving the one-time token, you can create the payment using one of the following options: Both options require you to provide the oneTimeToken and the checkoutSession. As creating the payment may raise errors, Yuno recommends you use a try/catch function here. Check payment status with yuno.mountStatusPayment. Example (createPayment and mountStatusPayment):

Payment creation flow

  1. Create Payment: Use the createPayment function with the one-time token and checkout session
  2. Check SDK Action: If sdk_action_required is true, call yuno.continuePayment() for additional customer actions
  3. Mount Status: If no SDK action is required, use yuno.mountStatusPayment() to display payment status

Mount status payment parameters

Complementary features

For styling, themes, form options, and additional configurations, see SDK customizations.