added service for sending beneficiary details to NPCI interface

This commit is contained in:
2025-08-07 01:58:37 +05:30
parent 6d675ad81c
commit ae14968739

View File

@@ -1,5 +1,6 @@
const axios = require('axios');
const { logger } = require('../util/logger');
const { v4: uuidv4 } = require('uuid');
async function validateWithinBank(accountNo) {
const url = 'http://localhost:8687/kccb/cbs/acctInfo/details';
@@ -16,4 +17,23 @@ async function validateWithinBank(accountNo) {
}
}
module.exports = { validateWithinBank };
async function validateOutsideBank(accountNo, ifscCode, name) {
const uuid = `KCC${uuidv4().replace(/-/g, '')}`;
const url = `http://localhost:9091/kccb/benenamelookup/ReqBeneDetails/${uuid}`;
try {
const response = await axios.post(url, {
acctNo: accountNo,
ifsccode: ifscCode,
remittername: name,
});
if (response.data) {
console.log(response.data);
return uuid;
}
} catch (error) {
logger.error(error, 'error while validating customer from NPCI');
throw new Error('error in beneficiary validation');
}
}
module.exports = { validateWithinBank, validateOutsideBank };