diff --git a/application/modules/hsm/topupResp.js b/application/modules/hsm/topupResp.js index 4d1de61..9dd5d60 100644 --- a/application/modules/hsm/topupResp.js +++ b/application/modules/hsm/topupResp.js @@ -206,18 +206,33 @@ const controller = async (req, res) => { ); // update data load balance - await loadBalance.loadingBalanceUpdate(data); - - result = { - code: '5002', - message: 'failed from HSM', - data: { - trxID: generate.buf2hex(transactionId), - responseCode: respData1.slice(6, 10), - transcode: null, - load_balance_number: update.data.load_balance_number, - }, - }; + let update = await loadBalance.loadingBalanceUpdate(data); + if (update) { + if (update.code == '00') { + result = { + code: '5002', + message: 'failed from HSM', + data: { + trxID: generate.buf2hex(transactionId), + responseCode: respData1.slice(6, 10), + transcode: null, + load_balance_number: update.data.load_balance_number, + }, + }; + } else { + result = { + code: update.code, + message: update.message, + data: {}, + }; + } + } else { + result = { + code: '423', + message: 'update/insert failed', + data: {}, + }; + } } else { // jika sudah mencapai maksimum counting flag, maka reset flag ke awal if (flag >= 255) {