modified handle NPCI success method to only put the beneficiary name in redis
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
const db = require('../config/db');
|
||||
const { getJson } = require('../config/redis');
|
||||
const { getJson, setJson } = require('../config/redis');
|
||||
const { logger } = require('../util/logger');
|
||||
|
||||
async function npciResponse(req, res) {
|
||||
@@ -15,26 +15,9 @@ async function npciResponse(req, res) {
|
||||
async function handleNPCISuccess(response) {
|
||||
const { txnid, benename } = response;
|
||||
try {
|
||||
const beneficiaryDetails = await getJson(txnid);
|
||||
if (!beneficiaryDetails) {
|
||||
logger.warn('no txnid in redis');
|
||||
return false;
|
||||
}
|
||||
const { customerNo, accountNo, ifscCode, accountType } = beneficiaryDetails;
|
||||
const query =
|
||||
'INSERT INTO beneficiaries (customer_no, account_no, name, account_type, ifsc_code) VALUES ($1, $2, $3, $4, $5)';
|
||||
const result = await db.query(query, [
|
||||
customerNo,
|
||||
accountNo,
|
||||
benename,
|
||||
accountType,
|
||||
ifscCode,
|
||||
]);
|
||||
logger.info(result);
|
||||
return true;
|
||||
await setJson(txnid, benename);
|
||||
} catch (error) {
|
||||
logger.error(error, 'error processing npci response');
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user