Copied!

UpdatePaymentMethodEvent

UpdatePaymentMethodEvent.php : 49
Extends AfterEvent

Event dispatched after a payment method is updated.

Typical use case is to perform some action after payment method is updated (e.g. logging, cache purge, reindexing, etc.)

The following example log the update of the payment method:

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

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

   public function onUpdatePaymentMethod(UpdatePaymentMethodEvent $event): void
   {
       $paymentMethod = $event->getPaymentMethodResult();

       $this->logger->info(
           'Payment method {name} has been updated',
           [
               'name' => $paymentMethod->getName()
           ]
       );
   }
}

Methods

public__construct()

UpdatePaymentMethodEvent.php : 57
public __construct(PaymentMethodInterface $paymentMethod, PaymentMethodUpdateStruct $updateStruct, PaymentMethodInterface $paymentMethodResult)

Parameters

Name Type Default value Description
$paymentMethod PaymentMethodInterface - -
$updateStruct PaymentMethodUpdateStruct - -
$paymentMethodResult PaymentMethodInterface - -

publicgetPaymentMethod()

UpdatePaymentMethodEvent.php : 70

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

public getPaymentMethod() : PaymentMethodInterface

Return values

PaymentMethodInterface

publicgetPaymentMethodResult()

UpdatePaymentMethodEvent.php : 86

Returns updated payment method (after update).

public getPaymentMethodResult() : PaymentMethodInterface

Return values

PaymentMethodInterface

publicgetUpdateStruct()

UpdatePaymentMethodEvent.php : 78

Returns update struct used to update payment method.

public getUpdateStruct() : PaymentMethodUpdateStruct

Return values

PaymentMethodUpdateStruct