This commit is contained in:
2026-01-18 18:28:09 +03:30
parent 8db3b8d1ac
commit b1a6af6feb
9 changed files with 222 additions and 192 deletions
@@ -1,25 +1,18 @@
import { Controller, Get, Post, Body, Patch, Param, Delete, UseGuards, Query } from '@nestjs/common';
import {
Controller, Get, Post, Body,
Param,
UseGuards,
} 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';
import { FindPaymentsDto } from '../dto/find-payments.dto';
@ApiTags('payments')
@Controller()
@@ -37,76 +30,38 @@ export class PaymentController {
return this.paymentsService.payOrder(orderId, dto);
}
// @Post('public/payments/verify')
// @ApiOperation({ summary: 'Verify a payment' })
@Post('public/payments/:token/verify/online')
@UseGuards(AuthGuard)
@ApiBearerAuth()
@ApiOperation({ summary: 'Verify online payment' })
verifyOnlinePayment(@Param('paymentId') token: string) {
return this.paymentsService.verifyOnlinePayment(token);
}
// @ApiBody({ type: VerifyPaymentDto })
// @ApiNotFoundResponse({ description: 'Payment not found' })
// verifyPayment(@Body() verifyPaymentDto: VerifyPaymentDto) {
// return this.paymentsService.verifyOnlinePayment(verifyPaymentDto.authority, verifyPaymentDto.orderId);
// }
@ApiBearerAuth()
@Get('admin/payments')
@ApiOperation({ summary: 'get all payments as admin' })
findAllByUser(@UserId() userId: string, @Body() dto: FindPaymentsDto) {
return this.paymentsService.findAllByUser(dto, userId);
}
/*===============Admin=============== */
@Post('admin/payments/:paymentId/verify/cash')
@UseGuards(AuthGuard)
@ApiBearerAuth()
@ApiOperation({ summary: 'Verify cash payment' })
verifyPayment(@Param('paymentId') paymentId: string) {
return this.paymentsService.verifyCashPayment(paymentId);
}
// @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' })
@ApiBearerAuth()
@Get('admin/payments')
@ApiOperation({ summary: 'get all payments as admin' })
findAllPayments(@Body() dto: FindPaymentsDto) {
return this.paymentsService.findAll(dto);
}
}