TumiPay Cards JS
JavaScript/TypeScript SDK for secure credit and debit card tokenization.Installation
Quick Start
Standard Response
All methods return the same envelope:Constructor
initialize({ merchantId })
Fetches merchant configuration from the TumiPay server and prepares the SDK for operation.
Must be called before generateSubscriptionToken and getBinInfo.
Response
Error Codes
| Code | Description | How to Fix |
|---|---|---|
INVALID_MERCHANT_ID | merchantId is empty or not provided | Ensure a valid merchantId is passed |
APP_CONFIGURATION_ERROR | Failed to retrieve configuration from server | Check connectivity and that the merchantId exists in TumiPay |
SDK_INIT_ERROR | Generic initialization error | Check the error message for more details |
validateCard(request)
Validates card data locally — no network calls. Does not require initialization.
Parameters
| Field | Type | Required | Description |
|---|---|---|---|
cardNumber | string | ✅ | Card number (13–19 digits) |
cardHolderName | string | ✅ | Cardholder name (min. 2 characters) |
expirationMonth | string | ✅ | Expiry month: "01"–"12" |
expirationYear | string | ✅ | Expiry year: "YY" or "YYYY" |
cvv | string | ✅ | CVV: 3 digits (4 for Amex) |
Response — success
Response — validation error
Supported Brands
| Brand | Pattern |
|---|---|
visa | Starts with 4, 13–16 digits |
mastercard | Starts with 51–55, 16 digits |
amex | Starts with 34 or 37, 15 digits |
discover | Starts with 6011 or 65, 16 digits |
diners | Starts with 300–305, 36 or 38, 14 digits |
jcb | Starts with 2131, 1800 or 35, 15–16 digits |
Error Codes
| Code | Field | Description | How to Fix |
|---|---|---|---|
CARD_NUMBER_EMPTY | cardNumber | Card number is empty | Provide the card number |
CARD_NUMBER_INVALID_FORMAT | cardNumber | Non-numeric characters found | Use digits only, no spaces or dashes |
CARD_NUMBER_INVALID_LENGTH | cardNumber | Length outside 13–19 range | Verify the full card number is entered |
CARD_NUMBER_LUHN_FAILED | cardNumber | Fails Luhn algorithm | The card number is invalid; double-check it |
CARDHOLDER_NAME_EMPTY | cardHolderName | Cardholder name is empty | Provide the name as shown on the card |
CARDHOLDER_NAME_TOO_SHORT | cardHolderName | Name shorter than 2 characters | Enter the cardholder’s full name |
EXPIRY_MONTH_INVALID | expirationMonth | Month outside 01–12 | Use format "01" to "12" |
EXPIRY_YEAR_INVALID | expirationYear | Year not provided | Provide the expiration year |
CARD_EXPIRED | expiration | Card is expired | Use a card with a valid expiration date |
CVV_EMPTY | cvv | CVV is empty | Provide the security code |
CVV_INVALID_LENGTH | cvv | CVV has wrong length | Use 3 digits (4 for American Express) |
BRAND_NOT_ALLOWED | cardNumber | Unsupported card brand | Use Visa, Mastercard, Amex, Discover, Diners or JCB |
generateSubscriptionToken(card)
Generates a subscription token via Kushki. Requires prior initialization.
Kushki credentials are sourced automatically from the context loaded in initialize().
Parameters
| Field | Type | Required | Description |
|---|---|---|---|
cardNumber | string | ✅ | Card number |
cardHolderName | string | ✅ | Cardholder name |
expirationMonth | string | ✅ | Expiry month |
expirationYear | string | ✅ | Expiry year |
cvv | string | ✅ | CVV |
documentNumber | string | ➖ | Document number (optional, required in some markets) |
email | string | ➖ | Email address (optional) |
Response
Error Codes
| Code | Description | How to Fix |
|---|---|---|
SDK_NOT_INITIALIZED | initialize() was not called first | Call sdk.initialize({ merchantId }) before this method |
MISSING_PUBLIC_KEY | public_key missing in configuration response | Verify the merchant has a payment provider configured |
MISSING_CURRENCY | currency not set in constructor | Pass currency when creating the SDK instance |
getBinInfo(bin)
Fetches bank, brand, and card type from Kushki. Requires prior initialization.
Parameters
| Field | Type | Required | Description |
|---|---|---|---|
bin | string | ✅ | First 6 digits of the card number (or full number) |
Response
Error Codes
| Code | Description | How to Fix |
|---|---|---|
SDK_NOT_INITIALIZED | initialize() was not called first | Call sdk.initialize({ merchantId }) before this method |
INVALID_BIN | BIN has fewer than 6 digits | Provide at least the first 6 digits of the card number |