If it's configured to capture on shipment - do this.

@param \Magento\Framework\Event\Observer $observer

@return $this
974613
public function execute(\Magento\Framework\Event\Observer $observer)
    {
        $dataObject = $observer->getEvent()->getDataObject();

        if ($dataObject->getCustomerId()
            && $dataObject->getStatusId()
            == \Magento\Review\Model\Review::STATUS_APPROVED
        ) {
            $customerId = $dataObject->getCustomerId();
            $this->helper->setConnectorContactToReImport($customerId);
            //save review info in the table
            $this->registerReview($dataObject);
            $store = $this->storeManager->getStore($dataObject->getStoreId());
            $storeName = $store->getName();
            $website = $this->storeManager->getStore($store)->getWebsite();
            $customer = $this->customerFactory->create();
            $this->customerResource->load($customer, $customerId);
            //if api is not enabled
            if (!$this->helper->isEnabled($website)) {
                return $this;
            }

            $programId
                = $this->helper->getWebsiteConfig('connector_automation/visitor_automation/review_automation');
            if ($programId) {
                $automation = $this->automationFactory->create();
                $automation->setEmail($customer->getEmail())
                    ->setAutomationType(\Dotdigitalgroup\Email\Model\Sync\Automation::AUTOMATION_TYPE_NEW_REVIEW)
                    ->setEnrolmentStatus(\Dotdigitalgroup\Email\Model\Sync\Automation::AUTOMATION_STATUS_PENDING)
                    ->setTypeId($dataObject->getReviewId())
                    ->setWebsiteId($website->getId())
                    ->setStoreName($storeName)
                    ->setProgramId($programId);
                $this->automationResource->save($automation);
            }
        }

        return $this;
    }
493206
public function execute(\Magento\Framework\Event\Observer $observer)
    {
        $numImported = $this->contactFactory->create()
            ->getNumberOfImportedContacs();

        $updated = $this->contactResource->resetAllContacts();

        $this->helper->log(
            '-- Imported contacts: ' . $numImported
            . ' reseted :  ' . $updated . ' --'
        );

        return $this;
    }
288871
public function execute(Observer $observer) {

        // Get the order
        $order = $observer->getEvent()->getOrder();

        // Get the payment method
        $paymentMethod = $order->getPayment()->getMethod();

        // Test the current method used
        if ($paymentMethod == ConfigProvider::CODE || $paymentMethod == ConfigProvider::CC_VAULT_CODE || $paymentMethod == ConfigProvider::THREE_DS_CODE) {

            // Update the hub API for cancelled order
            $this->orderService->cancelTransactionToRemote($order);    
        }

        return $this;
    }
262591
public function attach(SplObserver $observer)
    {
        if (!isset($this->__observers)) {
            $this->__observers = new SplObjectStorage;
        }
        $this->__observers->attach($observer);
    }
219467
public function subscribe( IObserver $observer ) : IObservable
   {

      if ( ! \in_array( $observer, $this->_observers, true ) )
      {
         $this->_observers[] = $observer;
      }

      return $this;

   }
523504
public function attach(ObserverInterface $observer): SubjectInterface
    {
        if ($observer instanceof TemplateInterface) {
            parent::attach($observer);
        }
        return $this;
    }
382907
public function execute(Observer $observer) {
        
        // Get a potential 3D Secure redirect url from session
        $redirectUrl = $this->session->get3DSRedirect();

        // Get the card id charge flag
        $isCardIdCharge = $this->session->getCardIdChargeFlag() == 'cardIdCharge';

        // Handle a 3D Secure redirection if needed
        if ($this->isUrl($redirectUrl)) {

            // Exit to force redirection in case of card id charge
            if ($isCardIdCharge) {
                // Unset the session variable
                $this->session->unsCardIdChargeFlag();
                exit();
            }
        }
    }
753912
public function execute(\Magento\Framework\Event\Observer $observer)
    {
        if (!$this->redirect->isAllowed()) {
            $this->session->unsetScript();

            return;
        }

        foreach ($this->getRedirects() as $redirect) {
            $redirect->run();
        }
    }
948748
public function execute(Observer $observer)
    {
        if (!$this->scopeConfig->getValue(self::CONFIG_PATH_REDIRECT_TO_CHECKOUT, ScopeInterface::SCOPE_STORE)) {
            return;
        }

        /** @var Http $request */
        $request = $observer->getData('request');
        $request->setParam('return_url', $this->url->getUrl('checkout'));
    }
319575
public function execute(\Magento\Framework\Event\Observer $observer)
    {
        $productModel = $observer->getEvent()->getDataObject();
        $productId = $productModel->getId();

        $emailCatalogModel = $this->catalogFactory->create();
        $emailCatalog = $emailCatalogModel->loadProductById($productId);

        if ($emailCatalog->getId()) {
            //update email catalog item when imported
            if ($emailCatalog->getImported()) {
                $emailCatalog->setModified(1);
                $this->catalogResource->save($emailCatalog);
            }
        } else {
            //create new email catalog item
            $emailCatalogModel->setProductId($productId);
            $this->catalogResource->save($emailCatalogModel);
        }

        return $this;
    }
446916
public function dispatch(Varien_Event_Observer $observer)
    {
        if (!Mage::getStoreConfigFlag('system/cron/enable')) {
            return;
        }

        $processManager = Mage::getModel('aoe_scheduler/processManager'); /* @var $processManager Aoe_Scheduler_Model_ProcessManager */
        $processManager->watchdog();

        $scheduleManager = Mage::getModel('aoe_scheduler/scheduleManager'); /* @var $scheduleManager Aoe_Scheduler_Model_ScheduleManager */
        $scheduleManager->logRun();

        $helper = Mage::helper('aoe_scheduler'); /* @var Aoe_Scheduler_Helper_Data $helper */
        $includeJobs = $helper->addGroupJobs((array) $observer->getIncludeJobs(), (array) $observer->getIncludeGroups());
        $excludeJobs = $helper->addGroupJobs((array) $observer->getExcludeJobs(), (array) $observer->getExcludeGroups());

        // Coalesce all jobs that should have run before now, by job code, by marking the oldest entries as missed.
        $scheduleManager->skipMissedSchedules();

        // Iterate over all pending jobs
        foreach ($scheduleManager->getPendingSchedules($includeJobs, $excludeJobs) as $schedule) {
            /* @var Aoe_Scheduler_Model_Schedule $schedule */
            $schedule->process();
        }

        // Generate new schedules
        $scheduleManager->generateSchedules();

        // Clean up schedule history
        $scheduleManager->cleanup();
    }
736616
protected function observe($observer)
    {
        if (method_exists($observer, 'saving')) {
            $this->hook('saving', array($observer, 'saving'));
        }

        if (method_exists($observer, 'saved')) {
            $this->hook('saved', array($observer, 'saved'));
        }

        if (method_exists($observer, 'filtering')) {
            $this->hook('filtering', array($observer, 'filtering'));
        }

        if (method_exists($observer, 'filtered')) {
            $this->hook('filtered', array($observer, 'filtered'));
        }

        if (method_exists($observer, 'removing')) {
            $this->hook('removing', array($observer, 'removing'));
        }

        if (method_exists($observer, 'removed')) {
            $this->hook('removed', array($observer, 'removed'));
        }

        if (method_exists($observer, 'searching')) {
            $this->hook('searching', array($observer, 'searching'));
        }

        if (method_exists($observer, 'searched')) {
            $this->hook('searched', array($observer, 'searched'));
        }

        if (method_exists($observer, 'attaching')) {
            $this->hook('attaching', array($observer, 'attaching'));
        }

        if (method_exists($observer, 'attached')) {
            $this->hook('attached', array($observer, 'attached'));
        }

        if (method_exists($observer, 'initialized')) {
            $this->hook('initialized', array($observer, 'initialized'));
        }
    }
722722
public function attachObserver(ObserverInterface $observer, $event){
		$this->observers->attach($observer, $event);
		$this->connection->attachObserver($observer, $event);
		$e = new NeevoException;
		$e->attachObserver($observer, $event);
	}
141165
public function handleShipGroupChargeType(Varien_Event_Observer $observer)
    {
        $event = $observer->getEvent();
        $shipGroup = $event->getShipGroupPayload();
        Mage::helper('radial_core/shipping_chargetype')->setShippingChargeType($shipGroup);
        return $this;
    }
1055960
public function execute(\Magento\Framework\Event\Observer $observer)
    {
        $productCollection = $observer->getEvent()->getData('product_collection');
        $storeId           = $observer->getEvent()->getData('store_id');

        if (($productCollection instanceof \Magento\Catalog\Model\ResourceModel\Product\Collection) && $storeId) {
            $this->logEvent($productCollection, $storeId);
        }
    }
1282536
public function unregisterObserver($observer) {
        if (!is_string($observer)) {
            $observer = $observer->getName();
        }
        unset($this->_observers[$observer]);
        return $this;
    }
597820
public function attach(ServerObserver $observer)
    {
        if ($this->state) {
            throw new \Error("Cannot attach observers after the server has started");
        }

        $this->observers->attach($observer);
    }