Copied!

UpdatePaymentEvent

UpdatePaymentEvent.php : 52
Extends AfterEvent

Event dispatched after a payment is updated.

Typical use case is to perform additional operations after payment update (e.g. logging, cache purge, reindexing, etc.)

The following example log the update of the payment:

final class PaymentEventSubscriber implements EventSubscriberInterface
{
    private function __construct(private LoggerInterface $logger)
    {
    }

    public static function getSubscribedEvents(): array
    {
        return [
            UpdatePaymentEvent::class => 'onUpdatePayment',
        ];
    }

    public function onUpdatePayment(UpdatePaymentEvent $event): void
    {
        $payment = $event->getPaymentResult();

        $this->logger->info(
            'Payment {identifier} has been updated',
            [
                'identifier' => $payment->getIdentifier(),
            ]
        );
    }
}
Tags
See
PaymentServiceInterface::updatePayment()

Methods

public__construct()

UpdatePaymentEvent.php : 60
public __construct(PaymentInterface $payment, PaymentUpdateStruct $updateStruct, PaymentInterface $paymentResult)

Parameters

Name Type Default value Description
$payment PaymentInterface - -
$updateStruct PaymentUpdateStruct - -
$paymentResult PaymentInterface - -

publicgetPayment()

UpdatePaymentEvent.php : 73

Returns the payment that has been updated (state before the update).

public getPayment() : PaymentInterface

Return values

PaymentInterface

publicgetPaymentResult()

UpdatePaymentEvent.php : 89

Returns the payment that has been updated (state after the update).

public getPaymentResult() : PaymentInterface

Return values

PaymentInterface

publicgetUpdateStruct()

UpdatePaymentEvent.php : 81

Returns update struct used to update payment.

public getUpdateStruct() : PaymentUpdateStruct

Return values

PaymentUpdateStruct

publicisPropagationStopped()

Event.php : 38
public isPropagationStopped() : bool

Return values

bool

publicstopPropagation()

Event.php : 50

Stops the propagation of the event to further event listeners.

public stopPropagation() : void

If multiple event listeners are connected to the same event, no further event listener will be triggered once any trigger calls stopPropagation().