update payos webhook
This commit is contained in:
35
src/Payos/payos.controller.ts
Normal file
35
src/Payos/payos.controller.ts
Normal 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
10
src/Payos/payos.module.ts
Normal 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 {}
|
||||
28
src/Payos/payos.service.ts
Normal file
28
src/Payos/payos.service.ts
Normal 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;
|
||||
}
|
||||
}
|
||||
@@ -2,9 +2,10 @@ import { Module } from '@nestjs/common';
|
||||
import { RestfulController } from './restful.controller';
|
||||
import { RestfulService } from './restful.service';
|
||||
import { ClerkModule } from '../Clerk/clerk.module';
|
||||
import { PayosModule } from '../Payos/payos.module';
|
||||
|
||||
@Module({
|
||||
imports: [ClerkModule],
|
||||
imports: [ClerkModule, PayosModule],
|
||||
controllers: [RestfulController],
|
||||
providers: [RestfulService],
|
||||
})
|
||||
|
||||
@@ -2,6 +2,7 @@ import { NestFactory } from '@nestjs/core';
|
||||
import { AppModule } from './app.module';
|
||||
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
|
||||
import graphqlUploadExpress from 'graphql-upload/graphqlUploadExpress.js';
|
||||
import { Logger } from '@nestjs/common';
|
||||
|
||||
async function bootstrap() {
|
||||
const app = await NestFactory.create(AppModule);
|
||||
@@ -52,8 +53,10 @@ async function bootstrap() {
|
||||
maxFiles: 10,
|
||||
}),
|
||||
);
|
||||
|
||||
const host = process.env.LISTEN_HOST ?? '0.0.0.0';
|
||||
const port = process.env.LISTEN_PORT ?? 3000; // Default to 3000 if LISTEN_PORT is not set
|
||||
await app.listen(port);
|
||||
await app.listen(port, host, () => {
|
||||
Logger.log(`Server is running on http://${host}:${port}`, 'Bootstrap');
|
||||
});
|
||||
}
|
||||
bootstrap();
|
||||
|
||||
Reference in New Issue
Block a user