From 00fd3da335c0d770b233c353ce5990bf9076e0af Mon Sep 17 00:00:00 2001 From: Adhidarma Hadiwinoto <adhisimon@gmail.com> Date: Fri, 2 Jul 2021 18:03:24 +0700 Subject: [PATCH] Penanganan missing params pada response --- lib/parse-result.js | 25 +++++++++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/lib/parse-result.js b/lib/parse-result.js index 5a988cf..ad7ce6a 100644 --- a/lib/parse-result.js +++ b/lib/parse-result.js @@ -23,7 +23,7 @@ module.exports = (xid, trxIdFromCaller, xml, isCallback) => { if (trxIdFromCaller) { report(xid, { - trx_id: trxIdFromCaller, + trx_id: trxIdFromCaller.toString(), rc: '68', message: { xid, @@ -38,6 +38,27 @@ module.exports = (xid, trxIdFromCaller, xml, isCallback) => { } const params = getParamsMemberObj(obj, false); + + if (!params) { + const e = new Error(`${MODULE_NAME} A7B7EB30: Can not get params from message`); + logger.warn(e.message, { xid }); + + if (trxIdFromCaller) { + report(xid, { + trx_id: trxIdFromCaller.toString(), + rc: '68', + message: { + xid, + responseType: isCallback ? 'CALLBACK' : 'DIRECT-RESPONSE', + 'GW-ERROR': { + message: e.message, + response: obj, + }, + }, + }); + } + } + logger.verbose(`${MODULE_NAME} 3D5400C1: Params extracted from response`, { xid, params }); const requestIdField = (config.partner.xmlrpc_field && config.partner.xmlrpc_field.requestId) || 'REQUESTID'; @@ -63,7 +84,7 @@ module.exports = (xid, trxIdFromCaller, xml, isCallback) => { const sn = (rc === '00' && snFromResponse) || null; report(xid, { - trx_id: trxId, + trx_id: trxId.toString(), rc, sn, message: { -- 1.9.0