Commit 3f0ff9875de535f30a3f513369d37724d2cddda9
1 parent
22e8136644
Exists in
master
getHarga dan getSaldo
Showing 1 changed file with 26 additions and 2 deletions Side-by-side Diff
partner-bayarkilat.js
... | ... | @@ -88,6 +88,26 @@ function getSn(response) { |
88 | 88 | } |
89 | 89 | } |
90 | 90 | |
91 | +function getHarga(response) { | |
92 | + try { | |
93 | + var harga = response.xml.amount[0]; | |
94 | + return harga; | |
95 | + } | |
96 | + catch (err) { | |
97 | + return; | |
98 | + } | |
99 | +} | |
100 | + | |
101 | +function getSaldo(response) { | |
102 | + try { | |
103 | + var saldo = response.xml.saldo[0]; | |
104 | + return saldo; | |
105 | + } | |
106 | + catch (err) { | |
107 | + return; | |
108 | + } | |
109 | +} | |
110 | + | |
91 | 111 | function parseResponse(body, task) { |
92 | 112 | xml2jsParser(body, function(err, response) { |
93 | 113 | if (err) { |
... | ... | @@ -111,11 +131,9 @@ function parseResponse(body, task) { |
111 | 131 | |
112 | 132 | var responseCode; |
113 | 133 | var message; |
114 | - var saldo; | |
115 | 134 | |
116 | 135 | try { |
117 | 136 | responseCode = response.xml.response_code[0]; |
118 | - saldo = response.xml.saldo[0]; | |
119 | 137 | message = response.xml.response_message[0]; |
120 | 138 | } |
121 | 139 | catch(errGetParam) { |
... | ... | @@ -158,6 +176,12 @@ function parseResponse(body, task) { |
158 | 176 | } |
159 | 177 | } |
160 | 178 | |
179 | + var harga = getHarga(response); | |
180 | + if (harga) { | |
181 | + st24message = st24message + '. Harga ' + harga; | |
182 | + } | |
183 | + | |
184 | + var saldo = getSaldo(response); | |
161 | 185 | if (saldo) { |
162 | 186 | st24message = st24message + '. Saldo ' + saldo; |
163 | 187 | aaa.updateBalance(saldo); |