diff --git a/src/transaction/transaction.service.ts b/src/transaction/transaction.service.ts index 76df149..4714ffa 100644 --- a/src/transaction/transaction.service.ts +++ b/src/transaction/transaction.service.ts @@ -1443,10 +1443,19 @@ export class TransactionService { if (callback['message']) { if (callback['message'].includes('METRO')) { + const response = callback['message']; + const responseBaru = response.split('.'); + dataTransaction.failed_reason = `Trx ${product.code} ke ${dataTransaction.destination} gagal. ${responseBaru[1]}`; if (callback['price'] != dataTransaction.product_price.price) { dataTransaction.product_price.price = parseInt(callback['price']); } } + } else if (callback['msg']) { + const response = callback['msg']; + const responseBaru = response.split('.'); + dataTransaction.failed_reason = `Trx ${product.code} ke ${dataTransaction.destination} gagal. ${responseBaru[1]}`; + } else { + dataTransaction.failed_reason = `Trx ${product.code} ke ${dataTransaction.destination} gagal`; } //GET COA @@ -1459,7 +1468,6 @@ export class TransactionService { dataTransaction.status = statusTransaction.FAILED; dataTransaction.callback_json = callback; - dataTransaction.failed_reason = `Trx ${product.code} ke ${dataTransaction.destination} gagal`; dataTransaction.balance_remaining = parseInt(coaAccount.amount.toString()) + parseInt(dataTransaction.amount.toString()); const coaInventory = await this.coaService.findByName( @@ -1509,7 +1517,7 @@ export class TransactionService { } if (userData.partner) { - const message = `Transaksi ${product.code} dengan tujuan ${dataTransaction.destination} telah gagal.`; + const message = dataTransaction.failed_reason; this.callbackToPartner( userData.partner.id,