update payos webhook

This commit is contained in:
2024-10-17 16:35:50 +07:00
parent 5c56e79d63
commit 4721077370
6 changed files with 86 additions and 3 deletions

View File

@@ -0,0 +1,35 @@
import {
Controller,
Get,
Post,
Put,
Delete,
Param,
Body,
Headers,
} from '@nestjs/common';
import { PayosService } from './payos.service';
import { ApiTags, ApiOperation } from '@nestjs/swagger';
@ApiTags('Payos')
@Controller('payos')
export class PayosController {
constructor(private readonly payosService: PayosService) {}
// webhook
@Post('webhook')
@ApiOperation({ summary: 'Webhook for Payos' })
async webhook(
@Body() body: any,
@Headers('x-payos-signature') signature: string,
) {
return this.payosService.webhook(body, signature);
}
// ping webhook
@Get('webhook')
@ApiOperation({ summary: 'Ping webhook' })
async ping() {
return this.payosService.ping();
}
}

10
src/Payos/payos.module.ts Normal file
View File

@@ -0,0 +1,10 @@
import { Module } from '@nestjs/common';
import { PayosService } from './payos.service';
import { PayosController } from './payos.controller';
@Module({
providers: [PayosService],
controllers: [PayosController],
exports: [PayosService],
})
export class PayosModule {}

View File

@@ -0,0 +1,28 @@
import { Injectable, Logger } from '@nestjs/common';
import { PrismaService } from '../Prisma/prisma.service';
@Injectable()
export class PayosService {
constructor(private readonly prisma: PrismaService) {}
async ping() {
return 'pong';
}
async webhook(body: any, signature: string) {
Logger.log('Webhook received', body);
return body;
}
async createPaymentURL(body: any) {
return body;
}
async cancelPaymentURL(body: any) {
return body;
}
async refundPayment(body: any) {
return body;
}
}