Integration Managing bank accounts List, add and delete bank accounts.
Add a new bank account
Here's an example code to add a new bank account.
Copy import { createSignature } from "./createSignature";
const axios = require('axios');
const apiKey = "{YOUR API KEY}";
const secret = "{YOUR SECRET}";
async function addBankAccount() {
const path = "https://idrx.co/api/auth/add-bank-account";
const req = {
"bankAccountNumber" : "{BANK ACCOUNT NUMBER}",
"bankCode" : "{BANK CODE}",
};
const bufferReq = Buffer.from(JSON.stringify(req), 'base64').toString('utf8');
const timestamp = Math.round((new Date()).getTime()).toString();
const sig = createSignature('POST', path, bufferReq, timestamp, secret);
const res = await axios.post(path, req, {
headers: {
'Content-Type': 'application/json',
'idrx-api-key': apiKey,
'idrx-api-sig': sig,
},
});
console.log('res.data: ');
console.log(JSON.stringify(res.data, null, 4));
}
addBankAccount();
You can get a list of available bank codes from this api .
After a successful request, you will get a response as follows:
Copy {
"statusCode": 201,
"message": "success",
"data": {
"id": 108,
"userId": 411,
"bankAccountNumber": "5017332241",
"bankAccountName": "JOHN SMITH",
"bankAccountNumberHash": null,
"bankCode": "014",
"bankName": "BANK CENTRAL ASIA",
"maxAmountTransfer": "100000000",
"deleted": false,
"DepositWalletAddress": {
"walletAddress": "0x07C158ab29f23D0821e7D24B191c5e5d9d72738b",
"createdAt": "2024-01-17T10:34:22.304Z"
}
}
}
Notice that a deposit wallet address is also included. Users can send funds to this deposit address to request a redeem to the associated bank account.
To list currently registered bank accounts, you can use this api .
Delete a bank account
Here's an example code to delete an existing bank account.
Copy import { createSignature } from "./createSignature";
const axios = require('axios');
const apiKey = "{YOUR API KEY}";
const secret = "{YOUR SECRET}";
async function deleteBank(bankId: string) {
const path = "https://idrx.co/api/auth/delete-bank-account/"+bankId;
const bufferReq = Buffer.from('', 'base64').toString('utf8');
const timestamp = Math.round((new Date()).getTime()).toString();
const sig = createSignature('GET', path, bufferReq, timestamp, secret);
const res = await axios.delete(path, {
headers: {
'Content-Type': 'application/json',
'idrx-api-key': apiKey,
'idrx-api-sig': sig,
},
});
console.log('res.data: ');
console.log(JSON.stringify(res.data, null, 4));
}
deleteBank('108');
After a successful request, you will get a response as follows:
Copy {
"statusCode": 200,
"message": "deleted",
"data": null
}