update order only if status is pending_payment
This commit is contained in:
@@ -239,7 +239,9 @@ export class PaymentsService {
|
|||||||
if (payment.status === PaymentStatusEnum.Paid) {
|
if (payment.status === PaymentStatusEnum.Paid) {
|
||||||
throw new BadRequestException(PaymentMessage.PAYMENT_ALREADY_PAID);
|
throw new BadRequestException(PaymentMessage.PAYMENT_ALREADY_PAID);
|
||||||
}
|
}
|
||||||
payment.order.status = OrderStatus.PAID;
|
if(payment.order.status === OrderStatus.PENDING_PAYMENT) {
|
||||||
|
payment.order.status = OrderStatus.PAID;
|
||||||
|
}
|
||||||
payment.status = PaymentStatusEnum.Paid;
|
payment.status = PaymentStatusEnum.Paid;
|
||||||
payment.paidAt = new Date();
|
payment.paidAt = new Date();
|
||||||
em.persist(payment);
|
em.persist(payment);
|
||||||
@@ -262,9 +264,6 @@ export class PaymentsService {
|
|||||||
payment.order.status = OrderStatus.CANCELED;
|
payment.order.status = OrderStatus.CANCELED;
|
||||||
}
|
}
|
||||||
|
|
||||||
private markAsPaid(order: Order) {
|
|
||||||
order.status = OrderStatus.PAID;
|
|
||||||
}
|
|
||||||
|
|
||||||
private async getOrCreateLatestPendingPayment(
|
private async getOrCreateLatestPendingPayment(
|
||||||
orderId: string,
|
orderId: string,
|
||||||
|
|||||||
Reference in New Issue
Block a user