Lite SDK (Enrollment)
To enable Enrollment Lite functionality, the first step is to make sure to include the Yuno SDK file in your webpage before closing the <body>
. See an example below:
Step 1: Include the library in your project.
<script src="https://sdk-web.y.uno/v1/static/js/main.min.js"></script>
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. Check the Get your API credentials guide if you do not have your credentials. In the example below, the initialized class is attributed to the yuno
constant.
const yuno = Yuno.initialize(PUBLIC_API_KEY)
Step 3: Create a customer session and an enrollment payment method object
Before continuing with the process, you will need to 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, you will need to define which one is going to be available for your customer to enroll (in the case of secure fields, only CARD is available).
Verify
In case you want to verify cards (zero value authorization) before the enrollment , you can complete the 'verify' struct while defining the payment method object for the customer session.
Step 4: Mount the enrollment lite
The configuration and mounting are done in the same step for the Enrollment Lite. To do it, use the yuno.mountEnrollmentLite
function and provide the necessary parameters. The following table lists all parameters and their descriptions.
Parameter | Description |
---|---|
customerSession | Refers to the current payment's customer session.Example: 'e15648b0-fcd5-4799-a14c-cc463ae8a133' |
countryCode | This parameter determines the country for which the payment process is being configured. It should be set to one of the following country codes: CO, BR, CL, PE, EC, UR, or MX. |
language | Defines the language to be used in the payment forms. You can set it to one of the available language options: es (Spanish), en (English), or pt (Portuguese). |
showLoading | Control the visibility of the Yuno loading/spinner page during the payment process. |
onLoading | Required to receive notifications about server calls or loading events during the payment process. |
renderMode | Determine the mode in which the payment forms will be displayed. |
elementSelector | Specifies the HTML element where you want to mount the Yuno SDK. The SDK will be rendered within this element. |
card | Define specific settings for the credit card form. |
yunoEnrollmentStatus | Define a call back to run after the enrollment process ends. It is called with vaultedToken and status parameters. The status returned can be one of:▪️ CREATED ▪️ EXPIRED ▪️ REJECTED ▪️ READY_TO_ENROLL ▪️ ENROLL_IN_PROCESS ▪️ UNENROLL_IN_PROCESS ▪️ ️ENROLLED ▪️ DECLINED ▪️ CANCELED ▪️ ERROR ▪️ UNENROLLED |
issuersFormEnable | Enable the issuer's form (bank list). |
texts | Provide custom text for payment form buttons to match your application's language or branding. |
externalPaymentButtons | Configure external payment buttons like Paypal, Google Pay, or Apple Pay. |
The next code block presents an example of the Enrollment Lite parameter configuration and mounting.
yuno.mountEnrollmentLite({
customerSession: 'e15648b0-fcd5-4799-a14c-cc463ae8a133',
/**
* country can be one of CO, BR, CL, PE, EC, UR, MX
*/
countryCode: country,
/**
* Language can be one of es, en, pt
* Default is browser language
*/
language: 'es',
/**
* Hide or show the Yuno loading/spinner page
* Default is true
* @optional
*/
showLoading: true,
/**
* Required if you'd like to be informed if there is a server call
* @param { isLoading: boolean, type: 'DOCUMENT' | 'ONE_TIME_TOKEN' } data
* @optional
*/
onLoading: (args) => {
console.log(args);
}
/**
* Where the forms will be shown
* Default { type: 'modal' }
* @optional
*/
renderMode: {
/**
* Type can be one of `modal` or `element`
* Default modal
*/
type: 'modal',
/**
* Element where the form will be rendered
* Only needed if type is element
*/
elementSelector: '#form-element',
},
/**
* API card
* @optional
*/
card: {
/**
* Mode render card can be step or extends
* Default extends
*/
type: "extends",
/**
* You can edit card form styles
* Only you should write css, then it will be injected into the iframe
* Example
* `@import url('https://fonts.googleapis.com/css2?family=Luckiest+Guy&display=swap');
* .Yuno-front-side-card__name-label {
* color: red !important;
* font-family: 'Luckiest Guy' !important;
* }`
*/
styles: '',
/**
* Show checkbox for save/enroll card
* Default is false
*/
cardSaveEnable: false,
/**
* Custom texts in Card forms buttons
* Example:
*
* texts: {
* cardForm?: {
* enrollmentSubmitButton?: string;
* paymentSubmitButton?: string;
* }
* cardStepper?: {
* numberCardStep?: {
* nextButton?: string;
* },
* cardHolderNameStep?: {
* prevButton?: string;
* nextButton?: string;
* },
* expirationDateStep?: {
* prevButton?: string;
* nextButton?: string;
* },
* cvvStep?: {
* prevButton?: string;
* nextButton?: string;
* }
* }
* }
*/
texts: {},
/**
* Hide or show the document fields into card form
* Default is true
* @optional
*/
documentEnable: true,
},
/**
* Call back is called with the following object
* @param {{
* status: 'CREATED'
* | 'EXPIRED',
* | 'REJECTED',
* | 'READY_TO_ENROLL',
* | 'ENROLL_IN_PROCESS',
* | 'UNENROLL_IN_PROCESS',
* | 'ENROLLED',
* | 'DECLINED',
* | 'CANCELED',
* | 'ERROR',
* | 'UNENROLLED',
* vaultedToken: string,
* }}
*/
yunoEnrollmentStatus: ({ status, vaultedToken}) => {
console.log('status', { status, vaultedToken})
},
/**
* If this is called the SDK should be mounted again
* @param { error: 'CANCELED_BY_USER' | any }
* @optional
*/
yunoError: (error) => {
console.log('There was an error', error)
},
});
Complementary Features
In addition to the code examples provided, you can access the Demo App for a complete implementation of Yuno SDKs or go directly to the HTML and JavaScript checkout demos available on GitHub.
Yuno Web SDK provides additional services and configurations you can use to improve customers' experience:
- Loader: Control the use of the loader.
Parameter | Description |
---|---|
keepLoader | You can choose whether to hide or show the Yuno loading/spinner page. Enabling this option ensures that the loading component remains displayed until either the hideLoader() or continuePayment() function is called. The default value is true. |
yuno.startCheckout({
showLoading: true,
})
- Mode of form rendering
Parameter | Description |
---|---|
renderMode | Determine the mode in which the payment forms will be displayed. - type : can be one of modal or element .- elementSelector : Element where the form will be rendered* Only needed if type is element . |
yuno.startCheckout({
renderMode: {
type: 'modal',
elementSelector: '#form-element',
},
})
- Card form configurations
Parameter | Description |
---|---|
card | Define specific settings for the credit card form - type : step o extends - styles : You can edit card form styles. Only you should write css, then it will be injected into the iframe.- texts : Custom texts in Card forms buttons. |
yuno.startCheckout({
card: {
type: "extends",
styles: '',
cardSaveEnable: false,
texts: {}
},
})
Rendering modes: Below you find screenshots presenting the difference between the:
- Render modes
modal
andelements
for the payment method list. - Render modes
step
andextends
for the credit card form.
- You also can choose one of the render options for the card form,
step
andextends
:
- Text payment form buttons
Parameter | Description |
---|---|
texts | Provide custom text for payment form buttons to match your application's language or branding. |
yuno.startCheckout({
texts: {
customerForm?: {
submitButton?: string;
}
paymentOtp?: {
sendOtpButton?: string;
}
}
})
- SDK Customizations: Change the SDK appearance to match your brand.
Updated 13 days ago