Skip to content

Payment Gateway Architecture

Gateway-agnostic payment infrastructure for EloSync Central. The Billing Engine talks only to PaymentGatewayInterface. Stripe and Laravel Cashier live exclusively inside StripeGateway.

Components

PieceRole
PaymentGatewayInterfaceContract: checkout, refunds, webhooks, test connection, capabilities, currencies
GatewayManagerResolves drivers by payment_gateways.code; binds encrypted config onto the driver
BillingEnginePurchase / consolidate / handle normalized GatewayEventno Stripe/Cashier imports
StripeGatewayCashier Checkout + Stripe SDK + webhook normalization
CreemGatewayCreem REST (HTTP client) + webhook normalization
ManualGatewaySynchronous offline settlement
PaymentGatewayServiceAdmin enable/disable/default/config/mode/test/logs
GatewayWebhookControllerPOST /webhooks/gateways/{code} → driver → Billing Engine
StripeWebhookControllerCashier-compatible /stripe/webhook + Billing Engine dispatch

Architecture

Checkout / activation sequence

ER (gateway-agnostic)

payment_methods is the workspace preferred-method table (tenant_id + is_default). No separate workspace_payment_methods table.

Product mapping

Gateways with checkout + subscriptions capabilities (requiresProductMapping()) store provider product/price references in payment_gateway_module_prices. Modules never store Stripe (or any provider) IDs.

Admin API: GET/PUT /payment-gateways/{id}/module-prices. Central UI: Billing → Payment Gateways → Product mapping.

Adding a new gateway

  1. Implement App\Billing\Drivers\{Name}Gateway extends AbstractGateway.
  2. Register in config/core-platform.phppayment_gateways.
  3. Seed a payment_gateways row (code, driver, capabilities, currencies).
  4. If the gateway needs provider price IDs, implement mapping via payment_gateway_module_prices (no Module schema changes).
  5. Point provider webhooks to POST /webhooks/gateways/{code}.
  6. Do not change BillingEngine or Module catalog fields.

Official documentation for the EloSync SaaS Platform.