payment permission

This commit is contained in:
2026-02-01 12:41:50 +03:30
parent f452fa0d11
commit 918d774cad
@@ -17,79 +17,80 @@ import { PayOrderDto } from '../dto/pay-order.dto';
import { FindPaymentsDto } from '../dto/find-payments.dto';
import { AdminAuthGuard } from 'src/modules/auth/guards/adminAuth.guard';
import { AdminId } from 'src/common/decorators/admin-id.decorator';
import { Permissions } from 'src/common/decorators/permissions.decorator';
import { Permission } from 'src/common/enums/permission.enum';
@ApiTags('payment')
@ApiBearerAuth()
@Controller()
export class PaymentController {
constructor(
private readonly paymentsService: PaymentService,
private readonly paymentService: PaymentService,
) { }
@Post('public/payments/pay-order/:orderId')
@Post('public/payments/order/:id/pay')
@UseGuards(AuthGuard)
@ApiBearerAuth()
@ApiOperation({ summary: 'Pay for an order' })
payAnOrder(@Param('orderId') orderId: string, @Body() dto: PayOrderDto) {
return this.paymentsService.payOrder(orderId, dto);
payAnOrder(@Param('id') orderId: string, @Body() dto: PayOrderDto) {
return this.paymentService.payOrder(orderId, dto);
}
@Post('public/payments/:token/verify/online')
@Post('public/payments/online/:token/verify')
@UseGuards(AuthGuard)
@ApiBearerAuth()
@ApiOperation({ summary: 'Verify online payment' })
verifyOnlinePayment(@Param('paymentId') token: string) {
return this.paymentsService.verifyOnlinePayment(token);
return this.paymentService.verifyOnlinePayment(token);
}
@ApiBearerAuth()
@Get('public/payments')
@ApiOperation({ summary: 'get all payments as user' })
findAllByUser(@UserId() userId: string, @Query() dto: FindPaymentsDto) {
return this.paymentsService.findAllByUser(dto, userId);
return this.paymentService.findAllByUser(dto, userId);
}
/*=============== Admin =============== */
@Post('admin/payments/pay-order/:orderId')
@Post('admin/payments/order/:id/pay')
@UseGuards(AdminAuthGuard)
@ApiBearerAuth()
@Permissions(Permission.MANAGE_PAYMENTS)
@ApiOperation({ summary: 'Pay for an order as Admin' })
payOrderAsAdmin(@Param('orderId') orderId: string, @AdminId() adminId: string, @Body() dto: PayOrderDto) {
return this.paymentsService.payOrder(orderId, dto, adminId);
return this.paymentService.payOrder(orderId, dto, adminId);
}
@Post('admin/payments/:token/verify/online')
@Post('admin/payments/online/:token/verify')
@UseGuards(AdminAuthGuard)
@ApiBearerAuth()
@Permissions(Permission.MANAGE_PAYMENTS)
@ApiOperation({ summary: 'Verify online payment as admin' })
verifyOnlinePaymentAsAdmin(@Param('paymentId') token: string) {
return this.paymentsService.verifyOnlinePayment(token);
return this.paymentService.verifyOnlinePayment(token);
}
@Post('admin/payments/:paymentId/verify/cash')
@UseGuards(AuthGuard)
@ApiBearerAuth()
@Post('admin/payments/:paymentId/cash/verify')
@UseGuards(AdminAuthGuard)
@Permissions(Permission.MANAGE_PAYMENTS)
@ApiOperation({ summary: 'Verify cash payment' })
confirmPayment(@Param('paymentId') paymentId: string) {
return this.paymentsService.confirmCashPayment(paymentId);
return this.paymentService.confirmCashPayment(paymentId);
}
@Delete('admin/payments/:paymentId/verify/cash')
@UseGuards(AuthGuard)
@ApiBearerAuth()
@Delete('admin/payments/:paymentId/cash/deny')
@UseGuards(AdminAuthGuard)
@Permissions(Permission.MANAGE_PAYMENTS)
@ApiOperation({ summary: 'Deny cash payment' })
denyPayment(@Param('paymentId') paymentId: string) {
return this.paymentsService.denyCashPayment(paymentId);
return this.paymentService.denyCashPayment(paymentId);
}
// @UseGuards(AdminAuthGuard)
// @Permissions(Permission.MANAGE_PAYMENTS)
@ApiBearerAuth()
@Get('admin/payments')
@UseGuards(AdminAuthGuard)
@Permissions(Permission.MANAGE_PAYMENTS)
@ApiOperation({ summary: 'get all payments as admin' })
findAllPayments(@Body() dto: FindPaymentsDto) {
return this.paymentsService.findAll(dto);
return this.paymentService.findAll(dto);
}
}