added service for sending beneficiary details to NPCI interface
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
const axios = require('axios');
|
const axios = require('axios');
|
||||||
const { logger } = require('../util/logger');
|
const { logger } = require('../util/logger');
|
||||||
|
const { v4: uuidv4 } = require('uuid');
|
||||||
|
|
||||||
async function validateWithinBank(accountNo) {
|
async function validateWithinBank(accountNo) {
|
||||||
const url = 'http://localhost:8687/kccb/cbs/acctInfo/details';
|
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 };
|
||||||
|
Reference in New Issue
Block a user