namespace GoodBooks.PAY.PAYBLL.Abstractions
{
///
/// Contract all payment gateway implementations must fulfill.
/// Vendor payout and transaction status query are Phase 2 features — all implementations
/// currently throw NotImplementedException for InitiatePayoutAsync.
///
public interface IPaymentGateway
{
string GatewayCode { get; }
Task CreateOrderAsync(CreateGatewayOrderRequest req, CancellationToken ct);
Task VerifyPaymentAsync(VerifyPaymentRequest req, CancellationToken ct);
Task InitiatePayoutAsync(PayoutRequest req, CancellationToken ct);
Task ParseAndVerifyWebhookAsync(string rawPayload, string sigHeader, string webhookSecret, CancellationToken ct);
Task GetTransactionStatusAsync(string gatewayTxnId, CancellationToken ct);
}
/// Result returned after creating an order/payment-intent on the gateway.
public record GatewayOrderResult(
bool Success,
string GatewayOrderId,
string? CheckoutUrl,
string? ErrorMessage);
/// Result returned after verifying a completed payment.
public record GatewayVerifyResult(
bool Success,
string Status,
string GatewayTransactionId,
decimal AmountPaid,
string? ErrorMessage);
/// Result returned after initiating a vendor payout (Phase 2).
public record GatewayPayoutResult(
bool Success,
string PayoutId,
string? ErrorMessage);
/// Parsed and signature-verified webhook event from a gateway.
public record GatewayWebhookEvent(
string IdempotencyKey,
string EventType,
string GatewayOrderId,
string GatewayTxnId,
string Status,
decimal Amount);
/// Live transaction status fetched from the gateway.
public record GatewayTransactionStatus(
string Status,
decimal Amount,
string? PaymentMethod,
DateTime? PaidAt);
// ── Request records ──────────────────────────────────────────────────────────
///
/// All data required to create a gateway order / payment-intent.
/// ApiKey and ApiSecret are pre-fetched from Vault by BLL before calling the gateway —
/// gateways are pure HTTP adapters with no infrastructure dependencies.
///
public record CreateGatewayOrderRequest(
int PayOrderId,
string PayOrderNo,
decimal Amount,
string Currency,
string CustomerEmail,
string CustomerPhone,
string CallbackUrl,
string ApiKey,
string ApiSecret);
///
/// Data required to verify a payment against the gateway.
/// ApiKey and ApiSecret are pre-fetched from Vault by BLL.
///
public record VerifyPaymentRequest(
string GatewayOrderId,
string GatewayTransactionId,
string ApiKey,
string ApiSecret);
///
/// Data required to initiate a vendor payout (Phase 2).
/// ApiKey and ApiSecret are pre-fetched from Vault by BLL.
///
public record PayoutRequest(
string RecipientAccount,
string RecipientIfsc,
decimal Amount,
string Reference,
string ApiKey,
string ApiSecret);
}