remove reservation table
This commit is contained in:
@@ -1,20 +0,0 @@
|
||||
import { BadRequestException, Injectable } from '@nestjs/common';
|
||||
import { PaymentGatewayEnum } from '../interface/payment';
|
||||
import { ZarinpalGateway } from '../gateways/zarinpal.gateway';
|
||||
import { IPaymentGateway } from '../interface/gateway';
|
||||
|
||||
@Injectable()
|
||||
export class GatewayManager {
|
||||
constructor(
|
||||
private readonly zarinpal: ZarinpalGateway,
|
||||
) { }
|
||||
|
||||
get(gateway: PaymentGatewayEnum): IPaymentGateway {
|
||||
switch (gateway) {
|
||||
case PaymentGatewayEnum.ZarinPal:
|
||||
return this.zarinpal;
|
||||
default:
|
||||
throw new BadRequestException(`Unsupported gateway: ${gateway}`);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -4,7 +4,7 @@ import { Payment } from '../entities/payment.entity';
|
||||
import { EntityManager } from '@mikro-orm/postgresql';
|
||||
import { Order } from '../../orders/entities/order.entity';
|
||||
import { Logger } from '@nestjs/common';
|
||||
import { GatewayManager } from './gateway.manager';
|
||||
import { GatewayManager } from '../gateways/gateway.manager';
|
||||
import { UserWallet } from 'src/modules/users/entities/user-wallet.entity';
|
||||
import { OrderPaymentContext } from '../interface/payment';
|
||||
import { InventoryService } from 'src/modules/inventory/inventory.service';
|
||||
@@ -209,8 +209,7 @@ export class PaymentsService {
|
||||
}
|
||||
this.markPaid(payment);
|
||||
this.confirmOrder(payment.order);
|
||||
await this.confirmStock(orderId, em);
|
||||
|
||||
|
||||
await em.flush();
|
||||
return payment;
|
||||
});
|
||||
@@ -241,9 +240,7 @@ export class PaymentsService {
|
||||
order.status = OrderStatus.PAID;
|
||||
}
|
||||
|
||||
private async confirmStock(orderId: string, em: EntityManager) {
|
||||
await this.inventoryService.confirmReservationByOrderId(em, orderId);
|
||||
}
|
||||
|
||||
|
||||
|
||||
private async getOrCreateLatestPendingPayment(
|
||||
|
||||
Reference in New Issue
Block a user