diff --git a/.vscode/settings.json b/.vscode/settings.json index fef8a46..fefb1ec 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -1,5 +1,6 @@ { "cSpell.words": [ + "emandate", "MPIN", "occured", "otpgenerator", diff --git a/src/routes/emandate.route.js b/src/routes/emandate.route.js new file mode 100644 index 0000000..90f7c29 --- /dev/null +++ b/src/routes/emandate.route.js @@ -0,0 +1,24 @@ +const express = require('express'); +const axios = require('axios'); +const { logger } = require('../util/logger'); +const router = express.Router(); +const emandateData = async (req, res) => { + const { data, mandateRequest, mandateType } = req.body; + if (!data || !mandateRequest | !mandateType) + return res.status(404).json({ error: 'DATA NOT FOUND FROM CLIENT' }) + try { + const reqData = { data, mandateRequest, mandateType }; + const response = await axios.post('http://192.168.1.166:9992/kccb/validation', reqData, + { + headers: { 'Content-Type': 'application/json', }, + } + ); + logger.info("Data validate"); + return response.data; + } catch (error) { + logger.error(error, 'error occured while E-Mandate validation'); + return res.status(500).json({ error: 'INTERNAL_SERVER_ERROR' }); + } +}; +router.post('/validation', emandateData); +module.exports = router; \ No newline at end of file diff --git a/src/routes/index.js b/src/routes/index.js index 8dd7a6f..da47254 100644 --- a/src/routes/index.js +++ b/src/routes/index.js @@ -11,7 +11,7 @@ const rtgsRoute = require('./rtgs.route'); const impsRoute = require('./imps.route'); const { npciResponse } = require('../controllers/npci.controller'); const otp = require('./otp.route'); - +const eMandate = require('./emandate.route'); const router = express.Router(); router.use('/auth', authRoute); @@ -25,5 +25,6 @@ router.use('/payment/imps', authenticate, impsRoute); router.use('/beneficiary', authenticate, beneficiaryRoute); router.use('/npci/beneficiary-response', npciResponse); router.use('/otp', otp); +router.use('/e-mandate',authenticate,eMandate); module.exports = router;