update payos webhook
This commit is contained in:
@@ -15,6 +15,7 @@ services:
|
|||||||
- CLERK_PUBLISHABLE_KEY=pk_test_aW4tY2hpbXAtOTcuY2xlcmsuYWNjb3VudHMuZGV2JA
|
- CLERK_PUBLISHABLE_KEY=pk_test_aW4tY2hpbXAtOTcuY2xlcmsuYWNjb3VudHMuZGV2JA
|
||||||
- CLERK_SECRET_KEY=sk_test_sA5lsb1GHwUNXWQCp5ev70QkaoF5EmdAHNWiCGwZF6
|
- CLERK_SECRET_KEY=sk_test_sA5lsb1GHwUNXWQCp5ev70QkaoF5EmdAHNWiCGwZF6
|
||||||
- CORS_ORIGIN=https://epess.org,https://admin.epess.org,https://center.epess.org,http://localhost:3000,http://localhost:3069,http://localhost:3001
|
- CORS_ORIGIN=https://epess.org,https://admin.epess.org,https://center.epess.org,http://localhost:3000,http://localhost:3069,http://localhost:3001
|
||||||
|
- LISTEN_HOST=0.0.0.0
|
||||||
- LISTEN_PORT=3069
|
- LISTEN_PORT=3069
|
||||||
- SWAGGER_PATH=/swagger
|
- SWAGGER_PATH=/swagger
|
||||||
- API_PATH=/v1
|
- API_PATH=/v1
|
||||||
@@ -22,6 +23,10 @@ services:
|
|||||||
- MINIO_BUCKET_NAME=epess
|
- MINIO_BUCKET_NAME=epess
|
||||||
- MINIO_ACCESS_KEY=71dNgJtzkelXtG3R6IVt
|
- MINIO_ACCESS_KEY=71dNgJtzkelXtG3R6IVt
|
||||||
- MINIO_SECRET_KEY=53LmFiDCZxvflJIOsVF9cf0aqkIjNU2oOWtLzGsf
|
- MINIO_SECRET_KEY=53LmFiDCZxvflJIOsVF9cf0aqkIjNU2oOWtLzGsf
|
||||||
|
- PAYOS_CLIENT_ID=5c582d1a-cb4e-4d97-bb3b-210b5a24a43b
|
||||||
|
- PAYOS_API_KEY=00d6d279-4bee-45d2-802e-d4c764d149a4
|
||||||
|
- PAYOS_CHECKSUM_KEY=e4456d229676bec941340b07a745f4713b06e8ed981721bacf9389ddf2e527a5
|
||||||
|
- PAYOS_WEBHOOK_URL=https://api.epess.org/v1/payos/webhook
|
||||||
labels:
|
labels:
|
||||||
- 'traefik.enable=true'
|
- 'traefik.enable=true'
|
||||||
- 'traefik.http.routers.api.rule=Host(`api.epess.org`)'
|
- 'traefik.http.routers.api.rule=Host(`api.epess.org`)'
|
||||||
@@ -30,6 +35,7 @@ services:
|
|||||||
- 'traefik.http.services.api.loadbalancer.server.port=3069'
|
- 'traefik.http.services.api.loadbalancer.server.port=3069'
|
||||||
networks:
|
networks:
|
||||||
- epess-net
|
- epess-net
|
||||||
|
restart: always
|
||||||
networks:
|
networks:
|
||||||
epess-net:
|
epess-net:
|
||||||
driver: bridge
|
driver: bridge
|
||||||
|
|||||||
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 { RestfulController } from './restful.controller';
|
||||||
import { RestfulService } from './restful.service';
|
import { RestfulService } from './restful.service';
|
||||||
import { ClerkModule } from '../Clerk/clerk.module';
|
import { ClerkModule } from '../Clerk/clerk.module';
|
||||||
|
import { PayosModule } from '../Payos/payos.module';
|
||||||
|
|
||||||
@Module({
|
@Module({
|
||||||
imports: [ClerkModule],
|
imports: [ClerkModule, PayosModule],
|
||||||
controllers: [RestfulController],
|
controllers: [RestfulController],
|
||||||
providers: [RestfulService],
|
providers: [RestfulService],
|
||||||
})
|
})
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ import { NestFactory } from '@nestjs/core';
|
|||||||
import { AppModule } from './app.module';
|
import { AppModule } from './app.module';
|
||||||
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
|
import { SwaggerModule, DocumentBuilder } from '@nestjs/swagger';
|
||||||
import graphqlUploadExpress from 'graphql-upload/graphqlUploadExpress.js';
|
import graphqlUploadExpress from 'graphql-upload/graphqlUploadExpress.js';
|
||||||
|
import { Logger } from '@nestjs/common';
|
||||||
|
|
||||||
async function bootstrap() {
|
async function bootstrap() {
|
||||||
const app = await NestFactory.create(AppModule);
|
const app = await NestFactory.create(AppModule);
|
||||||
@@ -52,8 +53,10 @@ async function bootstrap() {
|
|||||||
maxFiles: 10,
|
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
|
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();
|
bootstrap();
|
||||||
|
|||||||
Reference in New Issue
Block a user