From 399c6ff9e4d9dddc4a0097af99482b31470ec765 Mon Sep 17 00:00:00 2001 From: Fadli Date: Wed, 7 Sep 2022 01:25:35 +0700 Subject: [PATCH] - revert change for checking if callback already success or failed cannot hit 2 times --- src/transaction/transaction.service.ts | 80 +++++++++++++------------- 1 file changed, 40 insertions(+), 40 deletions(-) diff --git a/src/transaction/transaction.service.ts b/src/transaction/transaction.service.ts index 996cfaf..5176d1b 100644 --- a/src/transaction/transaction.service.ts +++ b/src/transaction/transaction.service.ts @@ -1117,23 +1117,23 @@ export class TransactionService { supplier_trx_id ); - // if (transactionData.status == statusTransaction.FAILED) { - // throw new HttpException( - // { - // statusCode: HttpStatus.BAD_REQUEST, - // error: 'failed to update, the transaction already failed', - // }, - // HttpStatus.BAD_REQUEST, - // ); - // } else if (transactionData.status == statusTransaction.SUCCESS) { - // throw new HttpException( - // { - // statusCode: HttpStatus.BAD_REQUEST, - // error: 'failed to update, the transaction already success', - // }, - // HttpStatus.BAD_REQUEST, - // ); - // } else { + if (transactionData.status == statusTransaction.FAILED) { + throw new HttpException( + { + statusCode: HttpStatus.BAD_REQUEST, + error: 'failed to update, the transaction already failed', + }, + HttpStatus.BAD_REQUEST, + ); + } else if (transactionData.status == statusTransaction.SUCCESS) { + throw new HttpException( + { + statusCode: HttpStatus.BAD_REQUEST, + error: 'failed to update, the transaction already success', + }, + HttpStatus.BAD_REQUEST, + ); + } else { const updateTransaction = await this.callbackOrderFailed( supplier_trx_id, callback, @@ -1148,33 +1148,33 @@ export class TransactionService { HttpStatus.BAD_REQUEST, ); - // } + } } async checkCallbackOrderSuccess(supplier_trx_id: string, callback: any) { - // const transactionData = await this.findDataTransactionBySupplierTrxId( - // supplier_trx_id - // ); - // - // if (transactionData.status == statusTransaction.FAILED) { - // throw new HttpException( - // { - // statusCode: HttpStatus.BAD_REQUEST, - // error: 'failed to update, the transaction already failed', - // }, - // HttpStatus.BAD_REQUEST, - // ); - // } else if (transactionData.status == statusTransaction.SUCCESS) { - // throw new HttpException( - // { - // statusCode: HttpStatus.BAD_REQUEST, - // error: 'failed to update, the transaction already success', - // }, - // HttpStatus.BAD_REQUEST, - // ); - // } else { + const transactionData = await this.findDataTransactionBySupplierTrxId( + supplier_trx_id + ); + + if (transactionData.status == statusTransaction.FAILED) { + throw new HttpException( + { + statusCode: HttpStatus.BAD_REQUEST, + error: 'failed to update, the transaction already failed', + }, + HttpStatus.BAD_REQUEST, + ); + } else if (transactionData.status == statusTransaction.SUCCESS) { + throw new HttpException( + { + statusCode: HttpStatus.BAD_REQUEST, + error: 'failed to update, the transaction already success', + }, + HttpStatus.BAD_REQUEST, + ); + } else { const updateTransaction = await this.callbackOrderSuccess( @@ -1191,7 +1191,7 @@ export class TransactionService { HttpStatus.OK, ); - // } + } }