From 8a747d38dc6eb882ab43e8dd182e9335d7f11324 Mon Sep 17 00:00:00 2001 From: Cristian Date: Thu, 18 May 2017 17:33:04 +0300 Subject: [PATCH] Improvements. Improvements to the logging. --- Controller/Webhooks/Index.php | 2 ++ Helper/SignifydSettingsMagento.php | 5 ++++- Model/Casedata.php | 8 +++++--- Observer/Purchase.php | 9 ++++++--- composer.json | 2 +- etc/module.xml | 2 +- 6 files changed, 19 insertions(+), 9 deletions(-) diff --git a/Controller/Webhooks/Index.php b/Controller/Webhooks/Index.php index b466da5e..bcb48646 100644 --- a/Controller/Webhooks/Index.php +++ b/Controller/Webhooks/Index.php @@ -138,6 +138,8 @@ public function execute() return; } + $this->_logger->debug("Api request: " . $rawRequest); + if ($this->_api->validWebhookRequest($rawRequest, $hash, $topic)) { // For the webhook test, all of the request data will be invalid if ($topic === 'cases/test') { diff --git a/Helper/SignifydSettingsMagento.php b/Helper/SignifydSettingsMagento.php index 072a5a95..1f52a1ec 100644 --- a/Helper/SignifydSettingsMagento.php +++ b/Helper/SignifydSettingsMagento.php @@ -7,6 +7,7 @@ namespace Signifyd\Connect\Helper; use Magento\Framework\App\Config\ScopeConfigInterface; +use Magento\Framework\App\Filesystem\DirectoryList; use Signifyd\Core\SignifydSettings; class SignifydSettingsMagento extends SignifydSettings @@ -18,7 +19,8 @@ class SignifydSettingsMagento extends SignifydSettings public function __construct( ScopeConfigInterface $scopeConfig, - LogHelper $logger + LogHelper $logger, + DirectoryList $directoryList ) { $this->enabled = $scopeConfig->isSetFlag('signifyd/general/enabled', 'store'); $this->apiKey = $scopeConfig->getValue('signifyd/general/key', 'store'); @@ -29,5 +31,6 @@ public function __construct( $logger->error("API Error: " . $message); }; $this->apiAddress = "https://api.signifyd.com/v2"; + //$this->logFileLocation = $directoryList->getPath('log'); } } diff --git a/Model/Casedata.php b/Model/Casedata.php index cf426553..a68006f0 100644 --- a/Model/Casedata.php +++ b/Model/Casedata.php @@ -76,6 +76,7 @@ public function updateCase($caseData) $order->getResource()->save($order); $this->getResource()->save($case); $this->updateOrder($caseData, $orderAction, $case); + $this->_logger->info('Case was saved, id:' . $case->getIncrementId()); } catch (\Exception $e){ $this->_logger->critical($e->__toString()); return false; @@ -87,7 +88,8 @@ public function updateCase($caseData) /** * @param array $caseData - * @param string $orderAction + * @param array $orderAction + * @param $case * @return bool * @throws \Magento\Framework\Exception\LocalizedException */ @@ -175,7 +177,7 @@ protected function updateOrder($caseData, $orderAction, $case) /** * @param $caseData * @throws \Magento\Framework\Exception\LocalizedException - * @return string + * @return array */ protected function handleStatusChange($caseData) { @@ -192,7 +194,7 @@ protected function handleStatusChange($caseData) /** * @param $caseData * @throws \Magento\Framework\Exception\LocalizedException - * @return string + * @return array */ protected function handleGuaranteeChange($caseData) { diff --git a/Observer/Purchase.php b/Observer/Purchase.php index 913bd2fa..378bbcbb 100644 --- a/Observer/Purchase.php +++ b/Observer/Purchase.php @@ -40,6 +40,8 @@ class Purchase implements ObserverInterface protected $specialMethods = ['payflow_express']; + protected $restrictedMethods = ['checkmo', 'banktransfer', 'purchaseorder', 'cashondelivery']; + public function __construct( LogHelper $logger, PurchaseHelper $helper, @@ -59,9 +61,10 @@ public function execute(Observer $observer) $order = $observer->getEvent()->getOrder(); // Check if a payment is available for this order yet - if($order->getState() == \Magento\Sales\Model\Order::STATE_PENDING_PAYMENT) { - return; - } + if($order->getState() == \Magento\Sales\Model\Order::STATE_PENDING_PAYMENT) { return; } + $this->_logger->debug($order->getPayment()->getMethod()); + + if(in_array($order->getPayment()->getMethod(), $this->restrictedMethods)){ return; } // Check if case already exists for this order if ($this->_helper->doesCaseExist($order)) { diff --git a/composer.json b/composer.json index e08561c2..830919fa 100644 --- a/composer.json +++ b/composer.json @@ -6,7 +6,7 @@ "signifyd/signifyd-php":"0.1.*" }, "type": "magento2-module", - "version": "2.0.5", + "version": "2.0.6", "autoload": { "files": [ "registration.php" ], "psr-4": { diff --git a/etc/module.xml b/etc/module.xml index 72027f73..65b3b179 100644 --- a/etc/module.xml +++ b/etc/module.xml @@ -5,7 +5,7 @@ */ --> - +