Extension Mechanisms

Payment Base is designed to be extended without modifications to its core. There are six mechanisms to do that — pick the smallest one that fits your use case.

The list is ordered from cheapest to most invasive. If two mechanisms could solve your problem, the earlier one in the list is almost always the right choice.

#

Mechanism

Use it when …

Effort

1

Event handler

You want to react to a contract or payment event. The default extension point.

Low

2

Service override via DI

You need to replace or decorate a Payment Base service binding. Inheritance + Symfony aliasing.

Medium

3

Contract metadata

You want to store custom data on a contract. setMetadata() survives the lifecycle and is persisted on the contract.

Low

4

Webhook handler addition

You need to handle a new PSP webhook event type. Extends AbstractWebhookProcessor.

Medium

5

Controller extension

You need to add UI or logic to existing checkout / admin pages. Use only for thin orchestration — business logic still goes through events.

Medium

6

Adapter decoration

You want to wrap an existing adapter (StripeAdapter, PayPalAdapter, …) for marketplace headers, logging, retries.

High

1 · Event handler

The default extension point. Subscribe to a contract or payment event, react in your handler, return. See Integration Examples for concrete handler shapes.

services:
  YourCompany\Erp\OrderCreationListener:
    tags:
      - name: kernel.event_listener
        event: OxidEsales\PaymentBase\EventSystem\Event\Contract\ContractCommittedEvent
        method: onContractCommitted

When in doubt, start here. Most integrations never need anything else.

2 · Service override via DI

When you need to replace a Payment Base service entirely — for example, to swap the default FraudCheckServiceInterface implementation against your own — use a service alias in your module’s services.yaml:

services:
  YourCompany\Fraud\StripeRadarFraudCheck:
    arguments: ['@stripe.client']

  OxidEsales\PaymentBase\Service\FraudCheckServiceInterface:
    alias: YourCompany\Fraud\StripeRadarFraudCheck

For decoration (keep the original behavior, add a layer around it) use Symfony’s decorates keyword.

3 · Contract metadata

For arbitrary per-contract data that you do not want to push into a new column or new event payload, attach it as metadata:

$contract->setMetadata('marketplace.seller_id', $sellerId);

The metadata is JSON-serialized into oe_payments_contract.OXMETADATA and survives all lifecycle transitions. Read it back from the same contract instance via $contract->getMetadata('marketplace.seller_id').

4 · Webhook handler addition

To process a webhook event type Payment Base doesn’t already route, extend AbstractWebhookProcessor in your PSP module:

use OxidEsales\PaymentBase\Webhook\AbstractWebhookProcessor;
use OxidEsales\PaymentBase\Webhook\WebhookEvent;

final class StripeWebhookProcessor extends AbstractWebhookProcessor
{
    protected function verifySignature(string $payload, array $headers): bool
    {
        return $this->adapter->verifyWebhookSignature(
            $payload,
            $headers['Stripe-Signature'],
            $this->secret,
        );
    }

    protected function routeEvent(WebhookEvent $event): void
    {
        match ($event->getType()) {
            'payment_intent.succeeded' => $this->dispatcher->dispatch(
                new PaymentAuthorizedEvent($contract, $context),
            ),
            'charge.refunded' => $this->dispatcher->dispatch(
                new PaymentRefundedEvent($contract, $context),
            ),
            default => null,
        };
    }
}

Idempotency, persistence into oe_payments_webhooklogs, and the provider-agnostic WebhookLogRepository all come from the abstract base. Your concrete class only knows how to read the PSP-specific payload.

5 · Controller extension

For UI or thin glue on existing OXID checkout or admin pages. Limit controllers to thin orchestration — dispatch events, render templates, return responses. Business logic still belongs in event handlers and services.

This is also how the shared admin Payment tab plugs into OXID, via the controllers map in metadata.php. See Shared “Payment” Tab on the Order Detail Page.

6 · Adapter decoration

The most invasive mechanism. Wrap an existing adapter for cross-cutting concerns:

services:
  YourCompany\Marketplace\MarketplaceAdapterDecorator:
    decorates: stripe.adapter
    arguments: ['@.inner']

Use cases: marketplace header injection, retry logic, custom logging, sandbox routing in tests.

Avoid this for business decisions — they belong in event handlers, where the decision is observable in the event log and can be tested in isolation.

Subsystem-specific extension points

The six mechanisms above extend Payment Base as a whole. Individual subsystems add their own tagged-service hooks, which follow the same principle — register a service, tag it, no core modification:

Tag

Purpose

oe.payment.admin_panel

Contribute a panel to the shared admin Payment tab. See Shared “Payment” Tab on the Order Detail Page.

oe.payment_base.validation_guard

Add a guard to the validation endpoint’s request chain. See Validation System.