README
TBC Payment Gateway for Node.js
Table of Contents
Installation
Get started by installing the package:
npm install --save node-tbc-payment-gateway
Usage
- Setup
- Create Transaction (SMS/DMS)
- Commit DMS Transaction
- Transaction Status
- Reverse Transaction
- Refund Transaction
- Close Day
- Card Registration
- Regular Payments
- Regular Payment Authorization
Setup
First, require the package in your file:
const TBC = require('node-tbc-payment-gateway');
Then, instantiate the class providing the cert file and passphrase:
const tbc = new TBC('cert_file', 'cert_passphrase');
You can now start working with the payment gateway.
Create Transaction
const result = await tbc
.setDescription('Test Transaction')
.setClientIpAddress('127.0.0.1')
.setLanguage('GE')
.setCurrency(981) // Georgian Lari
.setAmount(1)
.createTransaction();
console.log(result);
/*
{
TRANSACTION_ID: 'TRANSACTION_ID_HERE'
}
*/
Commit DMS Transaction
const result = await tbc
.setDescription('Test Transaction')
.setClientIpAddress('127.0.0.1')
.setCurrency(981) // Georgian Lari
.setAmount(1)
.commitTransaction('TRANSACTION_ID_HERE');
console.log(result);
/*
{
RESULT: '...',
RESULT_CODE: '...',
RRN: '...',
APPROVAL_CODE: '...',
CARD_NUMBER: '...'
}
*/
If transaction has been created with registered card, use commitTransaction('TRANSACTION_ID_HERE', true)
.
Transaction Status
const result = await tbc.getTransactionStatus('TRANSACTION_ID_HERE');
console.log(result);
/*
{
RESULT: '...',
RESULT_CODE: '...',
3DSECURE: '...',
RRN: '...',
APPROVAL_CODE: '...',
CARD_NUMBER: '...'
RECC_PMNT_ID: '...'
RECC_PMNT_EXPIRY: '...'
MRCH_TRANSACTION_ID: '...'
}
*/
Reverse Transaction
const result = await tbc.reverseTransaction('TRANSACTION_ID_HERE');
console.log(result);
/*
{
RESULT: '...',
RESULT_CODE: '...',
}
*/
Refund Transaction
const result = await tbc.refundTransaction('TRANSACTION_ID_HERE');
console.log(result);
/*
{
RESULT: '...',
RESULT_CODE: '...',
REFUND_TRANS_ID: '...',
}
*/
Close Day
const result = await tbc.closeDay();
console.log(result);
/*
{
RESULT: '...',
RESULT_CODE: '...',
FLD_074: '...',
FLD_075: '...',
FLD_076: '...',
FLD_077: '...',
FLD_086: '...',
FLD_087: '...',
FLD_088: '...',
FLD_089: '...',
}
*/
Card Registration
const result = await tbc
.setCurrency(981)
.setClientIpAddress('127.0.0.1')
.setDescription('Card Registration Test')
.registerCard('CARD_ID');
console.log(result);
/*
{
TRANSACTION_ID: '...',
}
*/
If you would like to make DMS transactions with registered cards, use registerCard('CARD_ID', true)
.
Regular Payments
const result = await tbc
.setCurrency(981)
.setClientIpAddress('127.0.0.1')
.setDescription('Regular Payment Test')
.setAmount(1)
.makeRegularPayment('CARD_ID');
console.log(result);
/*
{
TRANSACTION_ID: '...',
RESULT: '...',
RESULT_CODE: '...',
RRN: '...',
APPROVAL_CODE: '...',
}
*/
Regular Payment Authorization
const result = await tbc
.setCurrency(981)
.setClientIpAddress('127.0.0.1')
.setDescription('Regular Payment Test')
.setAmount(1)
.authorizeRegularPayment('CARD_ID');
console.log(result);
/*
{
TRANSACTION_ID: '...',
RESULT: '...',
RESULT_CODE: '...',
RRN: '...',
APPROVAL_CODE: '...',
}
*/
License
shota-mentesh/node-tbc-payment-gateway is licensed under a ISC License.