forked from ZyntariHQ/Invoisio
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpayments.controller.ts
More file actions
34 lines (29 loc) · 1.16 KB
/
Copy pathpayments.controller.ts
File metadata and controls
34 lines (29 loc) · 1.16 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
import { Controller, Post, Get, Body, Param, UseGuards, Req } from '@nestjs/common';
import { PaymentsService } from './payments.service';
import { InitiatePaymentDto } from './dto/initiate-payment.dto';
import { ConfirmPaymentDto } from './dto/confirm-payment.dto';
import { JwtAuthGuard } from '../../common/guards/jwt-auth.guard';
@Controller('api/payments')
@UseGuards(JwtAuthGuard)
export class PaymentsController {
constructor(private readonly paymentsService: PaymentsService) {}
@Post('initiate')
initiate(@Req() req: any, @Body() initiatePaymentDto: InitiatePaymentDto) {
const userId = req.user?.userId;
return this.paymentsService.initiatePayment(userId, initiatePaymentDto);
}
@Get(':id/status')
getStatus(@Req() req: any, @Param('id') id: string) {
const userId = req.user?.userId;
return this.paymentsService.getPaymentStatus(userId, id);
}
@Get('rates')
getRates() {
return this.paymentsService.getRates();
}
@Post(':id/confirm')
confirm(@Req() req: any, @Param('id') id: string, @Body() dto: ConfirmPaymentDto) {
const userId = req.user?.userId;
return this.paymentsService.confirmPayment(userId, id, dto);
}
}