Skip to content

Commit 1af3a17

Browse files
Fixing for cron and pending status
3.5.1
2 parents c851dc7 + b3e7da9 commit 1af3a17

File tree

4 files changed

+28
-11
lines changed

4 files changed

+28
-11
lines changed

Controller/Webhooks/Index.php

+13-2
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
use Signifyd\Connect\Logger\Logger;
1212
use Magento\Framework\App\Action\Action;
1313
use Magento\Framework\App\RequestInterface;
14+
use Magento\Framework\Filesystem\Driver\File;
1415

1516
/**
1617
* Controller action for handling webhook posts from Signifyd service
@@ -38,26 +39,36 @@ class Index extends Action
3839
protected $orderFactory;
3940

4041
/**
42+
* @var File
43+
*/
44+
protected $file;
45+
46+
/**
47+
* Index constructor.
4148
* @param Context $context
4249
* @param DateTime $dateTime
4350
* @param Logger $logger
4451
* @param \Signifyd\Connect\Helper\ConfigHelper $configHelper
4552
* @param \Magento\Sales\Model\OrderFactory $orderFactory
53+
* @param \Magento\Framework\Data\Form\FormKey $formKey
54+
* @param \Magento\Framework\View\File $file
4655
*/
4756
public function __construct(
4857
Context $context,
4958
DateTime $dateTime,
5059
Logger $logger,
5160
\Signifyd\Connect\Helper\ConfigHelper $configHelper,
5261
\Magento\Sales\Model\OrderFactory $orderFactory,
53-
\Magento\Framework\Data\Form\FormKey $formKey
62+
\Magento\Framework\Data\Form\FormKey $formKey,
63+
File $file
5464
) {
5565
parent::__construct($context);
5666

5767
$this->logger = $logger;
5868
$this->objectManager = $context->getObjectManager();
5969
$this->configHelper = $configHelper;
6070
$this->orderFactory = $orderFactory;
71+
$this->file = $file;
6172

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

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

8495
if ($post) {
8596
return $post;

Model/Casedata.php

+13-7
Original file line numberDiff line numberDiff line change
@@ -466,17 +466,18 @@ public function updateOrder($caseData, $orderAction, $case)
466466

467467
break;
468468

469+
// Do nothing, but do not complete the case on Magento side
470+
// This action should be used when something is processing on Signifyd end and extension should wait
471+
// E.g.: Signifyd returns guarantee disposition PENDING because case it is on manual review
472+
case 'wait':
473+
$orderAction['action'] = false;
474+
break;
475+
469476
// Nothing is an action from Signifyd workflow, different from when no action is given (null or empty)
470477
// If workflow is set to do nothing, so complete the case
471478
case 'nothing':
472479
$orderAction['action'] = false;
473-
474-
try {
475-
$completeCase = true;
476-
} catch (\Exception $e) {
477-
$this->logger->debug($e->__toString(), ['entity' => $case]);
478-
return false;
479-
}
480+
$completeCase = true;
480481
break;
481482
}
482483

@@ -513,8 +514,13 @@ protected function handleGuaranteeChange($caseData)
513514
switch ($response->guaranteeDisposition) {
514515
case "DECLINED":
515516
return ["action" => $negativeAction, "reason" => "guarantee declined"];
517+
516518
case "APPROVED":
517519
return ["action" => $positiveAction, "reason" => "guarantee approved"];
520+
521+
case 'PENDING':
522+
return ["action" => 'wait', "reason" => 'case in manual review'];
523+
518524
default:
519525
$message = "Signifyd: Unknown guaranty: " . $response->guaranteeDisposition;
520526
$this->logger->debug($message, ['entity' => $caseData['case']]);

composer.json

+1-1
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
"php": ">=5.5.22"
88
},
99
"type": "magento2-module",
10-
"version": "3.5.0",
10+
"version": "3.5.1",
1111
"autoload": {
1212
"files": [
1313
"registration.php"

etc/module.xml

+1-1
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
*/
66
-->
77
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="urn:magento:framework:Module/etc/module.xsd">
8-
<module name="Signifyd_Connect" setup_version="3.5.0">
8+
<module name="Signifyd_Connect" setup_version="3.5.1">
99
<sequence>
1010
<module name="Magento_Sales" />
1111
<module name="Magento_Payment" />

0 commit comments

Comments
 (0)