add: check unique trx id error
This commit is contained in:
parent
e58d359cae
commit
b3013eb2f2
|
@ -444,6 +444,22 @@ export class TransactionService {
|
||||||
await this.connection.transaction(async (manager) => {
|
await this.connection.transaction(async (manager) => {
|
||||||
const transactionData = new Transactions();
|
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.id = uuid.v4();
|
||||||
transactionData.amount =
|
transactionData.amount =
|
||||||
product_price.mark_up_price + product_price.price;
|
product_price.mark_up_price + product_price.price;
|
||||||
|
@ -778,6 +794,22 @@ export class TransactionService {
|
||||||
await this.connection.transaction(async (manager) => {
|
await this.connection.transaction(async (manager) => {
|
||||||
const transactionData = new Transactions();
|
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.id = uuid.v4();
|
||||||
transactionData.amount =
|
transactionData.amount =
|
||||||
product_price.mark_up_price + product_price.price;
|
product_price.mark_up_price + product_price.price;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user