npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2026 – Pkg Stats / Ryan Hefner

tumipay-cards-js

v3.0.2

Published

TypeScript SDK for TumiPay card payment processing

Readme

tumipay-cards-js

SDK JavaScript/TypeScript para tokenización segura de tarjetas de crédito y débito con TumiPay.

Instalación

npm install tumipay-cards-js

Inicio Rápido

import { TumiPayCardPaymentSDK } from 'tumipay-cards-js';

// 1. Crear instancia
const sdk = new TumiPayCardPaymentSDK({
  environment: 'staging',   // "staging" | "production"
  currency: 'COP',
});

// 2. Inicializar con las credenciales de TumiPay
await sdk.initialize({
  merchantId: 'tu-merchant-id',
  tokenTop: 'tu-token-top',
  basicAuthUser: 'tu-usuario',
  basicAuthPass: 'tu-contraseña'
});

// 3. Validar tarjeta (no requiere inicialización)
const validation = sdk.validateCard({
  cardNumber: '4111111111111111',
  cardHolderName: 'Juan Perez',
  expirationMonth: '12',
  expirationYear: '29',
  cvv: '123',
});

if (!validation.status) {
  console.error(validation.errors);
  return;
}

// 4. Autenticar tarjeta — el resultado incluye el token de suscripción
const auth = await sdk.authenticateCard({
  cardNumber: '4111111111111111',
  cardHolderName: 'Juan Perez',
  expirationMonth: '12',
  expirationYear: '29',
  cvv: '123',
}, {
  callbackUrl: 'https://tuapp.com/3ds-callback', // Requerido en producción
});

// 4a. Producción — siempre authType === '3ds' y llega redirectUrl
if (auth.data?.authType === '3ds' && auth.data.redirectUrl) {
  const token = auth.data.token; // usar para crear la suscripción
  window.location.href = auth.data.redirectUrl;

// 4b. Staging con 3DS modal — token disponible directo en la respuesta
} else if (auth.data?.authType === '3ds' && !auth.data.redirectUrl) {
  const token = auth.data.token;
  console.log(token);

// 4c. Staging sin autenticación adicional — solo puede ocurrir en staging
} else if (auth.data?.authType === 'none') {
  const token = auth.data.token;
  console.log(token);
}

API Reference

new TumiPayCardPaymentSDK(config)

Crea una instancia del SDK. No realiza llamadas a la red.

interface SdkConfig {
  environment: 'staging' | 'production';
  currency: string;  // Ej: "COP", "USD"
}

sdk.initialize({ merchantId, tokenTop, basicAuthUser, basicAuthPass })

Llama a /api/configuration y carga las credenciales internas del SDK.

Debe llamarse antes de authenticateCard y getBinInfo.

const result = await sdk.initialize({
  merchantId: 'tu-merchant-id',
  tokenTop: 'tu-token-top',
  basicAuthUser: 'tu-usuario',
  basicAuthPass: 'tu-contraseña'
});

Response:

{
  "initialized": true,
  "code": "SUCCESS",
  "status": true,
  "message": "Configuración obtenida correctamente",
  "data": {
    "payment_provider": {
      "external_merchant_id": "...",
      "public_key": "...",
      "environment": "uat"
    },
    "otp_config": {
      "id_credentials": "...",
      "public_key": "...",
      "private_key": "..."
    }
  }
}

sdk.validateCard(request)

Valida los datos de tarjeta localmente (sin llamadas a la red). No requiere inicialización.

sdk.validateCard({
  cardNumber: '4111111111111111',
  cardHolderName: 'Juan Perez',
  expirationMonth: '12',
  expirationYear: '29',
  cvv: '123',
});

Marcas soportadas: visa, mastercard, amex, discover, diners, jcb


sdk.authenticateCard(card, options?)

Autentica la tarjeta con el banco a través de Kushki (3DS). Requiere inicialización previa.

El comportamiento final depende del ambiente:

  • Producción → siempre retorna authType: "3ds", incluso si el banco indica que no se requiere autenticación. La respuesta incluye data.token y data.redirectUrl. callbackUrl requerida (HTTPS).
  • Staging con 3DS → challenge modal inline → data.token disponible directo.
  • Staging sin 3DS → retorna authType: "none"data.token disponible directo.
const auth = await sdk.authenticateCard(card, {
  callbackUrl: 'https://tuapp.com/3ds-callback',  // Requerido en producción (HTTPS)
  documentNumber: '1234567890',                    // Opcional
  email: '[email protected]',                     // Opcional
});

Response (authType "none" — solo staging):

{
  "code": "SUCCESS",
  "status": true,
  "message": "Autenticación no requerida por el banco",
  "data": {
    "authType": "none",
    "token": "406aea95..."
  }
}

Response (authType "3ds" — staging):

{
  "code": "SUCCESS",
  "status": true,
  "message": "Autenticación 3DS completada correctamente",
  "data": {
    "authType": "3ds",
    "token": "406aea95..."
  }
}

Response (authType "3ds" producción):

{
  "code": "SUCCESS",
  "status": true,
  "message": "Autenticación 3DS requerida",
  "data": {
    "authType": "3ds",
    "token": "406aea95...",
    "redirectUrl": "https://kushki-3ds.com/..."
  }
}

sdk.getBinInfo(bin)

Consulta información del BIN en Kushki. Requiere inicialización previa.

const result = await sdk.getBinInfo('411111');

sdk.isInitialized() / sdk.getConfig()

sdk.isInitialized(); // boolean
sdk.getConfig();     // { environment, currency }

Flujo Completo con Autenticación

import {
  TumiPayCardPaymentSDK,
  type AuthenticateCardResult,
} from 'tumipay-cards-js';

const sdk = new TumiPayCardPaymentSDK({ environment: 'staging', currency: 'COP' });
await sdk.initialize({
  merchantId: 'tu-merchant-id',
  tokenTop: 'tu-token-top',
  basicAuthUser: 'tu-usuario',
  basicAuthPass: 'tu-contraseña'
});

const card = {
  cardNumber: '4111111111111111', cardHolderName: 'Juan Perez',
  expirationMonth: '12', expirationYear: '29', cvv: '123',
};

// Paso 1 — Validar localmente
const validation = sdk.validateCard(card);
if (!validation.status) { /* mostrar errores */ return; }

// Paso 2 — Autenticar (obtiene el token de suscripción directamente)
const auth = await sdk.authenticateCard(card, {
  callbackUrl: 'https://tuapp.com/3ds',  // Requerido en producción para 3DS redirect
});

let token: string | undefined;

if (auth.data?.authType === '3ds' && auth.data.redirectUrl) {
  // Producción — este es el único flujo posible en producción
  token = auth.data.token;
  window.location.href = auth.data.redirectUrl;

} else if (auth.data?.authType === '3ds' && !auth.data.redirectUrl) {
  // Staging — 3DS modal completado inline, token disponible
  token = auth.data.token;

} else if (auth.data?.authType === 'none') {
  // Solo en staging — este flujo nunca ocurre en producción
  token = auth.data.token;
}

// Enviar `token` al backend
if (token) {
  await fetch('/api/suscripcion', {
    method: 'POST',
    body: JSON.stringify({ token, merchantId: 'tu-merchant-id' }),
  });
}

Tipos exportados

import type {
  SdkConfig,
  SdkInitOptions,
  SdkInitializationResult,
  ValidateCardRequest,
  ValidateCardResult,
  ValidateCardError,
  ValidateCardSuccessData,
  GetBinInfoResult,
  AuthType,
  AuthenticateCardOptions,
  AuthenticateCardResult,
  AuthenticateCardResultData,
  CardBrand,
  BinInfoResult,
  SdkEnvironment,
} from 'tumipay-cards-js';

Licencia

MIT