TumiPay Card Payment SDK
JavaScript/TypeScript SDK for secure credit and debit card tokenization.Installation
Quick Start
SDK Methods
1. initialize(options: InitializeOptions): Promise<void>
Initializes the SDK with the merchant ID. This method automatically retrieves all necessary configurations from the server.
Request
| Field | Type | Length | Required | Description |
|---|---|---|---|---|
merchantId | string | - | ✅ Yes | Unique merchant identifier (UUID format) |
Response
Error Codes
| Code | Description | Solution |
|---|---|---|
MERCHANT_NOT_FOUND | Merchant ID does not exist | Verify the provided ID |
INVALID_MERCHANT_ID | Invalid merchant ID format | Must be a valid UUID |
MERCHANT_INACTIVE | Merchant disabled or inactive | Contact support |
CONFIG_RETRIEVAL_ERROR | Error retrieving configuration from server | Check connectivity |
MISSING_CREDENTIALS | Missing credentials in server configuration | Contact support |
NETWORK_ERROR | Connection error with server | Check your internet connection |
SDK_ALREADY_INITIALIZED | SDK was already initialized | No need to initialize again |
2. validateCard(card: CardData): Promise<ResultValidation>
Validates card data without creating the token. Useful for real-time validation while the user enters data.
Request
| Field | Type | Length | Required | Description |
|---|---|---|---|---|
cardNumber | string | 13-19 digits | ✅ Yes | Card number (must pass Luhn validation). Only numeric characters allowed. |
cvv | string | 3-4 digits | ✅ Yes | Card security code. 3 digits for Visa/Mastercard, 4 digits for Amex. Only numeric characters. |
expirationMonth | string | 2 characters | ✅ Yes | Card expiration month (01-12). Must be zero-padded (e.g., “01”, “12”). |
expirationYear | string | 2 or 4 characters | ✅ Yes | Card expiration year. Accepts YY (e.g., “25”) or YYYY (e.g., “2025”) format. |
cardHolderName | string | Min: 3 chars | ✅ Yes | Cardholder full name as shown on the card. Must contain at least 3 characters. |
Response
Error Codes by Field
cardNumber:| Code | Description |
|---|---|
CARD_NUMBER_REQUIRED | Card number is required |
INVALID_CARD_NUMBER | Invalid card number (Luhn algorithm fails) |
INVALID_CARD_LENGTH | Incorrect length (must be 13-19 digits) |
CARD_NUMBER_NOT_NUMERIC | Only numbers allowed |
UNSUPPORTED_CARD_BRAND | Unsupported card brand |
| Code | Description |
|---|---|
CVV_REQUIRED | CVV is required |
INVALID_CVV_LENGTH | CVV must be 3 digits (Visa/MC) or 4 (Amex) |
CVV_NOT_NUMERIC | CVV can only contain numbers |
| Code | Description |
|---|---|
EXPIRATION_MONTH_REQUIRED | Expiration month is required |
INVALID_EXPIRATION_MONTH | Invalid month (must be 01-12) |
EXPIRATION_MONTH_NOT_NUMERIC | Month must be numeric |
| Code | Description |
|---|---|
EXPIRATION_YEAR_REQUIRED | Expiration year is required |
INVALID_EXPIRATION_YEAR | Invalid year or incorrect format |
CARD_EXPIRED | Card is already expired |
EXPIRATION_YEAR_TOO_FAR | Expiration year too far in future (max 20 years) |
| Code | Description |
|---|---|
CARDHOLDER_NAME_REQUIRED | Cardholder name is required |
CARDHOLDER_NAME_TOO_SHORT | Name too short (minimum 3 characters) |
CARDHOLDER_NAME_INVALID | Invalid characters in name |
| Code | Description |
|---|---|
SDK_NOT_INITIALIZED | Must call initialize() before validating |
VALIDATION_ERROR | General validation error |
3. createToken(request: TokenRequest): Promise<Token>
Creates a secure token for the card. This method automatically validates before tokenizing.
Request
| Field | Type | Length | Required | Description |
|---|---|---|---|---|
cardNumber | string | 13-19 digits | ✅ Yes | Card number (must pass Luhn validation). Only numeric characters allowed. |
cvv | string | 3-4 digits | ✅ Yes | Card security code. 3 digits for Visa/Mastercard, 4 digits for Amex. Only numeric characters. |
expirationMonth | string | 2 characters | ✅ Yes | Card expiration month (01-12). Must be zero-padded (e.g., “01”, “12”). |
expirationYear | string | 2 or 4 characters | ✅ Yes | Card expiration year. Accepts YY (e.g., “25”) or YYYY (e.g., “2025”) format. |
cardHolderName | string | Min: 3 chars | ✅ Yes | Cardholder full name as shown on the card. Must contain at least 3 characters. |
Response
Error Codes
Data Validation:| Code | Description |
|---|---|
VALIDATION_FAILED | Data validation failed (includes details) |
CARD_NUMBER_REQUIRED | Card number missing |
INVALID_CARD_NUMBER | Invalid card number |
CVV_REQUIRED | CVV missing |
INVALID_CVV | Invalid CVV |
CARD_EXPIRED | Card expired |
CARDHOLDER_NAME_REQUIRED | Cardholder name missing |
| Code | Description |
|---|---|
TOKENIZATION_FAILED | Error creating token |
KUSHKI_SERVICE_UNAVAILABLE | Tokenization service unavailable |
CARD_DECLINED | Card declined by issuer |
CARD_BLOCKED | Card blocked |
INSUFFICIENT_FUNDS | Insufficient funds (online validation only) |
DUPLICATE_TRANSACTION | Duplicate transaction |
FRAUD_DETECTION | Transaction blocked by fraud detection |
| Code | Description |
|---|---|
AUTHENTICATION_REQUIRED | Card requires 3DS or OTP authentication |
AUTHENTICATION_FAILED | 3DS/OTP authentication failed |
AUTHENTICATION_TIMEOUT | Authentication timeout |
AUTHENTICATION_REJECTED | User rejected authentication |
AUTHENTICATION_CANCELLED | User cancelled authentication |
3DS_NOT_ENROLLED | Card not enrolled in 3D Secure |
3DS_CHALLENGE_FAILED | 3D Secure challenge failed |
OTP_INVALID | Invalid OTP code |
OTP_EXPIRED | OTP code expired |
OTP_MAX_ATTEMPTS | Maximum OTP attempts reached |
| Code | Description |
|---|---|
SDK_NOT_INITIALIZED | SDK not initialized |
MISSING_CONFIGURATION | Required configuration missing |
INVALID_MERCHANT_CONFIG | Invalid merchant configuration |
| Code | Description |
|---|---|
NETWORK_ERROR | Connection error |
TIMEOUT_ERROR | Timeout error |
SERVICE_UNAVAILABLE | Service temporarily unavailable |
4. validateOTP(request: ValidateOTPRequest): Promise<ValidateOTPResponse>
Validates the OTP (One-Time Password) code sent to the customer as part of the authentication process. This method is used when the transaction requires additional verification via temporary code.
Request
| Field | Type | Length | Required | Description |
|---|---|---|---|---|
otpValue | string | 3-6 digits | ✅ Yes | One-Time Password code sent to the customer. Only numeric characters allowed. |
Response
Error Codes
OTP Validation:| Code | Description |
|---|---|
OTP_REQUIRED | OTP code is required |
INVALID_OTP | Incorrect or invalid OTP code |
OTP_EXPIRED | OTP code has expired |
OTP_MAX_ATTEMPTS | Maximum number of attempts reached |
OTP_NOT_FOUND | No active OTP session found |
OTP_ALREADY_USED | This OTP code was already used |
| Code | Description |
|---|---|
VALIDATION_FAILED | Data validation failed (includes details) |
OTP_INVALID_FORMAT | Invalid OTP format (must be numeric) |
OTP_INVALID_LENGTH | Incorrect OTP code length |
| Code | Description |
|---|---|
SDK_NOT_INITIALIZED | SDK not initialized |
MISSING_CONFIGURATION | Required configuration missing |
INVALID_MERCHANT_CONFIG | Invalid merchant configuration |
| Code | Description |
|---|---|
NETWORK_ERROR | Connection error |
TIMEOUT_ERROR | Timeout error |
SERVICE_UNAVAILABLE | Service temporarily unavailable |
Authentication Handling
The SDK automatically and internally handles all 3DS (3D Secure) and OTP authentication processes when the card requires it. For the client:- The
createToken()method performs the entire authentication flow transparently - If authentication is successful, you’ll receive the token normally
- If it fails, you’ll receive a specific error (see error codes above)
- Detecting if the card requires authentication
- Executing the 3DS or OTP flow as appropriate
- Validating authentication with the bank
- Returning the final token or a descriptive error
Test Cards
Fortest environment, use these cards:
| Brand | Number | CVV | Result |
|---|---|---|---|
| Visa | 4532015112830366 | 123 | Approved |
| Visa | 4111111111111111 | 123 | Approved |
| Visa | 4000000000000002 | 123 | Declined |
| Mastercard | 5425233430109903 | 123 | Approved |
| Mastercard | 5555555555554444 | 123 | Approved |
| Amex | 374245455400126 | 1234 | Approved |
12/2025)