Commit 3e992b49af884188a705350311ef29d1e434f9ba

Authored by Adhidarma Hadiwinoto
1 parent 30c32cde57
Exists in master

getSN

Showing 1 changed file with 13 additions and 0 deletions Side-by-side Diff

partner-trustlink.js
... ... @@ -150,6 +150,9 @@ function directResponseHandler(body, task) {
150 150  
151 151 if (status == '0') {
152 152 if (message.indexOf('SUKSES') >= 0) {
  153 + var sn = getSnFromMessage(message);
  154 + message = 'SN=' + sn + '; ' + message;
  155 +
153 156 response_code = '00';
154 157 }
155 158 else if (message.indexOf('GAGAL') >= 0) {
... ... @@ -178,6 +181,16 @@ function directResponseHandler(body, task) {
178 181 });
179 182 }
180 183  
  184 +function getSnFromMessage(message) {
  185 + try {
  186 + var sn_match = message.match(/SN=(\w+)/);
  187 + return sn_match[1].trim();
  188 + }
  189 + catch(e) {
  190 + return;
  191 + }
  192 +}
  193 +
181 194 exports.start = start;
182 195 exports.topupRequest = topupRequest;
183 196 exports.calculateSignature = calculateSignature;