> ## Documentation Index
> Fetch the complete documentation index at: https://docs.pandablue.com/llms.txt
> Use this file to discover all available pages before exploring further.

# Lite

> [!NOTE]
>
> The SDK is published as `@d24/sdk` / `@d24/sdk-minimal` and exposes `window.D24`. This is expected: use it as shown with your Pandablue credentials.

## **Installation**

**NPM**

```bash theme={null}
npm install @d24/sdk-minimal
```

**HTML Script Tag**

```html theme={null}
<script type="module" src="https://d24sdk.s3.amazonaws.com/releases/d24-minimal-1.0.19.es.js"></script>
```

> [!TIP]
>
> **Ensure to install the latest version in this** [**link**](https://www.npmjs.com/package/@d24/sdk-minimal)**!**

## **Constructor**

Initializes the SDK. This must be called before any other methods.

`new SDK(publicKey, options)`

**Parameters**

<table><thead><tr><th>Parameter</th><th>Type</th><th>Description</th><th>Required</th><th>Possible Values</th></tr></thead><tbody><tr><td>`publicKey`</td><td>`string`</td><td>Your public API key provided by Pandablue.</td><td>Yes</td><td>\
</td></tr><tr><td>`options`</td><td>`object`</td><td>Configuration options for the SDK.</td><td>Yes</td><td>\
</td></tr><tr><td>`options.environment`</td><td>`string`</td><td>The environment to use.</td><td>Yes</td><td>`'stg'`, `'production'`</td></tr></tbody></table>

### **Usage**

```javascript theme={null}
// NPM/ESM
import SDK from '@d24/sdk-minimal';
new SDK('as1i2nxal12bvd', { environment: 'stg' });

// UMD/Script Tag
new window.D24.SDK('as1i2nxal12bvd', { environment: 'stg' });

```

#### **Errors**

| Error Message | Reason |
| - | - |
| `SDK was already instantiate.` | The SDK constructor was called more than once. |
| `The environment [environment] is not supported.` | An invalid value was passed for `options.environment`. |

## **Methods**

**`generateToken({ card })`**

Validates credit card details and exchanges them for a secure, single-use token. This is an asynchronous method.

**Returns:** `Promise<{token: string}>` - A promise that resolves to an object containing the token.

### **Parameters**

<table><thead><tr><th>Parameter</th><th>Type</th><th>Description</th><th>Required</th></tr></thead><tbody><tr><td>`card`</td><td>`object`</td><td>An object containing the credit card details.</td><td>Yes</td></tr><tr><td>`card.number`</td><td>`string`</td><td>The full credit card number.</td><td>Yes</td></tr><tr><td>`card.holder`</td><td>`string`</td><td>The full name of the cardholder.</td><td>Yes</td></tr><tr><td>`card.cvv`</td><td>`string`</td><td>The 3-digit (or 4-digit for Amex) security code.</td><td>Yes</td></tr><tr><td>`card.expirationMonth`</td><td>`string`</td><td>The 2-digit expiration month (e.g., "09").</td><td>Yes</td></tr><tr><td>`card.expirationYear`</td><td>`string`</td><td>The 2-digit expiration year (e.g., "25").</td><td>Yes</td></tr></tbody></table>

### **Usage**

```javascript theme={null}
const cardDetails = {
  number: '4509953566233704',
  holder: 'Juan Perez',
  cvv: '123',
  expirationMonth: '11',
  expirationYear: '25',
};

try {
  const response = await window.D24.generateToken({ card: cardDetails });
  const token = response.token;
  // Send token to your server
} catch (error) {
  // Handle validation errors from the Joi library or API errors.
  console.error(error);
}

```

**Errors**

| Error Message | Reason |
| - | - |
| `You must instantiate D24CreditCardSDK before using SDK methods` | `generateToken` was called before the SDK was initialized with `new SDK()`. |
| (Joi Validation Error) | The `card` object failed validation. The error message will describe the specific field that is invalid. |


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.