mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-26 18:42:49 +00:00
28 lines
928 B
TypeScript
28 lines
928 B
TypeScript
import { Body, Controller, HttpCode, HttpStatus, Logger, Post } from '@nestjs/common';
|
|
import { ApiOperation, ApiTags } from '@nestjs/swagger';
|
|
import {
|
|
TelebirrWebhookPayload,
|
|
TelebirrWebhookService,
|
|
} from './telebirr-webhook.service';
|
|
|
|
@ApiTags('Payment Webhooks')
|
|
@Controller('payments/webhooks')
|
|
export class WebhooksController {
|
|
private readonly logger = new Logger(WebhooksController.name);
|
|
|
|
constructor(private readonly telebirr: TelebirrWebhookService) {}
|
|
|
|
@Post('telebirr')
|
|
@HttpCode(HttpStatus.OK)
|
|
@ApiOperation({ summary: 'Telebirr payment notification callback' })
|
|
async receiveTelebirr(@Body() payload: TelebirrWebhookPayload) {
|
|
try {
|
|
await this.telebirr.handle(payload);
|
|
} catch (err) {
|
|
const message = err instanceof Error ? err.message : String(err);
|
|
this.logger.error(`Telebirr webhook handler threw: ${message}`);
|
|
}
|
|
return { code: '0', message: 'OK' };
|
|
}
|
|
}
|