| 1234567891011121314151617181920212223242526272829303132333435363738394041 |
- import {
- Controller,
- Post,
- Body,
- UseGuards,
- Request,
- Logger,
- } from '@nestjs/common';
- import { JwtAuthGuard } from 'src/common/guards/jwt-auth.guard';
- import { PaymentPayload } from 'src/interface/interface';
- import { PaymentService } from 'src/services/payment.service';
- @Controller('payment')
- export class PaymentController {
- private logger: Logger = new Logger(`Payment Controller`)
- private service: PaymentService
- constructor(attendanceService: PaymentService) {
- this.service = attendanceService
- }
- @UseGuards(JwtAuthGuard)
- @Post()
- submitAttendance(
- @Request() req,
- @Body() body: PaymentPayload
- ) {
- const user = req.user; // ← comes from the token
- const { date } = body;
- this.service.emit({ name: user.name, date: date, verified: body.verified})
- return {
- message: `Payment received for ${user.name} on ${new Date(date).toDateString()}`,
- user: {
- id: user.sub,
- name: user.name,
- email: user.email,
- },
- };
- }
- }
|