Commit 00fd3da335c0d770b233c353ce5990bf9076e0af

Authored by Adhidarma Hadiwinoto
1 parent 356e544bcc
Exists in master

Penanganan missing params pada response

Showing 1 changed file with 23 additions and 2 deletions Side-by-side Diff

... ... @@ -23,7 +23,7 @@ module.exports = (xid, trxIdFromCaller, xml, isCallback) => {
23 23  
24 24 if (trxIdFromCaller) {
25 25 report(xid, {
26   - trx_id: trxIdFromCaller,
  26 + trx_id: trxIdFromCaller.toString(),
27 27 rc: '68',
28 28 message: {
29 29 xid,
... ... @@ -38,6 +38,27 @@ module.exports = (xid, trxIdFromCaller, xml, isCallback) => {
38 38 }
39 39  
40 40 const params = getParamsMemberObj(obj, false);
  41 +
  42 + if (!params) {
  43 + const e = new Error(`${MODULE_NAME} A7B7EB30: Can not get params from message`);
  44 + logger.warn(e.message, { xid });
  45 +
  46 + if (trxIdFromCaller) {
  47 + report(xid, {
  48 + trx_id: trxIdFromCaller.toString(),
  49 + rc: '68',
  50 + message: {
  51 + xid,
  52 + responseType: isCallback ? 'CALLBACK' : 'DIRECT-RESPONSE',
  53 + 'GW-ERROR': {
  54 + message: e.message,
  55 + response: obj,
  56 + },
  57 + },
  58 + });
  59 + }
  60 + }
  61 +
41 62 logger.verbose(`${MODULE_NAME} 3D5400C1: Params extracted from response`, { xid, params });
42 63  
43 64 const requestIdField = (config.partner.xmlrpc_field && config.partner.xmlrpc_field.requestId) || 'REQUESTID';
... ... @@ -63,7 +84,7 @@ module.exports = (xid, trxIdFromCaller, xml, isCallback) => {
63 84 const sn = (rc === '00' && snFromResponse) || null;
64 85  
65 86 report(xid, {
66   - trx_id: trxId,
  87 + trx_id: trxId.toString(),
67 88 rc,
68 89 sn,
69 90 message: {