Skip to main content

Quickstart

This guide helps you make your first API call with the Tingee SDK in just a few minutes.

Before you start
  • You have installed the SDK for your language
  • You have a clientId and secretKey from the Tingee Dashboard

1. Initialize the client​

import { TingeeClient, isSuccessResponse, isErrorResponse } from '@tingee/sdk-node';

const client = new TingeeClient({
secretKey: process.env.TINGEE_SECRET_KEY!,
clientId: process.env.TINGEE_CLIENT_ID!,
environment: 'uat', // use 'uat' for testing, 'production' when going live
});

2. Make your first API call​

Example: get the list of Merchants.

const result = await client.merchant.getPaging({
maxResultCount: 10,
skipCount: 0,
});

if (isSuccessResponse(result)) {
console.log('Merchant list:');
result.data.items.forEach(m => console.log(` - ${m.name}`));
} else {
console.error(`Error ${result.code}: ${result.message}`);
}

3. Handle the response​

The SDK returns a TingeeApiResponse for every API call:

{
"code": "00",
"message": "Success",
"data": { ... }
}
The SDK does not throw exceptions

When code !== '00', the SDK does not throw an exception. Check code yourself or use a helper:

import { isSuccessResponse, isErrorResponse } from '@tingee/sdk-node';

if (isSuccessResponse(result)) {
// code === '00' → handle result.data
} else if (isErrorResponse(result)) {
// code !== '00' → handle the error
console.error(`${result.code}: ${result.message}`);
}

4. More examples​

List supported banks​

const banks = await client.bank.getBanks();
if (isSuccessResponse(banks)) {
banks.data.forEach(b => console.log(`${b.shortName} (BIN: ${b.bin})`));
}
const deepLink = await client.deepLink.generate({
vaAccountNumber: '123456789',
amount: 150000,
orderId: 'ORD-001',
description: 'Thanh toán đơn hàng ORD-001',
});
if (isSuccessResponse(deepLink)) {
console.log('Deep Link:', deepLink.data);
}

Next steps​