Commit b1987100c4aeea4768985d86c544f040c198784b
1 parent
e04a9e4aa3
Exists in
master
Add direct response and xid on report
Showing 1 changed file with 23 additions and 6 deletions Side-by-side Diff
lib/partner.js
... | ... | @@ -7,6 +7,14 @@ const pull = require('komodo-sdk/gateway/pull'); |
7 | 7 | function buy(task, xid) { |
8 | 8 | logger.verbose('Got task from CORE', { xid, task }); |
9 | 9 | const [remoteProduct, amount] = task.remote_product.split(/ *, */); |
10 | + pull.report({ | |
11 | + trx_id: task.trx_id, | |
12 | + rc: '68', | |
13 | + message: { | |
14 | + xid, | |
15 | + msg: 'Waiting for result', | |
16 | + }, | |
17 | + }, xid); | |
10 | 18 | |
11 | 19 | setTimeout( |
12 | 20 | () => { |
... | ... | @@ -16,16 +24,22 @@ function buy(task, xid) { |
16 | 24 | pull.report({ |
17 | 25 | trx_id: task.trx_id, |
18 | 26 | rc: '68', |
19 | - message: `PENDING karena nomor tujuan ${task.destination} diakhiri 0`, | |
20 | 27 | balance: config.supplier_ending_balance, |
21 | - }); | |
28 | + message: { | |
29 | + xid, | |
30 | + msg: `PENDING karena nomor tujuan ${task.destination} diakhiri 0`, | |
31 | + }, | |
32 | + }, xid); | |
22 | 33 | } else if (destination % 2) { |
23 | 34 | pull.report({ |
24 | 35 | trx_id: task.trx_id, |
25 | 36 | rc: '14', |
26 | - message: `GAGAL karena nomor tujuan ${task.destination} adalah nomor ganjil`, | |
27 | 37 | balance: config.supplier_ending_balance, |
28 | - }); | |
38 | + message: { | |
39 | + xid, | |
40 | + msg: `GAGAL karena nomor tujuan ${task.destination} adalah nomor ganjil`, | |
41 | + }, | |
42 | + }, xid); | |
29 | 43 | } else { |
30 | 44 | pull.report({ |
31 | 45 | trx_id: task.trx_id, |
... | ... | @@ -33,9 +47,12 @@ function buy(task, xid) { |
33 | 47 | sn: moment().format('YYYYMMDDHHmmssSSS'), |
34 | 48 | amount, |
35 | 49 | remote_product: remoteProduct, |
36 | - message: `BERHASIL karena nomor tujuan ${task.destination} adalah nomor genap`, | |
37 | 50 | balance: config.supplier_ending_balance, |
38 | - }); | |
51 | + message: { | |
52 | + xid, | |
53 | + msg: `BERHASIL karena nomor tujuan ${task.destination} adalah nomor genap`, | |
54 | + }, | |
55 | + }, xid); | |
39 | 56 | } |
40 | 57 | }, |
41 | 58 | (config.max_result_timeout_ms || 2000) * Math.random(), |