using Web.Api.Common; using Web.Api.Extensions; using Application.Abstractions.Messaging; using System.Security.Claims; namespace Web.Api.Endpoints.Payment; /// 토스 결제 주문 생성 internal sealed class CreateOrder : IEndpoint { public sealed record Request(int Amount); public void MapEndpoint(IEndpointRouteBuilder app) { /// 충전 캐시(VAT 제외) 금액으로 주문 생성 → {orderID, orderName, amount, clientKey, customerKey} 반환 app.MapPost("api/payments/orders", async ( Request body, ClaimsPrincipal user, ISender sender, CancellationToken ct ) => { var memberID = user.GetRequiredMemberID(); var result = await sender.Send(new Application.Features.Api.Payment.Toss.CreateOrder.Command(body.Amount, memberID), ct); if (result.IsFailure) { return CustomResults.Problem(result); } return ApiResponse.Ok(result.Value); }) .WithTags("Payment") .RequireAuthorization(); } }