diff --git a/src/modules/order/providers/order.service.ts b/src/modules/order/providers/order.service.ts index 0473565..a35c597 100644 --- a/src/modules/order/providers/order.service.ts +++ b/src/modules/order/providers/order.service.ts @@ -179,7 +179,7 @@ export class OrderService { orderItem.status = OrderItemStatus.CONFIRMED - this.em.persistAndFlush(OrderItem) + await this.em.persistAndFlush(OrderItem) return orderItem } diff --git a/src/modules/payment/services/payments.service.ts b/src/modules/payment/services/payments.service.ts index 34012d1..96a291c 100644 --- a/src/modules/payment/services/payments.service.ts +++ b/src/modules/payment/services/payments.service.ts @@ -71,11 +71,13 @@ export class PaymentService { throw new BadRequestException("you can not pay beause Balance is zero") } - if (amount <= 0) { throw new BadRequestException(PaymentMessage.AMOUNT_MUST_BE_GREATER_THAN_ZERO); } + if (amount > order.balance) { + throw new BadRequestException(`You cant pay more than ${order.balance}`); + } return { user: order.user,