Without User Interface

Learn how to use our SDK in Javascript to allow integrations with our Deposits APIs

Getting started

Installation

Load D24 as a npm module

Install the D24.js from the npm public registry.

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

<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


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

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

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

constructor(publicKey, options)

Parameters

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

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

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

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 library is used, therefore the errors returned at the frontend level are generated with said library.

Parameters

Possible errors

Deposit Creation

Last updated