Blame view
lib/callback/handler-postpaid.js
1.74 KB
525f0bf55
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
const MODULE_NAME = 'CALLBACK.HANDLER-POSTPAID'; const logger = require('komodo-sdk/logger'); const report = require('../report/postpaid'); const getFromReq = require('../get-from-params-body-qs'); const translateRc = require('../translate-rc'); module.exports = (req, res) => { const { xid } = res.locals; res.json({ status: 'OK', error: null, ts: new Date(), xid, }); const reportCommand = getFromReq(req, 'command'); if (!reportCommand) { logger.warn(`${MODULE_NAME} C7A4A26C: Unknown command`, { xid }); return; } const isInquiry = reportCommand === 'INQUIRY'; const rcFromRequest = getFromReq(req, 'rc'); const translatedRc = rcFromRequest && (translateRc[rcFromRequest] || rcFromRequest); logger.verbose(`${MODULE_NAME} 475DA596: RC translated`, { xid, reportCommand, rcFromRequest, translatedRc, }); report(xid, { command: reportCommand, trx_id: getFromReq(req, 'request_id'), rc: translatedRc || (isInquiry && '90') || '68', sn: getFromReq(req, 'sn'), amount: Number(getFromReq(req, 'amount')) || undefined, balance: Number(getFromReq(req, 'ending_balance')) || undefined, amount_to_charge: (isInquiry && Number(getFromReq(req, 'amount_to_charge'))) || undefined, bill_count: Number(getFromReq(req, 'bill_count')) || undefined, base_bill_amount: Number(getFromReq(req, 'base_bill_amount')) || undefined, message: { xid, CALLBACK: { ip: req.ip, method: req.method, body: req.body, qs: req.query, }, }, }); }; |