This commit is contained in:
2025-12-15 15:53:41 +03:30
parent 5ef6ee26dd
commit 3fefb02921
3 changed files with 26 additions and 10 deletions
@@ -35,16 +35,15 @@ export class OrdersService {
) {}
async checkout(userId: string, restaurantId: string) {
console.log('Order created event emitted 000');
const cart = await this.cartService.findOneOrFail(userId, restaurantId);
const { order } = await this.createOrder(userId, restaurantId, cart);
if (!order.paymentMethod) {
throw new BadRequestException('Payment method is required for checkout');
}
// if (!order.paymentMethod) {
// throw new BadRequestException('Payment method is required for checkout');
// }
const { paymentUrl } = await this.paymentsService.startPayment(order.id);
// const { paymentUrl } = await this.paymentsService.startPayment(order.id);
await this.cartService.clearCart(userId, restaurantId);
@@ -57,7 +56,7 @@ export class OrdersService {
// new OrderPaymentSuccessEvent(restaurantId, order.user.id, order.id, order.total),
// );
console.log('Order created event emitted 111');
return { order, paymentUrl };
return { order };
}
async createOrder(userId: string, restaurantId: string, cart: Cart) {