SDKs
Javascript
This section describes the installation and usage of the Thanx Javascript SDK.
Thanx Card Encryption
This library contains utilities for encrypting credit card numbers. It relies on node-forge for the encryption primitives. This package is available via a private npm package located at https://www.npmjs.com/package/@thanx/encrypt-card.
Installation
Add @thanx/encrypt-card to your projects dependencies. Since this package is private, you’ll need to be authenticated to the thanx npm org.
yarn add @thanx/encrypt-card
or if you’re not using yarn
npm install @thanx/encrypt-card
Usage
The main entrypoint is encryptCard, which returns a string suitable for using in the encrypted_pan field passed to the thanx api.
import encryptCard from 'encrypt-card'
const publicKeyPem = // Public key returned by the thanx api
// Amex
const encryptedAmex = encryptCard('1111222233334444', {
type: 'amex',
publicKey: publicKeyPem,
})
// Mastercard
const encryptedMastercard = encryptCard('1111222233334444', {
type: 'mastercard',
publicKey: publicKeyPem,
})
// Visa
const encryptedVisa = encryptCard(number, {
type: 'visa',
publicKey: publicKeyPem,
uid: 'fakeuid', // User identifier provided by the thanx api
})