Commit f3b5c6324b8dac1e61cdffe05242fadcd2acb464
1 parent
e910d789c0
Exists in
master
parsing hasil
Showing 1 changed file with 17 additions and 3 deletions Side-by-side Diff
partner-cjk.js
... | ... | @@ -61,8 +61,13 @@ function createXmlPayload(params) { |
61 | 61 | } |
62 | 62 | |
63 | 63 | function getSNFromMessage(message) { |
64 | - var sn_match = message.match(/SN (\w+) /); | |
65 | - return sn_match[1]; | |
64 | + try { | |
65 | + var sn_match = message.match(/SN (\w+) /); | |
66 | + return sn_match[1]; | |
67 | + } | |
68 | + catch(err) { | |
69 | + return ''; | |
70 | + } | |
66 | 71 | } |
67 | 72 | |
68 | 73 | function topupResponseHandler(body) { |
... | ... | @@ -73,7 +78,16 @@ function topupResponseHandler(body) { |
73 | 78 | } |
74 | 79 | logger.info('XML message from partner', {result: result}); |
75 | 80 | |
76 | - console.log('XML fields', {rc: result.ciwaru.rc}); | |
81 | + var rc = '40'; | |
82 | + var message = result.ciwaru.msg[0]; | |
83 | + | |
84 | + if (message.indexOf('SUKSES')) { | |
85 | + var sn = getSNFromMessage(result.ciwaru.msg); | |
86 | + message = 'SN=' + sn + '; ' + message; | |
87 | + rc = '00'; | |
88 | + } | |
89 | + | |
90 | + callbackReport(result.ciwaru.reqnum, rc, message); | |
77 | 91 | }); |
78 | 92 | } |
79 | 93 |