diff --git a/src/app.ts b/src/app.ts index dd46728..3303a31 100644 --- a/src/app.ts +++ b/src/app.ts @@ -133,6 +133,7 @@ class App { * configure body parser */ app.use(express.json()); + app.use(express.urlencoded({ extended: true })); /** * configure morgan for http logging diff --git a/src/modules/payment/DTO/verifyOnlinePayment.dto.ts b/src/modules/payment/DTO/verifyOnlinePayment.dto.ts index 86d7f71..62f8211 100644 --- a/src/modules/payment/DTO/verifyOnlinePayment.dto.ts +++ b/src/modules/payment/DTO/verifyOnlinePayment.dto.ts @@ -1,14 +1,68 @@ +import { Expose } from "class-transformer"; +import { IsNotEmpty, IsString } from "class-validator"; + +import { ApiProperty } from "../../../common/decorator/swggerDocs"; + export class VerifyOnlinePaymentDTO { + @Expose() + @IsString() + @ApiProperty({ type: "string", description: "Merchant ID", example: "123456789" }) MID: string; + + @Expose() + @IsString() + @ApiProperty({ type: "string", description: "Transaction state", example: "OK" }) State: string; + + @Expose() + @IsNotEmpty() + @IsString() + @ApiProperty({ type: "string", description: "Transaction status", example: "OK" }) Status: string; + + @Expose() + @IsString() + @ApiProperty({ type: "string", description: "Retrieval Reference Number", example: "123456789012" }) RRN: string; + + @Expose() + @IsNotEmpty() + @IsString() + @ApiProperty({ type: "string", description: "Reference number", example: "123456789012" }) RefNum: string; + + @Expose() + @IsString() + @ApiProperty({ type: "string", description: "Reservation number", example: "123456" }) ResNum: string; + + @Expose() + @IsString() + @ApiProperty({ type: "string", description: "Terminal ID", example: "12345678" }) TerminalId: string; + + @Expose() + @IsString() + @ApiProperty({ type: "string", description: "Trace number", example: "123456" }) TraceNo: string; + + @Expose() + @IsString() + @ApiProperty({ type: "string", description: "Transaction amount", example: "10000" }) Amount: string; + + @Expose() + @IsString() + @ApiProperty({ type: "string", description: "Transaction wage", example: "0" }) Wage: string; + + @Expose() + @IsString() + @ApiProperty({ type: "string", description: "Secure PAN", example: "123456******7890" }) SecurePan: string; + + @Expose() + @IsString() + @ApiProperty({ type: "string", description: "Hashed card number", example: "hashed_value" }) HashedCardNumber: string; } diff --git a/src/modules/payment/payment.controller.ts b/src/modules/payment/payment.controller.ts index 27a91c9..01af650 100644 --- a/src/modules/payment/payment.controller.ts +++ b/src/modules/payment/payment.controller.ts @@ -12,6 +12,7 @@ import { BaseController } from "../../common/base/controller"; import { ApiAuth, ApiModel, ApiOperation, ApiParam, ApiQuery, ApiResponse, ApiTags } from "../../common/decorator/swggerDocs"; import { GatewayProvider } from "../../common/enums/payment.enum"; import { Guard } from "../../core/middlewares/guard.middleware"; +import { ValidationMiddleware } from "../../core/middlewares/validator.middleware"; import { IOCTYPES } from "../../IOC/ioc.types"; import { verifyPaymentTemplate } from "../../template/payment"; import { verifyPRPaymentTemplate } from "../../template/PRPayment"; @@ -110,7 +111,7 @@ class PaymentController extends BaseController { @ApiOperation("verify a payment for current session user for cartCheckout (method post for SEP)") @ApiResponse("successful", HttpStatus.Ok) @ApiParam("gateway", "the name of api gateway", true) - @httpPost("/verify/:gateway/cart") + @httpPost("/verify/:gateway/cart", ValidationMiddleware.validateInput(VerifyOnlinePaymentDTO)) public async VerifyCartCheckoutPost( @requestParam("gateway") gateway: string, @response() res: Response,