AnhLedger's picture
change amount in payment service
494e1c4
// payment.controller.ts
import { Controller, Post, Body, Req, Res, Get } from '@nestjs/common';
import { PaymentService } from './payment.service.js';
import { Request, Response } from 'express';
import { Public } from '../modules/authentication/authentication.decorator.js';
import { CreatePaymentUrlDto } from './dto/create-payment-url.dto.js';
@Controller('payment')
export class PaymentController {
constructor(private readonly paymentService: PaymentService) {}
@Public()
@Post('create_payment_url')
async createPaymentUrl(@Req() req: Request, @Body() body: CreatePaymentUrlDto) {
const ipAddr =
req.headers['x-forwarded-for'] ||
req.socket.remoteAddress ||
req.socket?.remoteAddress;
return await this.paymentService.createPaymentUrl(
body.amount,
body.orderId,
body.orderDescription,
body.orderType,
body.language,
ipAddr as string,
);
}
@Public()
@Get('vnpay_ipn')
async vnpayIpn(@Req() req: Request, @Body() body: any){
const reqQuery = req.query;
const res = await this.paymentService.vnpayIpn(reqQuery)
console.log(res);
return res;
}
}