Cancel.cs 864 B

12345678910111213141516171819202122232425262728
  1. using Web.Api.Common;
  2. using Web.Api.Extensions;
  3. using MediatR;
  4. using System.Security.Claims;
  5. namespace Web.Api.Endpoints.Payment;
  6. /// <summary>결제 취소</summary>
  7. internal sealed class Cancel : IEndpoint
  8. {
  9. public void MapEndpoint(IEndpointRouteBuilder app)
  10. {
  11. /// 결제 취소 (Paid 상태만 가능) → 다날 취소 API + 지갑 차감
  12. app.MapPost("api/payment/cancel", async (
  13. Application.Features.Api.Payment.Cancel.Command body,
  14. ClaimsPrincipal user,
  15. ISender sender,
  16. CancellationToken ct
  17. ) => {
  18. var memberID = user.GetRequiredMemberID();
  19. var command = body with { MemberID = memberID };
  20. await sender.Send(command, ct);
  21. return ApiResponse.Ok();
  22. })
  23. .WithTags("Payment")
  24. .RequireAuthorization();
  25. }
  26. }