Lite Web SDK v1.1 (Payment)

Follow this step-by-step guide to implement and enable Yuno's Lite Web SDK functionality in your application.

Step 1: Include the library in your project

Ensure the Yuno SDK file is included in your webpage before closing the </body> tag. Refer to the example below:

<script src="https://sdk-web.y.uno/v1.1/static/js/main.min.js"></script>

📘

TypeScript Support

If you are using TypeScript, Yuno provides a library that you can use to see all available methods available in the Yuno Web SDK.

Step 2: Initialize SDK 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.

Like the example below, use the initialized class that is attributed to the yunoconstant.

const yuno = await Yuno.initialize(PUBLIC_API_KEY)

Step 3: Start the checkout process

You will start the checkout process. To do it, use the yuno.startCheckout function and provide the necessary parameters.

The following table lists all required parameters and their descriptions. For optional parameters, go to Complementary Features.

ParameterDescription
checkoutSessionRefers to the current payment's checkout session. Example: '438413b7-4921-41e4-b8f3-28a5a0141638'
country_codeDetermines the country for which the payment process is being configured. See Country coverage for supported countries and their codes.
languageDefines the language for payment forms. Options: 'es' (Spanish), 'en' (English), 'pt' (Portuguese), 'fil' (Filipino), 'id' (Indonesian), 'ms' (Malay), 'th' (Thai).
onLoadingCallback function to receive notifications about server calls or loading events during the payment process.
showLoadingControls visibility of Yuno loading/spinner page during payment process. Default: true.
issuersFormEnableEnables the issuer's form. Default: true.
showPaymentStatusShows Yuno Payment Status page. Can be used when continuing a payment. Default: true.
card.isCreditCardProcessingOnlyOptional. When true, ensures all card transactions are processed as credit only. Useful in markets where cards can act as both credit and debit.
yuno.startCheckout({
  checkoutSession: '438413b7-4921-41e4-b8f3-28a5a0141638',
  country_code: "FR",
  language: 'fr',
  showLoading: true,
  issuersFormEnable: true,
  showPaymentStatus: true,
  onLoading: (args) => {
    console.log(args);
  },
  async yunoCreatePayment(oneTimeToken) {
    /**
     * The createPayment function calls the backend to create a payment in Yuno.
     * It uses the following endpoint https://docs.y.uno/reference/create-payment
     */
    await createPayment({ oneTimeToken, checkoutSession })
    yuno.continuePayment({ showPaymentStatus: true })
  },
})

📘

Transaction Types

Payments can be initiated by the customer (CIT) or by the merchant (MIT). You find more information about their characteristics in Stored credentials.

The step-by-step presented on this page refers to a customer-initiated transaction without the recurrence option. Typically, it's used in one-time online purchases, in-store purchases, ATM withdrawals, etc.

Step 4: Mount the SDK

Next, you have to mount the SDK, presenting the checkout based on the payment method selected by your customer. Remember, when using the Lite SDK, you're responsible for displaying the payment methods and capturing the customer's selection. Access Lite SDK (Payment) for additional information.

Use the yuno.mountCheckoutLite() function by selecting an HTML element and using a valid CSS selector (#, ., [data-*]) to display the checkout for the selected payment method.

yuno.mountCheckoutLite({
  /**
   * can be one of 'PAYPAL' | 'PIX' | 'APPLE_PAY' | 'GOOGLE_PAY' | CARD
   */
  paymentMethodType: PAYMENT_METHOD_TYPE,
  /**
   * Vaulted token related to payment method type.
   * Only if you already have it
   * @optional 
   */
  vaultedToken: VAULTED_TOKEN,
})

After mounting the SDK, the selected payment method flow will start automatically.

Step 5: Initiate the payment process

After the user has selected a payment method, remember to call yuno.startPayment() to initiate the payment flow. Below, you will find an example where yuno.startPayment() is called when the user clicks on button-pay:

const PayButton = document.querySelector('#button-pay')

PayButton.addEventListener('click', () => {
  yuno.startPayment()
})

Step 6: Get the OTT (one-time token)

Once the customer fills out the requested data in Yuno's payment forms, the SDK provides the one-time token. The configuration function yunoCreatePayment(oneTimeToken) is then triggered with the one-time token.

yunoCreatePayment(oneTimeToken)

You can also use tokenWithInformation to receive any additional info the customer gives at checkout, such as installments or document type/number.

yunoCreatePayment(oneTimeToken, tokenWithInformation)

📘

Loader Management

The merchant is responsible for managing the loader. Yuno provides a default loader option, but merchants may implement their own loader if preferred. In that case, they are responsible for making the necessary configurations.

Step 7: Create the Payment

Once you have completed the steps described before, you will be able to create a payment. The back-to-back payment creation must be carried out using the Create Payment endpoint. The merchant should call their backend to create the payment within Yuno, using the one-time token and the checkout session.

📘

Continue Payment Method

Yuno recommends integrating the continuePayment method of the SDK after the payment is created. This is because certain asynchronous payment methods require additional action from the customer to complete the payment. The API will inform you of this scenario via the sdk_action_required field of the response, which will be returned as true. The yuno.continuePayment() function will display additional screens to customers, where they can carry out the necessary actions to complete the payment. If sdk_action_required is false, this step is not necessary.

Complementary features

Yuno Web SDK provides additional services and configurations you can use to improve customers' experience:

Loader

Control the use of the loader.

ParameterDescription
showLoadingYou can 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,
})

Form of the issuer

ParameterDescription
issuersFormEnableThrough this parameter, you can configure the SDK to enable the issuer's form (bank list).
yuno.startCheckout({
  issuersFormEnable: true,
})

Mode of form rendering

📘

Enhanced Render Mode in Lite SDK v2.0.0

The enhanced Lite SDK v2.0 provides advanced render mode capabilities that embed Yuno's checkout forms directly within your interface. This gives you complete control over the checkout journey, including loading, status, and payment input screens, with full visual customization and seamless UX integration.

ParameterDescription
renderModeThis optional parameter determines how payment forms are displayed:<br>• type: Either 'modal' or 'element'<br>• elementSelector: Required if type is 'element'. Specifies where to render the form.
elementSelectorRequired when type is 'element'. Specifies where to mount the Yuno SDK:<br>• String (Deprecated): ID or selector for mounting the SDK<br>• Object: Specify elements for APM and action forms:<br> - apmForm: Element to display the APM<br> - actionForm: Element for the Continue Payment button, which opens a modal for completing provider-specific payment steps
yuno.startCheckout({
  renderMode: 

 

Card form configurations

ParameterDescription
cardDefine specific settings for the credit card form:<br><br>• type: step o extends<br>• styles: You can edit card form styles. Only you should write css, then it will be injected into the iframe.<br>• cardSaveEnable: Show checkbox for save/enroll card. The default value is false.<br>• texts: Custom texts in the Card forms buttons.
yuno.startCheckout({
  card: {
    type: "extends",
    styles: '',
    cardSaveEnable: false,
    texts: {}
  },
})

Save card for future payments

In addition, you can display a checkbox for saving or enrolling cards using the cardSaveEnable: true. Below are examples of the checkbox for both card form renders.

Rendering modes

Below you find screenshots presenting the difference between the following:

  • Render modes modal and elements for the payment method list
  • Render modes step and extends for the credit card form

You also can choose one of the render options for the card form, step and extends:

Text payment form buttons

ParameterDescription
textsProvide custom text for payment form buttons to match your application's language or branding.
yuno.startCheckout({
  texts: {
    customerForm?: {
      submitButton?: string;
    }
    paymentOtp?: {
      sendOtpButton?: string;
    }
  }
})

Persist credit card form to retry payments

If a transaction is rejected, you can use the credit card form to retry a payment after the customer has entered the credit card details. To do that, you will need to:

  1. Add the following parameter while initializing the SDK to persist the credit card form after the one-time use token is created:
    yuno.startCheckout({
      automaticallyUnmount: false,
    })
  2. In case the transaction is rejected, you will need to:
    1. Execute the method yuno.notifyError() to delete the previously entered CVV for the first transaction.
    2. Create a new checkout session and update the SDK with the new one by executing yuno.updateCheckoutSession(checkoutsession)
  3. Continue with the new checkout and one-time use token with the regular payment flow.

Hide Pay button

You can hide the Pay button when presenting the Card or Customer Data Forms. To control this feature, you'll set showPayButton to false when starting the checkout with the startCheckout function. The code block below presents an example of how to hide the payment button:

yuno.startCheckout({
  /**
   * Hide (false) or show (true) the customer or card form pay button
   * @default true
   * @optional
   */
  showPayButton: false,
})

The following images present examples of the Customer Data Form with and without the Pay button:

The following images present examples of the Card Form with and without the Pay button:

If you hide the Pay button, you will need to start the one-time token creation through your code. To create the one-time token and continue the payment in your backend, call the submitOneTimeTokenForm function. The code block below presents how to use the submitOneTimeTokenForm function.

/**
 * This function triggers the same functionality that is called when the customer clicks on the pay form button. This approach does not work if you choosed step for rendering mode.
 */
yuno.submitOneTimeTokenForm()

What's next?

Learn about the additional configurations from the Lite SDK accessing Complementary Features. You can also access other functions available on the Yuno Web SDK: