using Web.Api.Common;
using Application.Abstractions.Payment;

namespace Web.Api.Endpoints.Payment;

/// <summary>프론트엔드용 다날 클라이언트 설정</summary>
internal sealed class ClientConfig : IEndpoint
{
    public void MapEndpoint(IEndpointRouteBuilder app)
    {
        /// ClientKey, MerchantID 반환 (결제창 호출 시 필요)
        app.MapGet("api/payment/config", async (IDanalPayService danalPay, CancellationToken ct) => {
            var config = await danalPay.GetClientConfigAsync(ct);
            return ApiResponse.Ok(config);
        })
        .WithTags("Payment")
        .RequireAuthorization();
    }
}