Files
epess-web-backend/src/Payos/payos.controller.ts

48 lines
1.1 KiB
TypeScript

import {
Controller,
Get,
Post,
Put,
Delete,
Param,
Body,
Headers,
} from '@nestjs/common'
import { PayosService } from './payos.service'
import { ApiTags, ApiOperation } from '@nestjs/swagger'
import { WebhookType } from '@payos/node/lib/type'
@ApiTags('Payos')
@Controller('payos')
export class PayosController {
constructor(private readonly payosService: PayosService) {}
// webhook
@Post('webhook')
@ApiOperation({ summary: 'Webhook for Payos' })
async webhook(@Body() body: WebhookType) {
return this.payosService.webhook(body)
}
// ping webhook
@Get('webhook')
@ApiOperation({ summary: 'Ping webhook' })
async ping() {
return this.payosService.ping()
}
// test create payment url
@Post('create-payment-url')
@ApiOperation({ summary: 'Test create payment url' })
async createPaymentURL(@Body() body: any) {
return this.payosService.createPaymentURL(body)
}
// get payment status
@Get('get-payment-status/:orderId')
@ApiOperation({ summary: 'Get payment status' })
async getPaymentStatus(@Param('orderId') orderId: string | number) {
return this.payosService.getPaymentStatus(orderId)
}
}