_config = $scopeConfig; $this->_orderCollectionFactory = $orderCollectionFactory; $this->_utils = $utils; $this->_logger = $logger; } public function execute() { $collection = $this->_orderCollectionFactory->create()->addAttributeToSelect('*'); $cron_max_limit = $this->_config->getValue('payment/bnl_settings/chkmaxlimit'); if(empty($cron_max_limit)){ $this->_logger->addWarning('BNL Payment Cron is disabled!'); return $this; } $this->_logger->addInfo('BNL Payment Cron is active!'); $start_date = new \DateTime(); foreach ($collection as $order) { if ("payment_review" == $order->getStatus()) { $paymentMethod = $order->getPayment()->getMethodInstance()->getCode(); $this->_logger->addInfo('Checking the order: ' . $order->getIncrementId()); if (strpos($paymentMethod, "bnl_") !== false) { $since_start = $start_date->diff(new \DateTime($order->getCreatedAt())); $this->_logger->addInfo('This order has been paid by BNL Payment Gateway: ' . $order->getIncrementId()); if ($since_start->i > $cron_max_limit) { $result = $this->_utils->inquiryTransaction($order); if($result){ $this->_logger->addInfo('The payment gateway replies with: ' . $result); } } } } } return $this; } }