Skip to content

Dev Events Payload

Vitalij Mik edited this page Oct 23, 2026 · 2 revisions

Payload Events

Available since plugin version 5.x (Mollie Payments API).

Payload events are dispatched right before a request is sent to the Mollie API. They give you a mutable payload object, so you can adjust or extend the data (metadata, custom fields, ...) before it reaches Mollie.

All events live in the namespace of their respective component. See Events (Overview) for the general concept.

ModifyCreatePaymentPayloadEvent

Dispatched before a payment is created at Mollie. This is the event to use when you want to adjust the payment payload (e.g. metadata) before the API call.

FQCN Mollie\Shopware\Component\Payment\Event\ModifyCreatePaymentPayloadEvent
Getter getPayment(): CreatePayment, getContext(): Context
Setter setPayment(CreatePayment $payment): void
use Mollie\Shopware\Component\Payment\Event\ModifyCreatePaymentPayloadEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class MolliePaymentSubscriber implements EventSubscriberInterface
{
    public static function getSubscribedEvents(): array
    {
        return [
            ModifyCreatePaymentPayloadEvent::class => 'onCreatePayment',
        ];
    }

    public function onCreatePayment(ModifyCreatePaymentPayloadEvent $event): void
    {
        $payment = $event->getPayment();
        // adjust the payment payload here, e.g. metadata
        $event->setPayment($payment);
    }
}

Adding custom metadata

(since 5.7.0) Plugins can add their own metadata to the Mollie payment with CreatePayment::addMetadata(string $key, string $value): bool. The metadata is sent to Mollie together with the payment and is visible in the Mollie Dashboard and in the API.

The plugin always stores the Shopware order number in the metadata key shopwareOrderNumber. This key is reserved: addMetadata() does not overwrite it and returns false instead.

public function onCreatePayment(ModifyCreatePaymentPayloadEvent $event): void
{
    $payment = $event->getPayment();

    $payment->addMetadata('erpReference', 'ERP-4711');
    $payment->addMetadata('source', 'my-plugin');
}

FilterLineItemEvent

(since 5.5.0) Dispatched for every line item before it becomes part of a Mollie payload (payment lines, Apple Pay Direct cart, shipments, cancellations) and when the Mollie line item status is shown in the Administration. It is dispatched for cart line items as well as for order line items.

Plugins that add their own line item types (e.g. product sets, bundles or container items that only group other line items) can use this event to keep these items out of the Mollie payload. A listener that recognises one of its items calls disallow(). This can not be undone by another listener, so the order of the listeners does not matter.

FQCN Mollie\Shopware\Component\Mollie\Event\FilterLineItemEvent
Getter getItem(): LineItem|OrderLineItemEntity, getType(): string, getPayload(): array, hasChildren(): bool, getTotalPrice(): float, isAllowed(): bool
Setter disallow(): self

Only exclude items whose price is already covered by other line items (e.g. a container whose children are sent to Mollie). The sum of all lines sent to Mollie still has to match the order amount.

use Mollie\Shopware\Component\Mollie\Event\FilterLineItemEvent;
use Symfony\Component\EventDispatcher\EventSubscriberInterface;

class MyProductSetSubscriber implements EventSubscriberInterface
{
    public static function getSubscribedEvents(): array
    {
        return [
            FilterLineItemEvent::class => 'onFilterLineItem',
        ];
    }

    public function onFilterLineItem(FilterLineItemEvent $event): void
    {
        // the container only groups its children, the children are sent to Mollie
        if ($event->getType() === 'my-product-set' && $event->hasChildren()) {
            $event->disallow();
        }
    }
}

The plugin itself uses this event to support several third-party plugins. You can find these listeners in shopware/Component/ItemFilter/Subscriber as further examples.

ModifyCreateOrderPayloadEvent

Dispatched before an order is created via the Mollie Orders API. Since 5.x this is only used for the few payment methods that still run on the Orders API (e.g. PayPal Express); all other payments use ModifyCreatePaymentPayloadEvent.

FQCN Mollie\Shopware\Component\Payment\Event\ModifyCreateOrderPayloadEvent
Getter getOrder(): CreateOrder, getContext(): Context
Setter setOrder(CreateOrder $order): void

ModifyCreatePaymentLinkPayloadEvent

Dispatched before a payment link is created at Mollie.

FQCN Mollie\Shopware\Component\Payment\Event\ModifyCreatePaymentLinkPayloadEvent
Getter getPaymentLink(): CreatePaymentLink, getContext(): Context
Setter setPaymentLink(CreatePaymentLink $paymentLink): void

ModifyCreateRefundPayloadEvent

Dispatched before a refund is sent to Mollie. In addition to the payload, this event also exposes the affected order.

FQCN Mollie\Shopware\Component\Refund\Event\ModifyCreateRefundPayloadEvent
Getter getCreateRefund(): CreateRefund, getOrder(): OrderEntity, getContext(): Context
Setter setCreateRefund(CreateRefund $createRefund): void

ModifyCreateSubscriptionPayloadEvent

Dispatched before a subscription is created via the Mollie Subscription API. Use it to modify and extend the subscription payload.

FQCN Mollie\Shopware\Component\Subscription\Event\ModifyCreateSubscriptionPayloadEvent
Getter getCreateSubscription(): CreateSubscription, getContext(): Context

Clone this wiki locally