| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566 |
- using System.Security.Claims;
- using MediatR;
- using Web.Api.Common;
- using Web.Api.Extensions;
- namespace Web.Api.Endpoints.V1.Purchases;
- internal sealed class Get : IEndpoint
- {
- public void MapEndpoint(IEndpointRouteBuilder app)
- {
- app.MapGet("v1/purchases/{orderID}", async (
- string orderID,
- ClaimsPrincipal user,
- ISender sender,
- CancellationToken ct,
- int? marketplace = null
- ) => {
- var query = new Application.Features.Api.V1.Purchases.Get.Query(
- user.GetApplicationID(),
- user.GetPatOwnerMemberID(),
- orderID,
- marketplace
- );
- var result = await sender.Send(query, ct);
- return result.Match(
- data => ApiResponse.Ok(data),
- CustomResults.Problem
- );
- })
- .WithTags("결제 보고")
- .WithGroupName("public")
- .WithName("GetPurchase")
- .WithSummary("결제 단건 조회")
- .WithDescription("""
- 등록한 결제의 상태를 조회합니다 (대사용).
- - OAuth2 앱 토큰: 해당 앱이 등록한 건만 조회
- - PAT: 본인 소유 앱 전체의 등록 건 조회
- ### 필수 scope
- - `read:purchases`
- ### status 값
- | 값 | 의미 |
- |---|---|
- | `Pending` | 보류 — 확정 예정 (`confirmDueAt` 참조) |
- | `Confirmed` | 확정 — 채널 수수료 적립 완료 |
- | `Canceled` | 취소됨 |
- ### 에러
- - `400` — 여러 건 조회됨 (marketplace 지정 필요)
- - `404` — 등록 내역 없음
- """)
- .Produces<ApiResponse>(StatusCodes.Status200OK)
- .ProducesProblem(StatusCodes.Status400BadRequest)
- .ProducesProblem(StatusCodes.Status401Unauthorized)
- .ProducesProblem(StatusCodes.Status403Forbidden)
- .ProducesProblem(StatusCodes.Status404NotFound)
- .RequireAuthorization(policy => policy
- .AddAuthenticationSchemes("ApiKey", "OAuth2Bearer")
- .RequireAuthenticatedUser())
- .RequireScope("read:purchases");
- }
- }
|