Core Concepts
Payments combines Entries blueprints for configuration and catalog data with dedicated transactional SQL tables for high-integrity financial ledgers.
Payment Lifecycle & Ledger Flow
Section titled “Payment Lifecycle & Ledger Flow”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 & Intent Primitives
Section titled “Money & Intent Primitives”Money: Immutable value object constructed viaMoney::fromMajor('4900.00', 'EUR')orMoney::fromMinor(490000, 'EUR'). Eliminates floating-point rounding drift across captures, refunds, and marketplace splits.PaymentIntentRequest: Typed request DTO carrying theMoneyamount,payableType,payableId(for exampleCHR-2026-104), idempotency key, customer details, optionalgatewayHandle, and optional marketplaceplatformFeeMinor/splits.
Storage Model: Blueprints + Transactional Managed Tables
Section titled “Storage Model: Blueprints + Transactional Managed Tables”EntriesBlueprints (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-onlypayments_subscription_events, invoices, and inbound webhook logs withSELECT ... FOR UPDATErow locking to prevent concurrent double-captures or double-refunds.
Gateways & Capability Interfaces
Section titled “Gateways & Capability Interfaces”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:
SavedSourceGatewayInterfaceInstallmentGatewayInterfaceSubscriptionGatewayInterfaceQuantitySubscriptionGatewayInterfaceMeteredSubscriptionGatewayInterfaceMarketplaceGatewayInterfaceWebhookGatewayInterfaceInvoiceGatewayInterfaceTransactionStatusGatewayInterface
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.
SecretBox Credential Sealing
Section titled “SecretBox Credential Sealing”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 authenticatedsodium_crypto_secretboxkeyed from your installation salt.