Commit 56ec0ab1f742a3313a7f611a1a08101c534cce6d

Authored by Adhidarma Hadiwinoto
1 parent 9693703099
Exists in master and in 1 other branch dev

Tune on callback-sender

Showing 2 changed files with 9 additions and 7 deletions Side-by-side Diff

lib/core-callback/index.js
  1 +const MODULE_NAME = 'CORE-CALLBACK';
  2 +
1 3 const DEFAULT_LISTENER_FROM_CORE = 25613;
2 4  
3 5 const express = require('express');
... ... @@ -12,7 +14,7 @@ app.use(express.json({ extended: true }));
12 14 app.use(express.urlencoded({ extended: true }));
13 15  
14 16 app.use((req, res, next) => {
15   - res.locals.httpgetx_subsystem = 'CORE-CALLBACK';
  17 + res.locals.httpgetx_subsystem = MODULE_NAME;
16 18 next();
17 19 });
18 20  
... ... @@ -27,8 +29,8 @@ const port = (config.listener && config.listener.core && config.listener.core.po
27 29 || DEFAULT_LISTENER_FROM_CORE;
28 30  
29 31 app.listen(port, () => {
30   - logger.info(`Listen from CORE callback on port ${port}`);
  32 + logger.info(`${MODULE_NAME} 0375DC4E: Listen from CORE callback on port ${port}`);
31 33 }).on('error', (e) => {
32   - logger.error(`Can not listen CORE callback on port ${port}. ${e.toString()}`);
  34 + logger.error(`${MODULE_NAME} A90E42D5: Can not listen CORE callback on port ${port}. ${e.toString()}`);
33 35 process.exit(1);
34 36 });
lib/core-callback/sender.js
... ... @@ -23,13 +23,13 @@ const sender = async (data, xid, retry) => {
23 23 destination: data.destination,
24 24 rc: data.rc,
25 25 sn: data.sn,
  26 + amount: Number(data.amount) || undefined,
  27 + ending_balance: Number(data.ending_balance) || undefined,
26 28 message: data.message,
27   - amount: data.amount,
28   - ending_balance: data.ending_balance,
29 29 };
30 30  
31   - if (data.command === 'INQUIRY' && data.amount_to_charge) {
32   - params.amount_to_charge = data.amount_to_charge;
  31 + if (data.command === 'INQUIRY' && Number(data.amount_to_charge)) {
  32 + params.amount_to_charge = Number(data.amount_to_charge);
33 33 }
34 34  
35 35 const fullUrl = urlConcatQs(data.reverse_url, params);