Commit a258f7014d27aa4cbe8527d91d9c067527dd9028

Authored by Adhidarma Hadiwinoto
1 parent 9bc606946e
Exists in master

reflow

Showing 1 changed file with 28 additions and 17 deletions Side-by-side Diff

partner-bayarkilat.js
... ... @@ -90,34 +90,45 @@ function parseResponse(body, task) {
90 90  
91 91 logger.info('Got response', {response: response});
92 92  
93   - var responseCode = '68';
94   - var message = '';
  93 + var responseCode;
  94 + var message;
  95 + var saldo;
95 96  
96 97 try {
97 98 responseCode = response.xml.response_code[0];
98 99 saldo = response.xml.saldo[0];
99 100 message = response.xml.response_message[0];
100   -
101   - var st24rc = '40';
102   - if (parseInt(responseCode) == 0) {
103   - st24rc = '00';
104   - }
105   - else if (parseInt(responseCode) == '99') {
106   - st24rc = '68'
107   - }
108   - else {
109   - st24rc = '40';
110   - }
111   -
112   - var st24message = responseCode + ' ' + message + '. Saldo ' + saldo;
113   -
114   - callbackReport(task.requestId, st24rc, st24message);
115 101 }
116 102 catch(errGetParam) {
117 103 logger.warn('Exception saat parsing hasil', {error: errGetParam, task: task, responseBody: body});
118 104 callbackReport(task.requestId, '68', 'Exception saat parsing hasil. ' + errGetParam);
  105 + return;
  106 + }
  107 +
  108 + var st24rc;
  109 + if (parseInt(responseCode) == 0) {
  110 + st24rc = '00';
  111 + }
  112 + else if (parseInt(responseCode) == '99') {
  113 + st24rc = '68'
  114 + }
  115 + else {
  116 + st24rc = '40';
119 117 }
120 118  
  119 + var st24message = message;
  120 + if (responseCode) {
  121 + st24message = responseCode + ' ' + st24message;
  122 + }
  123 +
  124 + if (saldo) {
  125 + st24message = st24message + '. Saldo ' + saldo;
  126 + }
  127 +
  128 + callbackReport(task.requestId, st24rc, st24message);
  129 +
  130 +
  131 +
121 132 });
122 133 }
123 134