# Lite SDK (Enrollment Web)

<Warning>

**Orientation: Choosing Your Integration Flow**, before you begin, please review the [Official Integration Flow](/docs/sdks/overview/understanding-flows).
- **Standard Flow ([Full Checkout](/docs/sdks/full-checkout/web-payments))**: Recommended for most merchants. WHITELABEL handles the UI, security, and automatic updates for payment methods.  
- **Custom Flow (This SDK)**: Use this only if you require full control over the UX. **Note**: You will be responsible for manually handling payment statuses, 3DS transitions, and fraud routing data collection.
</Warning>
Follow this step-by-step guide to implement and enable WHITELABEL's Lite Web SDK enrollment capability in your app.

## Step 1: Include the library in your project

Before proceeding with the Lite SDK implementation, see the [Quickstart Guide](/docs/sdks/overview/quickstart) 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

Choose the integration method that best suits your development workflow and technical requirements. After completing the SDK integration, you can proceed with the following steps to implement the lite enrollment capability.

<Note>
**TypeScript Library**

If you are using TypeScript, WHITELABEL offers a [library](https://www.npmjs.com/package/@yuno-payments/sdk-web-types) that provides access to all available methods in the WHITELABEL Web SDK.
</Note>

## Step 2: Initialize SDK with the public key

Initialize the WHITELABEL SDK in your JavaScript application by providing a valid `PUBLIC_API_KEY`:

```javascript
const whitelabel = await Yuno.initialize(PUBLIC_API_KEY);
```

<Note>
**Credentials**

See the credentials page for more information: [/reference/getting-started/authentication](/reference/getting-started/authentication)
</Note>

## Step 3: Create a customer session

To start the enrollment process, you need to provide the `customer_session`. First, you need to create a customer. Use the [Create Customer](/reference/customers/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](/reference/customer-sessions-enrollment/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:

```javascript
await whitelabel.mountEnrollment({
  customerSession: "438413b7-4921-41e4-b8f3-28a5a0141638",
  elementSelector: "#root",
  countryCode: "US",
  language: "en-US",
  showLoading: true,
  issuersFormEnable: true,
  onLoading: (args) => console.log(args),
  card: {
    type: "extends",
    styles: "",
    texts: {},
  },
  texts: {},
  yunoEnrollmentStatus(data) {
    console.log("Enrollment status:", data);
  },
  yunoError(error, data) {
    console.error("An error occurred:", error);
    await whitelabel.hideLoader();
  },
});
```

When using `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](/reference/customer-sessions-enrollment/create-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 WHITELABEL 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 (for example, 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.                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                           |
| `onChange`                        | Reports whether the enrollment form is complete. Receives `{ form: { isValid } }`. Available since v1.10.11. |

<Note>
**Status Values**

Common status values include `ENROLLED`, `DECLINED`, `CANCELED`, and `ERROR`.
</Note>

## PayPal enrollment with element render mode

<Note>
Available from Web SDK **1.10.13**.
</Note>

By default, `mountEnrollmentLite` opens the WHITELABEL modal for PayPal enrollment. The shopper clicks your PayPal button, sees the modal, and has to click PayPal a second time. With element render mode the PayPal button renders directly on your page, and the shopper completes the enrollment in one click.

### How it works

Add an empty container to your page, then pass `renderMode: { type: 'element', elementSelector }` to `mountEnrollmentLite`. The SDK renders the real PayPal button inside that container and shows a loading skeleton until PayPal finishes loading.

The PayPal button replaces your own button — do not place your button in front of it. If you do not pass `renderMode`, the modal behavior stays exactly as before.

### Integration steps

1. Remove your existing PayPal button.
2. Add an empty `<div>` where the PayPal button should appear.
3. Pass `renderMode` with `type: 'element'` and an `elementSelector` pointing at that `<div>`.

```html
<div id="paypal-enrollment"></div>
```

```javascript
await whitelabel.mountEnrollmentLite({
  customerSession: "438413b7-4921-41e4-b8f3-28a5a0141638",
  countryCode: "US",
  language: "en-US",
  renderMode: {
    type: "element",
    elementSelector: "#paypal-enrollment",
  },
  yunoEnrollmentStatus(data) {
    console.log("Enrollment status:", data);
  },
  yunoError(error, data) {
    console.error("An error occurred:", error);
  },
});
```

The button takes 100% of the container width unless you set `width`.

### Customizing the PayPal button

Optional. Pass `externalButtons.paypal` to `mountEnrollmentLite` to style the button, using the same properties as the [PayPal express button](/docs/sdks/resources/references/web#paypal) in checkout. The defaults differ from checkout, so they are listed in full below.

```javascript
await whitelabel.mountEnrollmentLite({
  customerSession: "438413b7-4921-41e4-b8f3-28a5a0141638",
  countryCode: "US",
  language: "en-US",
  renderMode: {
    type: "element",
    elementSelector: "#paypal-enrollment",
  },
  externalButtons: {
    paypal: {
      color: "blue",
      shape: "pill",
      label: "paypal",
      height: 48,
      width: 300,
      locale: "en_US",
    },
  },
  // ... rest of config
});
```

<div className="nowrap-col1-table dense-table">

| Property | Type | Default | Description |
| -------- | ---- | ------- | ----------- |
| `color` | `'gold'` \| `'blue'` \| `'silver'` \| `'white'` \| `'black'` | PayPal decides | Button background color |
| `shape` | `'rect'` \| `'pill'` \| `'sharp'` | `'rect'` | Button shape |
| `label` | `'paypal'` \| `'checkout'` \| `'buynow'` \| `'pay'` \| `'installment'` | PayPal decides | Button label text |
| `height` | `number` | `48` | Button height in px (valid range: 25–55) |
| `width` | `number` | 100% of the container | Wrapper width in px |
| `locale` | `string` | PayPal decides from the shopper's browser | Button language, in PayPal's `language_COUNTRY` format (for example `en_US`, `es_ES`, `pt_BR`). See PayPal's [supported locales](https://developer.paypal.com/sdk/js/configuration/#locale). |

</div>

### Result

- The shopper clicks the PayPal button, approves in the PayPal popup, and the SDK completes the enrollment.
- `yunoEnrollmentStatus` receives the `vaultedToken` with status `ENROLLED`.
- If the shopper closes the popup, `yunoError` receives `CANCELED_BY_USER`.

## Step 5: Initiate the enrollment (Required)

After mounting the SDK using `await whitelabel.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.

<Note>
**Demo App**

In addition to the code examples provided, you can access the [Demo App](https://github.com/yuno-payments/yuno-sdk-web) for a complete implementation of WHITELABEL SDKs (clone from the repository).
</Note>

## Error handling

Handle errors returned by the SDK in your app, such as failed enrollment or validation errors. For HTTP status and response codes, see [Status and response codes](/reference/getting-started/response-codes) in the API reference.

## Stay updated

Visit the [changelog](/changelog/web#v1-6-0) for the latest SDK updates and version history.