Commit 883fdb10286513a45ad41b000f234268b254c446

Authored by Adhidarma Hadiwinoto
1 parent 9ab7768236
Exists in master

parsing message utk respon error

Showing 1 changed file with 22 additions and 8 deletions Side-by-side Diff

... ... @@ -99,19 +99,26 @@ function directResponseHandler(body, request_id) {
99 99 if (status === 'failed') {
100 100 response_code = '40';
101 101  
102   - if (message.indexOf('Jenis produk tidak cocok') >= 0) {
103   - response_code = '14';
104   - } else if (message.indexOf('GAGAL. Nomor telp salah.') >= 0) {
105   - response_code = '14';
106   - } else if (message.indexOf('GAGAL. MSISDN tidak ditemukan') >= 0) {
107   - response_code = '14';
  102 + var new_response_code = responseCodeFromMessage(message);
  103 + if (new_response_code) {
  104 + response_code = new_response_code;
108 105 }
109 106  
110 107 }
111 108  
112 109 callbackReport(request_id, response_code, message);
113 110 });
114   -
  111 +}
  112 +
  113 +function responseCodeFromMessage(message) {
  114 + if (message.indexOf('Jenis produk tidak cocok') >= 0) {
  115 + return '14';
  116 + } else if (message.indexOf('GAGAL. Nomor telp salah.') >= 0) {
  117 + return '14';
  118 + } else if (message.indexOf('GAGAL. MSISDN tidak ditemukan') >= 0) {
  119 + return '14';
  120 + }
  121 + return;
115 122 }
116 123  
117 124 function createServer() {
... ... @@ -138,7 +145,14 @@ function createServer() {
138 145 } else if (qs.code == 4) {
139 146 response_code = '00';
140 147 message = 'SN=' + qs.sn + ';' + message;
141   - }
  148 + }
  149 +
  150 + if (respose_code == '40') {
  151 + var new_response_code = responseCodeFromMessage(message);
  152 + if (new_response_code) {
  153 + response_code = new_response_code;
  154 + }
  155 + }
142 156  
143 157 callbackReport(request_id, response_code, message);
144 158 });