added imps transactions payment feature

This commit is contained in:
2025-08-22 15:31:13 +05:30
parent 1e32b4a5a6
commit 0d2cea8902
4 changed files with 117 additions and 0 deletions

View File

@@ -0,0 +1,43 @@
const axios = require('axios');
const { logger } = require('../util/logger');
async function send(
fromAccount,
toAccount,
amount,
ifscCode,
beneficiaryName,
beneficiaryAcctType = 'SAVING',
remarks = ''
) {
try {
const reqData = {
stBenAccNo: toAccount,
stBeneName: beneficiaryName,
stBenAccType: beneficiaryAcctType,
stBenIFSC: ifscCode,
stFromAccDetails: fromAccount,
stTransferAmount: amount,
stRemarks: remarks,
};
logger.info(reqData, 'request data to be sent to IMPS server');
const response = await axios.post(
'http://localhost:6768/kccb/api/IMPS/Producer',
reqData,
{
headers: {
'Content-Type': 'application/json',
},
}
);
logger.info(response, 'response from IMPS');
return response.data;
} catch (error) {
logger.error(error, 'error from IMPS');
throw new Error(
'API call failed: ' + (error.response?.data?.message || error.message)
);
}
}
module.exports = { send };