Commit f4bce3729af68c5e5af8a1b64b59e803ed0dd5a2
1 parent
d30bb2a374
Exists in
master
perbaikan sn dan resend
Showing 1 changed file with 16 additions and 3 deletions Side-by-side Diff
partner-cjk.js
... | ... | @@ -62,7 +62,7 @@ function createXmlPayload(params) { |
62 | 62 | |
63 | 63 | function getSNFromMessage(message) { |
64 | 64 | try { |
65 | - var sn_match = message.match(/SN (\w+) /); | |
65 | + var sn_match = message.match(/SN: (\w+)/); | |
66 | 66 | return sn_match[1]; |
67 | 67 | } |
68 | 68 | catch(err) { |
... | ... | @@ -70,6 +70,18 @@ function getSNFromMessage(message) { |
70 | 70 | } |
71 | 71 | } |
72 | 72 | |
73 | +function hasSuccessKeywords(message) { | |
74 | + var keywords = ['SUKSES', 'Finish']; | |
75 | + | |
76 | + var count = keywords.length; | |
77 | + for (var i=0; i < count; i++) { | |
78 | + if (message.indexOf(keywords[i]) >= 0) { | |
79 | + return true; | |
80 | + } | |
81 | + } | |
82 | + return false; | |
83 | +} | |
84 | + | |
73 | 85 | function topupResponseHandler(body) { |
74 | 86 | logger.info('Got reply from partner', {body: body}); |
75 | 87 | xml2js(body, function(err, result) { |
... | ... | @@ -80,14 +92,15 @@ function topupResponseHandler(body) { |
80 | 92 | |
81 | 93 | var rc = '40'; |
82 | 94 | var message = result.ciwaru.msg[0]; |
95 | + var trxid = result.ciwaru.trxid[0]; | |
83 | 96 | |
84 | - if (message.indexOf('SUKSES') >= 0) { | |
97 | + if (hasSuccessKeywords(message)) { | |
85 | 98 | var sn = getSNFromMessage(result.ciwaru.msg); |
86 | 99 | message = 'SN=' + sn + '; ' + message; |
87 | 100 | rc = '00'; |
88 | 101 | } |
89 | 102 | |
90 | - callbackReport(result.ciwaru.reqnum[0], rc, message); | |
103 | + callbackReport(trxid, rc, message); | |
91 | 104 | }); |
92 | 105 | } |
93 | 106 |