using Web.Api.Common; using Web.Api.Extensions; using Application.Abstractions.Messaging; using System.Security.Claims; namespace Web.Api.Endpoints.Payment; /// 토스 결제 승인 internal sealed class Confirm : IEndpoint { public sealed record Request(string PaymentKey, string OrderID, int Amount); public void MapEndpoint(IEndpointRouteBuilder app) { /// successUrl 콜백의 {paymentKey, orderId, amount} 로 승인 — 서버 저장 금액과 대조 후 지갑 캐시 충전 app.MapPost("api/payments/confirm", async ( Request body, ClaimsPrincipal user, ISender sender, CancellationToken ct ) => { var memberID = user.GetRequiredMemberID(); var data = await sender.Send(new Application.Features.Api.Payment.Toss.Confirm.Command( body.PaymentKey, body.OrderID, body.Amount, memberID ), ct); return ApiResponse.Ok(data); }) .WithTags("Payment") .RequireAuthorization(); } }