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 oe.payment.admin_panel — there are no per-PSP admin order tabs anymore. See Shared “Payment” Tab on the Order Detail Page.

Domain models

PaymentContract aggregate, BasketSnapshot value object, Transaction, ContractCondition, ContractState enum. Payment Base owns all six database tables (see Database Schema).

Event system

PSR-14 EventDispatcher, request-scoped EventContext, HandlerInterface, 30+ events covering contract lifecycle, payment lifecycle and admin actions. See Available Events.

Smart Contracts

State machine DRAFT → … → FULFILLED with extensible ContractCondition set (payment_authorized, fraud_check, …). Early-Order-Creation pattern out of the box. See Smart-Contract Lifecycle.

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\StripeClient or 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 PaymentAdapterInterface is 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
  1. Payment module performs an action (capture, refund, …).

  2. Event is dispatched with a typed Contract or Payment payload.

  3. EventDispatcher notifies all registered listeners.

  4. Each handler receives the event and processes it independently.

  5. 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

AbstractHandler

Any PSR-14 event handler that needs the standard EventContext plumbing.

ContractCreationHandler

PSP-specific contract creation hooks (provider-side intent / order creation).

AbstractPaymentCaptureService

Capture flow (partial-capture aware, idempotent).

AbstractPaymentRefundService

Refund flow (partial-refund aware, idempotent).

AbstractWebhookProcessor

Inbound webhook processing (signature verification, idempotency, routing).

AbstractFileLoggerFactory

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. opalreturns and 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 hooks

  • Eshop/ — shop-core extensions (the checkout controllers and the Order model)

  • EventSystem/ — events, dispatcher, listener provider, handlers

  • Math/ — currency-safe amount arithmetic (see Money and Currency Arithmetic)

  • Mcp/ — model-context-protocol integration points

  • Model/ — OXID model overrides

  • Repository/ — Doctrine-backed persistence

  • Return/ — return / refund domain

  • Service/ — 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.