chore: add payment module
This commit is contained in:
@@ -1,4 +1,42 @@
|
||||
import { Controller } from "@nestjs/common";
|
||||
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")
|
||||
export class PaymentsController {}
|
||||
@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);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user