Skip to content

Commit

Permalink
Improvements.
Browse files Browse the repository at this point in the history
Improvements to the logging.
  • Loading branch information
cristian-vatca-osf committed May 18, 2017
1 parent 0d07abc commit 8a747d3
Show file tree
Hide file tree
Showing 6 changed files with 19 additions and 9 deletions.
2 changes: 2 additions & 0 deletions Controller/Webhooks/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -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') {
Expand Down
5 changes: 4 additions & 1 deletion Helper/SignifydSettingsMagento.php
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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');
Expand All @@ -29,5 +31,6 @@ public function __construct(
$logger->error("API Error: " . $message);
};
$this->apiAddress = "https://api.signifyd.com/v2";
//$this->logFileLocation = $directoryList->getPath('log');
}
}
8 changes: 5 additions & 3 deletions Model/Casedata.php
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
*/
Expand Down Expand Up @@ -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)
{
Expand All @@ -192,7 +194,7 @@ protected function handleStatusChange($caseData)
/**
* @param $caseData
* @throws \Magento\Framework\Exception\LocalizedException
* @return string
* @return array
*/
protected function handleGuaranteeChange($caseData)
{
Expand Down
9 changes: 6 additions & 3 deletions Observer/Purchase.php
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand All @@ -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)) {
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -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": {
Expand Down
2 changes: 1 addition & 1 deletion etc/module.xml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
*/
-->
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
<module name="Signifyd_Connect" setup_version="2.0.5">
<module name="Signifyd_Connect" setup_version="2.0.6">
<sequence>
<module name="Magento_Sales" />
<module name="Magento_Payment" />
Expand Down

0 comments on commit 8a747d3

Please sign in to comment.