This commit is contained in:
2026-01-18 17:28:53 +03:30
parent a10b6129b9
commit 8db3b8d1ac
8 changed files with 55 additions and 97 deletions
@@ -0,0 +1,112 @@
import { Controller, Get, Post, Body, Patch, Param, Delete, UseGuards, Query } from '@nestjs/common';
import { PaymentService } from '../services/payments.service';
import {
ApiTags,
ApiOperation,
ApiNotFoundResponse,
ApiBody,
ApiParam,
ApiBearerAuth,
ApiHeader,
} from '@nestjs/swagger';
import { AdminAuthGuard } from 'src/modules/auth/guards/adminAuth.guard';
import { CreatePaymentMethodDto } from '../dto/create-payment-method.dto';
import { UpdatePaymentMethodDto } from '../dto/update-payment-method.dto';
import { VerifyPaymentDto } from '../dto/verify-payment.dto';
import { PaymentChartDto } from '../dto/payment-chart.dto';
import { UserId } from 'src/common/decorators';
import { AuthGuard } from 'src/modules/auth/guards/auth.guard';
import { Permissions } from 'src/common/decorators/permissions.decorator';
import { Permission } from 'src/common/enums/permission.enum';
import { PayOrderDto } from '../dto/pay-order.dto';
@ApiTags('payments')
@Controller()
export class PaymentController {
constructor(
private readonly paymentsService: PaymentService,
) { }
@Get('public/payments/pay-order/:orderId')
@UseGuards(AuthGuard)
@ApiBearerAuth()
@ApiOperation({ summary: 'Pay for an order' })
payAnOrder(@Param('orderId') orderId: string, @Body() dto: PayOrderDto) {
return this.paymentsService.payOrder(orderId, dto);
}
// @Post('public/payments/verify')
// @ApiOperation({ summary: 'Verify a payment' })
// @ApiBody({ type: VerifyPaymentDto })
// @ApiNotFoundResponse({ description: 'Payment not found' })
// verifyPayment(@Body() verifyPaymentDto: VerifyPaymentDto) {
// return this.paymentsService.verifyOnlinePayment(verifyPaymentDto.authority, verifyPaymentDto.orderId);
// }
// @UseGuards(AdminAuthGuard)
// @Permissions(Permission.MANAGE_PAYMENTS)
// @ApiBearerAuth()
// @Post('admin/payments/methods')
// @ApiOperation({ summary: 'Create a new restaurant payment method' })
// @ApiBody({ type: CreatePaymentMethodDto })
// createRestaurantPaymentMethod( @Body() createPaymentMethodDto: CreatePaymentMethodDto) {
// return this.paymentMethodService.create( createPaymentMethodDto);
// }
// @UseGuards(AdminAuthGuard)
// @Permissions(Permission.MANAGE_PAYMENTS)
// @ApiBearerAuth()
// @Get('admin/payments/methods/:paymentMethodId')
// @ApiOperation({ summary: 'Get restaurant payment method by ID' })
// @ApiParam({ name: 'paymentMethodId', type: 'string', description: 'Payment method ID' })
// findOneRestaurantPaymentMethod(@Param('paymentMethodId') paymentMethodId: string) {
// return this.paymentMethodService.findOne(paymentMethodId);
// }
// @UseGuards(AdminAuthGuard)
// @Permissions(Permission.MANAGE_PAYMENTS)
// @ApiBearerAuth()
// @Patch('admin/payments/methods/:paymentMethodId')
// @ApiOperation({ summary: 'Update a restaurant payment method' })
// @ApiParam({ name: 'paymentMethodId', type: 'string', description: 'Payment method ID' })
// @ApiBody({ type: UpdatePaymentMethodDto })
// updateRestaurantPaymentMethod(
// @Param('paymentMethodId') paymentMethodId: string,
// @Body() updatePaymentMethodDto: UpdatePaymentMethodDto,
// ) {
// return this.paymentMethodService.update(paymentMethodId, updatePaymentMethodDto);
// }
// @UseGuards(AdminAuthGuard)
// @Permissions(Permission.MANAGE_PAYMENTS)
// @ApiBearerAuth()
// @Delete('admin/payments/methods/:paymentMethodId')
// @ApiOperation({ summary: 'Delete a restaurant payment method' })
// @ApiParam({ name: 'paymentMethodId', type: 'string', description: 'Payment method ID' })
// removeRestaurantPaymentMethod(@Param('paymentMethodId') paymentMethodId: string) {
// return this.paymentMethodService.remove(paymentMethodId);
// }
// @UseGuards(AdminAuthGuard)
// @Permissions(Permission.MANAGE_PAYMENTS)
// @ApiBearerAuth()
// @Post('admin/payments/verify-cash-method/:paymentId')
// @ApiOperation({ summary: 'Verify cash payment ' })
// @ApiParam({ name: 'paymentId', type: 'string', description: 'Payment ID' })
// verifyCashPayment(@Param('paymentId') paymentId: string) {
// return this.paymentsService.verifyCashPayment(paymentId);
// }
// @UseGuards(AdminAuthGuard)
// @Permissions(Permission.VIEW_REPORTS)
// @ApiBearerAuth()
// @Get('admin/payments/chart')
// @ApiOperation({ summary: 'Get payment chart data with date and period filters' })
}