Files
dzone-api/src/modules/payments/payments.controller.ts
T
2025-05-20 16:25:49 +03:30

43 lines
1.6 KiB
TypeScript

import { Body, Controller, Get, Param, Post, Query, Res } from "@nestjs/common";
import { ApiOperation, ApiTags } from "@nestjs/swagger";
import { FastifyReply } from "fastify";
import { CheckoutPaymentDto } from "./DTO/checkout-payment.dto";
import { VerifyParamDto, VerifyQueryDto } from "./DTO/verify-payment.dto";
import { PaymentsService } from "./services/payments.service";
import { AuthGuards } from "../../common/decorators/auth-guard.decorator";
import { UserDec } from "../../common/decorators/user.decorator";
import { PaginationDto } from "../../common/DTO/pagination.dto";
@Controller("payments")
@ApiTags("Payments")
export class PaymentsController {
constructor(private readonly paymentsService: PaymentsService) {}
@AuthGuards()
@ApiOperation({ summary: "get all available gateways" })
@Get("gateways")
getAvailableGateways() {
return this.paymentsService.getAvailableGateways();
}
@ApiOperation({ summary: "Charge wallet ==> user route" })
@AuthGuards()
@Post("checkout")
checkoutPayment(@Body() checkoutDto: CheckoutPaymentDto, @UserDec("id") userId: string) {
return this.paymentsService.checkoutPayment(checkoutDto, userId);
}
@ApiOperation({ summary: "get deposit gateway payment ==> admin route" })
@AuthGuards()
@Get("checkout/gateway")
getDepositGatewayPayment(@Query() queryDto: PaginationDto) {
return this.paymentsService.getDepositGatewayPayment(queryDto);
}
@Get("verify/:gateway")
verifyPayments(@Param() paramDto: VerifyParamDto, @Query() queryDto: VerifyQueryDto, @Res({ passthrough: true }) rep: FastifyReply) {
return this.paymentsService.verifyPayment(paramDto, queryDto, rep);
}
}