diff --git a/src/transaction/transaction.service.ts b/src/transaction/transaction.service.ts index 1f53375..804666f 100644 --- a/src/transaction/transaction.service.ts +++ b/src/transaction/transaction.service.ts @@ -444,6 +444,22 @@ export class TransactionService { await this.connection.transaction(async (manager) => { const transactionData = new Transactions(); + const partnerExist = await this.transactionRepository.findOne({ + where: { + partner_trx_id: orderTransactionDto.trx_id, + } + }); + + if (partnerExist) { + throw new HttpException( + { + statusCode: HttpStatus.BAD_REQUEST, + error: 'Previous transaction with the same ID have been made. Please contact administrator for more information.', + }, + HttpStatus.BAD_REQUEST + ); + } + transactionData.id = uuid.v4(); transactionData.amount = product_price.mark_up_price + product_price.price; @@ -778,6 +794,22 @@ export class TransactionService { await this.connection.transaction(async (manager) => { const transactionData = new Transactions(); + const partnerExist = await this.transactionRepository.findOne({ + where: { + partner_trx_id: orderTransactionDto.trx_id, + } + }); + + if (partnerExist) { + throw new HttpException( + { + statusCode: HttpStatus.BAD_REQUEST, + error: 'Previous transaction with the same ID have been made. Please contact administrator for more information.', + }, + HttpStatus.BAD_REQUEST + ); + } + transactionData.id = uuid.v4(); transactionData.amount = product_price.mark_up_price + product_price.price;