npm install txnpay
After installing, initialize by importing the package and using the public and secret keys.
// ES5
const { TraxionPay } = require('txnpay');
// ES6
import { TraxionPay } from 'txnpay';
const traxionpay = new TraxionPay(apiKey, secretKey);
// Sample arguments are the bare minimum for cash_in
const response = await traxionpay.cashIn({
merchant_id: 6328,
merchant_ref_no: "ABC123DEF456",
merchant_additional_data: { "payment_code": "ABC123DEF456" },
description: "My test payment",
amount: 1500.0,
status_notification_url: apiurl,
success_page_url: devUrl,
failure_page_url: devUrl,
cancel_page_url: devUrl,
pending_page_url: devUrl,
billing_details: {
billing_email: '[email protected]'
}
});
const { code } = await traxionpay.fetchOTP();
const response = await traxionpay.cashOut({
OTP: code,
amount: 100,
bank_account: 433
});
const response = await traxionpay.linkBankAccount({
bank: '6311',
bank_type: 'savings',
account_name: 'John Doe',
account_number: '123456789'
});
const { code } = await traxionpay.fetchOTP();
const bankAccounts = await traxionpay.fetchBankAccounts();
const banks = await traxionpay.fetchBanks();