| 1234567891011121314151617181920212223242526272829303132333435 |
- using Web.Api.Common;
- using Web.Api.Extensions;
- using Application.Abstractions.Messaging;
- using System.Security.Claims;
- namespace Web.Api.Endpoints.Payment;
- /// <summary>토스 결제 주문 생성</summary>
- 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();
- }
- }
|