Last active
March 6, 2019 18:00
-
-
Save shinesoftware/24b0ee9a0493b9c7a58b2542f8d2a36d to your computer and use it in GitHub Desktop.
Revisions
-
shinesoftware revised this gist
Mar 6, 2019 . 1 changed file with 2 additions and 4 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -58,17 +58,15 @@ public function execute() $this->_logger->addInfo('BNL Payment Cron is active!'); 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) { $order_date = new \DateTime($order->getCreatedAt()); $since_start = $order_date->diff(new \DateTime()); $this->_logger->addInfo('This order has been paid by BNL Payment Gateway: ' . $order->getIncrementId()); if ($since_start->i > $cron_max_limit) { -
shinesoftware created this gist
Mar 6, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,88 @@ <?php namespace Shinesoftware\Bnl\Cron; use Shinesoftware\Bnl\Model\Utils; class CheckPayments { /** * @var \Shinesoftware\Bnl\Model\Logger\Shinelogger */ protected $_logger; /** * @var Utils */ protected $_utils; /** * @var \Magento\Framework\App\Config\ScopeConfigInterface */ protected $_config; /** * @var \Magento\Sales\Model\ResourceModel\Order\CollectionFactory */ protected $_orderCollectionFactory; /** * CheckPayments constructor. * @param \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig * @param \Magento\Sales\Model\ResourceModel\Order\CollectionFactory $orderCollectionFactory * @param \Shinesoftware\Bnl\Model\Logger\Shinelogger $logger */ public function __construct( \Magento\Framework\App\Config\ScopeConfigInterface $scopeConfig, \Magento\Sales\Model\ResourceModel\Order\CollectionFactory $orderCollectionFactory, \Shinesoftware\Bnl\Model\Utils $utils, \Shinesoftware\Bnl\Model\Logger\Shinelogger $logger ) { $this->_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; } }