add: check unique trx id error

This commit is contained in:
wdhanadipa 2023-12-15 13:32:33 +07:00
parent e58d359cae
commit b3013eb2f2

View File

@ -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;