Skip to content

Core Concepts

Payments combines Entries blueprints for configuration and catalog data with dedicated transactional SQL tables for high-integrity financial ledgers.

flowchart LR
  App["App or Sibling Module"] --> Intent["PaymentIntentRequest + Money (Minor Units)"]
  Intent --> Router["GatewayRepository (Priority & Currency Routing)"]
  Router --> Driver["PaymentGatewayInterface + Capability Interfaces"]
  Driver --> Lock["SELECT FOR UPDATE + Idempotency Fingerprint"]
  Lock --> Ledger["Managed SQL Ledger (transactions, subscriptions, events)"]
  Provider["External PSP"] --> Webhook["/_payments/webhook/{handle} (Verified Signature)"]
  Webhook --> Queue["ProcessWebhookQueue (payments-webhooks)"]
  Queue --> Lock
  Lock --> Hooks["Payments::after* Hooks & Account Notifications"]
  • Money: Immutable value object constructed via Money::fromMajor('4900.00', 'EUR') or Money::fromMinor(490000, 'EUR'). Eliminates floating-point rounding drift across captures, refunds, and marketplace splits.
  • PaymentIntentRequest: Typed request DTO carrying the Money amount, payableType, payableId (for example CHR-2026-104), idempotency key, customer details, optional gatewayHandle, and optional marketplace platformFeeMinor / splits.

Storage Model: Blueprints + Transactional Managed Tables

Section titled “Storage Model: Blueprints + Transactional Managed Tables”
  • Entries Blueprints (PaymentsBlueprints): Stores gateway configurations, recurring billing plans (payments-plans), hosted payment links, saved sources, and module settings.
  • Managed SQL Tables (entries_tbl_payments_*): Stores transactional ledger records, payments_subscriptions, append-only payments_subscription_events, invoices, and inbound webhook logs with SELECT ... FOR UPDATE row locking to prevent concurrent double-captures or double-refunds.

A Driver (for example stripe, paypal, paddle, iyzico, manual, dummy, or a custom paymentsDriver module) implements PaymentGatewayInterface and declares its feature matrix via GatewayCapabilities. Optional features are exposed through nine focused capability interfaces:

  1. SavedSourceGatewayInterface
  2. InstallmentGatewayInterface
  3. SubscriptionGatewayInterface
  4. QuantitySubscriptionGatewayInterface
  5. MeteredSubscriptionGatewayInterface
  6. MarketplaceGatewayInterface
  7. WebhookGatewayInterface
  8. InvoiceGatewayInterface
  9. TransactionStatusGatewayInterface

An administrator can configure multiple Gateway Instances from the same driver (for example separate EUR and USD accounts) and control fallback order through GatewayRepository priority and currency routing.

Every gateway secret field supports three storage modes via SecretBox:

  • $env:STRIPE_SECRET_KEY: Reads the secret from the process environment at runtime (never stored in the database).
  • $config:stripeSecretKey: Reads from ProcessWire’s $config.
  • enc:v1:...: Encrypts the value at rest using authenticated sodium_crypto_secretbox keyed from your installation salt.

Next steps