From 634f7946e54128f3f3f071de2d683e92f127a791 Mon Sep 17 00:00:00 2001 From: Fadli Date: Wed, 28 Sep 2022 00:54:58 +0700 Subject: [PATCH] - fix check-bill for si hemat --- src/transaction/transaction.service.ts | 97 +++++++++++++++++++------- 1 file changed, 70 insertions(+), 27 deletions(-) diff --git a/src/transaction/transaction.service.ts b/src/transaction/transaction.service.ts index 2865e49..ef82e6d 100644 --- a/src/transaction/transaction.service.ts +++ b/src/transaction/transaction.service.ts @@ -589,16 +589,29 @@ export class TransactionService { }) .join(''); - const hitLoginHemat = await doAuthorizeHemat('wndpt001', '3NHESIJ5', supplier); + let hitLoginHemat; + + if (supplier.code == 'Hemat') { + hitLoginHemat = await doAuthorizeHemat('wndpt001', '3NHESIJ5', supplier); + } + + let hitSupplier = supplier.code == 'Hemat' ? + await doTransaction( + orderTransactionDto.productCode, + orderTransactionDto.destination, + trxId, + supplier, + hitLoginHemat.data, + product.type == 'prepaid' ? 'PURCHASE' : 'PAYMENT', + ) : await doTransaction( + orderTransactionDto.productCode, + orderTransactionDto.destination, + trxId, + supplier, + "", + product.type == 'prepaid' ? 'PURCHASE' : 'PAYMENT', + ); - let hitSupplier = await doTransaction( - orderTransactionDto.productCode, - orderTransactionDto.destination, - trxId, - supplier, - hitLoginHemat.data, - product.type == 'prepaid' ? 'PURCHASE' : 'PAYMENT', - ); // let hitSupplier; console.log('iniresponsupplierharga', hitSupplier) @@ -623,7 +636,7 @@ export class TransactionService { if (orderTransactionDto.bill_trx_id !== null) { hitSupplier.harga = product_price.price; } - } else if (supplier.code == 'hemat') { + } else if (supplier.code == 'Hemat') { const newHitSupplier = { success: hitSupplier.success, harga: product_price.price, @@ -823,16 +836,28 @@ export class TransactionService { }) .join(''); - const hitLoginHemat = await doAuthorizeHemat('wndpt001', '3NHESIJ5', supplier); + let hitLoginHemat; - let hitSupplier = await doTransaction( - orderTransactionDto.productCode, - orderTransactionDto.destination, - trxId, - supplier, - hitLoginHemat.data, - product - ); + if (supplier.code == 'Hemat') { + hitLoginHemat = await doAuthorizeHemat('wndpt001', '3NHESIJ5', supplier); + } + + let hitSupplier = supplier.code == 'Hemat' ? + await doTransaction( + orderTransactionDto.productCode, + orderTransactionDto.destination, + trxId, + supplier, + hitLoginHemat.data, + product.type == 'prepaid' ? 'PURCHASE' : 'PAYMENT', + ) : await doTransaction( + orderTransactionDto.productCode, + orderTransactionDto.destination, + trxId, + supplier, + "", + product.type == 'prepaid' ? 'PURCHASE' : 'PAYMENT', + ); if (supplier.code != 'IRS') { const parsingResponse = hitSupplier.split(' '); @@ -966,23 +991,41 @@ export class TransactionService { let status; try { - const hitLoginHemat = await doAuthorizeHemat('wndpt001', '3NHESIJ5', supplier); - let hitSupplier = await doTransaction( - `CEK${orderTransactionDto.productCode.slice(3)}`, + let hitLoginHemat; + + if (supplier.code == 'Hemat') { + hitLoginHemat = await doAuthorizeHemat('wndpt001', '3NHESIJ5', supplier); + } + + let hitSupplier = supplier.code == 'Hemat' ? await doTransaction( + orderTransactionDto.productCode, orderTransactionDto.destination, trxId, supplier, hitLoginHemat.data, 'INQUIRY' + ) : await doTransaction( + `CEK${orderTransactionDto.productCode.slice(3)}`, + orderTransactionDto.destination, + trxId, + supplier, + "", + 'INQUIRY' ); const parsingResponse = hitSupplier.split(' '); - hitSupplier = { - success: hitSupplier.includes('diproses'), - msg: hitSupplier, - }; - + if (supplier.code == 'Hemat') { + hitSupplier = { + success: hitSupplier.success == true, + msg: hitSupplier.msg, + }; + } else { + hitSupplier = { + success: hitSupplier.includes('diproses'), + msg: hitSupplier, + }; + } if (!hitSupplier.success) { status = statusTransaction[statusTransaction.FAILED]; throw new HttpException(