made the function validateOutsideBank return beneficiary name rather than refNo
Also removed the now redundant checkBeneficiaryName controller and paths
This commit is contained in:
@@ -1,8 +1,6 @@
|
||||
const { logger } = require('../util/logger');
|
||||
const { setJson, getJson } = require('../config/redis');
|
||||
const beneficiaryService = require('../services/beneficiary.service');
|
||||
const db = require('../config/db');
|
||||
const axios = require('axios');
|
||||
|
||||
async function validateWithinBank(req, res) {
|
||||
const { accountNumber } = req.query;
|
||||
@@ -40,7 +38,9 @@ async function validateOutsideBank(req, res) {
|
||||
);
|
||||
if (!refNo)
|
||||
return res.status(401).json({ error: 'invalid account number' });
|
||||
return res.json({ refNo });
|
||||
//**IN PRODUCTION** poll the redis server continuously giving the refNo since the response from NPCI will be stored there
|
||||
await delay(3000);
|
||||
return res.json({ name: 'John Doe' });
|
||||
} catch (err) {
|
||||
logger.error(err, 'beneficiary validation within bank failed');
|
||||
res.status(500).json({ error: 'invalid account number' });
|
||||
@@ -86,24 +86,6 @@ async function getBeneficiary(req, res) {
|
||||
}
|
||||
}
|
||||
|
||||
async function checkBeneficiaryName(req, res) {
|
||||
await delay(2000);
|
||||
const { refNo } = req.query;
|
||||
if (!refNo) {
|
||||
res.status(403).json({ error: 'BAD_REQUEST' });
|
||||
return;
|
||||
}
|
||||
|
||||
//uncomment in production for actual name from beneficiary
|
||||
// const beneficiaryName = await getJson(refNo);
|
||||
const beneficiaryName = 'John Doe';
|
||||
if (!beneficiaryName) {
|
||||
res.status(404).json({ error: 'NOT_FOUND' });
|
||||
return;
|
||||
}
|
||||
res.json({ message: beneficiaryName });
|
||||
}
|
||||
|
||||
async function getIfscDetails(req, res) {
|
||||
const { ifscCode } = req.query;
|
||||
if (!ifscCode) {
|
||||
@@ -134,7 +116,6 @@ module.exports = {
|
||||
validateWithinBank,
|
||||
validateOutsideBank,
|
||||
addBeneficiary,
|
||||
checkBeneficiaryName,
|
||||
getIfscDetails,
|
||||
getBeneficiary,
|
||||
};
|
||||
|
@@ -6,7 +6,6 @@ const router = express.Router();
|
||||
|
||||
router.get('/validate/within-bank', beneficiaryController.validateWithinBank);
|
||||
router.get('/validate/outside-bank', beneficiaryController.validateOutsideBank);
|
||||
router.get('/check', beneficiaryController.checkBeneficiaryName);
|
||||
router.get('/ifsc-details', beneficiaryController.getIfscDetails);
|
||||
router.get('/get', beneficiaryController.getBeneficiary);
|
||||
router.post(
|
||||
|
Reference in New Issue
Block a user