Skip to content

Commit

Permalink
Fixing for cron and pending status
Browse files Browse the repository at this point in the history
3.5.1
  • Loading branch information
sig-chrismorris528 authored Nov 26, 2019
2 parents c851dc7 + b3e7da9 commit 1af3a17
Show file tree
Hide file tree
Showing 4 changed files with 28 additions and 11 deletions.
15 changes: 13 additions & 2 deletions Controller/Webhooks/Index.php
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
use Signifyd\Connect\Logger\Logger;
use Magento\Framework\App\Action\Action;
use Magento\Framework\App\RequestInterface;
use Magento\Framework\Filesystem\Driver\File;

/**
* Controller action for handling webhook posts from Signifyd service
Expand Down Expand Up @@ -38,26 +39,36 @@ class Index extends Action
protected $orderFactory;

/**
* @var File
*/
protected $file;

/**
* Index constructor.
* @param Context $context
* @param DateTime $dateTime
* @param Logger $logger
* @param \Signifyd\Connect\Helper\ConfigHelper $configHelper
* @param \Magento\Sales\Model\OrderFactory $orderFactory
* @param \Magento\Framework\Data\Form\FormKey $formKey
* @param \Magento\Framework\View\File $file
*/
public function __construct(
Context $context,
DateTime $dateTime,
Logger $logger,
\Signifyd\Connect\Helper\ConfigHelper $configHelper,
\Magento\Sales\Model\OrderFactory $orderFactory,
\Magento\Framework\Data\Form\FormKey $formKey
\Magento\Framework\Data\Form\FormKey $formKey,
File $file
) {
parent::__construct($context);

$this->logger = $logger;
$this->objectManager = $context->getObjectManager();
$this->configHelper = $configHelper;
$this->orderFactory = $orderFactory;
$this->file = $file;

// Compatibility with Magento 2.3+ which required form_key on every request
// Magento expects class to implement \Magento\Framework\App\CsrfAwareActionInterface but this causes
Expand All @@ -79,7 +90,7 @@ protected function getRawPost()
return $HTTP_RAW_POST_DATA;
}

$post = file_get_contents("php://input");
$post = $this->file->fileGetContents("php://input");

if ($post) {
return $post;
Expand Down
20 changes: 13 additions & 7 deletions Model/Casedata.php
Original file line number Diff line number Diff line change
Expand Up @@ -466,17 +466,18 @@ public function updateOrder($caseData, $orderAction, $case)

break;

// Do nothing, but do not complete the case on Magento side
// This action should be used when something is processing on Signifyd end and extension should wait
// E.g.: Signifyd returns guarantee disposition PENDING because case it is on manual review
case 'wait':
$orderAction['action'] = false;
break;

// Nothing is an action from Signifyd workflow, different from when no action is given (null or empty)
// If workflow is set to do nothing, so complete the case
case 'nothing':
$orderAction['action'] = false;

try {
$completeCase = true;
} catch (\Exception $e) {
$this->logger->debug($e->__toString(), ['entity' => $case]);
return false;
}
$completeCase = true;
break;
}

Expand Down Expand Up @@ -513,8 +514,13 @@ protected function handleGuaranteeChange($caseData)
switch ($response->guaranteeDisposition) {
case "DECLINED":
return ["action" => $negativeAction, "reason" => "guarantee declined"];

case "APPROVED":
return ["action" => $positiveAction, "reason" => "guarantee approved"];

case 'PENDING':
return ["action" => 'wait', "reason" => 'case in manual review'];

default:
$message = "Signifyd: Unknown guaranty: " . $response->guaranteeDisposition;
$this->logger->debug($message, ['entity' => $caseData['case']]);
Expand Down
2 changes: 1 addition & 1 deletion composer.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"php": ">=5.5.22"
},
"type": "magento2-module",
"version": "3.5.0",
"version": "3.5.1",
"autoload": {
"files": [
"registration.php"
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="3.5.0">
<module name="Signifyd_Connect" setup_version="3.5.1">
<sequence>
<module name="Magento_Sales" />
<module name="Magento_Payment" />
Expand Down

0 comments on commit 1af3a17

Please sign in to comment.