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