Available Events
All events are dispatched via a PSR-14 compatible EventDispatcher. Each
event class lives under OxidEsales\PaymentBase\EventSystem\Event\ and has
a matching …Interface companion so listeners can bind against either the
concrete class or the interface.
Contract lifecycle events
These events track the payment contract through its lifecycle (see Smart-Contract Lifecycle):
Event |
When fired |
Typical use case |
|---|---|---|
|
Customer initiates checkout, contract enters |
Reserve inventory, write audit log. |
|
All draft-phase setup is done; contract is about to transition. |
Final validation hooks before the PSP is contacted. |
|
Payment process started; contract enters |
Lock basket items, start session timers. |
|
A single condition (e.g. |
Per-condition side effects, observability metrics. |
|
All conditions met; contract enters |
Create the OXID order from the basket snapshot. |
|
Order created, contract carries |
Export order to ERP, notify downstream systems. |
|
Payment captured; contract enters |
Trigger fulfillment / shipping. |
|
Contract cancelled before fulfillment. |
Release inventory, refund any captured amount. |
|
|
Cleanup reservations, log abandonment. |
|
A condition failed permanently (e.g. fraud rejected). |
Notify the customer, alert the merchant. |
Payment events
These events track payment-specific actions, independent of the contract state machine:
Event |
When fired |
Typical use case |
|---|---|---|
|
Customer starts the payment flow. |
Analytics tracking, funnel measurement. |
|
PSP confirms funds are reserved. |
Fraud check, |
|
Funds transferred to the merchant account. |
Ship order, sync to ERP. |
|
Refund processed by the PSP. |
Update CRM, restore stock. |
|
Payment declined or errored. |
Alert, retry logic, fail the contract. |
|
Shop order created from the contract. |
Sync to external order management. |
|
Order finalized (delivered, invoice issued). |
Send confirmation, close the loop. |
|
Any webhook from a PSP arrived. |
Generic webhook auditing. |
EventContext data reference
The legacy EventContext array (used by the original payment-component
EventHandlerInterface) exposes the following keys:
Key |
Type |
Available in |
|---|---|---|
|
string |
All order / payment events |
|
string |
All contract events |
|
string |
All events |
|
float |
Payment events |
|
string |
Payment events |
|
float |
Refund events |
|
array |
Contract events |
|
string |
Failed events |
|
string |
Webhook-sourced events (used for idempotency) |
Listeners bound through Symfony’s tagged-listener mechanism receive the
typed event object instead. Use $event->getContract() /
$event->getOrder() and the event-specific accessors documented on each
class — they are stricter and don’t require array lookups.
Listener binding
Two ways to listen for events:
Tagged service (recommended for module developers):
services:
YourCompany\Erp\OrderCreationListener:
tags:
- name: kernel.event_listener
event: OxidEsales\PaymentBase\EventSystem\Event\Contract\ContractCommittedEvent
method: onContractCommitted
Symfony’s EventDispatcher resolves listeners by the exact dispatched
class name, not by interface walk. If you want to listen to an interface
(e.g. ContractTerminatedEventInterface which is implemented by
ContractCancelledEvent, ContractExpiredEvent and
ContractFailedEvent), bind one listener per concrete event class.
Subscriber class (when one consumer handles multiple events):
use OxidEsales\PaymentBase\EventSystem\Event\Contract\ContractReadyToCommitEvent;
use OxidEsales\PaymentBase\EventSystem\SubscriberInterface;
class OrderCreationSubscriber implements SubscriberInterface
{
public static function getSubscribedEvents(): array
{
return [
ContractReadyToCommitEvent::class => 'onContractReady',
];
}
public function onContractReady(ContractReadyToCommitEvent $event): void
{
$contract = $event->getContract();
$order = $this->orderService->createFromContract($contract);
$contract->commit($order->getId());
$this->contractRepository->save($contract);
}
}