Signifyd_Connect - Version 3.16.3

Version Notes

Supports all versions of Magento

Download this release

Release Info

Developer signifyd
Extension Signifyd_Connect
Version 3.16.3
Comparing to
See all releases


Code changes from version 3.16.1 to 3.16.3

app/code/community/Signifyd/Connect/Block/Renderer.php CHANGED
@@ -8,8 +8,8 @@ class Signifyd_Connect_Block_Renderer extends Mage_Adminhtml_Block_Widget_Grid_C
8
$column = $this->getColumn()->getId();
9
$helper = Mage::helper('signifyd_connect');
10
11
- $url = $helper->getCaseUrl($row->getIncrementId());
12
-
13
if ($column == "score") {
14
if(!is_numeric($value)) {
15
return $helper->__('N/A');
8
$column = $this->getColumn()->getId();
9
$helper = Mage::helper('signifyd_connect');
10
11
+ $url = $helper->getCaseUrlByOrderId($row->getIncrementId());
12
+
13
if ($column == "score") {
14
if(!is_numeric($value)) {
15
return $helper->__('N/A');
app/code/community/Signifyd/Connect/Helper/Data.php CHANGED
@@ -1,5 +1,11 @@
1
<?php
2
-
3
class Signifyd_Connect_Helper_Data extends Mage_Core_Helper_Abstract
4
{
5
const UNPROCESSED_STATUS = 0;
@@ -7,11 +13,6 @@ class Signifyd_Connect_Helper_Data extends Mage_Core_Helper_Abstract
7
const CASE_CREATED_STATUS = 2;
8
const TRANSACTION_SENT_STATUS = 3;
9
10
- const WAITING_SUBMISSION_STATUS = "waiting_submission";
11
- const IN_REVIEW_STATUS = "in_review";
12
- const PROCESSING_RESPONSE_STATUS = "processing_response";
13
- const COMPLETED_STATUS = "completed";
14
-
15
public function logRequest($message)
16
{
17
if (Mage::getStoreConfig('signifyd_connect/log/all')) {
@@ -413,12 +414,29 @@ class Signifyd_Connect_Helper_Data extends Mage_Core_Helper_Abstract
413
return $this->request($url, $case, $auth, 'application/json');
414
}
415
416
public function getUrl()
417
{
418
- // return Mage::getStoreConfig('signifyd_connect/settings/url') . '/cases';
419
return 'https://api.signifyd.com/v2/cases';
420
}
421
422
public function getAuth()
423
{
424
return Mage::getStoreConfig('signifyd_connect/settings/key');
@@ -527,7 +545,7 @@ class Signifyd_Connect_Helper_Data extends Mage_Core_Helper_Abstract
527
$case_object->setUpdated(strftime('%Y-%m-%d %H:%M:%S', time()));
528
$case_object->setCode($caseId);
529
$case_object->setTransactionId($case['purchase']['transactionId']);
530
- $case_object->setMagentoStatus(self::IN_REVIEW_STATUS);
531
$case_object->save();
532
533
$order->addStatusHistoryComment("Signifyd: case $caseId created for order");
@@ -556,7 +574,7 @@ class Signifyd_Connect_Helper_Data extends Mage_Core_Helper_Abstract
556
return $url;
557
}
558
559
- public function getCaseUrl($order_id)
560
{
561
$case = Mage::getModel('signifyd_connect/case')->load($order_id);
562
@@ -789,8 +807,33 @@ class Signifyd_Connect_Helper_Data extends Mage_Core_Helper_Abstract
789
return ($case->getGuarantee() == 'DECLINED')? true : false;
790
}
791
792
public function isEnabled()
793
{
794
return Mage::getStoreConfig('signifyd_connect/settings/enabled');
795
}
796
}
1
<?php
2
+ /**
3
+ * Data Helper
4
+ *
5
+ * @category Signifyd Connect
6
+ * @package Signifyd_Connect
7
+ * @author Signifyd
8
+ */
9
class Signifyd_Connect_Helper_Data extends Mage_Core_Helper_Abstract
10
{
11
const UNPROCESSED_STATUS = 0;
13
const CASE_CREATED_STATUS = 2;
14
const TRANSACTION_SENT_STATUS = 3;
15
16
public function logRequest($message)
17
{
18
if (Mage::getStoreConfig('signifyd_connect/log/all')) {
414
return $this->request($url, $case, $auth, 'application/json');
415
}
416
417
+ /**
418
+ * Getting the cases url
419
+ * @return string
420
+ */
421
public function getUrl()
422
{
423
return 'https://api.signifyd.com/v2/cases';
424
}
425
426
+ /**
427
+ * Getting the case url based on the case code
428
+ * @param $caseCode
429
+ * @return string
430
+ */
431
+ public function getCaseUrl($caseCode)
432
+ {
433
+ return 'https://api.signifyd.com/v2/cases/' . $caseCode;
434
+ }
435
+
436
+ /**
437
+ * Getting the Api Key for authentication with Signifyd
438
+ * @return mixed
439
+ */
440
public function getAuth()
441
{
442
return Mage::getStoreConfig('signifyd_connect/settings/key');
545
$case_object->setUpdated(strftime('%Y-%m-%d %H:%M:%S', time()));
546
$case_object->setCode($caseId);
547
$case_object->setTransactionId($case['purchase']['transactionId']);
548
+ $case_object->setMagentoStatus(Signifyd_Connect_Model_Case::IN_REVIEW_STATUS);
549
$case_object->save();
550
551
$order->addStatusHistoryComment("Signifyd: case $caseId created for order");
574
return $url;
575
}
576
577
+ public function getCaseUrlByOrderId($order_id)
578
{
579
$case = Mage::getModel('signifyd_connect/case')->load($order_id);
580
807
return ($case->getGuarantee() == 'DECLINED')? true : false;
808
}
809
810
+ /**
811
+ * Is the extension enabled in the admin
812
+ * @return mixed
813
+ */
814
public function isEnabled()
815
{
816
return Mage::getStoreConfig('signifyd_connect/settings/enabled');
817
}
818
+
819
+ /**
820
+ * Getting the action for accepted from guaranty
821
+ * @param $storeId
822
+ * @return mixed
823
+ */
824
+ public function getAcceptedFromGuaranty($storeId){
825
+ return Mage::getStoreConfig('signifyd_connect/advanced/accepted_from_guaranty', $storeId);
826
+ }
827
+
828
+ /**
829
+ * Getting the action for declined from guaranty
830
+ * @param $storeId
831
+ * @return mixed
832
+ */
833
+ public function getDeclinedFromGuaranty($storeId){
834
+ return Mage::getStoreConfig('signifyd_connect/advanced/declined_from_guaranty', $storeId);
835
+ }
836
}
837
+
838
+ /* Filename: Data.php */
839
+ /* Location: ../app/code/Community/Signifyd/Connect/Helper/Data.php */
app/code/community/Signifyd/Connect/Helper/Log.php CHANGED
@@ -17,7 +17,15 @@ class Signifyd_Connect_Helper_Log extends Mage_Core_Helper_Abstract
17
18
public function addLog($msg)
19
{
20
- return Mage::log($msg, null, $this->logFile);
21
}
22
}
23
17
18
public function addLog($msg)
19
{
20
+ if($this->isLogEnabled())
21
+ Mage::log($msg, null, $this->logFile);
22
+
23
+ return true;
24
+ }
25
+
26
+ public function isLogEnabled()
27
+ {
28
+ return Mage::getStoreConfig('signifyd_connect/log/all');
29
}
30
}
31
app/code/community/Signifyd/Connect/Model/Case.php CHANGED
@@ -1,14 +1,55 @@
1
<?php
2
-
3
class Signifyd_Connect_Model_Case extends Mage_Core_Model_Abstract
4
{
5
protected $logger;
6
7
protected function _construct()
8
{
9
$this->_init('signifyd_connect/case');
10
$this->_isPkAutoIncrement = false;
11
$this->logger = Mage::helper('signifyd_connect/log');
12
}
13
14
public function setMagentoStatusTo($case, $status)
@@ -26,4 +67,247 @@ class Signifyd_Connect_Model_Case extends Mage_Core_Model_Abstract
26
27
return true;
28
}
29
}
1
<?php
2
+ /**
3
+ * Case Model
4
+ *
5
+ * @category Signifyd Connect
6
+ * @package Signifyd_Connect
7
+ * @author Signifyd
8
+ */
9
class Signifyd_Connect_Model_Case extends Mage_Core_Model_Abstract
10
{
11
+ /* The log helper */
12
protected $logger;
13
14
+ /* The order related to the case */
15
+ protected $order = false;
16
+
17
+ /* The store id of the order related to the case */
18
+ protected $storeId;
19
+
20
+ /* The topic of the request */
21
+ protected $topic;
22
+
23
+ /* The data helper */
24
+ protected $helper;
25
+
26
+ /* The request data */
27
+ protected $_request;
28
+
29
+ /* The previous guarantee for the case */
30
+ public $_previousGuarantee = false;
31
+
32
+ /* The previous score for the case */
33
+ public $_previousScore = false;
34
+
35
+ /* The status when a case is created */
36
+ const WAITING_SUBMISSION_STATUS = "waiting_submission";
37
+
38
+ /* The status for a case when the first response from Signifyd is received */
39
+ const IN_REVIEW_STATUS = "in_review";
40
+
41
+ /* The status for a case when the case is processing the response */
42
+ const PROCESSING_RESPONSE_STATUS = "processing_response";
43
+
44
+ /* The status for a case that is completed */
45
+ const COMPLETED_STATUS = "completed";
46
+
47
protected function _construct()
48
{
49
$this->_init('signifyd_connect/case');
50
$this->_isPkAutoIncrement = false;
51
$this->logger = Mage::helper('signifyd_connect/log');
52
+ $this->helper = Mage::helper('signifyd_connect');
53
}
54
55
public function setMagentoStatusTo($case, $status)
67
68
return true;
69
}
70
+
71
+ public function processFallback($request)
72
+ {
73
+ $this->logger->addLog('Attempting auth via fallback request');
74
+ $request = json_decode($request, true);
75
+ $this->_request = $request;
76
+ $this->topic = "cases/review"; // Topic header is most likely not available
77
+
78
+ if (is_array($request) && isset($request['orderId']))
79
+ $case = $this->load($request['orderId']);
80
+ else
81
+ return false;
82
+
83
+ $this->order = Mage::getModel('sales/order')->loadByIncrementId($request['orderId']);
84
+
85
+ if ($this->order && $this->order->getId()) {
86
+ $this->storeId = $this->order->getStoreId();
87
+ }
88
+
89
+ if ($case) {
90
+ $lookup = $this->caseLookup($case);
91
+ if ($lookup && is_array($lookup)) {
92
+ $this->processReview($case, $lookup);
93
+ } else {
94
+ $this->logger->addLog('Fallback failed with an invalid response from Signifyd');
95
+ }
96
+ } else {
97
+ $this->logger->addLog('Fallback failed with no matching case found');
98
+ }
99
+
100
+ return true;
101
+ }
102
+
103
+ public function processReview($case, $request)
104
+ {
105
+ if (!$case) return;
106
+ $this->_request = $request;
107
+ $this->setPrevious($case);
108
+ $this->setOrder();
109
+ $this->logger->addLog('Process review case:' . $case->getId());
110
+
111
+ $original_status = $case->getSignifydStatus();
112
+
113
+ $case = $this->updateScore($case);
114
+ $case = $this->updateStatus($case);
115
+ $case = $this->updateGuarantee($case);
116
+
117
+ $case->setUpdated(strftime('%Y-%m-%d %H:%M:%S', time()));
118
+ try {
119
+ $case->save();
120
+ $this->processAdditional($case, $original_status);
121
+ } catch (Exception $e) {
122
+ $this->logger->addLog('Process review error: ' . $e->__toString());
123
+ }
124
+
125
+ }
126
+
127
+ public function processAdditional($case, $original_status = false, $custom_order = null)
128
+ {
129
+ $this->logger->addLog('Process additional case: ' . $case['order_increment']);
130
+ if ($custom_order)
131
+ $order = $custom_order;
132
+ else
133
+ $order = $this->order;
134
+
135
+ if ($order && $order->getId()) {
136
+ $positiveAction = $this->helper->getAcceptedFromGuaranty($order->getStoreId());
137
+ $negativeAction = $this->helper->getDeclinedFromGuaranty($order->getStoreId());
138
+ $newGuarantee = null;
139
+ try{
140
+ if ($custom_order)
141
+ $newGuarantee = $case['guarantee'];
142
+ else
143
+ $newGuarantee = isset($this->_request['guaranteeDisposition']) ? $this->_request['guaranteeDisposition'] : null;
144
+ } catch(Exception $e){
145
+ $this->logger->addLog('ERROR ON WEBHOOK: ' . $e->__toString());
146
+ }
147
+
148
+ // If a guarantee has been set, we no longer care about other actions
149
+ if (isset($newGuarantee) && $newGuarantee != $this->_previousGuarantee) {
150
+ // Loading the signifyd order model
151
+ $orderModel = Mage::getModel('signifyd_connect/order');
152
+ if ($newGuarantee == 'DECLINED' ) {
153
+ if ($negativeAction == 1) {
154
+ // this is for when config is set to keep order on hold
155
+ $orderModel->keepOrderOnHold($order, "guarantee declined");
156
+ $orderModel->finalStatus($order, 1, $case);
157
+ } else if ($negativeAction == 2) {
158
+ // this is for when config is set to cancel close order
159
+ // $orderModel->cancelCloseOrder($order, "guarantee declined");
160
+ $orderModel->finalStatus($order, 2, $case);
161
+ } else {
162
+ // this is when the config is not set or it is set to something unknown
163
+ $this->logger->addLog("Unknown action $negativeAction");
164
+ }
165
+ } else if ($newGuarantee == 'APPROVED') {
166
+ if ($positiveAction == 1) {
167
+ // this is for when config is set to unhold order
168
+ $orderModel->unholdOrder($order, "guarantee approved");
169
+ $orderModel->finalStatus($order, 2, $case);
170
+ } elseif($positiveAction == 2){
171
+ // this is for when config is set to unhold, invoice and capture
172
+ // $orderModel->unholdOrderAndCapture($order, "guarantee approved");
173
+ $orderModel->finalStatus($order, 2, $case);
174
+ } else {
175
+ // this is when the config is not set or it is set to something unknown
176
+ $this->logger->addLog("Unknown action $positiveAction");
177
+ }
178
+ }
179
+ // add else for unknown guarantee
180
+ }
181
+ }
182
+
183
+ return true;
184
+ }
185
+
186
+ public function caseLookup($case)
187
+ {
188
+ $result = false;
189
+
190
+ try {
191
+ $url = $this->helper->getUrl() . '/' . $case->getCode();
192
+ $response = $this->helper->request($url, null, $this->helper->getAuth(), null, 'application/json');
193
+ $response_code = $response->getHttpCode();
194
+ if (substr($response_code, 0, 1) == '2') {
195
+ $result = json_decode($response->getRawResponse(), true);
196
+ } else {
197
+ $this->logger->addLog('Fallback request received a ' . $response_code . ' response from Signifyd');
198
+ }
199
+ } catch (Exception $e) {
200
+ $this->logger->addLog('Fallback issue: ' . $e->__toString());
201
+ }
202
+
203
+ return $result;
204
+ }
205
+
206
+ private function updateScore($case)
207
+ {
208
+ if (isset($this->_request['score'])) {
209
+ $case->setScore($this->_request['score']);
210
+ $this->logger->addLog('Set score to ' . $this->_request['score']);
211
+ } else {
212
+ $this->logger->addLog('No score value available');
213
+ }
214
+
215
+ return $case;
216
+ }
217
+
218
+ private function updateStatus($case)
219
+ {
220
+ if (isset($this->_request['status'])) {
221
+ $case->setSignifydStatus($this->_request['status']);
222
+ $this->logger->addLog('Set status to ' . $this->_request['status']);
223
+ } else {
224
+ $this->logger->addLog('No status value available');
225
+ }
226
+
227
+ return $case;
228
+ }
229
+
230
+ private function updateGuarantee($case)
231
+ {
232
+ try {
233
+ if (isset($this->_request['guaranteeDisposition'])) {
234
+ $case->setGuarantee($this->_request['guaranteeDisposition']);
235
+ $case->setMagentoStatus(self::PROCESSING_RESPONSE_STATUS);
236
+ $this->logger->addLog('Set guarantee to ' . $this->_request['guaranteeDisposition']);
237
+ }
238
+ } catch(Exception $e) {
239
+ $this->logger->addLog('ERROR ON WEBHOOK: ' . $e->__toString());
240
+ }
241
+
242
+ return $case;
243
+ }
244
+
245
+ public function processCreation($case, $request)
246
+ {
247
+ if (!$case) return false;
248
+ $this->_request = $request;
249
+ $this->setPrevious($case);
250
+ $this->setOrder();
251
+
252
+ $case = $this->updateScore($case);
253
+ $case = $this->updateStatus($case);
254
+ $case = $this->updateGuarantee($case);
255
+
256
+ $case->setUpdated(strftime('%Y-%m-%d %H:%M:%S', time()));
257
+ try {
258
+ $case->save();
259
+ $this->processAdditional($case);
260
+ $this->logger->addLog('Case ' . $case->getId() . ' created with status ' . $case->getSignifydStatus() . ' and score ' . $case->getScore());
261
+ } catch (Exception $e) {
262
+ $this->logger->addLog('Process creation error: ' . $e->__toString());
263
+ return false;
264
+ }
265
+
266
+ return true;
267
+ }
268
+
269
+ public function processGuarantee($case, $request)
270
+ {
271
+ if (!$case) return false;
272
+ $this->_request = $request;
273
+ $this->setPrevious($case);
274
+ $this->setOrder();
275
+
276
+ $original_status = $case->getSignifydStatus();
277
+
278
+ $case = $this->updateScore($case);
279
+ $case = $this->updateStatus($case);
280
+ $case = $this->updateGuarantee($case);
281
+
282
+ $case->setUpdated(strftime('%Y-%m-%d %H:%M:%S', time()));
283
+ try {
284
+ $case->save();
285
+ $this->processAdditional($case, $original_status);
286
+ } catch (Exception $e) {
287
+ $this->logger->addLog('Process guarantee error: ' . $e->__toString());
288
+ return false;
289
+ }
290
+
291
+ return true;
292
+ }
293
+
294
+ /**
295
+ * Setting the previous case guarantee and score
296
+ * @param $case
297
+ */
298
+ public function setPrevious($case)
299
+ {
300
+ $this->_previousGuarantee = $case->getGuarantee();
301
+ $this->_previousScore = $case->getScore();
302
+ }
303
+
304
+ public function setOrder(){
305
+ if($this->order === false){
306
+ $this->order = Mage::getModel('sales/order')->loadByIncrementId($this->_request['orderId']);
307
+ }
308
+ return;
309
+ }
310
}
311
+
312
+ /* Filename: Case.php */
313
+ /* Location: ../app/code/Community/Signifyd/Connect/Model/Case.php */
app/code/community/Signifyd/Connect/Model/Cron.php CHANGED
@@ -8,23 +8,16 @@
8
*/
9
class Signifyd_Connect_Model_Cron
10
{
11
- /* The status when a case is created */
12
- const WAITING_SUBMISSION_STATUS = "waiting_submission";
13
-
14
- /* The status for a case when the first response from Signifyd is received */
15
- const IN_REVIEW_STATUS = "in_review";
16
-
17
- /* The status for a case when the case is processing the response */
18
- const PROCESSING_RESPONSE_STATUS = "processing_response";
19
-
20
- /* The status for a case that is completed */
21
- const COMPLETED_STATUS = "completed";
22
-
23
protected $logger;
24
25
public function __construct()
26
{
27
$this->logger = Mage::helper('signifyd_connect/log');
28
}
29
30
/**
@@ -34,7 +27,7 @@ class Signifyd_Connect_Model_Cron
34
{
35
$this->logger->addLog("Main retry method called");
36
// Getting all the cases that were not submitted to Signifyd
37
- $cases_for_resubmit = $this->getRetryCasesByStatus(self::WAITING_SUBMISSION_STATUS);
38
foreach ($cases_for_resubmit as $current_case) {
39
$this->logger->addLog("Signifyd: preparing for send case no: {$current_case['order_increment']}");
40
$current_order_id = $current_case['order_increment'];
@@ -43,22 +36,19 @@ class Signifyd_Connect_Model_Cron
43
}
44
45
// Getting all the cases that are awaiting review from Signifyd
46
- $cases_for_resubmit = $this->getRetryCasesByStatus(self::IN_REVIEW_STATUS);
47
foreach ($cases_for_resubmit as $current_case) {
48
$this->logger->addLog("Signifyd: preparing for review case no: {$current_case['order_increment']}");
49
$this->processInReviewCase($current_case);
50
}
51
52
// Getting all the cases that need processing after the response was received
53
- $cases_for_resubmit = $this->getRetryCasesByStatus(self::PROCESSING_RESPONSE_STATUS);
54
foreach ($cases_for_resubmit as $current_case) {
55
- $this->logger->addLog("Signifyd: preparing for review case no: {$current_case['order_increment']}");
56
$current_order_id = $current_case['order_increment'];
57
$current_order = Mage::getModel('sales/order')->loadByIncrementId($current_order_id);
58
- // need to refactor this
59
- $this->loadClass();
60
- $signifyd_controller = @new Signifyd_Connect_ConnectController();
61
- $signifyd_controller->processAdditional($current_case,false,$current_order);
62
}
63
64
$this->logger->addLog("Main retry method ended");
@@ -90,46 +80,30 @@ class Signifyd_Connect_Model_Cron
90
/**
91
* Process the cases that are in review
92
* @param $case
93
*/
94
public function processInReviewCase($case)
95
{
96
- $case_url = $this->getCaseUrl($case['code']);
97
- $response = Mage::helper('signifyd_connect')->request($case_url,null,Mage::helper('signifyd_connect')->getAuth(),'application/json');
98
try {
99
$response_code = $response->getHttpCode();
100
if (substr($response_code, 0, 1) == '2') {
101
$response_data = $response->getRawResponse();
102
- // need to refactor this
103
- $this->loadClass();
104
- $signifyd_controller = @new Signifyd_Connect_ConnectController();
105
- $signifyd_controller->processFallback($response_data);
106
- return;
107
}
108
} catch (Exception $e) {
109
Mage::log($e->__toString(), null, 'signifyd_connect.log');
110
}
111
- }
112
-
113
- /**
114
- * Get the cases url
115
- * @param $case_code
116
- * @return string
117
- */
118
- public function getCaseUrl($case_code)
119
- {
120
- // $url = Mage::getStoreConfig('signifyd_connect/settings/url') . '/cases/' . $case_code;
121
- // return (empty($url))? "https://api.signifyd.com/v2/cases/" . $case_code : $url;
122
- return 'https://api.signifyd.com/v2/cases/' . $case_code;
123
- }
124
125
- public function loadClass(){
126
- if(!@class_exists('Signifyd_Connect_ConnectController')) //in case the class already exists
127
- {
128
- $dir = Mage::getModuleDir('controllers', 'Signifyd_Connect');
129
- require_once($dir . '/ConnectController.php');
130
- }
131
return true;
132
}
133
}
134
135
/* Filename: Cron.php */
8
*/
9
class Signifyd_Connect_Model_Cron
10
{
11
protected $logger;
12
+ protected $helper;
13
14
+ /**
15
+ * Signifyd_Connect_Model_Cron constructor.
16
+ */
17
public function __construct()
18
{
19
$this->logger = Mage::helper('signifyd_connect/log');
20
+ $this->helper = Mage::helper('signifyd_connect');
21
}
22
23
/**
27
{
28
$this->logger->addLog("Main retry method called");
29
// Getting all the cases that were not submitted to Signifyd
30
+ $cases_for_resubmit = $this->getRetryCasesByStatus(Signifyd_Connect_Model_Case::WAITING_SUBMISSION_STATUS);
31
foreach ($cases_for_resubmit as $current_case) {
32
$this->logger->addLog("Signifyd: preparing for send case no: {$current_case['order_increment']}");
33
$current_order_id = $current_case['order_increment'];
36
}
37
38
// Getting all the cases that are awaiting review from Signifyd
39
+ $cases_for_resubmit = $this->getRetryCasesByStatus(Signifyd_Connect_Model_Case::IN_REVIEW_STATUS);
40
foreach ($cases_for_resubmit as $current_case) {
41
$this->logger->addLog("Signifyd: preparing for review case no: {$current_case['order_increment']}");
42
$this->processInReviewCase($current_case);
43
}
44
45
// Getting all the cases that need processing after the response was received
46
+ $cases_for_resubmit = $this->getRetryCasesByStatus(Signifyd_Connect_Model_Case::PROCESSING_RESPONSE_STATUS);
47
foreach ($cases_for_resubmit as $current_case) {
48
+ $this->logger->addLog("Signifyd: preparing for response processing of case no: {$current_case['order_increment']}");
49
$current_order_id = $current_case['order_increment'];
50
$current_order = Mage::getModel('sales/order')->loadByIncrementId($current_order_id);
51
+ Mage::getModel('signifyd_connect/case')->processAdditional($current_case, false, $current_order);
52
}
53
54
$this->logger->addLog("Main retry method ended");
80
/**
81
* Process the cases that are in review
82
* @param $case
83
+ * @return bool
84
*/
85
public function processInReviewCase($case)
86
{
87
+ if(empty($case['code'])) return false;
88
+
89
+ $this->logger->addLog('Process in review case: ' . $case['code']);
90
+ $case_url = $this->helper->getCaseUrl($case['code']);
91
+ $response = $this->helper->request($case_url,null, $this->helper->getAuth(),'application/json');
92
try {
93
$response_code = $response->getHttpCode();
94
if (substr($response_code, 0, 1) == '2') {
95
$response_data = $response->getRawResponse();
96
+ Mage::getModel('signifyd_connect/case')->processFallback($response_data);
97
+ return true;
98
}
99
} catch (Exception $e) {
100
Mage::log($e->__toString(), null, 'signifyd_connect.log');
101
+ return false;
102
}
103
104
return true;
105
}
106
+
107
}
108
109
/* Filename: Cron.php */
app/code/community/Signifyd/Connect/Model/Order.php CHANGED
@@ -363,6 +363,7 @@ class Signifyd_Connect_Model_Order extends Mage_Core_Model_Abstract
363
public function finalStatus($order, $type, $case)
364
{
365
$id = (is_array($case))? $case['order_increment'] : $case->getId();
366
try {
367
$holdStatus = $this->checkStatus($order, Mage_Sales_Model_Order::STATE_HOLDED);
368
$caseModel = Mage::getModel('signifyd_connect/case');
@@ -370,20 +371,20 @@ class Signifyd_Connect_Model_Order extends Mage_Core_Model_Abstract
370
if($type == 1){
371
// needs to be true
372
if($holdStatus === true){
373
- $caseModel->setMagentoStatusTo($case, Signifyd_Connect_Helper_Data::COMPLETED_STATUS);
374
}
375
} elseif($type == 2) {
376
// needs to be false
377
if($holdStatus === false){
378
- $caseModel->setMagentoStatusTo($case, Signifyd_Connect_Helper_Data::COMPLETED_STATUS);
379
}
380
} else {
381
$this->logger->addLog('Final status unknown type');
382
}
383
384
- $this->logger->addLog("Case no:{$id}, set status to complete successful.");
385
} catch (Exception $e){
386
- $this->logger->addLog("Case no:{$id}, set status to complete fail: " . $e->__toString());
387
return false;
388
}
389
363
public function finalStatus($order, $type, $case)
364
{
365
$id = (is_array($case))? $case['order_increment'] : $case->getId();
366
+ $this->logger->addLog("Final status for case: {$id}");
367
try {
368
$holdStatus = $this->checkStatus($order, Mage_Sales_Model_Order::STATE_HOLDED);
369
$caseModel = Mage::getModel('signifyd_connect/case');
371
if($type == 1){
372
// needs to be true
373
if($holdStatus === true){
374
+ $caseModel->setMagentoStatusTo($case, Signifyd_Connect_Model_Case::COMPLETED_STATUS);
375
}
376
} elseif($type == 2) {
377
// needs to be false
378
if($holdStatus === false){
379
+ $caseModel->setMagentoStatusTo($case, Signifyd_Connect_Model_Case::COMPLETED_STATUS);
380
}
381
} else {
382
$this->logger->addLog('Final status unknown type');
383
}
384
385
+ $this->logger->addLog("Case no: {$id}, set status to complete successful.");
386
} catch (Exception $e){
387
+ $this->logger->addLog("Case no: {$id}, set status to complete fail: " . $e->__toString());
388
return false;
389
}
390
app/code/community/Signifyd/Connect/controllers/ConnectController.php CHANGED
@@ -10,77 +10,46 @@ class Signifyd_Connect_ConnectController extends Mage_Core_Controller_Front_Acti
10
{
11
public $_request = array();
12
public $_topic = false;
13
- public $_order = false;
14
- public $_store_id = null;
15
public $_case = false;
16
- public $_previousGuarantee = false;
17
- public $_previousScore = false;
18
- public $_unholdRetries = 0;
19
-
20
- const WAITING_SUBMISSION_STATUS = "waiting_submission";
21
- const IN_REVIEW_STATUS = "in_review";
22
- const PROCESSING_RESPONSE_STATUS = "processing_response";
23
- const COMPLETED_STATUS = "completed";
24
-
25
- public function getApiKey()
26
- {
27
- return Mage::getStoreConfig('signifyd_connect/settings/key');
28
- }
29
-
30
- public function getAcceptedFromGuaranty(){
31
- return Mage::getStoreConfig('signifyd_connect/advanced/accepted_from_guaranty', $this->_store_id);
32
- }
33
-
34
- public function getDeclinedFromGuaranty(){
35
- return Mage::getStoreConfig('signifyd_connect/advanced/declined_from_guaranty', $this->_store_id);
36
- }
37
-
38
- public function enabled()
39
- {
40
- return Mage::getStoreConfig('signifyd_connect/settings/enabled');
41
- }
42
-
43
- public function getUrl($code)
44
- {
45
- // return Mage::getStoreConfig('signifyd_connect/settings/url', $this->_store_id) . '/cases/' . $code;
46
- return 'https://api.signifyd.com/v2/cases/' . $code;
47
- }
48
-
49
- public function logErrors()
50
- {
51
- return Mage::getStoreConfig('signifyd_connect/log/all');
52
- }
53
-
54
- public function logRequest()
55
- {
56
- return Mage::getStoreConfig('signifyd_connect/log/all');
57
- }
58
59
public function getRawPost()
60
{
61
- if (isset($HTTP_RAW_POST_DATA) && $HTTP_RAW_POST_DATA) {
62
return $HTTP_RAW_POST_DATA;
63
- }
64
65
$post = file_get_contents("php://input");
66
-
67
- if ($post) {
68
return $post;
69
- }
70
71
return '';
72
}
73
74
public function getDefaultMessage()
75
{
76
return 'This URL is working! Please copy & paste the current URL into your <a href="https://signifyd.com/settings">settings</a> page in the Notifications section';
77
}
78
79
public function getDisabledMessage()
80
{
81
return 'This URL is disabled in the Magento admin panel! Please enable score retrieval under Admin>System>Config>Signifyd Connect>Advanced before setting this url in your Signifyd <a href="https://signifyd.com/settings">settings</a> page.';
82
}
83
84
public function unsupported()
85
{
86
Mage::app()->getResponse()
@@ -90,6 +59,9 @@ class Signifyd_Connect_ConnectController extends Mage_Core_Controller_Front_Acti
90
exit;
91
}
92
93
public function complete()
94
{
95
Mage::app()->getResponse()
@@ -99,6 +71,9 @@ class Signifyd_Connect_ConnectController extends Mage_Core_Controller_Front_Acti
99
exit;
100
}
101
102
public function conflict()
103
{
104
Mage::app()->getResponse()
@@ -107,88 +82,41 @@ class Signifyd_Connect_ConnectController extends Mage_Core_Controller_Front_Acti
107
exit;
108
}
109
110
- private function updateScore($case)
111
- {
112
- if (isset($this->_request['score'])) {
113
- $case->setScore($this->_request['score']);
114
-
115
- if ($this->logRequest()) {
116
- Mage::log('Set score to ' . $this->_request['score'], null, 'signifyd_connect.log');
117
- }
118
- } else {
119
- if ($this->logRequest()) {
120
- Mage::log('No score value available', null, 'signifyd_connect.log');
121
- }
122
- }
123
- }
124
-
125
- private function updateStatus($case)
126
- {
127
- if (isset($this->_request['status'])) {
128
- $case->setSignifydStatus($this->_request['status']);
129
-
130
- if ($this->logRequest()) {
131
- Mage::log('Set status to ' . $this->_request['status'], null, 'signifyd_connect.log');
132
- }
133
- } else {
134
- if ($this->logRequest()) {
135
- Mage::log('No status value available', null, 'signifyd_connect.log');
136
- }
137
- }
138
- }
139
-
140
- private function updateGuarantee($case)
141
- {
142
- try {
143
- if (isset($this->_request['guaranteeDisposition'])) {
144
- $case->setGuarantee($this->_request['guaranteeDisposition']);
145
- $case->setMagentoStatus(self::PROCESSING_RESPONSE_STATUS);
146
-
147
- if ($this->logRequest()) {
148
- Mage::log('Set guarantee to ' . $this->_request['guaranteeDisposition'], null,
149
- 'signifyd_connect.log');
150
- }
151
- }
152
- } catch(Exception $e) {
153
- if ($this->logErrors()) {
154
- Mage::log('ERROR ON WEBHOOK: ' . $e->__toString(), null, 'signifyd_connect.log');
155
- }
156
- }
157
- }
158
-
159
public function validRequest($request, $hash)
160
{
161
- $check = base64_encode(hash_hmac('sha256', $request, $this->getApiKey(), true));
162
-
163
- if ($this->logRequest()) {
164
- Mage::log('API request hash check: ' . $check, null, 'signifyd_connect.log');
165
- }
166
167
if ($check == $hash) {
168
return true;
169
- }
170
- else if ($this->getHeader('X-SIGNIFYD-TOPIC') == "cases/test"){
171
// In the case that this is a webhook test, the encoding ABCDE is allowed
172
$check = base64_encode(hash_hmac('sha256', $request, 'ABCDE', true));
173
- if ($check == $hash) {
174
return true;
175
- }
176
}
177
178
return false;
179
}
180
181
- public function initCase($order_increment)
182
{
183
$case = false;
184
185
- if (isset($this->_request['orderId']))
186
- {
187
$case = Mage::getModel('signifyd_connect/case')->load($this->_request['orderId']);
188
if($case->isObjectNew()) {
189
- if ($this->logErrors()) {
190
- Mage::log('Case not yet in DB. Likely timing issue. order_increment: ' . $this->_request['orderId'], null, 'signifyd_connect.log');
191
- }
192
$this->conflict();
193
}
194
}
@@ -196,6 +124,10 @@ class Signifyd_Connect_ConnectController extends Mage_Core_Controller_Front_Acti
196
return $case;
197
}
198
199
public function initRequest($request)
200
{
201
$this->_request = json_decode($request, true);
@@ -207,208 +139,16 @@ class Signifyd_Connect_ConnectController extends Mage_Core_Controller_Front_Acti
207
// For the webhook test, all of the request data will be invalid
208
if ($topic == "cases/test") return;
209
210
- $this->_case = $this->initCase($this->_request['orderId']);
211
- $this->_previousGuarantee = $this->_case->getGuarantee();
212
- $this->_previousScore = $this->_case->getScore();
213
-
214
- $this->_order = Mage::getModel('sales/order')->loadByIncrementId($this->_request['orderId']);
215
-
216
- if ($this->_order && $this->_order->getId()) {
217
- $this->_store_id = $this->_order->getStoreId();
218
- }
219
-
220
- if (!$this->_case && $this->logRequest()) {
221
- Mage::log('No matching case was found for this request. order_increment: ' . $this->_request['orderId'], null, 'signifyd_connect.log');
222
- }
223
- }
224
-
225
- public function processAdditional($case, $original_status = false,$custom_order = null)
226
- {
227
- if ($custom_order)
228
- $order = $custom_order;
229
- else
230
- $order = $this->_order;
231
-
232
- if ($order && $order->getId()) {
233
- $positiveAction = $this->getAcceptedFromGuaranty();
234
- $negativeAction = $this->getDeclinedFromGuaranty();
235
- $newGuarantee = null;
236
- try{
237
- if ($custom_order)
238
- $newGuarantee = $case['guarantee'];
239
- else
240
- $newGuarantee = isset($this->_request ['guaranteeDisposition']) ? $this->_request ['guaranteeDisposition'] : null;
241
- } catch(Exception $e){
242
- if ($this->logErrors()) {
243
- Mage::log('ERROR ON WEBHOOK: ' . $e->__toString(), null, 'signifyd_connect.log');
244
- }
245
- }
246
- // If a guarantee has been set, we no longer care about other actions
247
- if (isset($newGuarantee) && $newGuarantee != $this->_previousGuarantee) {
248
- // Loading the signifyd order model
249
- $orderModel = Mage::getModel('signifyd_connect/order');
250
- if ($newGuarantee == 'DECLINED' ) {
251
- if ($negativeAction == 1) {
252
- // this is for when config is set to keep order on hold
253
- $orderModel->keepOrderOnHold($order, "guarantee declined");
254
- $orderModel->finalStatus($order, 1, $case);
255
- } else if ($negativeAction == 2) {
256
- // this is for when config is set to cancel close order
257
- // $orderModel->cancelCloseOrder($order, "guarantee declined");
258
- $orderModel->finalStatus($order, 2, $case);
259
- } else {
260
- // this is when the config is not set or it is set to something unknown
261
- Mage::log("Unknown action $negativeAction", null, 'signifyd_connect.log');
262
- }
263
- } else if ($newGuarantee == 'APPROVED') {
264
- if ($positiveAction == 1) {
265
- // this is for when config is set to unhold order
266
- $orderModel->unholdOrder($order, "guarantee approved");
267
- $orderModel->finalStatus($order, 2, $case);
268
- } elseif($positiveAction == 2){
269
- // this is for when config is set to unhold, invoice and capture
270
- // $orderModel->unholdOrderAndCapture($order, "guarantee approved");
271
- $orderModel->finalStatus($order, 2, $case);
272
- } else {
273
- // this is when the config is not set or it is set to something unknown
274
- Mage::log("Unknown action $positiveAction", null, 'signifyd_connect.log');
275
- }
276
- }
277
- // add else for unknown guarantee
278
- }
279
- }
280
- }
281
-
282
- public function processCreation()
283
- {
284
- $case = $this->_case;
285
-
286
- if (!$case) {
287
- return;
288
- }
289
-
290
- $this->updateScore($case);
291
- $this->updateStatus($case);
292
- $this->updateGuarantee($case);
293
-
294
- $case->setUpdated(strftime('%Y-%m-%d %H:%M:%S', time()));
295
- $case->save();
296
-
297
- if ($this->logRequest()) {
298
- Mage::log('Case ' . $case->getId() . ' created with status ' . $case->getSignifydStatus() . ' and score ' . $case->getScore(), null, 'signifyd_connect.log');
299
- }
300
-
301
- $this->processAdditional($case);
302
- }
303
-
304
- public function processReview()
305
- {
306
- $case = $this->_case;
307
-
308
- if (!$case) {
309
- return;
310
- }
311
-
312
- $original_status = $case->getSignifydStatus();
313
-
314
- $this->updateScore($case);
315
- $this->updateStatus($case);
316
- $this->updateGuarantee($case);
317
-
318
- $case->setUpdated(strftime('%Y-%m-%d %H:%M:%S', time()));
319
- $case->save();
320
-
321
- $this->processAdditional($case, $original_status);
322
- }
323
-
324
- public function processGuarantee()
325
- {
326
- $case = $this->_case;
327
-
328
- if (!$case) {
329
- return;
330
- }
331
-
332
- $original_status = $case->getSignifydStatus();
333
-
334
- $this->updateScore($case);
335
- $this->updateStatus($case);
336
- $this->updateGuarantee($case);
337
-
338
- $case->setUpdated(strftime('%Y-%m-%d %H:%M:%S', time()));
339
- $case->save();
340
-
341
- $this->processAdditional($case, $original_status);
342
- }
343
-
344
- public function caseLookup()
345
- {
346
- $result = false;
347
- $case = $this->_case;
348
-
349
- try {
350
- $url = $this->getUrl($case->getCode());
351
-
352
- $response = Mage::helper('signifyd_connect')->request($url, null, $this->getApiKey(), null, 'application/json');
353
-
354
- $response_code = $response->getHttpCode();
355
-
356
- if (substr($response_code, 0, 1) == '2') {
357
- $result = json_decode($response->getRawResponse(), true);
358
- } else {
359
- if ($this->logRequest()) {
360
- Mage::log('Fallback request received a ' . $response_code . ' response from Signifyd', null, 'signifyd_connect.log');
361
- }
362
- }
363
- } catch (Exception $e) {
364
- if ($this->logErrors()) {
365
- Mage::log('Fallback issue: ' . $e->__toString(), null, 'signifyd_connect.log');
366
- }
367
- }
368
-
369
- return $result;
370
- }
371
-
372
- public function processFallback($request)
373
- {
374
- if ($this->logRequest()) {
375
- Mage::log('Attempting auth via fallback request', null, 'signifyd_connect.log');
376
- }
377
-
378
- $request = json_decode($request, true);
379
-
380
- $this->_topic = "cases/review"; // Topic header is most likely not available
381
-
382
- if (is_array($request) && isset($request['orderId']))
383
- {
384
- $this->_case = Mage::getModel('signifyd_connect/case')->load($request['orderId']);
385
- }
386
-
387
- $this->_order = Mage::getModel('sales/order')->loadByIncrementId($this->_request['orderId']);
388
-
389
- if ($this->_order && $this->_order->getId()) {
390
- $this->_store_id = $this->_order->getStoreId();
391
- }
392
-
393
- if ($this->_case) {
394
- $lookup = $this->caseLookup();
395
-
396
- if ($lookup && is_array($lookup)) {
397
- $this->_request = $lookup;
398
-
399
- $this->processReview();
400
- } else {
401
- if ($this->logRequest()) {
402
- Mage::log('Fallback failed with an invalid response from Signifyd', null, 'signifyd_connect.log');
403
- }
404
- }
405
- } else {
406
- if ($this->logRequest()) {
407
- Mage::log('Fallback failed with no matching case found', null, 'signifyd_connect.log');
408
- }
409
- }
410
}
411
412
public function getHeader($header)
413
{
414
// T379: Some frameworks add an extra HTTP_ before the header, so check for both names
@@ -423,7 +163,7 @@ class Signifyd_Connect_ConnectController extends Mage_Core_Controller_Front_Acti
423
return $_SERVER[$extraHttp];
424
}
425
426
- Mage::log('Valid Header Not Found: ' . $header, null, 'signifyd_connect.log');
427
return '';
428
429
}
@@ -433,63 +173,41 @@ class Signifyd_Connect_ConnectController extends Mage_Core_Controller_Front_Acti
433
*/
434
public function apiAction()
435
{
436
- if (!$this->enabled()) {
437
echo $this->getDisabledMessage();
438
return;
439
}
440
441
// Prevent recurring on save
442
- if(is_null(Mage::registry('signifyd_action'))){
443
Mage::register('signifyd_action', 1);
444
- }
445
446
$request = $this->getRawPost();
447
448
$hash = $this->getHeader('X-SIGNIFYD-SEC-HMAC-SHA256');
449
450
- if ($this->logRequest()) {
451
- Mage::log('API request: ' . $request, null, 'signifyd_connect.log');
452
- Mage::log('API request hash: ' . $hash, null, 'signifyd_connect.log');
453
- }
454
455
if ($request) {
456
if ($this->validRequest($request, $hash)) {
457
$this->initRequest($request);
458
459
$topic = $this->_topic;
460
-
461
- if ($this->logRequest()) {
462
- Mage::log('API request topic: ' . $topic, null, 'signifyd_connect.log');
463
- }
464
465
switch ($topic) {
466
case "cases/creation":
467
- try {
468
- $this->processCreation($request);
469
- } catch (Exception $e) {
470
- if ($this->logErrors()) {
471
- Mage::log('Case scoring issue: ' . $e->__toString(), null, 'signifyd_connect.log');
472
- }
473
- }
474
break;
475
case "cases/rescore":
476
case "cases/review":
477
- try {
478
- $this->processReview($request);
479
- } catch (Exception $e) {
480
- if ($this->logErrors()) {
481
- Mage::log('Case review issue: ' . $e->__toString(), null, 'signifyd_connect.log');
482
- }
483
- }
484
break;
485
case "guarantees/completion":
486
- try {
487
- $this->processGuarantee($request);
488
- } catch (Exception $ex) {
489
- if ($this->logErrors()) {
490
- Mage::log('Case guarantee issue: ' . $ex->__toString(), null, 'signifyd_connect.log');
491
- }
492
- }
493
break;
494
case "cases/test":
495
// Test is only verifying that the endpoint is reachable. So we just complete here
@@ -499,11 +217,8 @@ class Signifyd_Connect_ConnectController extends Mage_Core_Controller_Front_Acti
499
$this->unsupported();
500
}
501
} else {
502
- if ($this->logRequest()) {
503
- Mage::log('API request failed auth', null, 'signifyd_connect.log');
504
- }
505
-
506
- $this->processFallback($request);
507
}
508
} else {
509
echo $this->getDefaultMessage();
@@ -512,6 +227,9 @@ class Signifyd_Connect_ConnectController extends Mage_Core_Controller_Front_Acti
512
$this->complete();
513
}
514
515
public function cronAction()
516
{
517
Mage::getModel('signifyd_connect/cron')->retry();
10
{
11
public $_request = array();
12
public $_topic = false;
13
public $_case = false;
14
+ public $logger;
15
16
+ /**
17
+ * Getting the row post data
18
+ * @return string
19
+ */
20
public function getRawPost()
21
{
22
+ if (isset($HTTP_RAW_POST_DATA) && $HTTP_RAW_POST_DATA)
23
return $HTTP_RAW_POST_DATA;
24
25
$post = file_get_contents("php://input");
26
+ if ($post)
27
return $post;
28
29
return '';
30
}
31
32
+ /**
33
+ * Getting the default message for the API
34
+ * @return string
35
+ */
36
public function getDefaultMessage()
37
{
38
return 'This URL is working! Please copy & paste the current URL into your <a href="https://signifyd.com/settings">settings</a> page in the Notifications section';
39
}
40
41
+ /**
42
+ * Getting the disabled message for the extension
43
+ * @return string
44
+ */
45
public function getDisabledMessage()
46
{
47
return 'This URL is disabled in the Magento admin panel! Please enable score retrieval under Admin>System>Config>Signifyd Connect>Advanced before setting this url in your Signifyd <a href="https://signifyd.com/settings">settings</a> page.';
48
}
49
50
+ /**
51
+ * Returning response as unsupported
52
+ */
53
public function unsupported()
54
{
55
Mage::app()->getResponse()
59
exit;
60
}
61
62
+ /**
63
+ * Returning response as completed
64
+ */
65
public function complete()
66
{
67
Mage::app()->getResponse()
71
exit;
72
}
73
74
+ /**
75
+ * Returning response as conflict
76
+ */
77
public function conflict()
78
{
79
Mage::app()->getResponse()
82
exit;
83
}
84
85
+ /**
86
+ * Checking if the received request is valid
87
+ * @param $request
88
+ * @param $hash
89
+ * @return bool
90
+ */
91
public function validRequest($request, $hash)
92
{
93
+ $check = base64_encode(hash_hmac('sha256', $request, Mage::helper('signifyd_connect')->getAuth(), true));
94
+ $this->logger->addLog('API request hash check: ' . $check);
95
96
if ($check == $hash) {
97
return true;
98
+ } else if ($this->getHeader('X-SIGNIFYD-TOPIC') == "cases/test"){
99
// In the case that this is a webhook test, the encoding ABCDE is allowed
100
$check = base64_encode(hash_hmac('sha256', $request, 'ABCDE', true));
101
+ if ($check == $hash)
102
return true;
103
}
104
105
return false;
106
}
107
108
+ /**
109
+ * Initializing the Signifyd Case
110
+ * @return bool|Mage_Core_Model_Abstract
111
+ */
112
+ public function initCase()
113
{
114
$case = false;
115
116
+ if (isset($this->_request['orderId'])) {
117
$case = Mage::getModel('signifyd_connect/case')->load($this->_request['orderId']);
118
if($case->isObjectNew()) {
119
+ $this->logger->addLog('Case not yet in DB. Likely timing issue. order_increment: ' . $this->_request['orderId']);
120
$this->conflict();
121
}
122
}
124
return $case;
125
}
126
127
+ /**
128
+ * Initializing the class params
129
+ * @param $request
130
+ */
131
public function initRequest($request)
132
{
133
$this->_request = json_decode($request, true);
139
// For the webhook test, all of the request data will be invalid
140
if ($topic == "cases/test") return;
141
142
+ $this->_case = $this->initCase();
143
+ if (!$this->_case)
144
+ $this->logger->addLog('No matching case was found for this request. order_increment: ' . $this->_request['orderId']);
145
}
146
147
+ /**
148
+ * Retrieving the header
149
+ * @param $header
150
+ * @return string
151
+ */
152
public function getHeader($header)
153
{
154
// T379: Some frameworks add an extra HTTP_ before the header, so check for both names
163
return $_SERVER[$extraHttp];
164
}
165
166
+ $this->logger->addLog('Valid Header Not Found: ' . $header);
167
return '';
168
169
}
173
*/
174
public function apiAction()
175
{
176
+ if (!Mage::helper('signifyd_connect')->isEnabled()) {
177
echo $this->getDisabledMessage();
178
return;
179
}
180
181
+ $this->logger = Mage::helper('signifyd_connect/log');
182
+
183
// Prevent recurring on save
184
+ if(is_null(Mage::registry('signifyd_action')))
185
Mage::register('signifyd_action', 1);
186
187
$request = $this->getRawPost();
188
189
$hash = $this->getHeader('X-SIGNIFYD-SEC-HMAC-SHA256');
190
191
+ $this->logger->addLog('API request: ' . $request);
192
+ $this->logger->addLog('API request hash: ' . $hash);
193
194
if ($request) {
195
if ($this->validRequest($request, $hash)) {
196
$this->initRequest($request);
197
198
$topic = $this->_topic;
199
+ $this->logger->addLog('API request topic: ' . $topic);
200
201
switch ($topic) {
202
case "cases/creation":
203
+ Mage::getModel('signifyd_connect/case')->processCreation($this->_case, $this->_request);
204
break;
205
case "cases/rescore":
206
case "cases/review":
207
+ Mage::getModel('signifyd_connect/case')->processReview($this->_case, $this->_request);
208
break;
209
case "guarantees/completion":
210
+ Mage::getModel('signifyd_connect/case')->processGuarantee($this->_case, $this->_request);
211
break;
212
case "cases/test":
213
// Test is only verifying that the endpoint is reachable. So we just complete here
217
$this->unsupported();
218
}
219
} else {
220
+ $this->logger->addLog('API request failed auth');
221
+ Mage::getModel('signifyd_connect/case')->processFallback($this->_request);
222
}
223
} else {
224
echo $this->getDefaultMessage();
227
$this->complete();
228
}
229
230
+ /**
231
+ * Manually start the processing made by the cron job
232
+ */
233
public function cronAction()
234
{
235
Mage::getModel('signifyd_connect/cron')->retry();
app/code/community/Signifyd/Connect/etc/config.xml CHANGED
@@ -3,7 +3,7 @@
3
<config>
4
<modules>
5
<Signifyd_Connect>
6
- <version>3.16.1</version>
7
</Signifyd_Connect>
8
</modules>
9
<global>
3
<config>
4
<modules>
5
<Signifyd_Connect>
6
+ <version>3.16.3</version>
7
</Signifyd_Connect>
8
</modules>
9
<global>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
<?xml version="1.0"?>
2
<package>
3
<name>Signifyd_Connect</name>
4
- <version>3.16.1</version>
5
<stability>stable</stability>
6
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
7
<channel>community</channel>
@@ -10,9 +10,9 @@
10
<description>Supports all versions of Magento</description>
11
<notes>Supports all versions of Magento</notes>
12
<authors><author><name>signifyd</name><user>signifyd</user><email>manelis@signifyd.com</email></author></authors>
13
- <date>2016-11-09</date>
14
- <time>09:27:09</time>
15
- <contents><target name="mageetc"><dir name="modules"><file name="Signifyd_Connect.xml" hash="bcd998a24567eba8a20423c40fba2adf"/></dir></target><target name="magecommunity"><dir name="Signifyd"><dir name="Connect"><dir name="Block"><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><file name="Grid.php" hash="2c2e8af2c67a09c041d5015c26eff587"/></dir><file name="Order.php" hash="e49f869c0aa5fb3ab6b70fb5752049ac"/></dir><dir name="System"><dir name="Config"><dir name="Fieldset"><file name="Hint.php" hash="c83481d3f9f01e629bb48d34358a53f6"/></dir></dir></dir></dir><file name="Renderer.php" hash="b16dfa77aad966640705f55f09304fc2"/><file name="Url.php" hash="dbe3e967879a69a2c943056f820e4688"/></dir><dir name="Helper"><file name="Data.php" hash="241fc27fefd644f3c3e9caa53a981035"/><file name="Log.php" hash="96f1286eb9c273f637178ffd94a04d42"/></dir><dir name="Model"><file name="Authnet.php" hash="0387e631fb232778cdc82c0c72c16781"/><file name="Case.php" hash="12f39bf0b1d962a8b0cdabe6c401a9ae"/><file name="Cron.php" hash="8080b5e259ee8763beaa44fe98b92876"/><file name="Link.php" hash="c8a690bfe4b0ab789c02173a347f0f13"/><file name="Observer.php" hash="110cde415010768235322ed2a2143aab"/><dir name="Order"><file name="Payment.php" hash="a0ad3107170b7bae94b8402960b5cf48"/></dir><file name="Order.php" hash="991a2f535825328fa44cbc2bbbf8bd51"/><dir name="Resource"><dir name="Case"><file name="Collection.php" hash="b7dac9979a0c81db56294d1548570fc2"/></dir><file name="Case.php" hash="60d14407c9c90148aad543ce6868f343"/><dir name="Retries"><file name="Collection.php" hash="bd94e095c3a6367d20f5ebdd756740c8"/></dir><file name="Retries.php" hash="8027995f79188f624b6a681e4868d2e6"/></dir><file name="Retries.php" hash="28780c04867b083b1d51878e59fa380b"/><file name="Setup.php" hash="e803ffb4b86c7d8ec1d149e665d65877"/><dir name="System"><dir name="Config"><dir name="Source"><dir name="Options"><file name="Accepted.php" hash="bfa242f435e794f77843f38f11122691"/><file name="Declined.php" hash="f48482c1a78be0568b7b60cd5042906e"/></dir></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="SignifydController.php" hash="c241dc4434631e3eb345c731c8cf177d"/></dir><file name="ConnectController.php" hash="7e3f80117b0a4703e65b79130c9ed7cf"/></dir><dir name="etc"><file name="adminhtml.xml" hash="894bd3f5ac76e9f602ab6ab592648b03"/><file name="config.xml" hash="327cd17e7b051ccf5df8dbcbddf15d58"/><file name="system.xml" hash="5b89a88ea3510e2ee6623582f639910e"/></dir><dir name="sql"><dir name="signifyd_connect_setup"><file name="mysql4-install-3.1.1.php" hash="7fb2ccaf8352eea26e626ace6de53d80"/><file name="mysql4-install-3.12.0.php" hash="e4ec4d7445fbbc13a7008bcd69c529c4"/><file name="mysql4-install-3.3.0.php" hash="f61d0c018b28ae04d8d14b38556d18ad"/><file name="mysql4-install-3.4.0.php" hash="109cc5ca60974d0c4755dcb0f5ade3e7"/><file name="mysql4-install-3.4.5.php" hash="401b92235c0e534c941a64c60d24b851"/><file name="mysql4-install-3.7.0.php" hash="48a9d427944a4e63a000343ab329f517"/><file name="mysql4-install-3.8.0.php" hash="0fb3583eb4481c21b84ea674abc200f0"/><file name="mysql4-upgrade-3.10.0-3.10.1.php" hash="3ceb86495f33475774d4fc8727254cfc"/><file name="mysql4-upgrade-3.10.1-3.11.0.php" hash="3ceb86495f33475774d4fc8727254cfc"/><file name="mysql4-upgrade-3.11.0-3.11.1.php" hash="3ceb86495f33475774d4fc8727254cfc"/><file name="mysql4-upgrade-3.11.1-3.12.0.php" hash="df5447c6223f66c03ddeacefc64322b8"/><file name="mysql4-upgrade-3.12.0-3.13.0.php" hash="f2e8ccb1fd199a0a678b3e34181aac18"/><file name="mysql4-upgrade-3.15.1-3.16.0.php" hash="7cde716fe0e3e849c1f82bbd7bf8ec3a"/><file name="mysql4-upgrade-3.2.0-3.2.1.php" hash="9e36c608afd6e30e3052334e085eeff4"/><file name="mysql4-upgrade-3.2.1-3.2.2.php" hash="efcc5d46a41e549e508a693f1e77bf44"/><file name="mysql4-upgrade-3.2.2-3.2.3.php" hash="3ceb86495f33475774d4fc8727254cfc"/><file name="mysql4-upgrade-3.2.3-3.3.0.php" hash="94b907c2cacde5fb9831408ce9a06190"/><file name="mysql4-upgrade-3.3.0-3.4.0.php" hash="6eb18705081483bb8d9c14adcdefd095"/><file name="mysql4-upgrade-3.4.0-3.4.1.php" hash="79f2064f1fa20d646e66aa3e7912d2a0"/><file name="mysql4-upgrade-3.4.1-3.4.2.php" hash="3ceb86495f33475774d4fc8727254cfc"/><file name="mysql4-upgrade-3.4.2-3.4.3.php" hash="3ceb86495f33475774d4fc8727254cfc"/><file name="mysql4-upgrade-3.4.3-3.4.4.php" hash="3ceb86495f33475774d4fc8727254cfc"/><file name="mysql4-upgrade-3.4.4-3.4.5.php" hash="5b7507d6bb97bf44d27b7a89c56924bb"/><file name="mysql4-upgrade-3.4.5-3.4.6.php" hash="3ceb86495f33475774d4fc8727254cfc"/><file name="mysql4-upgrade-3.4.6-3.4.7.php" hash="3ceb86495f33475774d4fc8727254cfc"/><file name="mysql4-upgrade-3.4.7-3.4.8.php" hash="3ceb86495f33475774d4fc8727254cfc"/><file name="mysql4-upgrade-3.4.8-3.5.0.php" hash="3ceb86495f33475774d4fc8727254cfc"/><file name="mysql4-upgrade-3.5.0-3.5.1.php" hash="3ceb86495f33475774d4fc8727254cfc"/><file name="mysql4-upgrade-3.5.1-3.5.2.php" hash="3ceb86495f33475774d4fc8727254cfc"/><file name="mysql4-upgrade-3.5.2-3.5.3.php" hash="3ceb86495f33475774d4fc8727254cfc"/><file name="mysql4-upgrade-3.5.3-3.6.0.php" hash="3ceb86495f33475774d4fc8727254cfc"/><file name="mysql4-upgrade-3.6.0-3.7.0.php" hash="1456a6d0ddf091be9c87b3bbc91263ba"/><file name="mysql4-upgrade-3.7.0-3.8.0.php" hash="e6fc207541cacc5079e8ea8e4d55f356"/><file name="mysql4-upgrade-3.8.0-3.9.0.php" hash="3ceb86495f33475774d4fc8727254cfc"/><file name="mysql4-upgrade-3.9.0-3.10.0.php" hash="3ceb86495f33475774d4fc8727254cfc"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="signifyd"><dir name="connect"><dir name="config"><file name="hint.phtml" hash="e1f1d39ed2980473f1fef0aeb73a7e1c"/></dir></dir></dir></dir></dir></dir></dir></target></contents>
16
<compatible/>
17
- <dependencies><required><php><min>5.2.0</min><max>5.6.26</max></php></required></dependencies>
18
</package>
1
<?xml version="1.0"?>
2
<package>
3
<name>Signifyd_Connect</name>
4
+ <version>3.16.3</version>
5
<stability>stable</stability>
6
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
7
<channel>community</channel>
10
<description>Supports all versions of Magento</description>
11
<notes>Supports all versions of Magento</notes>
12
<authors><author><name>signifyd</name><user>signifyd</user><email>manelis@signifyd.com</email></author></authors>
13
+ <date>2017-02-20</date>
14
+ <time>10:18:17</time>
15
+ <contents><target name="mageetc"><dir name="modules"><file name="Signifyd_Connect.xml" hash="bcd998a24567eba8a20423c40fba2adf"/></dir></target><target name="magecommunity"><dir name="Signifyd"><dir name="Connect"><dir name="Block"><dir name="Adminhtml"><dir name="Sales"><dir name="Order"><file name="Grid.php" hash="2c2e8af2c67a09c041d5015c26eff587"/></dir><file name="Order.php" hash="e49f869c0aa5fb3ab6b70fb5752049ac"/></dir><dir name="System"><dir name="Config"><dir name="Fieldset"><file name="Hint.php" hash="c83481d3f9f01e629bb48d34358a53f6"/></dir></dir></dir></dir><file name="Renderer.php" hash="f55b4ac4a447141df9886ca864e7b75e"/><file name="Url.php" hash="dbe3e967879a69a2c943056f820e4688"/></dir><dir name="Helper"><file name="Data.php" hash="cb3be1f7e5458308a98e9b03dc970941"/><file name="Log.php" hash="6cabab7d2bf1956496b250ccc638e8de"/></dir><dir name="Model"><file name="Authnet.php" hash="0387e631fb232778cdc82c0c72c16781"/><file name="Case.php" hash="74ca11b208625db4aa29352a79b8b62a"/><file name="Cron.php" hash="521c218b03ced0777cd1066ec1c67b45"/><file name="Link.php" hash="c8a690bfe4b0ab789c02173a347f0f13"/><file name="Observer.php" hash="110cde415010768235322ed2a2143aab"/><dir name="Order"><file name="Payment.php" hash="a0ad3107170b7bae94b8402960b5cf48"/></dir><file name="Order.php" hash="0f0bd365c02eef9b5f28cebfd6dac22d"/><dir name="Resource"><dir name="Case"><file name="Collection.php" hash="b7dac9979a0c81db56294d1548570fc2"/></dir><file name="Case.php" hash="60d14407c9c90148aad543ce6868f343"/><dir name="Retries"><file name="Collection.php" hash="bd94e095c3a6367d20f5ebdd756740c8"/></dir><file name="Retries.php" hash="8027995f79188f624b6a681e4868d2e6"/></dir><file name="Retries.php" hash="28780c04867b083b1d51878e59fa380b"/><file name="Setup.php" hash="e803ffb4b86c7d8ec1d149e665d65877"/><dir name="System"><dir name="Config"><dir name="Source"><dir name="Options"><file name="Accepted.php" hash="bfa242f435e794f77843f38f11122691"/><file name="Declined.php" hash="f48482c1a78be0568b7b60cd5042906e"/></dir></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="SignifydController.php" hash="c241dc4434631e3eb345c731c8cf177d"/></dir><file name="ConnectController.php" hash="51653f529f3ed033e9c8299ce14d50b5"/></dir><dir name="etc"><file name="adminhtml.xml" hash="894bd3f5ac76e9f602ab6ab592648b03"/><file name="config.xml" hash="6817bb22491e8e8a0436e9999580fcee"/><file name="system.xml" hash="5b89a88ea3510e2ee6623582f639910e"/></dir><dir name="sql"><dir name="signifyd_connect_setup"><file name="mysql4-install-3.1.1.php" hash="7fb2ccaf8352eea26e626ace6de53d80"/><file name="mysql4-install-3.12.0.php" hash="e4ec4d7445fbbc13a7008bcd69c529c4"/><file name="mysql4-install-3.3.0.php" hash="f61d0c018b28ae04d8d14b38556d18ad"/><file name="mysql4-install-3.4.0.php" hash="109cc5ca60974d0c4755dcb0f5ade3e7"/><file name="mysql4-install-3.4.5.php" hash="401b92235c0e534c941a64c60d24b851"/><file name="mysql4-install-3.7.0.php" hash="48a9d427944a4e63a000343ab329f517"/><file name="mysql4-install-3.8.0.php" hash="0fb3583eb4481c21b84ea674abc200f0"/><file name="mysql4-upgrade-3.10.0-3.10.1.php" hash="3ceb86495f33475774d4fc8727254cfc"/><file name="mysql4-upgrade-3.10.1-3.11.0.php" hash="3ceb86495f33475774d4fc8727254cfc"/><file name="mysql4-upgrade-3.11.0-3.11.1.php" hash="3ceb86495f33475774d4fc8727254cfc"/><file name="mysql4-upgrade-3.11.1-3.12.0.php" hash="df5447c6223f66c03ddeacefc64322b8"/><file name="mysql4-upgrade-3.12.0-3.13.0.php" hash="f2e8ccb1fd199a0a678b3e34181aac18"/><file name="mysql4-upgrade-3.15.1-3.16.0.php" hash="7cde716fe0e3e849c1f82bbd7bf8ec3a"/><file name="mysql4-upgrade-3.2.0-3.2.1.php" hash="9e36c608afd6e30e3052334e085eeff4"/><file name="mysql4-upgrade-3.2.1-3.2.2.php" hash="efcc5d46a41e549e508a693f1e77bf44"/><file name="mysql4-upgrade-3.2.2-3.2.3.php" hash="3ceb86495f33475774d4fc8727254cfc"/><file name="mysql4-upgrade-3.2.3-3.3.0.php" hash="94b907c2cacde5fb9831408ce9a06190"/><file name="mysql4-upgrade-3.3.0-3.4.0.php" hash="6eb18705081483bb8d9c14adcdefd095"/><file name="mysql4-upgrade-3.4.0-3.4.1.php" hash="79f2064f1fa20d646e66aa3e7912d2a0"/><file name="mysql4-upgrade-3.4.1-3.4.2.php" hash="3ceb86495f33475774d4fc8727254cfc"/><file name="mysql4-upgrade-3.4.2-3.4.3.php" hash="3ceb86495f33475774d4fc8727254cfc"/><file name="mysql4-upgrade-3.4.3-3.4.4.php" hash="3ceb86495f33475774d4fc8727254cfc"/><file name="mysql4-upgrade-3.4.4-3.4.5.php" hash="5b7507d6bb97bf44d27b7a89c56924bb"/><file name="mysql4-upgrade-3.4.5-3.4.6.php" hash="3ceb86495f33475774d4fc8727254cfc"/><file name="mysql4-upgrade-3.4.6-3.4.7.php" hash="3ceb86495f33475774d4fc8727254cfc"/><file name="mysql4-upgrade-3.4.7-3.4.8.php" hash="3ceb86495f33475774d4fc8727254cfc"/><file name="mysql4-upgrade-3.4.8-3.5.0.php" hash="3ceb86495f33475774d4fc8727254cfc"/><file name="mysql4-upgrade-3.5.0-3.5.1.php" hash="3ceb86495f33475774d4fc8727254cfc"/><file name="mysql4-upgrade-3.5.1-3.5.2.php" hash="3ceb86495f33475774d4fc8727254cfc"/><file name="mysql4-upgrade-3.5.2-3.5.3.php" hash="3ceb86495f33475774d4fc8727254cfc"/><file name="mysql4-upgrade-3.5.3-3.6.0.php" hash="3ceb86495f33475774d4fc8727254cfc"/><file name="mysql4-upgrade-3.6.0-3.7.0.php" hash="1456a6d0ddf091be9c87b3bbc91263ba"/><file name="mysql4-upgrade-3.7.0-3.8.0.php" hash="e6fc207541cacc5079e8ea8e4d55f356"/><file name="mysql4-upgrade-3.8.0-3.9.0.php" hash="3ceb86495f33475774d4fc8727254cfc"/><file name="mysql4-upgrade-3.9.0-3.10.0.php" hash="3ceb86495f33475774d4fc8727254cfc"/></dir></dir></dir></dir></target><target name="magedesign"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="template"><dir name="signifyd"><dir name="connect"><dir name="config"><file name="hint.phtml" hash="e1f1d39ed2980473f1fef0aeb73a7e1c"/></dir></dir></dir></dir></dir></dir></dir></target></contents>
16
<compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>5.6.28</max></php></required></dependencies>
18
</package>