Blame view

lib/callback/handler-prepaid.js 1.15 KB
385d8ff59   Adhidarma Hadiwinoto   PREPAID topup tested
1
  const MODULE_NAME = 'CALLBACK.HANDLER-PREPAID';
3d8701130   Adhidarma Hadiwinoto   Migrate to tektra...
2
  const logger = require('tektrans-logger');
385d8ff59   Adhidarma Hadiwinoto   PREPAID topup tested
3
4
5
  const report = require('../report/prepaid');
  const getFromReq = require('../get-from-params-body-qs');
  const translateRc = require('../translate-rc');
d4661aa84   Adhidarma Hadiwinoto   Ready to test pre...
6
7
8
9
10
11
12
13
  module.exports = (req, res) => {
      const { xid } = res.locals;
      res.json({
          status: 'OK',
          error: null,
          ts: new Date(),
          xid,
      });
385d8ff59   Adhidarma Hadiwinoto   PREPAID topup tested
14
15
16
17
18
19
20
21
22
23
24
25
26
  
      const rcFromRequest = getFromReq(req, 'rc');
      const translatedRc = rcFromRequest && (translateRc[rcFromRequest] || rcFromRequest);
      logger.verbose(`${MODULE_NAME} 2B7BE44D: RC translated`, {
          xid,
          rcFromRequest,
          translatedRc,
      });
  
      report(xid, {
          trx_id: getFromReq(req, 'request_id'),
          rc: translatedRc || '68',
          sn: getFromReq(req, 'sn'),
1e63f3741   Adhidarma Hadiwinoto   Number on amount ...
27
28
          amount: Number(getFromReq(req, 'amount')) || undefined,
          balance: Number(getFromReq(req, 'ending_balance')) || undefined,
385d8ff59   Adhidarma Hadiwinoto   PREPAID topup tested
29
30
31
32
33
34
35
36
37
38
          message: {
              xid,
              CALLBACK: {
                  ip: req.ip,
                  method: req.method,
                  body: req.body,
                  qs: req.query,
              },
          },
      });
d4661aa84   Adhidarma Hadiwinoto   Ready to test pre...
39
  };