> For the complete documentation index, see [llms.txt](https://apidocs.onekeypayments.com/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://apidocs.onekeypayments.com/deposits-tools/cards-sdk/without-user-interface.md).

# Without User Interface

## Getting started

### Installation

#### Load D24 as a npm module

Install the D24.js from the npm public registry.

```bash
npm install @d24/sdk-minimal
```

or

#### Manually load the D24.js script

Add the D24.js module as a script in the of your app HTML

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

### How to use

#### Instantiation

First of all, we must instantiate the SDK.

Keep in mind that the SDK can be instantiated only once, and it is a requirement to be able to use all its methods.

In order to instantiate the SDK we need to specify the public key and the environment.

* npm

```javascript

import SDK from '@d24/sdk-minimal';

new SDK('as1i2nxal12bvd', {environment: 'stg'});
```

* umd&#x20;

```javascript
new window.D24.SDK('as1i2nxal12bvd', {environment: 'stg'});
```

**constructor(publicKey, options)**

**Parameters**

<table><thead><tr><th width="213">Parameter</th><th width="176">Type</th><th>Description</th><th>Required</th><th>Possible values</th></tr></thead><tbody><tr><td>publicKey</td><td>string</td><td>Public key provided by us</td><td>true</td><td>-</td></tr><tr><td>options</td><td>object</td><td>Options</td><td>true</td><td>-</td></tr><tr><td>options.environment</td><td>string</td><td>Environment</td><td>true</td><td><code>stg</code>, <code>production</code></td></tr></tbody></table>

#### Tokenization a credit card

Once we instantiate the SDK, we can tokenize a card, said token will be used later to send it to the backend and generate the payment through an endpoint.

* npm

```javascript
import {generateToken} from '@d24/sdk-minimal';

const creditCard = {
    number: '4509953566233704',
    holder: 'Juan Perez',
    cvv: '123',
    expirationMonth: '11',
    expirationYear: '25',
}

const response = await generateToken({card: creditCard});
const token = response.token;
```

* umd

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

const response = await window.D24.generateToken({card: creditCard});
const token = response.token;
```

## API

#### Possible errors

| Error                                                   | Explanation                                                                                                |
| ------------------------------------------------------- | ---------------------------------------------------------------------------------------------------------- |
| SDK was already instantiate.                            | The SDK has already been instantiated and you are trying to instantiate it again                           |
| The environment \[config.environment] is not supported. | The environment you passed to the constructor is not valid, remember that it only accepts "test" or "prod" |

### generateToken({card}): Promise<{token: string}>

This method validates that the card data is correct and generates a token. Although it has validations that occur at the frontend level, it uses a D24 endpoint to be able to generate the token which executes additional validations.

To validate the data structure, the [joi](https://joi.dev/api/?v=17.9.1#errors) library is used, therefore the errors returned at the frontend level are generated with said library.

#### Parameters

<table><thead><tr><th width="234">Parameter</th><th>Type</th><th width="278">Description</th><th>Required</th><th>Example</th></tr></thead><tbody><tr><td>card</td><td>object</td><td>Credit card values</td><td>true</td><td>-</td></tr><tr><td>card.number</td><td>string</td><td>Credit card number</td><td>true</td><td>4509953566233704</td></tr><tr><td>card.holder</td><td>string</td><td>Credit card holder</td><td>true</td><td>Juan Perez</td></tr><tr><td>card.cvv</td><td>string</td><td>Credit card security code. Must be 3 digits, except for AMEX which are 4</td><td>true</td><td>123, 1234</td></tr><tr><td>card.expirationMonth</td><td>string</td><td>Credit card expiration month. Must be 2 digits</td><td>true</td><td>11</td></tr><tr><td>card.expirationYear</td><td>string</td><td>Credit card expiration year. Must be 2 digits</td><td>true</td><td>25</td></tr></tbody></table>

#### Possible errors

| Error                                                          | Explanation                                                            |
| -------------------------------------------------------------- | ---------------------------------------------------------------------- |
| You must instantiate D24CreditCardSDK before using SDK methods | You executed the method without having previously instantiated the SDK |

## Deposit Creation

To learn who to use the Cards SDK Without User Interface within the Deposit Creation, please visit de page below of our Knowledge Base :sunglasses:

{% content-ref url="/pages/2YOaKheDYzkTqbaiykan" %}
[Without User Interface](/knowledge-base/deposits-with-cards-sdk/without-user-interface.md)
{% endcontent-ref %}
