Commit 520954cddcd104b98080917a966e3b79986a4c88
1 parent
d56473046f
Exists in
master
rc st24
Showing 1 changed file with 20 additions and 5 deletions Side-by-side Diff
partner-cjk.js
... | ... | @@ -82,6 +82,19 @@ function hasSuccessKeywords(message) { |
82 | 82 | return false; |
83 | 83 | } |
84 | 84 | |
85 | +function supplierRcToST24Rc(rc) { | |
86 | + var rcs = { | |
87 | + '0001': '40', | |
88 | + '0019': '51', | |
89 | + } | |
90 | + | |
91 | + if (rcs[rc]) { | |
92 | + return rcs[rc]; | |
93 | + } else { | |
94 | + return; | |
95 | + } | |
96 | +} | |
97 | + | |
85 | 98 | function topupResponseHandler(body) { |
86 | 99 | //logger.info('Got reply from partner', {body: body}); |
87 | 100 | xml2js(body, function(err, result) { |
... | ... | @@ -90,7 +103,7 @@ function topupResponseHandler(body) { |
90 | 103 | } |
91 | 104 | logger.info('XML message from partner', {result: result}); |
92 | 105 | |
93 | - var rc = '40'; | |
106 | + var rc = '68'; | |
94 | 107 | var message = result.ciwaru.msg[0]; |
95 | 108 | |
96 | 109 | var trxid = 0; |
... | ... | @@ -101,13 +114,15 @@ function topupResponseHandler(body) { |
101 | 114 | trxid = result.ciwaru.trxid[0]; |
102 | 115 | } |
103 | 116 | |
104 | - if (hasSuccessKeywords(message)) { | |
117 | + if (message.indexOf('PENDING') >= 0) { | |
118 | + rc = '68'; | |
119 | + } | |
120 | + else if (hasSuccessKeywords(message)) { | |
105 | 121 | var sn = getSNFromMessage(result.ciwaru.msg); |
106 | 122 | message = 'SN=' + sn + '; ' + message; |
107 | 123 | rc = '00'; |
108 | - } | |
109 | - else if (message.indexOf('PENDING') >= 0) { | |
110 | - rc = '68'; | |
124 | + } else { | |
125 | + rc = supplierRcToST24Rc(result.ciwaru.rc[0]); | |
111 | 126 | } |
112 | 127 | |
113 | 128 | callbackReport(trxid, rc, message); |