using FastEndpoints; using GB5Shared.DTO.Framework.Login; using GB5Shared.DTO.Framework.ResponseStandard; using GB5Shared.FastEndPoint; using GoodBooks.PAY.PAYBLL.Checkout; using static GB5Shared.GB5Constant.Constant; namespace GoodBooks.PAY.PAYSL.Endpoints.Checkout { // Entitlement↔Payment loose coupling (Docs/Platform-Architecture-Integration-Reference.md // §9.1) — lets any caller (Entitlement's own GetMyPaymentHistory pass-through, or a future // module registering its own SourceDocType) read the full order history for one source // document without needing to know PAY's internal PayOrderId ahead of time. public class GetPayOrdersBySourceDoc : BaseEndpoint> { private readonly IPayOrderBLL _bll; public GetPayOrdersBySourceDoc(IPayOrderBLL bll) => _bll = bll; public override void Configure() { Get("/Pay/Order/GetPayOrdersBySourceDoc"); AllowAnonymous(); } public record GetPayOrdersBySourceDocParameters( [property: FromHeader] string Login, [property: QueryParam] int SourceDocType, [property: QueryParam] int SourceDocId ); /// NOT_REQUIRED — payment order state changes frequently. Always query live. protected override string? GetCacheKey(GetPayOrdersBySourceDocParameters req, LoginDTO login) => null; protected override async Task> ExecuteAsync( GetPayOrdersBySourceDocParameters req, LoginDTO login, CancellationToken ct) { try { var result = await _bll.GetPayOrdersBySourceDoc(req.SourceDocType, req.SourceDocId, login, ct); return await GB5Shared.ResponseStandard.Response.CreateSuccessResponse( result, CacheKeyLevel.NOT_REQUIRED, login); } catch (Exception ex) { return await GB5Shared.ResponseStandard.Response.CreateExceptionError( ex, CacheKeyLevel.NOT_REQUIRED, login, ex.Message, 500); } } } }