Step 1: Include the library in your project
Before proceeding with the Lite SDK 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
TypeScript LibraryIf you are using TypeScript, Yuno offers a library that provides access to all available methods in the Yuno Web SDK.
Step 2: Initialize SDK with the public key
Initialize the Yuno SDK in your JavaScript application by providing a validPUBLIC_API_KEY:
CredentialsSee the credentials page for more information: /reference/getting-started/authentication
Step 3: Create a customer session
To start the enrollment process, you need to provide thecustomer_session. First, you need to create a customer. Use the Create Customer endpoint to create new customers. In the response, you will receive the customer id, which you use to create the customer session.
After creating the customer, you can create the customer session. Use the customer id and the Create Customer Session endpoint. The customer_session will be provided in the response. You need a new customer_session every time you enroll in a new payment method.
Step 4: Start the enrollment process
Use the configuration below to provide a lite and user-friendly enrollment experience for your customers:mountEnrollment, specify the callbacks to handle enrollment. You can also customize the interface using the texts objects.
Parameters
Configure the lite enrollment with the following options:| Parameter | Description |
|---|---|
customerSession | Refers to the current enrollment’s customer session. |
elementSelector | The HTML element where the enrollment form will be rendered. |
countryCode | This parameter specifies the country code for which the enrollment is being set up. |
language | Language for enrollment forms. |
showLoading | Controls the visibility of the Yuno loading/spinner page during the enrollment process. |
onLoading | Required to receive notifications about server calls or loading events during the enrollment process. |
issuersFormEnable | Enables the issuer’s form (e.g., a list of banks). |
card | Defines the configuration for the card form. |
texts | Allows you to set custom button texts. |
yunoEnrollmentStatus | Callback invoked when the enrollment process finishes. Receives { vaultedToken, status }. |
yunoError | Callback invoked when there is an error in the enrollment process. |
Status ValuesCommon status values include
ENROLLED, DECLINED, CANCELED, and ERROR.Step 5: Initiate the enrollment (Required)
After mounting the SDK usingawait yuno.mountEnrollment(), the form will be displayed in the specified element. The user can then proceed with entering their payment method details to complete the enrollment.
Demo AppIn addition to the code examples provided, you can access the Demo App for a complete implementation of Yuno SDKs (clone from the repository).