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

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

        // Exchange rate
        $changed |= $this->updateExchangeRate($payment);

        // Completed state
        $changed |= $this->handleCompletedState($payment);

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

        $sale = $this->getSaleFromPayment($payment);

        $this->customerUpdater->handlePaymentInsert($payment);

        $this->scheduleSaleContentChangeEvent($sale);
    }
public function onInsert(ResourceEventInterface $event)
    {
        $payment = $this->getPaymentFromEvent($event);

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

        // Exchange rate
        $changed |= $this->updateExchangeRate($payment);

        // Completed state
        $changed |= $this->handleCompletedState($payment);

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

        $sale = $this->getSaleFromPayment($payment);

        $this->customerUpdater->handlePaymentInsert($payment);

        $this->scheduleSaleContentChangeEvent($sale);
    }
Insert event handler.

@param ResourceEventInterface $event