Commit a042446079a3c4e2e9fcfbc0abbfbd5f7311d796

Authored by Adhidarma Hadiwinoto
1 parent 1fbcb90950
Exists in master

Add log and config.only_direct_response

Showing 2 changed files with 17 additions and 4 deletions Side-by-side Diff

1 1 {
2 2 "handler_name": "DUMMY2022",
3 3 "pull_interval_ms": 1000,
  4 + "only_direct_response": false,
4 5 "apiserver": {
5 6 "apikey": "PLEASE_CHANGE_ME",
6 7 "port": 12602,
... ... @@ -19,7 +19,8 @@ exports.buy = (task, callerXid) => {
19 19  
20 20 logger.verbose(`${MODULE_NAME} 6022C627: Remote product parsed`, { xid, remoteProduct });
21 21  
22   - if (remoteProduct.ONLY_DIRECT_RESPONSE) {
  22 + if (config.only_direct_response || remoteProduct.ONLY_DIRECT_RESPONSE) {
  23 + logger.verbose(`${MODULE_NAME} 6CB89503: Sending final direct response`, { xid });
23 24 report({
24 25 trx_id: task.trx_id,
25 26 rc: remoteProduct.RC || '00',
... ... @@ -33,6 +34,8 @@ exports.buy = (task, callerXid) => {
33 34 return;
34 35 }
35 36  
  37 + logger.verbose(`${MODULE_NAME} 207C6F31: Sending intermediate report`, { xid });
  38 +
36 39 report({
37 40 trx_id: task.trx_id,
38 41 rc: '68',
... ... @@ -43,7 +46,18 @@ exports.buy = (task, callerXid) => {
43 46 },
44 47 });
45 48  
  49 + const delay = Math.floor(
  50 + Math.random() * (config.max_wait_ms_before_callback || 3000),
  51 + );
  52 +
  53 + logger.verbose(`${MODULE_NAME} 091163B7: Will send callback`, {
  54 + xid,
  55 + delay,
  56 + });
  57 +
46 58 setTimeout(() => {
  59 + logger.verbose(`${MODULE_NAME} 685B89B9: Sending final callback`, { xid });
  60 +
47 61 report({
48 62 trx_id: task.trx_id,
49 63 rc: remoteProduct.RC,
... ... @@ -53,7 +67,5 @@ exports.buy = (task, callerXid) => {
53 67 msg: 'SELESAI',
54 68 },
55 69 }, xid);
56   - }, Math.floor(
57   - Math.random() * (config.max_wait_ms_before_callback || 3000),
58   - ));
  70 + }, delay);
59 71 };