course_web01 / backend /src /payment /payment.controller.ts
trae-bot
Fix all linting errors in frontend and backend
8268e91
import { Controller, Post, Body, UseGuards, Request } from '@nestjs/common';
import { PaymentService } from './payment.service';
import { PreparePaymentDto } from './dto/prepare-payment.dto';
import { JwtAuthGuard } from '../auth/guards/jwt-auth.guard';
@Controller('api/payment')
export class PaymentController {
constructor(private readonly paymentService: PaymentService) {}
@UseGuards(JwtAuthGuard)
@Post('prepare')
async prepare(@Request() req, @Body() preparePaymentDto: PreparePaymentDto) {
const data = await this.paymentService.prepare(
req.user.userId,
preparePaymentDto,
);
return { success: true, data };
}
// Webhook for testing
@Post('callback')
async callback(
@Body() body: { paymentNo: string; status: 'SUCCESS' | 'FAILED' },
) {
const data = await this.paymentService.handleCallback(
body.paymentNo,
body.status,
);
return data;
}
}