mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-27 16:40:56 +00:00
36 lines
1.3 KiB
TypeScript
36 lines
1.3 KiB
TypeScript
import {
|
|
Body,
|
|
Controller,
|
|
HttpCode,
|
|
HttpStatus,
|
|
Post,
|
|
UseGuards,
|
|
} from "@nestjs/common";
|
|
import { ApiOperation, ApiTags } from "@nestjs/swagger";
|
|
import { ServiceAuthGuard } from "../../common/guards/service-auth.guard";
|
|
import { PaymentEventDto, MarkPaidResponseDto } from "./internal-payment.dto";
|
|
import { PaymentService } from "./payment.service";
|
|
|
|
/**
|
|
* Consumer side of the payment microservice's outbox relay.
|
|
* Only the payment service may call this (shared SERVICE_AUTH_TOKEN).
|
|
* Idempotent by design — the relay delivers at-least-once, so duplicates must be harmless.
|
|
* Becomes a queue consumer via PaymentEventsConsumer when RabbitMQ is available;
|
|
* this HTTP endpoint remains as a transport-agnostic fallback.
|
|
*/
|
|
@ApiTags("Internal Payments")
|
|
@UseGuards(ServiceAuthGuard)
|
|
@Controller("internal/payments")
|
|
export class InternalPaymentController {
|
|
constructor(private readonly paymentService: PaymentService) { }
|
|
|
|
@Post("mark-paid")
|
|
@HttpCode(HttpStatus.OK)
|
|
@ApiOperation({
|
|
summary: "Apply a payment.succeeded / payment.failed event from the payment service (idempotent)",
|
|
})
|
|
async markPaid(@Body() event: PaymentEventDto): Promise<MarkPaidResponseDto> {
|
|
return this.paymentService.handlePaymentEvent(event);
|
|
}
|
|
}
|