Signifyd_Connect - Version 3.13.0

Version Notes

Supports all versions of Magento

Download this release

Release Info

Developer Magento Core Team
Extension Signifyd_Connect
Version 3.13.0
Comparing to
See all releases


Code changes from version 3.12.3 to 3.13.0

app/code/community/Signifyd/Connect/Block/Adminhtml/Sales/Order/Grid.php CHANGED
@@ -105,6 +105,7 @@ class Signifyd_Connect_Block_Adminhtml_Sales_Order_Grid extends Mage_Adminhtml_B
105
'type' => 'text',
106
'index' => 'guarantee',
107
'filter' => false,
108
));
109
110
$this->addColumn('order_status', array(
105
'type' => 'text',
106
'index' => 'guarantee',
107
'filter' => false,
108
+ 'renderer' => 'signifyd_connect/renderer',
109
));
110
111
$this->addColumn('order_status', array(
app/code/community/Signifyd/Connect/Block/Renderer.php CHANGED
@@ -3,18 +3,22 @@
3
class Signifyd_Connect_Block_Renderer extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
4
{
5
public function render(Varien_Object $row)
6
- {
7
$value = $row->getData($this->getColumn()->getIndex());
8
$helper = Mage::helper('signifyd_connect');
9
10
$url = $helper->getCaseUrl($row->getIncrementId());
11
12
- if (!is_numeric($value)) {
13
- return $helper->__('N/A');
14
}
15
16
- $value = floor($value);
17
-
18
if ($url) {
19
$value = "<a href=\"$url\" target=\"_blank\">$value</a>";
20
}
3
class Signifyd_Connect_Block_Renderer extends Mage_Adminhtml_Block_Widget_Grid_Column_Renderer_Abstract
4
{
5
public function render(Varien_Object $row)
6
+ {
7
$value = $row->getData($this->getColumn()->getIndex());
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');
16
+ }
17
+ $value = floor($value);
18
+ } else if ($column == "guarantee" && $value == "N/A") {
19
+ return $value;
20
}
21
22
if ($url) {
23
$value = "<a href=\"$url\" target=\"_blank\">$value</a>";
24
}
app/code/community/Signifyd/Connect/Helper/.Data.php.swp ADDED
Binary file
app/code/community/Signifyd/Connect/Helper/Data.php CHANGED
@@ -3,8 +3,30 @@
3
class Signifyd_Connect_Helper_Data extends Mage_Core_Helper_Abstract
4
{
5
const UNPROCESSED_STATUS = 0;
6
- const CASE_CREATED_STATUS = 1;
7
- const TRANSACTION_SENT_STATUS = 2;
8
9
public function getProducts($quote)
10
{
@@ -164,9 +186,24 @@ class Signifyd_Connect_Helper_Data extends Mage_Core_Helper_Abstract
164
return null;
165
}
166
167
private function getTransactionId($payment)
168
{
169
- return $payment->getCcTransId();
170
}
171
172
public function getPurchase($order)
@@ -357,6 +394,7 @@ class Signifyd_Connect_Helper_Data extends Mage_Core_Helper_Abstract
357
$case['recipient'] = $this->getRecipient($order);
358
$case['card'] = $this->getCard($order, $payment);
359
$case['userAccount'] = $this->getUserAccount($customer, $order);
360
361
return $case;
362
}
@@ -440,8 +478,18 @@ class Signifyd_Connect_Helper_Data extends Mage_Core_Helper_Abstract
440
$orderIds = array_map('intval', explode(',', $orderIds));
441
}
442
if (!is_array($orderIds)) {
443
- Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Please select order(s)'));
444
} else {
445
$collection = Mage::getModel('sales/order')->getCollection()
446
->addFieldToSelect('*')
447
->addFieldToFilter('entity_id', array('in' => $orderIds));
@@ -449,21 +497,26 @@ class Signifyd_Connect_Helper_Data extends Mage_Core_Helper_Abstract
449
foreach ($collection as $order) {
450
$result = $this->buildAndSendOrderToSignifyd($order, /*forceSend*/ true);
451
if($result == "sent") {
452
- Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')->__('Successfully sent order ' . $order->getIncrementId() . '.'));
453
} else if ($result == "exists") {
454
- Mage::getSingleton('adminhtml/session')->addWarning(Mage::helper('adminhtml')->__('Order ' . $order->getIncrementId() . ' has already been sent to Signifyd.'));
455
} else if ($result == "nodata") {
456
- if(Mage::getStoreConfig('signifyd_connect/log/request')) {
457
- Mage::log("Request/Update not sent because there is no data", null, 'signifyd_connect.log');
458
- }
459
} else {
460
- Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Order ' . $order->getIncrementId() . ' failed to send. See log for details.'));
461
}
462
}
463
}
464
} catch(Exception $ex) {
465
- Mage::log($ex->__toString(), null, 'signifyd_connect.log');
466
- Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')->__('Send failed. See log for details'));
467
}
468
}
469
@@ -505,17 +558,50 @@ class Signifyd_Connect_Helper_Data extends Mage_Core_Helper_Abstract
505
if (substr($response_code, 0, 1) == '2') {
506
$response_data = json_decode($response->getRawResponse(), true);
507
508
$case_object = Mage::getModel('signifyd_connect/case')->load($case_object->getOrderIncrement());
509
$case_object->setUpdated(strftime('%Y-%m-%d %H:%M:%S', time()));
510
- $case_object->setCode($response_data['investigationId']);
511
$case_object->setTransactionId($case['purchase']['transactionId']);
512
$case_object->save();
513
return "sent";
514
}
515
} catch (Exception $e) {
516
Mage::log($e->__toString(), null, 'signifyd_connect.log');
517
- return "error";
518
}
519
}
520
}
521
@@ -558,8 +644,6 @@ class Signifyd_Connect_Helper_Data extends Mage_Core_Helper_Abstract
558
559
public function getStoreName()
560
{
561
- $store = Mage::app()->getStore();
562
-
563
return Mage::getStoreConfig('trans_email/ident_general/name', 0);
564
}
565
@@ -581,10 +665,14 @@ class Signifyd_Connect_Helper_Data extends Mage_Core_Helper_Abstract
581
{
582
return self::TRANSACTION_SENT_STATUS;
583
}
584
- else if ($case->getId())
585
{
586
return self::CASE_CREATED_STATUS;
587
}
588
589
return self::UNPROCESSED_STATUS;
590
}
@@ -608,7 +696,23 @@ class Signifyd_Connect_Helper_Data extends Mage_Core_Helper_Abstract
608
$case->delete();
609
}
610
}
611
-
612
public function request($url, $data = null, $auth = null, $contenttype = "application/x-www-form-urlencoded",
613
$accept = null, $is_update = false)
614
{
@@ -640,7 +744,7 @@ class Signifyd_Connect_Helper_Data extends Mage_Core_Helper_Abstract
640
}
641
642
if ($data) {
643
- if($is_update) curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
644
else curl_setopt($curl, CURLOPT_POST, 1);
645
646
$headers[] = "Content-Type: $contenttype";
3
class Signifyd_Connect_Helper_Data extends Mage_Core_Helper_Abstract
4
{
5
const UNPROCESSED_STATUS = 0;
6
+ const ENTITY_CREATED_STATUS = 1;
7
+ const CASE_CREATED_STATUS = 2;
8
+ const TRANSACTION_SENT_STATUS = 3;
9
+
10
+ public function logRequest($message)
11
+ {
12
+ if (Mage::getStoreConfig('signifyd_connect/log/request')) {
13
+ Mage::log($message, null, 'signifyd_connect.log');
14
+ }
15
+ }
16
+
17
+ public function logResponse($message)
18
+ {
19
+ if (Mage::getStoreConfig('signifyd_connect/log/response')) {
20
+ Mage::log($message, null, 'signifyd_connect.log');
21
+ }
22
+ }
23
+
24
+ public function logError($message)
25
+ {
26
+ if (Mage::getStoreConfig('signifyd_connect/log/error')) {
27
+ Mage::log($message, null, 'signifyd_connect.log');
28
+ }
29
+ }
30
31
public function getProducts($quote)
32
{
186
return null;
187
}
188
189
+ private function getVersions()
190
+ {
191
+ $version = array();
192
+ $version['platform'] = 'magento';
193
+ $version['platformVersion'] = Mage::getVersion();
194
+ $version['pluginVersion'] = (string)(Mage::getConfig()->getNode()->modules->Signifyd_Connect->version);
195
+ return $version;
196
+ }
197
+
198
private function getTransactionId($payment)
199
{
200
+ $transId = $payment->getCcTransId();
201
+ if(is_array($transId) && is_string($transId[0])) {
202
+ $transId = $transId[0];
203
+ } else if(!is_string($transId)) {
204
+ $transId = null;
205
+ }
206
+ return $transId;
207
}
208
209
public function getPurchase($order)
394
$case['recipient'] = $this->getRecipient($order);
395
$case['card'] = $this->getCard($order, $payment);
396
$case['userAccount'] = $this->getUserAccount($customer, $order);
397
+ $case['clientVersion'] = $this->getVersions();
398
399
return $case;
400
}
478
$orderIds = array_map('intval', explode(',', $orderIds));
479
}
480
if (!is_array($orderIds)) {
481
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')
482
+ ->__('Please select order(s)'));
483
} else {
484
+ // Reference T2395
485
+ $user = "Unknown";
486
+ try {
487
+ $user = Mage::getSingleton('admin/session')->getUser()->getUsername();
488
+ } catch (Exception $ex) {
489
+ $this->logError($ex->__toString());
490
+ }
491
+ $this->logRequest("Bulk send initiated by: $user");
492
+
493
$collection = Mage::getModel('sales/order')->getCollection()
494
->addFieldToSelect('*')
495
->addFieldToFilter('entity_id', array('in' => $orderIds));
497
foreach ($collection as $order) {
498
$result = $this->buildAndSendOrderToSignifyd($order, /*forceSend*/ true);
499
if($result == "sent") {
500
+ Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('adminhtml')
501
+ ->__('Successfully sent order ' . $order->getIncrementId() . '.'));
502
} else if ($result == "exists") {
503
+ Mage::getSingleton('adminhtml/session')->addWarning(Mage::helper('adminhtml')
504
+ ->__('Order ' . $order->getIncrementId() . ' has already been sent to Signifyd.'));
505
} else if ($result == "nodata") {
506
+ $this->logRequest("Request/Update not sent because there is no data");
507
} else {
508
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')
509
+ ->__('Order ' . $order->getIncrementId() . ' failed to send. See log for details.'));
510
}
511
}
512
+ if (Mage::getStoreConfig('signifyd_connect/log/request')) {
513
+ $this->logRequest("Bulk send complete");
514
+ }
515
}
516
} catch(Exception $ex) {
517
+ $this->logError($ex->__toString());
518
+ Mage::getSingleton('adminhtml/session')->addError(Mage::helper('adminhtml')
519
+ ->__('Send failed. See log for details'));
520
}
521
}
522
558
if (substr($response_code, 0, 1) == '2') {
559
$response_data = json_decode($response->getRawResponse(), true);
560
561
+ $caseId = $response_data['investigationId'];
562
$case_object = Mage::getModel('signifyd_connect/case')->load($case_object->getOrderIncrement());
563
$case_object->setUpdated(strftime('%Y-%m-%d %H:%M:%S', time()));
564
+ $case_object->setCode($caseId);
565
$case_object->setTransactionId($case['purchase']['transactionId']);
566
$case_object->save();
567
+
568
+ $order->addStatusHistoryComment("Signifyd: case $caseId created for order");
569
+ $order->save(); // Note: this will trigger recursion
570
return "sent";
571
}
572
} catch (Exception $e) {
573
Mage::log($e->__toString(), null, 'signifyd_connect.log');
574
}
575
+ return "error";
576
+ }
577
+ }
578
+
579
+ /**
580
+ * Run through up to $max items in the retry queue
581
+ * @param int $max The maximum numbers of items to process
582
+ */
583
+ public function processRetryQueue($max = 99999)
584
+ {
585
+ $failed_orders = Mage::getModel('signifyd_connect/retries')->getCollection();
586
+ $process_count = 0;
587
+ try {
588
+ foreach ($failed_orders as $order_id) {
589
+ if ($process_count++ >= $max) {
590
+ return;
591
+ }
592
+ $order = Mage::getModel('sales/order')->loadByIncrementId($order_id->getOrderIncrement());
593
+ $result = "unset";
594
+ if ($order != null && $this->processedStatus($order) < self::CASE_CREATED_STATUS) {
595
+ $result = $this->buildAndSendOrderToSignifyd($order, true);
596
+ }
597
+ if ($result !== "error") {
598
+ Mage::register('isSecureArea', true);
599
+ $order_id->delete();
600
+ Mage::unregister('isSecureArea');
601
+ }
602
+ }
603
+ } catch (Exception $e) {
604
+ Mage::log($e->__toString(), null, 'signifyd_connect.log');
605
}
606
}
607
644
645
public function getStoreName()
646
{
647
return Mage::getStoreConfig('trans_email/ident_general/name', 0);
648
}
649
665
{
666
return self::TRANSACTION_SENT_STATUS;
667
}
668
+ else if ($case->getCode())
669
{
670
return self::CASE_CREATED_STATUS;
671
}
672
+ else if ($case->getId())
673
+ {
674
+ return self::ENTITY_CREATED_STATUS;
675
+ }
676
677
return self::UNPROCESSED_STATUS;
678
}
696
$case->delete();
697
}
698
}
699
+
700
+ public function cancelGuarantee($case)
701
+ {
702
+ $caseId = $case->getCode();
703
+ $url = $this->getUrl() . "/$caseId/guarantee";
704
+ $body = json_encode(array("guaranteeDisposition" => "CANCELED"));
705
+ $response = $this->request($url, $body, $this->getAuth(), 'application/json', null, true);
706
+ $code = $response->getHttpCode();
707
+ if(substr($code, 0, 1) == '2') {
708
+ $case->setGuarantee('CANCELED');
709
+ $case->save();
710
+ } else {
711
+ $this->logError("Guarantee cancel failed");
712
+ }
713
+ $this->logResponse("Received $code from guarantee cancel");
714
+ }
715
+
716
public function request($url, $data = null, $auth = null, $contenttype = "application/x-www-form-urlencoded",
717
$accept = null, $is_update = false)
718
{
744
}
745
746
if ($data) {
747
+ if($is_update) curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
748
else curl_setopt($curl, CURLOPT_POST, 1);
749
750
$headers[] = "Content-Type: $contenttype";
app/code/community/Signifyd/Connect/Model/Observer.php CHANGED
@@ -25,11 +25,28 @@ class Signifyd_Connect_Model_Observer extends Varien_Object
25
return;
26
}
27
28
- Mage::helper('signifyd_connect')->buildAndSendOrderToSignifyd($order);
29
-
30
} catch (Exception $e) {
31
Mage::log($e->__toString(), null, 'signifyd_connect.log');
32
}
33
}
34
35
public function logData($order, $payment, $quote)
@@ -252,6 +269,7 @@ class Signifyd_Connect_Model_Observer extends Varien_Object
252
'type' => 'text',
253
'index' => 'guarantee',
254
'filter' => false,
255
'width' => '100px',
256
),
257
'status'
@@ -261,4 +279,38 @@ class Signifyd_Connect_Model_Observer extends Varien_Object
261
}
262
}
263
}
264
}
25
return;
26
}
27
28
+ $result = Mage::helper('signifyd_connect')->buildAndSendOrderToSignifyd($order);
29
+ if($result !== "error") {
30
+ if($result !== "notready") {
31
+ // Handle two of the retry items in queue
32
+ Mage::helper('signifyd_connect')->processRetryQueue(2);
33
+ }
34
+ return;
35
+ }
36
} catch (Exception $e) {
37
Mage::log($e->__toString(), null, 'signifyd_connect.log');
38
}
39
+ // If we get here, then we have failed to create the case.
40
+ $this->addToRetryQueue($order);
41
+ }
42
+
43
+ private function addToRetryQueue($order)
44
+ {
45
+ Mage::log("Add to retries", null, 'signifyd_connect.log');
46
+ $order_tag = Mage::getModel('signifyd_connect/retries');
47
+ $order_tag->setOrderIncrement($order->getIncrementId());
48
+ $order_tag->setCreated(strftime('%Y-%m-%d %H:%M:%S', time()));
49
+ $order_tag->save();
50
}
51
52
public function logData($order, $payment, $quote)
269
'type' => 'text',
270
'index' => 'guarantee',
271
'filter' => false,
272
+ 'renderer' => 'signifyd_connect/renderer',
273
'width' => '100px',
274
),
275
'status'
279
}
280
}
281
}
282
+
283
+ public function handleCancel($order)
284
+ {
285
+ $helper = Mage::helper('signifyd_connect');
286
+ $case = Mage::getModel('signifyd_connect/case')->load($order);
287
+ if($case->isObjectNew()) {
288
+ $helper->logError("Guarantee cancel: Signifyd case for order $order does not exist in DB");
289
+ return;
290
+ }
291
+ if($case->getGuarantee() == 'N/A') {
292
+ $helper->logRequest("Guarantee cancel: Skipped. No guarantee active");
293
+ return;
294
+ }
295
+
296
+ $helper->logRequest("Guarantee cancel for case " . $case->getCode());
297
+ $helper->cancelGuarantee($case);
298
+ }
299
+
300
+ public function salesOrderPaymentCancel($observer)
301
+ {
302
+ $helper = Mage::helper('signifyd_connect');
303
+ try {
304
+ $event = $observer->getEvent();
305
+ if($event->getPayment()->getOrder()) {
306
+ $order = $event->getPayment()->getOrder()->getIncrementId();
307
+ } else {
308
+ $helper->logError("Event salesOrderPaymentCancel has no order");
309
+ return;
310
+ }
311
+ $this->handleCancel($order);
312
+ } catch(Exception $ex) {
313
+ $helper->logError("Guarantee cancel: $ex");
314
+ }
315
+ }
316
}
app/code/community/Signifyd/Connect/Model/Resource/Retries.php ADDED
@@ -0,0 +1,10 @@
1
+ <?php
2
+
3
+ class Signifyd_Connect_Model_Resource_Retries extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ protected function _construct()
6
+ {
7
+ $this->_init('signifyd_connect/retries', 'order_increment');
8
+ $this->_isPkAutoIncrement = false;
9
+ }
10
+ }
app/code/community/Signifyd/Connect/Model/Resource/Retries/Collection.php ADDED
@@ -0,0 +1,9 @@
1
+ <?php
2
+
3
+ class Signifyd_Connect_Model_Resource_Retries_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('signifyd_connect/retries');
8
+ }
9
+ }
app/code/community/Signifyd/Connect/Model/Retries.php ADDED
@@ -0,0 +1,10 @@
1
+ <?php
2
+
3
+ class Signifyd_Connect_Model_Retries extends Mage_Core_Model_Abstract
4
+ {
5
+ protected function _construct()
6
+ {
7
+ $this->_init('signifyd_connect/retries');
8
+ $this->_isPkAutoIncrement = false;
9
+ }
10
+ }
app/code/community/Signifyd/Connect/controllers/ConnectController.php CHANGED
@@ -7,6 +7,8 @@ class Signifyd_Connect_ConnectController extends Mage_Core_Controller_Front_Acti
7
public $_order = false;
8
public $_store_id = null;
9
public $_case = false;
10
11
public function getApiKey()
12
{
@@ -215,6 +217,8 @@ class Signifyd_Connect_ConnectController extends Mage_Core_Controller_Front_Acti
215
if ($topic == "cases/test") return;
216
217
$this->_case = $this->initCase($this->_request['orderId']);
218
219
$this->_order = Mage::getModel('sales/order')->loadByIncrementId($this->_request['orderId']);
220
@@ -227,10 +231,11 @@ class Signifyd_Connect_ConnectController extends Mage_Core_Controller_Front_Acti
227
}
228
}
229
230
- public function holdOrder($order)
231
{
232
if ($order && $order->getId() && $order->canHold()) {
233
$order->hold();
234
$order->save();
235
236
if ($this->logRequest()) {
@@ -239,10 +244,11 @@ class Signifyd_Connect_ConnectController extends Mage_Core_Controller_Front_Acti
239
}
240
}
241
242
- public function unholdOrder($order)
243
{
244
if ($order && $order->getId() && $order->canUnhold()) {
245
$order->unhold();
246
$order->save();
247
248
if ($this->logRequest()) {
@@ -251,10 +257,11 @@ class Signifyd_Connect_ConnectController extends Mage_Core_Controller_Front_Acti
251
}
252
}
253
254
- public function cancelOrder($order)
255
{
256
if ($order && $order->getId() && $order->canCancel()) {
257
$order->cancel();
258
$order->save();
259
260
if ($this->logRequest()) {
@@ -288,64 +295,52 @@ class Signifyd_Connect_ConnectController extends Mage_Core_Controller_Front_Acti
288
public function processAdditional($case, $original_status = false)
289
{
290
$order = $this->_order;
291
- $impeded = false;
292
293
if ($order && $order->getId()) {
294
$threshold = $this->holdThreshold();
295
296
$negativeAction = $this->negativeGuaranteeAction();
297
$positiveAction = $this->positiveGuaranteeAction();
298
299
- if (isset($this->_request ['guaranteeDisposition'])) {
300
- if ($this->_request ['guaranteeDisposition'] == 'DECLINED' && $negativeAction != 'nothing') {
301
if ($negativeAction == 'hold') {
302
- $this->holdOrder($order);
303
- $impeded = true;
304
} else if ($negativeAction == 'cancel') {
305
- $this->cancelOrder($order);
306
- $impeded = true;
307
} else {
308
Mage::log("Unknown action $negativeAction", null, 'signifyd_connect.log');
309
}
310
- } else if ($this->_request ['guaranteeDisposition'] == 'APPROVED' && $positiveAction != 'nothing') {
311
if ($positiveAction == 'unhold') {
312
- $this->unholdOrder($order);
313
} else {
314
Mage::log("Unknown action $positiveAction", null, 'signifyd_connect.log');
315
}
316
}
317
- }
318
-
319
- if (!$original_status || $original_status == 'PENDING') {
320
- if ($threshold && $case->getScore() <= $threshold && $this->canReviewHold()) {
321
- $this->holdOrder($order);
322
- $impeded = true;
323
- }
324
- } else if ($original_status) {
325
- if ($this->_request['reviewDisposition'] == 'FRAUDULENT') {
326
- if ($order->canHold() && $this->canReviewHold()) {
327
- $order->hold();
328
- $order->save();
329
-
330
- if ($this->logRequest()) {
331
- Mage::log('Order ' . $order->getId() . ' held', null, 'signifyd_connect.log');
332
- }
333
}
334
- } else if ($this->_request['reviewDisposition'] == 'GOOD') {
335
- if ($order->canUnhold() && $this->canReviewHold()) {
336
- $order->unhold();
337
- $order->save();
338
-
339
- if ($this->logRequest()) {
340
- Mage::log('Order ' . $order->getId() . ' unheld', null, 'signifyd_connect.log');
341
}
342
}
343
}
344
}
345
-
346
- if ($order && $order->getId() && $this->canInvoice() && !$impeded && !$original_status) {
347
- $this->invoiceOrder($order);
348
- }
349
}
350
}
351
@@ -496,6 +491,11 @@ class Signifyd_Connect_ConnectController extends Mage_Core_Controller_Front_Acti
496
497
}
498
499
public function sendAction()
500
{
501
try {
7
public $_order = false;
8
public $_store_id = null;
9
public $_case = false;
10
+ public $_previousGuarantee = false;
11
+ public $_previousScore = false;
12
13
public function getApiKey()
14
{
217
if ($topic == "cases/test") return;
218
219
$this->_case = $this->initCase($this->_request['orderId']);
220
+ $this->_previousGuarantee = $this->_case->getGuarantee();
221
+ $this->_previousScore = $this->_case->getScore();
222
223
$this->_order = Mage::getModel('sales/order')->loadByIncrementId($this->_request['orderId']);
224
231
}
232
}
233
234
+ public function holdOrder($order, $reason)
235
{
236
if ($order && $order->getId() && $order->canHold()) {
237
$order->hold();
238
+ $order->addStatusHistoryComment("Signifyd: order held because $reason");
239
$order->save();
240
241
if ($this->logRequest()) {
244
}
245
}
246
247
+ public function unholdOrder($order, $reason)
248
{
249
if ($order && $order->getId() && $order->canUnhold()) {
250
$order->unhold();
251
+ $order->addStatusHistoryComment("Signifyd: order unheld because $reason");
252
$order->save();
253
254
if ($this->logRequest()) {
257
}
258
}
259
260
+ public function cancelOrder($order, $reason)
261
{
262
if ($order && $order->getId() && $order->canCancel()) {
263
$order->cancel();
264
+ $order->addStatusHistoryComment("Signifyd: order canceled because $reason");
265
$order->save();
266
267
if ($this->logRequest()) {
295
public function processAdditional($case, $original_status = false)
296
{
297
$order = $this->_order;
298
299
if ($order && $order->getId()) {
300
$threshold = $this->holdThreshold();
301
302
$negativeAction = $this->negativeGuaranteeAction();
303
$positiveAction = $this->positiveGuaranteeAction();
304
+ $newGuarantee = $this->_request ['guaranteeDisposition'];
305
+ $newScore = $case->getScore();
306
307
+ // If a guarantee has been set, we no longer care about other actions
308
+ if (isset($newGuarantee) && $newGuarantee != $this->_previousGuarantee) {
309
+ if ($newGuarantee == 'DECLINED' && $negativeAction != 'nothing') {
310
if ($negativeAction == 'hold') {
311
+ $this->holdOrder($order, "guarantee declined");
312
} else if ($negativeAction == 'cancel') {
313
+ $this->cancelOrder($order, "guarantee declined");
314
} else {
315
Mage::log("Unknown action $negativeAction", null, 'signifyd_connect.log');
316
}
317
+ } else if ($newGuarantee == 'APPROVED' && $positiveAction != 'nothing') {
318
if ($positiveAction == 'unhold') {
319
+ $this->unholdOrder($order, "guarantee approved");
320
} else {
321
Mage::log("Unknown action $positiveAction", null, 'signifyd_connect.log');
322
}
323
}
324
+ } else if($this->_previousGuarantee == "N/A") {
325
+ if (!$original_status || $original_status == 'PENDING') {
326
+ if ($threshold && $this->_previousScore != $newScore
327
+ && $newScore <= $threshold
328
+ && $this->canReviewHold())
329
+ {
330
+ $this->holdOrder($order, "score below threshold");
331
}
332
+ } else if ($original_status) {
333
+ if ($this->_request['reviewDisposition'] == 'FRAUDULENT') {
334
+ if ($this->canReviewHold()) {
335
+ $this->holdOrder($order, "case review fraudulent");
336
+ }
337
+ } else if ($this->_request['reviewDisposition'] == 'GOOD') {
338
+ if ($this->canReviewHold()) {
339
+ $this->unholdOrder($order, "case review good");
340
}
341
}
342
}
343
}
344
}
345
}
346
491
492
}
493
494
+ public function retriesAction()
495
+ {
496
+ Mage::helper('signifyd_connect')->processRetryQueue();
497
+ }
498
+
499
public function sendAction()
500
{
501
try {
app/code/community/Signifyd/Connect/etc/config.xml CHANGED
@@ -3,7 +3,7 @@
3
<config>
4
<modules>
5
<Signifyd_Connect>
6
- <version>3.12.3</version>
7
</Signifyd_Connect>
8
</modules>
9
<global>
@@ -23,6 +23,9 @@
23
<case>
24
<table>signifyd_connect_case</table>
25
</case>
26
</entities>
27
</signifyd_connect_resource>
28
</models>
@@ -167,6 +170,14 @@
167
</signifyd_connect>
168
</observers>
169
</sales_order_grid_collection_load_before>
170
<core_block_abstract_to_html_before>
171
<observers>
172
<signifyd_connect>
3
<config>
4
<modules>
5
<Signifyd_Connect>
6
+ <version>3.13.0</version>
7
</Signifyd_Connect>
8
</modules>
9
<global>
23
<case>
24
<table>signifyd_connect_case</table>
25
</case>
26
+ <retries>
27
+ <table>signifyd_connect_retries</table>
28
+ </retries>
29
</entities>
30
</signifyd_connect_resource>
31
</models>
170
</signifyd_connect>
171
</observers>
172
</sales_order_grid_collection_load_before>
173
+ <sales_order_payment_cancel>
174
+ <observers>
175
+ <signifyd_connect>
176
+ <model>signifyd_connect/observer</model>
177
+ <method>salesOrderPaymentCancel</method>
178
+ </signifyd_connect>
179
+ </observers>
180
+ </sales_order_payment_cancel>
181
<core_block_abstract_to_html_before>
182
<observers>
183
<signifyd_connect>
app/code/community/Signifyd/Connect/etc/system.xml CHANGED
@@ -185,6 +185,7 @@
185
<show_in_default>1</show_in_default>
186
<show_in_website>1</show_in_website>
187
<show_in_store>1</show_in_store>
188
<fields>
189
<request>
190
<label>Log requests</label>
185
<show_in_default>1</show_in_default>
186
<show_in_website>1</show_in_website>
187
<show_in_store>1</show_in_store>
188
+ <comment><![CDATA[Note: You must also enable logging for the site. You can find the setting in Configuration->Advanced->Developer->Log Settings]]></comment>
189
<fields>
190
<request>
191
<label>Log requests</label>
app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.12.0-3.13.0.php ADDED
@@ -0,0 +1,15 @@
1
+ <?php
2
+
3
+ try {
4
+ $this->startSetup();
5
+ $this->run("
6
+ CREATE TABLE IF NOT EXISTS `{$this->getTable('signifyd_connect_retries')}` (
7
+ `order_increment` varchar(255) NOT NULL,
8
+ `created` timestamp NULL DEFAULT NULL,
9
+ PRIMARY KEY (`order_increment`)
10
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
11
+ ");
12
+ $this->endSetup();
13
+ } catch (Exception $e) {
14
+ Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
15
+ }
package.xml CHANGED
@@ -1,7 +1,7 @@
1
<?xml version="1.0"?>
2
<package>
3
<name>Signifyd_Connect</name>
4
- <version>3.12.3</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>auto-converted</user><email>manelis@signifyd.com</email></author></authors>
13
- <date>2015-12-04</date>
14
- <time>02:00:23</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="52843fc84cdb65214bb3469b6390bee5"/></dir><file name="Order.php" hash="e49f869c0aa5fb3ab6b70fb5752049ac"/></dir></dir><file name="Renderer.php" hash="5564e9c6926afbbdade26a6fe746948a"/></dir><dir name="Helper"><file name="Data.php" hash="bc670522fab50a08520201059937cccd"/></dir><dir name="Model"><dir name="Resource"><dir name="Case"><file name="Collection.php" hash="b7dac9979a0c81db56294d1548570fc2"/></dir><file name="Case.php" hash="60d14407c9c90148aad543ce6868f343"/></dir><dir name="System"><dir name="Config"><dir name="Source"><dir name="Options"><file name="Negative.php" hash="098488fbb0ea84945fdd1e1fe8449b4b"/><file name="Positive.php" hash="80b4cdd2bae6e2a2f3a273fa49d32331"/></dir></dir></dir></dir><file name="Authnet.php" hash="0387e631fb232778cdc82c0c72c16781"/><file name="Case.php" hash="2a28a63f02df1b9103b89a562c0abe1b"/><file name="Cron.php" hash="51665978bd2bcf67b493f2a2b450d1b8"/><file name="Link.php" hash="ecaf4c403a586b4b5c8b67c77f6ac433"/><file name="Observer.php" hash="5acd7494fbbf73f0c6b629631bdce05d"/><file name="Setup.php" hash="e803ffb4b86c7d8ec1d149e665d65877"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="SignifydController.php" hash="5787eb1c3ad32d7f2fc1b909f332a50f"/></dir><file name="ConnectController.php" hash="9505328a87b9e97f60a53dc71da55c31"/></dir><dir name="etc"><file name="adminhtml.xml" hash="894bd3f5ac76e9f602ab6ab592648b03"/><file name="config.xml" hash="0abb76748d8f174b5247172244761144"/><file name="system.xml" hash="8fd9633f3b4a0a6e0af95a690edd2c59"/></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.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></contents>
16
<compatible/>
17
<dependencies/>
18
</package>
1
<?xml version="1.0"?>
2
<package>
3
<name>Signifyd_Connect</name>
4
+ <version>3.13.0</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>auto-converted</user><email>manelis@signifyd.com</email></author></authors>
13
+ <date>2016-04-03</date>
14
+ <time>03:48:47</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><file name="Renderer.php" hash="b16dfa77aad966640705f55f09304fc2"/></dir><dir name="Helper"><file name="Data.php" hash="e726228b65072e4b4510d0f0daf405ed"/><file name=".Data.php.swp" hash="5dee45005f944dfb764936be7296b6f8"/></dir><dir name="Model"><dir name="Resource"><dir name="Case"><file name="Collection.php" hash="b7dac9979a0c81db56294d1548570fc2"/></dir><dir name="Retries"><file name="Collection.php" hash="bd94e095c3a6367d20f5ebdd756740c8"/></dir><file name="Case.php" hash="60d14407c9c90148aad543ce6868f343"/><file name="Retries.php" hash="8027995f79188f624b6a681e4868d2e6"/></dir><dir name="System"><dir name="Config"><dir name="Source"><dir name="Options"><file name="Negative.php" hash="098488fbb0ea84945fdd1e1fe8449b4b"/><file name="Positive.php" hash="80b4cdd2bae6e2a2f3a273fa49d32331"/></dir></dir></dir></dir><file name="Authnet.php" hash="0387e631fb232778cdc82c0c72c16781"/><file name="Case.php" hash="2a28a63f02df1b9103b89a562c0abe1b"/><file name="Cron.php" hash="51665978bd2bcf67b493f2a2b450d1b8"/><file name="Link.php" hash="ecaf4c403a586b4b5c8b67c77f6ac433"/><file name="Observer.php" hash="d5f2fef416e1c5c43ed98c2cfc8f4cd8"/><file name="Retries.php" hash="28780c04867b083b1d51878e59fa380b"/><file name="Setup.php" hash="e803ffb4b86c7d8ec1d149e665d65877"/></dir><dir name="controllers"><dir name="Adminhtml"><file name="SignifydController.php" hash="5787eb1c3ad32d7f2fc1b909f332a50f"/></dir><file name="ConnectController.php" hash="5f18dc693fd69a4d94030500cc61eacb"/></dir><dir name="etc"><file name="adminhtml.xml" hash="894bd3f5ac76e9f602ab6ab592648b03"/><file name="config.xml" hash="47d92b84d47ea6021db2988192248f4b"/><file name="system.xml" hash="3bf253bc739ef6b213add6a77114fe93"/></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.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></contents>
16
<compatible/>
17
<dependencies/>
18
</package>