Architecture
OXID Payment Base is the provider-agnostic core that lives below every PSP module (Stripe, PayPal, …), every returns flow, and every shipping integration. PSPs and downstream modules never import each other — they share only Payment Base.
Four pillars
Payment Base ships four things, end of list. Anything you build on top of it composes these four pieces:
Pillar |
What it gives you |
|---|---|
Shared admin Payment tab |
One single tab on the OXID admin Order Detail page. PSP modules
contribute panels via the tagged service |
Domain models |
|
Event system |
PSR-14 |
Smart Contracts |
State machine |
The boundary rule
The rule decides, for every line of code, whether it belongs in Payment Base or in a PSP module:
If it could work with another PSP — it lives in
payment-base. If it touches\Stripe\StripeClientor PayPal SDK concepts — it lives in the PSP module.
PayPal and Stripe are peers. Neither imports the other; both share Payment Base. PSP modules ship pre-commit “architecture grep guards” that fail any cross-import attempt.
The same rule applies to downstream consumers: a returns module
(opalreturns) and a shipping integration depend on Payment Base, never
on a specific PSP. They subscribe to ContractFulfilledEvent and
PaymentRefundedEvent — not to StripeChargeCapturedEvent.
Layered overview
┌─────────────────────────────────────────────────────────────┐
│ CONTROLLER LAYER thin controllers, emit events only │
└────────────────────────────┬─────────────────────────────────┘
│ emits
┌────────────────────────────▼─────────────────────────────────┐
│ EVENT SYSTEM PSR-14 domain events + handlers │
└────────────────────────────┬─────────────────────────────────┘
│ triggers
┌────────────────────────────▼─────────────────────────────────┐
│ SERVICE LAYER ContractService, CheckoutOrchestrator │
└────────────────────────────┬─────────────────────────────────┘
│ uses
┌────────────────────────────▼─────────────────────────────────┐
│ ADAPTER LAYER PaymentAdapterInterface (per provider) │
└────────────────────────────┬─────────────────────────────────┘
│ persists
┌────────────────────────────▼─────────────────────────────────┐
│ REPOSITORY LAYER ContractRepository, TransactionRepo │
└──────────────────────────────────────────────────────────────┘
Why these layers matter:
Controllers never call PSP SDKs directly — they only dispatch events. This keeps shop-facing entry points stable across PSP changes.
The event system decouples consumers (ERP, CRM, shipping, returns) from producers. Handlers fail independently; adding a consumer never touches Payment Base code.
Services own the orchestration logic (e.g. “all conditions met → emit
ContractReadyToCommitEvent”). Pure PHP, no I/O.Adapters are the only place provider quirks live. The
PaymentAdapterInterfaceis the seam between the core and the PSP SDK.Repositories isolate persistence behind Doctrine; the rest of the code never touches DBAL directly.
Event-driven coupling
Traditional approach (tightly coupled):
PaymentService → ShippingService → CRMService → ERPService
Event-driven approach (loosely coupled):
PaymentCapturedEvent → [ShippingHandler, CRMHandler, ERPHandler]
(independent, parallel execution)
Anyone can introduce a new event. Handlers are tagged services. No central switch statements.
Symfony’s EventDispatcher resolves listeners by exact dispatched
class name, not by walking interfaces. Consumers therefore bind their
kernel.event_listener tags to concrete event classes (see
Refund Intent Routing for a real-world example).
How an event flows
┌─────────────────┐ ┌────────────────────┐ ┌─────────────────┐
│ Payment Module │────▶│ EventDispatcher │────▶│ Your Handler │
│ (Stripe, etc.) │ │ (PSR-14) │ │ (CRM, ERP...) │
└─────────────────┘ └────────────────────┘ └─────────────────┘
│ │ │
│ dispatch(event) │ notify subscribers │ handle(event)
▼ ▼ ▼
PaymentCapturedEvent EventListenerProvider Update external system
Payment module performs an action (capture, refund, …).
Event is dispatched with a typed
ContractorPaymentpayload.EventDispatcher notifies all registered listeners.
Each handler receives the event and processes it independently.
Failures are isolated — handler exceptions never bubble back to the PSP.
The same event bus carries admin actions. When the merchant clicks
“Capture” inside the shared admin panel, PaymentAdminActionDispatcher
emits the same event that a webhook would have raised — so downstream
listeners run identically regardless of trigger origin.
Abstract base classes you extend
Payment Base exposes six abstract bases for PSP modules to extend instead of copy — you extend, you don’t copy:
Class |
Extend it for |
|---|---|
|
Any PSR-14 event handler that needs the standard
|
|
PSP-specific contract creation hooks (provider-side intent / order creation). |
|
Capture flow (partial-capture aware, idempotent). |
|
Refund flow (partial-refund aware, idempotent). |
|
Inbound webhook processing (signature verification, idempotency, routing). |
|
PSP-specific log channel with the shared rotation / format. |
Roughly 25 interfaces (PaymentAdapterInterface,
ShopAdapterInterface, SessionAdapterInterface, the repository and
service interfaces …) form the seam between Payment Base and the
implementations. The boundary rule above tells you on which side of each
interface your code belongs.
Architecture invariants
These invariants are enforced by pre-commit grep guards in PSP modules and by code-review checklists in Payment Base itself:
PSPs are peers. No PSP module may import another PSP module.
Consumer modules are PSP-agnostic.
opalreturnsand shipping modules subscribe only to Payment Base events.No direct contract mutations in controllers. Controllers dispatch events; services and handlers mutate the contract.
Repositories only. No DBAL calls outside the
Repository/package.
Source-tree layout
The companion module oxid-esales/payment-base ships the following
top-level src/ packages:
Adapter/— provider abstraction (PaymentAdapterInterface+ request / response DTOs)Admin/— shared admin Payment tab (controller, panel registry, action dispatcher)Checkout/— checkout-flow decisions (single payment method / single delivery set: resolvers, assigners, settings — see Module Settings)Command/— console commands (abandoned-checkout cleanup, see Maintenance)Contract/— Smart-Contract domain (PaymentContract,ContractCondition,BasketSnapshot)Controller/— base controllers (webhook entry points, …)Core/— module bootstrap, lifecycle hooksEshop/— shop-core extensions (the checkout controllers and theOrdermodel)EventSystem/— events, dispatcher, listener provider, handlersMath/— currency-safe amount arithmetic (see Money and Currency Arithmetic)Mcp/— model-context-protocol integration pointsModel/— OXID model overridesRepository/— Doctrine-backed persistenceReturn/— return / refund domainService/— orchestration services (capture, refund, fulfillment, …)Validation/— shared field validator, guard chain, rate limiting (see Validation System)Webhook/— webhook processing pipeline
A separate migration/data/ directory holds the three Doctrine
migrations that create the six database tables documented in
Database Schema.