Payment/EventListener/AbstractPaymentListener.php
public function onUpdate(ResourceEventInterface $event)
    {
        $payment = $this->getPaymentFromEvent($event);

        // Generate number and key
        $changed = $this->generateNumber($payment);
        $changed |= $this->generateKey($payment);

        if ($this->persistenceHelper->isChanged($payment, 'state')) {
            $changed |= $this->handleCompletedState($payment);
        }

        if ($changed) {
            $this->persistenceHelper->persistAndRecompute($payment);
        }

        if ($this->persistenceHelper->isChanged($payment, 'method')) {
            $methodCs = $this->persistenceHelper->getChangeSet($payment, 'method');
            /** @var \Ekyna\Component\Commerce\Payment\Model\PaymentMethodInterface $fromMethod */
            $fromMethod = $methodCs[0];
            /** @var \Ekyna\Component\Commerce\Payment\Model\PaymentMethodInterface $toMethod */
            $toMethod = $methodCs[1];

            if ($fromMethod->isManual() && !$toMethod->isManual()) {
                throw new LogicException("Payment method can't be changed from manual to non manual method.");
            } elseif (!$fromMethod->isManual()) {
                throw new LogicException("Payment method can't be changed.");
            }
        }

        if ($this->persistenceHelper->isChanged($payment, ['amount', 'state'])) {
            $this->scheduleSaleContentChangeEvent($this->getSaleFromPayment($payment));

            $this->customerUpdater->handlePaymentUpdate($payment);
        }
    }
public function onUpdate(ResourceEventInterface $event)
    {
        $payment = $this->getPaymentFromEvent($event);

        // Generate number and key
        $changed = $this->generateNumber($payment);
        $changed |= $this->generateKey($payment);

        if ($this->persistenceHelper->isChanged($payment, 'state')) {
            $changed |= $this->handleCompletedState($payment);
        }

        if ($changed) {
            $this->persistenceHelper->persistAndRecompute($payment);
        }

        if ($this->persistenceHelper->isChanged($payment, 'method')) {
            $methodCs = $this->persistenceHelper->getChangeSet($payment, 'method');
            /** @var \Ekyna\Component\Commerce\Payment\Model\PaymentMethodInterface $fromMethod */
            $fromMethod = $methodCs[0];
            /** @var \Ekyna\Component\Commerce\Payment\Model\PaymentMethodInterface $toMethod */
            $toMethod = $methodCs[1];

            if ($fromMethod->isManual() && !$toMethod->isManual()) {
                throw new LogicException("Payment method can't be changed from manual to non manual method.");
            } elseif (!$fromMethod->isManual()) {
                throw new LogicException("Payment method can't be changed.");
            }
        }

        if ($this->persistenceHelper->isChanged($payment, ['amount', 'state'])) {
            $this->scheduleSaleContentChangeEvent($this->getSaleFromPayment($payment));

            $this->customerUpdater->handlePaymentUpdate($payment);
        }
    }
public function onUpdate ( ResourceEventInterface $ event ) { $ payment = $ this -> getPaymentFromEvent ( $ event ) ; // Generate number and key $ changed = $ this -> generateNumber ( $ payment ) ; $ changed |= $ this -> generateKey ( $ payment ) ; if ( $ this -> persistenceHelper -> isChanged ( $ payment , 'state' ) ) { $ changed |= $ this -> handleCompletedState ( $ payment ) ; } if ( $ changed ) { $ this -> persistenceHelper -> persistAndRecompute ( $ payment ) ; } if ( $ this -> persistenceHelper -> isChanged ( $ payment , 'method' ) ) { $ methodCs = $ this -> persistenceHelper -> getChangeSet ( $ payment , 'method' ) ; /** @var \Ekyna\Component\Commerce\Payment\Model\PaymentMethodInterface $fromMethod */ $ fromMethod = $ methodCs [ 0 ] ; /** @var \Ekyna\Component\Commerce\Payment\Model\PaymentMethodInterface $toMethod */ $ toMethod = $ methodCs [ 1 ] ; if ( $ fromMethod -> isManual ( ) && ! $ toMethod -> isManual ( ) ) { throw new LogicException ( "Payment method can't be changed from manual to non manual method." ) ; } elseif ( ! $ fromMethod -> isManual ( ) ) { throw new LogicException ( "Payment method can't be changed." ) ; } } if ( $ this -> persistenceHelper -> isChanged ( $ payment , [ 'amount' , 'state' ] ) ) { $ this -> scheduleSaleContentChangeEvent ( $ this -> getSaleFromPayment ( $ payment ) ) ; $ this -> customerUpdater -> handlePaymentUpdate ( $ payment ) ; } }
Update event handler.

@param ResourceEventInterface $event

@throws LogicException
Update event handler .