| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546 |
- using Domain.Entities.Payments.ValueObject;
- using Application.Abstractions.Messaging;
- using System.Security.Claims;
- using System.Text.Json.Serialization;
- using Web.Api.Common;
- using Web.Api.Extensions;
- namespace Web.Api.Endpoints.Payment;
- public sealed class Request
- {
- /// <summary>충전할 포인트 (VAT 제외). PG 결제 총액은 서버에서 VAT 10% 별도 가산.</summary>
- [JsonPropertyName("amount")]
- public int Amount { get; set; }
- [JsonPropertyName("paymentMethod")]
- [JsonConverter(typeof(JsonStringEnumConverter))]
- public PaymentMethod PaymentMethod { get; set; }
- }
- /// <summary>결제 주문 생성</summary>
- internal sealed class CreateOrder : IEndpoint
- {
- public void MapEndpoint(IEndpointRouteBuilder app)
- {
- /// 금액/결제수단으로 주문 생성 → orderId, clientKey, successUrl 반환
- app.MapPost("api/payment/order", async (
- Request body,
- ClaimsPrincipal user,
- ISender sender,
- CancellationToken ct
- ) => {
- var memberID = user.GetRequiredMemberID();
- var command = new Application.Features.Api.Payment.CreateOrder.Command(
- body.Amount,
- body.PaymentMethod,
- memberID
- );
- var data = await sender.Send(command, ct);
- return ApiResponse.Ok(data);
- })
- .WithTags("Payment")
- .RequireAuthorization();
- }
- }
|