using System.Data.Common; using GB5Shared.DTO.Framework.Login; using GoodBooks.PAY.PAYDAL.DTO.Order; namespace GoodBooks.PAY.PAYDAL.CustomCode.Order { public interface IPayOrderDAL { Task GetPayOrder(int payOrderId, LoginDTO loginDTO); /// /// Returns a typed DTO (not JSON) for use in webhook processing where the order is /// looked up by the gateway-assigned order ID rather than the internal PayOrderId. /// Task GetPayOrderByGatewayOrderId(string gatewayOrderId, LoginDTO loginDTO); Task GetPayOrderList(int pageOffset, int pageSize, LoginDTO loginDTO); /// /// Entitlement↔Payment loose coupling (Docs/Platform-Architecture-Integration- /// Reference.md §9.1) — every order ever created for one (SourceDocType, SourceDocId) /// pair, newest first. Backs both a caller's own payment-history view (e.g. /// Entitlement's client-portal Billing screen) and a reconciliation job checking /// whether a specific subscription's payment ever resolved. /// Task GetPayOrdersBySourceDoc(int sourceDocType, int sourceDocId, LoginDTO loginDTO); /// /// Returns the count of TPAYORDER rows for the given source document with an active /// order status (Pending=1, Processing=2, Paid=3). Used to prevent duplicate payment /// order creation for the same source document. /// Task CountActiveOrdersForSourceDoc(int sourceDocType, int sourceDocId, LoginDTO loginDTO); Task InsertPayOrder(PayOrderDTO dto, LoginDTO loginDTO, DbTransaction? tx = null); /// /// Targeted status update — updates ORDERSTATUS, GATEWAYPAYORDERID, PAIDAMT, and audit fields only. /// Used by webhook callback handler and payment return endpoint. /// Task UpdatePayOrderStatus(int payOrderId, int orderStatus, string? gatewayPayOrderId, decimal paidAmt, LoginDTO loginDTO, DbTransaction? tx = null); /// /// Updates the VoucherId on a pay order after the Finance module posts the receipt voucher. /// Task UpdatePayOrderVoucherId(int payOrderId, int voucherId, LoginDTO loginDTO, DbTransaction? tx = null); } }