Signifyd_Connect - Version 3.15.0

Version Notes

Supports all versions of Magento

Download this release

Release Info

Developer signifyd
Extension Signifyd_Connect
Version 3.15.0
Comparing to
See all releases


Code changes from version 3.13.1 to 3.15.0

Files changed (65) hide show
  1. app/code/community/Signifyd/Connect/Block/Adminhtml/Sales/Order.php +13 -13
  2. app/code/community/Signifyd/Connect/Block/Adminhtml/Sales/Order/Grid.php +134 -134
  3. app/code/community/Signifyd/Connect/Block/Renderer.php +28 -28
  4. app/code/community/Signifyd/Connect/Block/Url.php +10 -0
  5. app/code/community/Signifyd/Connect/Helper/Data.php +790 -794
  6. app/code/community/Signifyd/Connect/Helper/Log.php +25 -0
  7. app/code/community/Signifyd/Connect/Model/Authnet.php +17 -17
  8. app/code/community/Signifyd/Connect/Model/Case.php +29 -10
  9. app/code/community/Signifyd/Connect/Model/Cron.php +136 -9
  10. app/code/community/Signifyd/Connect/Model/Link.php +9 -9
  11. app/code/community/Signifyd/Connect/Model/Observer.php +299 -316
  12. app/code/community/Signifyd/Connect/Model/Order.php +412 -0
  13. app/code/community/Signifyd/Connect/Model/Order/Payment.php +29 -0
  14. app/code/community/Signifyd/Connect/Model/Resource/Case.php +10 -10
  15. app/code/community/Signifyd/Connect/Model/Resource/Case/Collection.php +9 -9
  16. app/code/community/Signifyd/Connect/Model/Resource/Retries.php +10 -10
  17. app/code/community/Signifyd/Connect/Model/Resource/Retries/Collection.php +9 -9
  18. app/code/community/Signifyd/Connect/Model/Retries.php +10 -10
  19. app/code/community/Signifyd/Connect/Model/Setup.php +53 -53
  20. app/code/community/Signifyd/Connect/Model/System/Config/Source/Options/Accepted.php +19 -0
  21. app/code/community/Signifyd/Connect/Model/System/Config/Source/Options/Declined.php +19 -0
  22. app/code/community/Signifyd/Connect/Model/System/Config/Source/Options/Negative.php +0 -22
  23. app/code/community/Signifyd/Connect/Model/System/Config/Source/Options/Positive.php +0 -18
  24. app/code/community/Signifyd/Connect/controllers/Adminhtml/SignifydController.php +22 -27
  25. app/code/community/Signifyd/Connect/controllers/ConnectController.php +523 -593
  26. app/code/community/Signifyd/Connect/etc/adminhtml.xml +16 -16
  27. app/code/community/Signifyd/Connect/etc/config.xml +214 -199
  28. app/code/community/Signifyd/Connect/etc/system.xml +133 -222
  29. app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-install-3.1.1.php +13 -13
  30. app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-install-3.12.0.php +26 -26
  31. app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-install-3.3.0.php +19 -19
  32. app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-install-3.4.0.php +21 -21
  33. app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-install-3.4.5.php +21 -21
  34. app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-install-3.7.0.php +18 -18
  35. app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-install-3.8.0.php +19 -19
  36. app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.10.0-3.10.1.php +8 -8
  37. app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.10.1-3.11.0.php +8 -8
  38. app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.11.0-3.11.1.php +8 -8
  39. app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.11.1-3.12.0.php +17 -17
  40. app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.12.0-3.13.0.php +15 -15
  41. app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.14.0-3.15.0.php +10 -0
  42. app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.2.0-3.2.1.php +5 -5
  43. app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.2.1-3.2.2.php +17 -17
  44. app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.2.2-3.2.3.php +8 -8
  45. app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.2.3-3.3.0.php +10 -10
  46. app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.3.0-3.4.0.php +11 -11
  47. app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.4.0-3.4.1.php +10 -10
  48. app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.4.1-3.4.2.php +8 -8
  49. app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.4.2-3.4.3.php +8 -8
  50. app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.4.3-3.4.4.php +8 -8
  51. app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.4.4-3.4.5.php +13 -13
  52. app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.4.5-3.4.6.php +8 -8
  53. app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.4.6-3.4.7.php +8 -8
  54. app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.4.7-3.4.8.php +8 -8
  55. app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.4.8-3.5.0.php +8 -8
  56. app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.5.0-3.5.1.php +8 -8
  57. app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.5.1-3.5.2.php +8 -8
  58. app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.5.2-3.5.3.php +8 -8
  59. app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.5.3-3.6.0.php +8 -8
  60. app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.6.0-3.7.0.php +31 -31
  61. app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.7.0-3.8.0.php +10 -10
  62. app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.8.0-3.9.0.php +8 -8
  63. app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.9.0-3.10.0.php +8 -8
  64. app/etc/modules/Signifyd_Connect.xml +9 -9
  65. package.xml +6 -6
app/code/community/Signifyd/Connect/Block/Adminhtml/Sales/Order.php CHANGED
@@ -1,13 +1,13 @@
1
- <?php
2
-
3
- class Signifyd_Connect_Block_Adminhtml_Sales_Order extends Mage_Adminhtml_Block_Widget_Grid_Container
4
- {
5
- public function __construct()
6
- {
7
- $this->_blockGroup = 'signifyd_connect';
8
- $this->_controller = 'adminhtml_sales_order';
9
- $this->_headerText = Mage::helper('signifyd_connect')->__('Signifyd Scores');
10
- parent::__construct();
11
- $this->_removeButton('add');
12
- }
13
- }
1
+ <?php
2
+
3
+ class Signifyd_Connect_Block_Adminhtml_Sales_Order extends Mage_Adminhtml_Block_Widget_Grid_Container
4
+ {
5
+ public function __construct()
6
+ {
7
+ $this->_blockGroup = 'signifyd_connect';
8
+ $this->_controller = 'adminhtml_sales_order';
9
+ $this->_headerText = Mage::helper('signifyd_connect')->__('Signifyd Scores');
10
+ parent::__construct();
11
+ $this->_removeButton('add');
12
+ }
13
+ }
app/code/community/Signifyd/Connect/Block/Adminhtml/Sales/Order/Grid.php CHANGED
@@ -1,134 +1,134 @@
1
- <?php
2
-
3
- class Signifyd_Connect_Block_Adminhtml_Sales_Order_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
- {
5
- public function __construct()
6
- {
7
- parent::__construct();
8
- $this->setId('signifyd_connect_grid');
9
- $this->setDefaultSort('increment_id');
10
- $this->setDefaultDir('DESC');
11
- $this->setSaveParametersInSession(true);
12
- $this->setUseAjax(true);
13
- }
14
-
15
- public function oldSupport()
16
- {
17
- $model = Mage::getSingleton('signifyd_connect/observer');
18
-
19
- return $model->oldSupport();
20
- }
21
-
22
- protected function _prepareCollection()
23
- {
24
- $collection = Mage::getResourceModel('sales/order_collection');
25
-
26
- if ($this->oldSupport()) {
27
- $collection->getSelect()->joinLeft(
28
- array('signifyd' => Mage::getSingleton('core/resource')->getTableName('signifyd_connect_case')),
29
- 'signifyd.order_increment = e.increment_id',
30
- array(
31
- 'score' => 'score',
32
- )
33
- );
34
- } else {
35
- $collection->addExpressionFieldToSelect(
36
- 'fullname',
37
- 'CONCAT({{customer_firstname}}, \' \', {{customer_lastname}})',
38
- array('customer_firstname' => 'main_table.customer_firstname', 'customer_lastname' => 'main_table.customer_lastname')
39
- );
40
-
41
- $collection->getSelect()->joinLeft(
42
- array('signifyd' => Mage::getSingleton('core/resource')->getTableName('signifyd_connect_case')),
43
- 'signifyd.order_increment = main_table.increment_id',
44
- array(
45
- 'score' => 'score',
46
- 'guarantee' => 'guarantee',
47
- )
48
- );
49
- }
50
-
51
- $this->setCollection($collection);
52
- parent::_prepareCollection();
53
- return $this;
54
- }
55
-
56
- protected function _prepareColumns()
57
- {
58
- $helper = Mage::helper('signifyd_connect');
59
- $currency = (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE);
60
-
61
- $this->addColumn('increment_id', array(
62
- 'header' => $helper->__('Order #'),
63
- 'index' => 'increment_id'
64
- ));
65
-
66
- $this->addColumn('purchased_on', array(
67
- 'header' => $helper->__('Purchased On'),
68
- 'type' => 'datetime',
69
- 'index' => 'created_at'
70
- ));
71
-
72
- if (!$this->oldSupport()) {
73
- $this->addColumn('fullname', array(
74
- 'header' => $helper->__('Name'),
75
- 'index' => 'fullname',
76
- 'filter_index' => 'CONCAT(customer_firstname, \' \', customer_lastname)'
77
- ));
78
- }
79
-
80
- $this->addColumn('grand_total', array(
81
- 'header' => $helper->__('Grand Total'),
82
- 'index' => 'grand_total',
83
- 'type' => 'currency',
84
- 'currency_code' => $currency
85
- ));
86
-
87
- $this->addColumn('shipping_method', array(
88
- 'header' => $helper->__('Shipping Method'),
89
- 'index' => 'shipping_description'
90
- ));
91
-
92
- $this->addColumn('score', array(
93
- 'header' => $helper->__('Signifyd Score'),
94
- 'align' => 'left',
95
- 'type' => 'text',
96
- 'index' => 'score',
97
- 'filter' => false,
98
- 'renderer' => 'signifyd_connect/renderer',
99
- 'width' => '100px',
100
- ));
101
-
102
- $this->addColumn('guarantee', array(
103
- 'header' => $helper->__('Signifyd Guarantee Status'),
104
- 'align' => 'left',
105
- 'type' => 'text',
106
- 'index' => 'guarantee',
107
- 'filter' => false,
108
- 'renderer' => 'signifyd_connect/renderer',
109
- ));
110
-
111
- $this->addColumn('order_status', array(
112
- 'header' => $helper->__('Status'),
113
- 'index' => 'status',
114
- 'type' => 'options',
115
- 'options' => Mage::getSingleton('sales/order_config')->getStatuses(),
116
- ));
117
-
118
- return parent::_prepareColumns();
119
- }
120
-
121
- public function getRowUrl($row)
122
- {
123
- if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
124
- return $this->getUrl('*/sales_order/view', array('order_id' => $row->getId()));
125
- }
126
-
127
- return false;
128
- }
129
-
130
- public function getGridUrl()
131
- {
132
- return $this->getUrl('*/*/grid', array('_current'=>true));
133
- }
134
- }
1
+ <?php
2
+
3
+ class Signifyd_Connect_Block_Adminhtml_Sales_Order_Grid extends Mage_Adminhtml_Block_Widget_Grid
4
+ {
5
+ public function __construct()
6
+ {
7
+ parent::__construct();
8
+ $this->setId('signifyd_connect_grid');
9
+ $this->setDefaultSort('increment_id');
10
+ $this->setDefaultDir('DESC');
11
+ $this->setSaveParametersInSession(true);
12
+ $this->setUseAjax(true);
13
+ }
14
+
15
+ public function oldSupport()
16
+ {
17
+ $model = Mage::getSingleton('signifyd_connect/observer');
18
+
19
+ return $model->oldSupport();
20
+ }
21
+
22
+ protected function _prepareCollection()
23
+ {
24
+ $collection = Mage::getResourceModel('sales/order_collection');
25
+
26
+ if ($this->oldSupport()) {
27
+ $collection->getSelect()->joinLeft(
28
+ array('signifyd' => Mage::getSingleton('core/resource')->getTableName('signifyd_connect_case')),
29
+ 'signifyd.order_increment = e.increment_id',
30
+ array(
31
+ 'score' => 'score',
32
+ )
33
+ );
34
+ } else {
35
+ $collection->addExpressionFieldToSelect(
36
+ 'fullname',
37
+ 'CONCAT({{customer_firstname}}, \' \', {{customer_lastname}})',
38
+ array('customer_firstname' => 'main_table.customer_firstname', 'customer_lastname' => 'main_table.customer_lastname')
39
+ );
40
+
41
+ $collection->getSelect()->joinLeft(
42
+ array('signifyd' => Mage::getSingleton('core/resource')->getTableName('signifyd_connect_case')),
43
+ 'signifyd.order_increment = main_table.increment_id',
44
+ array(
45
+ 'score' => 'score',
46
+ 'guarantee' => 'guarantee',
47
+ )
48
+ );
49
+ }
50
+
51
+ $this->setCollection($collection);
52
+ parent::_prepareCollection();
53
+ return $this;
54
+ }
55
+
56
+ protected function _prepareColumns()
57
+ {
58
+ $helper = Mage::helper('signifyd_connect');
59
+ $currency = (string) Mage::getStoreConfig(Mage_Directory_Model_Currency::XML_PATH_CURRENCY_BASE);
60
+
61
+ $this->addColumn('increment_id', array(
62
+ 'header' => $helper->__('Order #'),
63
+ 'index' => 'increment_id'
64
+ ));
65
+
66
+ $this->addColumn('purchased_on', array(
67
+ 'header' => $helper->__('Purchased On'),
68
+ 'type' => 'datetime',
69
+ 'index' => 'created_at'
70
+ ));
71
+
72
+ if (!$this->oldSupport()) {
73
+ $this->addColumn('fullname', array(
74
+ 'header' => $helper->__('Name'),
75
+ 'index' => 'fullname',
76
+ 'filter_index' => 'CONCAT(customer_firstname, \' \', customer_lastname)'
77
+ ));
78
+ }
79
+
80
+ $this->addColumn('grand_total', array(
81
+ 'header' => $helper->__('Grand Total'),
82
+ 'index' => 'grand_total',
83
+ 'type' => 'currency',
84
+ 'currency_code' => $currency
85
+ ));
86
+
87
+ $this->addColumn('shipping_method', array(
88
+ 'header' => $helper->__('Shipping Method'),
89
+ 'index' => 'shipping_description'
90
+ ));
91
+
92
+ $this->addColumn('score', array(
93
+ 'header' => $helper->__('Signifyd Score'),
94
+ 'align' => 'left',
95
+ 'type' => 'text',
96
+ 'index' => 'score',
97
+ 'filter' => false,
98
+ 'renderer' => 'signifyd_connect/renderer',
99
+ 'width' => '100px',
100
+ ));
101
+
102
+ $this->addColumn('guarantee', array(
103
+ 'header' => $helper->__('Signifyd Guarantee Status'),
104
+ 'align' => 'left',
105
+ 'type' => 'text',
106
+ 'index' => 'guarantee',
107
+ 'filter' => false,
108
+ 'renderer' => 'signifyd_connect/renderer',
109
+ ));
110
+
111
+ $this->addColumn('order_status', array(
112
+ 'header' => $helper->__('Status'),
113
+ 'index' => 'status',
114
+ 'type' => 'options',
115
+ 'options' => Mage::getSingleton('sales/order_config')->getStatuses(),
116
+ ));
117
+
118
+ return parent::_prepareColumns();
119
+ }
120
+
121
+ public function getRowUrl($row)
122
+ {
123
+ if (Mage::getSingleton('admin/session')->isAllowed('sales/order/actions/view')) {
124
+ return $this->getUrl('*/sales_order/view', array('order_id' => $row->getId()));
125
+ }
126
+
127
+ return false;
128
+ }
129
+
130
+ public function getGridUrl()
131
+ {
132
+ return $this->getUrl('*/*/grid', array('_current'=>true));
133
+ }
134
+ }
app/code/community/Signifyd/Connect/Block/Renderer.php CHANGED
@@ -1,28 +1,28 @@
1
- <?php
2
-
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
- }
25
-
26
- return $value;
27
- }
28
- }
1
+ <?php
2
+
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
+ }
25
+
26
+ return $value;
27
+ }
28
+ }
app/code/community/Signifyd/Connect/Block/Url.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Signifyd_Connect_Block_Url
5
+ {
6
+ public function setForm()
7
+ {
8
+ return Mage::getUrl('/');
9
+ }
10
+ }
app/code/community/Signifyd/Connect/Helper/Data.php CHANGED
@@ -1,794 +1,790 @@
1
- <?php
2
-
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
- {
33
- $products = array();
34
-
35
- foreach ($quote->getAllItems() as $item) {
36
- $product_type = $item->getProductType();
37
-
38
- if (!$product_type || $product_type == 'simple' || $product_type == 'downloadable' || $product_type == 'grouped') {
39
- $product_object = $item->getData('product');
40
-
41
- if (!$product_object || !$product_object->getId()) {
42
- $product_object = Mage::getModel('catalog/product')->load($product_type);
43
- }
44
-
45
- if ($product_object) {
46
- $product = array();
47
-
48
- $product['itemId'] = $item->getSku();
49
- $product['itemName'] = $item->getName();
50
- $product['itemUrl'] = $this->getProductUrl($product_object);
51
- $product['itemImage'] = $this->getProductImage($product_object);
52
-
53
- $qty = 1;
54
- if ($item->getQty()) {
55
- $qty = $item->getQty();
56
- } else if ($item->getQtyOrdered()) {
57
- $qty = $item->getQtyOrdered();
58
- }
59
-
60
- $price = 0;
61
- if ($item->getPrice() > 0) {
62
- $price = $item->getPrice();
63
- } else if ($item->getBasePrice() > 0) {
64
- $price = $item->getBasePrice();
65
- } else if ($product_object->getData('price') > 0) {
66
- $price = $product_object->getData('price');
67
- } else {
68
- $parent = $item->getData('parent');
69
-
70
- if (!$parent) {
71
- $parent = $item->getParentItem();
72
- }
73
-
74
- if ($parent) {
75
- if ($parent->getBasePrice() > 0) {
76
- $price = $parent->getBasePrice();
77
- } else if ($parent->getPrice()) {
78
- $price = $parent->getPrice();
79
- }
80
- }
81
- }
82
-
83
- $weight = 0;
84
- if ($item->hasWeight()) {
85
- $weight = $item->getWeight();
86
- } else if ($product_object->hasWeight()) {
87
- $weight = $product_object->getWeight();
88
- }
89
-
90
- $product['itemQuantity'] = intval($qty);
91
- $product['itemPrice'] = floatval($price);
92
- $product['itemWeight'] = floatval($weight);
93
-
94
- $products[] = $product;
95
- }
96
- }
97
- }
98
-
99
- return $products;
100
- }
101
-
102
- public function getIPAddress($order)
103
- {
104
- if ($order->getRemoteIp()) {
105
- if ($order->getXForwardedFor()) {
106
- return $this->filterIp($order->getXForwardedFor());
107
- }
108
-
109
- return $this->filterIp($order->getRemoteIp());
110
- }
111
-
112
- // Checks each configured value in app/etc/local.xml & falls back to REMOTE_ADDR. See app/etc/local.xml.additional for examples.
113
- return $this->filterIp(Mage::helper('core/http')->getRemoteAddr(false));
114
- }
115
-
116
- public function filterIp($ip)
117
- {
118
- $matches = array();
119
-
120
- if (preg_match('/[0-9]{1,3}(?:\.[0-9]{1,3}){3}/', $ip, $matches)) { //ipv4
121
- return current($matches);
122
- }
123
-
124
- if (preg_match('/[a-f0-9]{0,4}(?:\:[a-f0-9]{0,4}){2,7}/', strtolower($ip), $matches)) { //ipv6
125
- return current($matches);
126
- }
127
-
128
- return preg_replace('/[^0-9a-zA-Z:\.]/', '', strtok(str_replace($ip, ',', "\n"), "\n"));
129
- }
130
-
131
- public function formatAvs($value)
132
- {
133
- // http://www.emsecommerce.net/avs_cvv2_response_codes.htm
134
- $codes = array('X', 'Y', 'A', 'W', 'Z', 'N', 'U', 'R', 'E', 'S', 'D', 'M', 'B', 'P', 'C', 'I', 'G');
135
-
136
- if ($value) {
137
- $value = strtoupper($value);
138
-
139
- if (strlen($value) > 1) {
140
- if (preg_match('/\([A-Z]\)/', $value)) {
141
- $matches = array();
142
-
143
- preg_match('/\([A-Z]\)/', $value, $matches);
144
-
145
- foreach ($matches as $match) {
146
- $match = preg_replace('/[^A-Z]/', '', $match);
147
-
148
- if (in_array($match, $codes)) {
149
- $value = $match;
150
- }
151
- }
152
- }
153
- }
154
-
155
- if (strlen($value) > 1) {
156
- $value = substr($value, 0, 1);
157
- }
158
-
159
- if (!in_array($value, $codes)) {
160
- $value = null;
161
- }
162
- }
163
-
164
- return $value;
165
- }
166
-
167
- public function getAvsResponse($payment)
168
- {
169
- $value = null;
170
-
171
- if ($payment->getAdditionalInformation('paypal_avs_code')) {
172
- $value = $payment->getAdditionalInformation('paypal_avs_code');
173
- } else if ($payment->getAdditionalInformation('cc_avs_status')) {
174
- $value = $payment->getAdditionalInformation('cc_avs_status');
175
- }
176
-
177
- return $this->formatAvs($value);
178
- }
179
-
180
- public function getCvvResponse($payment)
181
- {
182
- if ($payment->getAdditionalInformation('paypal_cvv2_match')) {
183
- return $payment->getAdditionalInformation('paypal_cvv2_match');
184
- }
185
-
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)
210
- {
211
- $purchase = array();
212
- $payment = $order->getPayment();
213
-
214
- // T715: Send null rather than false when we can't get the IP Address
215
- $purchase['browserIpAddress'] = ($this->getIpAddress($order) ? $this->getIpAddress($order) : null);
216
- $purchase['orderId'] = $order->getIncrementId();
217
- $purchase['createdAt'] = date('c', strtotime($order->getCreatedAt())); // e.g: 2004-02-12T15:19:21+00:00
218
- $purchase['currency'] = $order->getOrderCurrencyCode();
219
- $purchase['totalPrice'] = floatval($order->getGrandTotal());
220
- $purchase['shippingPrice'] = floatval($order->getShippingAmount());
221
- $purchase['products'] = $this->getProducts($order);
222
- $purchase['paymentGateway'] = $payment->getMethod();
223
- $purchase['transactionId'] = $this->getTransactionId($payment);
224
-
225
- $purchase['avsResponseCode'] = $this->getAvsResponse($payment);
226
- $purchase['cvvResponseCode'] = $this->getCvvResponse($payment);
227
-
228
- return $purchase;
229
- }
230
-
231
- public function isPaymentCC($payment)
232
- {
233
- // Although the payment structure only has the entity data for the payment
234
- // the original payment method object is stored within the entity data.
235
- // It's not a requirement, but every CC handler I've found subclasses
236
- // from Mage_Payment_Model_Method_Cc, so we are using that as an
237
- // assumption for whether a method is based on CC data
238
- $method = $payment->getData('method_instance');
239
- if($method)
240
- {
241
- return is_subclass_of($method, 'Mage_Payment_Model_Method_Cc');
242
- }
243
- return false;
244
- }
245
-
246
- public function getCard($order, $payment)
247
- {
248
- $billing = $order->getBillingAddress();
249
-
250
- $card = array();
251
-
252
- $card['cardHolderName'] = null;
253
- $card['bin'] = null;
254
- $card['last4'] = null;
255
- $card['expiryMonth'] = null;
256
- $card['expiryYear'] = null;
257
- $card['hash'] = null;
258
-
259
- $card['billingAddress'] = $this->getSignifydAddress($billing);
260
-
261
- if ($payment->getCcOwner()) {
262
- $card['cardHolderName'] = $payment->getCcOwner();
263
- } else {
264
- $card['cardHolderName'] = $billing->getFirstname() . ' ' . $billing->getLastname();
265
- }
266
-
267
- // Card data may be set on payment even if payment was not with card.
268
- // If it is, we want to ignore the data
269
- if(!$this->isPaymentCC($payment)) return $card;
270
-
271
- if ($payment->getData('cc_last4')) {
272
- $card['last4'] = $payment->getData('cc_last4');
273
- }
274
-
275
- if ($payment->getData('cc_exp_year')) {
276
- $card['expiryYear'] = $payment->getData('cc_exp_year');
277
- }
278
-
279
- if ($payment->getData('cc_exp_month')) {
280
- $card['expiryMonth'] = $payment->getData('cc_exp_month');
281
- }
282
-
283
- if ($payment->getData('cc_number_enc')) {
284
- $card['hash'] = $payment->getData('cc_number_enc');
285
- }
286
-
287
- if ($payment->getData('cc_number') && is_numeric($payment->getData('cc_number')) && strlen((string)$payment->getData('cc_number')) > 6) {
288
- $card['bin'] = substr((string)$payment->getData('cc_number'), 0, 6);
289
- }
290
-
291
- return $card;
292
- }
293
-
294
- public function getSignifydAddress($address_object)
295
- {
296
- $address = array();
297
-
298
- $address['streetAddress'] = $address_object->getStreet1();
299
- $address['unit'] = null;
300
-
301
- if ($address_object->getStreet2()) {
302
- $address['unit'] = $address_object->getStreet2();
303
- }
304
-
305
- $address['city'] = $address_object->getCity();
306
-
307
- $address['provinceCode'] = $address_object->getRegionCode();
308
- $address['postalCode'] = $address_object->getPostcode();
309
- $address['countryCode'] = $address_object->getCountryId();
310
-
311
- $address['latitude'] = null;
312
- $address['longitude'] = null;
313
-
314
- return $address;
315
- }
316
-
317
- public function getRecipient($order)
318
- {
319
- $recipient = array();
320
-
321
- // In the case of non-shipped (ex: downloadable) orders, shipping address will be null so
322
- // in that case, we need to avoid the exception.
323
- $shipping_address = $order->getShippingAddress();
324
- if($shipping_address) {
325
- $recipient['deliveryAddress'] = $this->getSignifydAddress($shipping_address);
326
- $recipient['fullName'] = $shipping_address->getFirstname() . ' ' . $shipping_address->getLastname();
327
- $recipient['confirmationPhone'] = $shipping_address->getTelephone();
328
- // Email: Note that this field is always the same for both addresses
329
- $recipient['confirmationEmail'] = $shipping_address->getEmail();
330
- }
331
- // Some customers have reported seeing "n/a@na.na" come through instead of a valid or null address
332
- // We suspect that it is due to an older version of Magento. If it becomes unnecessary, do remove the extra check.
333
- if (!$recipient['confirmationEmail'] || $recipient['confirmationEmail'] == 'n/a@na.na') {
334
- $recipient['confirmationEmail'] = $order->getCustomerEmail();
335
- }
336
-
337
- return $recipient;
338
- }
339
-
340
- public function getUserAccount($customer, $order)
341
- {
342
- $user = array(
343
- "emailAddress" => null,
344
- "username" => null,
345
- "phone" => null,
346
- "createdDate" => null,
347
- "accountNumber" => null,
348
- "lastOrderId" => null,
349
- "aggregateOrderCount" => null,
350
- "aggregateOrderDollars" => null,
351
- "lastUpdateDate" => null
352
- );
353
-
354
- if ($customer && $customer->getId()) {
355
- $user['emailAddress'] = $customer->getEmail();
356
-
357
- $user['phone'] = $order->getBillingAddress()->getTelephone();
358
-
359
- $user['createdDate'] = date('c', strtotime($customer->getCreatedAt()));
360
- $user['lastUpdateDate'] = date('c', strtotime($customer->getUpdatedAt()));
361
-
362
- $user['accountNumber'] = $customer->getId();
363
-
364
- $last_order_id = null;
365
-
366
- $orders = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('customer_id', $customer->getId());
367
- $orders->getSelect()->order('created_at DESC');
368
-
369
- $aggregate_total = 0.;
370
- $order_count = 0;
371
-
372
- foreach ($orders as $order) {
373
- if ($last_order_id === null) {
374
- $last_order_id = $order->getIncrementId();
375
- }
376
-
377
- $aggregate_total += floatval($order->getGrandTotal());
378
- $order_count += 1;
379
- }
380
-
381
- $user['lastOrderId'] = $last_order_id;
382
- $user['aggregateOrderCount'] = $order_count;
383
- $user['aggregateOrderDollars'] = floatval($aggregate_total);
384
- }
385
-
386
- return $user;
387
- }
388
-
389
- public function generateCase($order, $payment, $customer)
390
- {
391
- $case = array();
392
-
393
- $case['purchase'] = $this->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
- }
401
-
402
- public function submitCase($case, $url, $auth)
403
- {
404
- $case = json_encode($case);
405
-
406
- return $this->request($url, $case, $auth, 'application/json');
407
- }
408
-
409
- public function getUrl()
410
- {
411
- return Mage::getStoreConfig('signifyd_connect/settings/url') . '/cases';
412
- }
413
-
414
- public function getAuth()
415
- {
416
- return Mage::getStoreConfig('signifyd_connect/settings/key');
417
- }
418
-
419
- public function sendOrderUpdateToSignifyd($order)
420
- {
421
- if ($order && $order->getId() && Mage::getStoreConfig('signifyd_connect/advanced/enable_payment_updates')) {
422
- $case = Mage::getModel('signifyd_connect/case')->load($order->getIncrementId());
423
- $caseId = $case->getCode();
424
- if (Mage::getStoreConfig('signifyd_connect/log/request')) {
425
- Mage::log("Created new case: $caseId", null, 'signifyd_connect.log');
426
- }
427
-
428
- $updateData = array();
429
- $payment = $order->getPayment();
430
-
431
- // These are the only supported update fields
432
- $purchase = array();
433
- $purchase['paymentGateway'] = $payment->getMethod();
434
- $purchase['transactionId'] = $this->getTransactionId($payment);
435
- $purchase['avsResponseCode'] = $this->getAvsResponse($payment);
436
- $purchase['cvvResponseCode'] = $this->getCvvResponse($payment);
437
-
438
- // Do not make request if there is no data to send
439
- if( $purchase['transactionId'] == null ||
440
- $purchase['transactionId'] == null ||
441
- $purchase['transactionId'] == null)
442
- {
443
- return "nodata";
444
- }
445
-
446
-
447
- $updateData['purchase'] = $purchase;
448
-
449
- $data = json_encode($updateData);
450
-
451
- $response = $this->request($this->getUrl() . "/$caseId", $data, $this->getAuth(), 'application/json', null, true);
452
-
453
- try {
454
- $response_code = $response->getHttpCode();
455
-
456
- if (substr($response_code, 0, 1) == '2') {
457
- $case->setUpdated(strftime('%Y-%m-%d %H:%M:%S', time()));
458
- $case->setTransactionId($updateData['purchase']['transactionId']);
459
- $case->save();
460
- if (Mage::getStoreConfig('signifyd_connect/log/request')) {
461
- Mage::log("Wrote case to database: $caseId", null, 'signifyd_connect.log');
462
- }
463
- return "sent";
464
- }
465
- } catch (Exception $e) {
466
- Mage::log($e->__toString(), null, 'signifyd_connect.log');
467
- return "error";
468
- }
469
- }
470
- }
471
-
472
- public function bulkSend($controller)
473
- {
474
- try {
475
- $orderIds = $controller->getRequest()->getParam('order_ids');
476
- if(is_string($orderIds))
477
- {
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));
496
-
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
-
523
- public function buildAndSendOrderToSignifyd($order, $forceSend = false)
524
- {
525
- if ($order && $order->getId()) {
526
- $processStatus = $this->processedStatus($order);
527
- if ($processStatus > 0 && !$forceSend) {
528
- if($processStatus == self::TRANSACTION_SENT_STATUS) return "exists";
529
- else return $this->sendOrderUpdateToSignifyd($order);
530
- }
531
-
532
- $payments = $order->getPaymentsCollection();
533
- $last_payment = null;
534
- foreach ($payments as $payment) {
535
- $last_payment = $payment;
536
- }
537
-
538
- $state = $order->getState();
539
-
540
- if (!$state || $state == Mage_Sales_Model_Order::STATE_PENDING_PAYMENT) {
541
- return "notready"; // Note: would not be in the order grid if this were the case
542
- }
543
-
544
- $customer = null;
545
- if ($order->getCustomer()) {
546
- $customer = $order->getCustomer();
547
- }
548
-
549
- $case = $this->generateCase($order, $last_payment, $customer);
550
-
551
- $case_object = $this->markProcessed($order);
552
-
553
- $response = $this->submitCase($case, $this->getUrl(), $this->getAuth());
554
-
555
- try {
556
- $response_code = $response->getHttpCode();
557
-
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
-
571
- return "sent";
572
- }
573
- } catch (Exception $e) {
574
- Mage::log($e->__toString(), null, 'signifyd_connect.log');
575
- }
576
- $this->unmarkProcessed($order);
577
- return "error";
578
- }
579
- }
580
-
581
- /**
582
- * Run through up to $max items in the retry queue
583
- * @param int $max The maximum numbers of items to process
584
- */
585
- public function processRetryQueue($max = 99999)
586
- {
587
- $failed_orders = Mage::getModel('signifyd_connect/retries')->getCollection();
588
- $process_count = 0;
589
- try {
590
- foreach ($failed_orders as $order_id) {
591
- if ($process_count++ >= $max) {
592
- return;
593
- }
594
- $order = Mage::getModel('sales/order')->loadByIncrementId($order_id->getOrderIncrement());
595
- $result = "unset";
596
- $this->logRequest("Retrying " . $order_id->getOrderIncrement());
597
- if ($order != null && $this->processedStatus($order) < self::CASE_CREATED_STATUS) {
598
- $result = $this->buildAndSendOrderToSignifyd($order);
599
- }
600
- if ($result !== "error") {
601
- $this->logRequest("Completed retry " . $order_id->getOrderIncrement());
602
- Mage::register('isSecureArea', true);
603
- $order_id->delete();
604
- Mage::unregister('isSecureArea');
605
- } else {
606
- $this->logError("Failed retry " . $order_id->getOrderIncrement());
607
- }
608
- }
609
- } catch (Exception $e) {
610
- $this->logError($e->__toString());
611
- }
612
- }
613
-
614
- public function getProductUrl($product)
615
- {
616
- $url = null;
617
-
618
- try {
619
- $url = $product->getUrlModel()->getProductUrl($product);
620
- } catch (Exception $e) {
621
- $url = null;
622
- }
623
-
624
- return $url;
625
- }
626
-
627
- public function getCaseUrl($order_id)
628
- {
629
- $case = Mage::getModel('signifyd_connect/case')->load($order_id);
630
-
631
- if ($case->getCode()) {
632
- return "https://www.signifyd.com/cases/" . $case->getCode();
633
- }
634
- Mage::log('Case URL not found: '.$order_id, null, 'signifyd_connect.log');
635
- return '';
636
- }
637
-
638
- public function getProductImage($product, $size="150")
639
- {
640
- $image = null;
641
-
642
- try {
643
- $image = (string)Mage::helper('catalog/image')->init($product, 'image')->resize($size, $size)->keepFrame(true)->keepAspectRatio(true);
644
- } catch (Exception $e) {
645
- $image = null;
646
- }
647
-
648
- return $image;
649
- }
650
-
651
- public function getStoreName()
652
- {
653
- return Mage::getStoreConfig('trans_email/ident_general/name', 0);
654
- }
655
-
656
- public function getStoreEmail()
657
- {
658
- return Mage::getStoreConfig('trans_email/ident_general/email', 0);
659
- }
660
-
661
- public function getStoreUrl()
662
- {
663
- return Mage::getBaseUrl();
664
- }
665
-
666
- public function processedStatus($order)
667
- {
668
- $case = Mage::getModel('signifyd_connect/case')->load($order->getIncrementId());
669
-
670
- if ($case->getTransactionId)
671
- {
672
- return self::TRANSACTION_SENT_STATUS;
673
- }
674
- else if ($case->getCode())
675
- {
676
- return self::CASE_CREATED_STATUS;
677
- }
678
- else if ($case->getId())
679
- {
680
- return self::ENTITY_CREATED_STATUS;
681
- }
682
-
683
- return self::UNPROCESSED_STATUS;
684
- }
685
-
686
- public function markProcessed($order)
687
- {
688
- $case = Mage::getModel('signifyd_connect/case');
689
- $case->setOrderIncrement($order->getIncrementId());
690
- $case->setCreated(strftime('%Y-%m-%d %H:%M:%S', time()));
691
- $case->setUpdated(strftime('%Y-%m-%d %H:%M:%S', time()));
692
- $case->save();
693
-
694
- return $case;
695
- }
696
-
697
- public function unmarkProcessed($order)
698
- {
699
- $case = Mage::getModel('signifyd_connect/case')->load($order->getIncrementId());
700
- if($case && !$case->isObjectNew())
701
- {
702
- Mage::register('isSecureArea', true);
703
- $case->delete();
704
- Mage::unregister('isSecureArea');
705
- }
706
- }
707
-
708
- public function cancelGuarantee($case)
709
- {
710
- $caseId = $case->getCode();
711
- $url = $this->getUrl() . "/$caseId/guarantee";
712
- $body = json_encode(array("guaranteeDisposition" => "CANCELED"));
713
- $response = $this->request($url, $body, $this->getAuth(), 'application/json', null, true);
714
- $code = $response->getHttpCode();
715
- if(substr($code, 0, 1) == '2') {
716
- $case->setGuarantee('CANCELED');
717
- $case->save();
718
- } else {
719
- $this->logError("Guarantee cancel failed");
720
- }
721
- $this->logResponse("Received $code from guarantee cancel");
722
- }
723
-
724
- public function request($url, $data = null, $auth = null, $contenttype = "application/x-www-form-urlencoded",
725
- $accept = null, $is_update = false)
726
- {
727
- if (Mage::getStoreConfig('signifyd_connect/log/request')) {
728
- $authMask = preg_replace ( "/\S/", "*", $auth, strlen($auth) - 4 );
729
- Mage::log("Request:\nURL: $url \nAuth: $authMask\nData: $data", null, 'signifyd_connect.log');
730
- }
731
-
732
- $curl = curl_init();
733
- $response = new Varien_Object;
734
- $headers = array();
735
-
736
- curl_setopt($curl, CURLOPT_URL, $url);
737
-
738
- if (stripos($url, 'https://') === 0) {
739
- curl_setopt($curl, CURLOPT_PORT, 443);
740
- curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
741
- }
742
-
743
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
744
-
745
- if ($auth) {
746
- curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
747
- curl_setopt($curl, CURLOPT_USERPWD, $auth);
748
- }
749
-
750
- if ($accept) {
751
- $headers[] = 'Accept: ' . $accept;
752
- }
753
-
754
- if ($data) {
755
- if($is_update) curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
756
- else curl_setopt($curl, CURLOPT_POST, 1);
757
-
758
- $headers[] = "Content-Type: $contenttype";
759
- $headers[] = "Content-length: " . strlen($data);
760
- curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
761
- }
762
-
763
- if (count($headers)) {
764
- curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
765
- }
766
-
767
- curl_setopt($curl, CURLOPT_TIMEOUT, 4);
768
- curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 4);
769
-
770
- $raw_response = curl_exec($curl);
771
- $response->setRawResponse($raw_response);
772
-
773
- $response_data = curl_getinfo($curl);
774
- $response->addData($response_data);
775
-
776
- if (Mage::getStoreConfig('signifyd_connect/log/response')) {
777
- Mage::log("Response ($url):\n " . print_r($response, true), null, 'signifyd_connect.log');
778
- }
779
-
780
- if ($raw_response === false || curl_errno($curl)) {
781
- $error = curl_error($curl);
782
-
783
- if (Mage::getStoreConfig('signifyd_connect/log/error')) {
784
- Mage::log("ERROR ($url):\n$error", null, 'signifyd_connect.log');
785
- }
786
-
787
- $response->setData('error', $error);
788
- }
789
-
790
- curl_close($curl);
791
-
792
- return $response;
793
- }
794
- }
1
+ <?php
2
+
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
+ 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/request')) {
18
+ Mage::log($message, null, 'signifyd_connect.log');
19
+ }
20
+ }
21
+
22
+ public function logResponse($message)
23
+ {
24
+ if (Mage::getStoreConfig('signifyd_connect/log/response')) {
25
+ Mage::log($message, null, 'signifyd_connect.log');
26
+ }
27
+ }
28
+
29
+ public function logError($message)
30
+ {
31
+ if (Mage::getStoreConfig('signifyd_connect/log/error')) {
32
+ Mage::log($message, null, 'signifyd_connect.log');
33
+ }
34
+ }
35
+
36
+ public function getProducts($quote)
37
+ {
38
+ $products = array();
39
+
40
+ foreach ($quote->getAllItems() as $item) {
41
+ $product_type = $item->getProductType();
42
+
43
+ if (!$product_type || $product_type == 'simple' || $product_type == 'downloadable'
44
+ || $product_type == 'grouped' || $product_type == 'virtual' ) {
45
+ $product_object = $item->getData('product');
46
+
47
+ if (!$product_object || !$product_object->getId()) {
48
+ $product_object = Mage::getModel('catalog/product')->load($product_type);
49
+ }
50
+
51
+ if ($product_object) {
52
+ $product = array();
53
+
54
+ $product['itemId'] = $item->getSku();
55
+ $product['itemName'] = $item->getName();
56
+ $product['itemUrl'] = $this->getProductUrl($product_object);
57
+ $product['itemImage'] = $this->getProductImage($product_object);
58
+
59
+ $qty = 1;
60
+ if ($item->getQty()) {
61
+ $qty = $item->getQty();
62
+ } else if ($item->getQtyOrdered()) {
63
+ $qty = $item->getQtyOrdered();
64
+ }
65
+
66
+ $price = 0;
67
+ if ($item->getPrice() > 0) {
68
+ $price = $item->getPrice();
69
+ } else if ($item->getBasePrice() > 0) {
70
+ $price = $item->getBasePrice();
71
+ } else if ($product_object->getData('price') > 0) {
72
+ $price = $product_object->getData('price');
73
+ } else {
74
+ $parent = $item->getData('parent');
75
+
76
+ if (!$parent) {
77
+ $parent = $item->getParentItem();
78
+ }
79
+
80
+ if ($parent) {
81
+ if ($parent->getBasePrice() > 0) {
82
+ $price = $parent->getBasePrice();
83
+ } else if ($parent->getPrice()) {
84
+ $price = $parent->getPrice();
85
+ }
86
+ }
87
+ }
88
+
89
+ $weight = 0;
90
+ if ($item->hasWeight()) {
91
+ $weight = $item->getWeight();
92
+ } else if ($product_object->hasWeight()) {
93
+ $weight = $product_object->getWeight();
94
+ }
95
+
96
+ $product['itemQuantity'] = intval($qty);
97
+ $product['itemPrice'] = floatval($price);
98
+ $product['itemWeight'] = floatval($weight);
99
+
100
+ $products[] = $product;
101
+ }
102
+ }
103
+ }
104
+
105
+ return $products;
106
+ }
107
+
108
+ public function getIPAddress($order)
109
+ {
110
+ if ($order->getRemoteIp()) {
111
+ if ($order->getXForwardedFor()) {
112
+ return $this->filterIp($order->getXForwardedFor());
113
+ }
114
+
115
+ return $this->filterIp($order->getRemoteIp());
116
+ }
117
+
118
+ // Checks each configured value in app/etc/local.xml & falls back to REMOTE_ADDR. See app/etc/local.xml.additional for examples.
119
+ return $this->filterIp(Mage::helper('core/http')->getRemoteAddr(false));
120
+ }
121
+
122
+ public function filterIp($ip)
123
+ {
124
+ $matches = array();
125
+
126
+ if (preg_match('/[0-9]{1,3}(?:\.[0-9]{1,3}){3}/', $ip, $matches)) { //ipv4
127
+ return current($matches);
128
+ }
129
+
130
+ if (preg_match('/[a-f0-9]{0,4}(?:\:[a-f0-9]{0,4}){2,7}/', strtolower($ip), $matches)) { //ipv6
131
+ return current($matches);
132
+ }
133
+
134
+ return preg_replace('/[^0-9a-zA-Z:\.]/', '', strtok(str_replace($ip, ',', "\n"), "\n"));
135
+ }
136
+
137
+ public function formatAvs($value)
138
+ {
139
+ // http://www.emsecommerce.net/avs_cvv2_response_codes.htm
140
+ $codes = array('X', 'Y', 'A', 'W', 'Z', 'N', 'U', 'R', 'E', 'S', 'D', 'M', 'B', 'P', 'C', 'I', 'G');
141
+
142
+ if ($value) {
143
+ $value = strtoupper($value);
144
+
145
+ if (strlen($value) > 1) {
146
+ if (preg_match('/\([A-Z]\)/', $value)) {
147
+ $matches = array();
148
+
149
+ preg_match('/\([A-Z]\)/', $value, $matches);
150
+
151
+ foreach ($matches as $match) {
152
+ $match = preg_replace('/[^A-Z]/', '', $match);
153
+
154
+ if (in_array($match, $codes)) {
155
+ $value = $match;
156
+ }
157
+ }
158
+ }
159
+ }
160
+
161
+ if (strlen($value) > 1) {
162
+ $value = substr($value, 0, 1);
163
+ }
164
+
165
+ if (!in_array($value, $codes)) {
166
+ $value = null;
167
+ }
168
+ }
169
+
170
+ return $value;
171
+ }
172
+
173
+ public function getAvsResponse($payment)
174
+ {
175
+ $value = null;
176
+
177
+ if ($payment->getAdditionalInformation('paypal_avs_code')) {
178
+ $value = $payment->getAdditionalInformation('paypal_avs_code');
179
+ } else if ($payment->getAdditionalInformation('cc_avs_status')) {
180
+ $value = $payment->getAdditionalInformation('cc_avs_status');
181
+ }
182
+
183
+ return $this->formatAvs($value);
184
+ }
185
+
186
+ public function getCvvResponse($payment)
187
+ {
188
+ if ($payment->getAdditionalInformation('paypal_cvv2_match')) {
189
+ return $payment->getAdditionalInformation('paypal_cvv2_match');
190
+ }
191
+
192
+ return null;
193
+ }
194
+
195
+ private function getVersions()
196
+ {
197
+ $version = array();
198
+ $version['platform'] = 'magento';
199
+ $version['platformVersion'] = Mage::getVersion();
200
+ $version['pluginVersion'] = (string)(Mage::getConfig()->getNode()->modules->Signifyd_Connect->version);
201
+ return $version;
202
+ }
203
+
204
+ private function getTransactionId($payment)
205
+ {
206
+ $transId = $payment->getCcTransId();
207
+ if(is_array($transId) && is_string($transId[0])) {
208
+ $transId = $transId[0];
209
+ } else if(!is_string($transId)) {
210
+ $transId = null;
211
+ }
212
+ return $transId;
213
+ }
214
+
215
+ public function getPurchase($order)
216
+ {
217
+ $purchase = array();
218
+ $payment = $order->getPayment();
219
+
220
+ // T715: Send null rather than false when we can't get the IP Address
221
+ $purchase['browserIpAddress'] = ($this->getIpAddress($order) ? $this->getIpAddress($order) : null);
222
+ $purchase['orderId'] = $order->getIncrementId();
223
+ $purchase['createdAt'] = date('c', strtotime($order->getCreatedAt())); // e.g: 2004-02-12T15:19:21+00:00
224
+ $purchase['currency'] = $order->getOrderCurrencyCode();
225
+ $purchase['totalPrice'] = floatval($order->getGrandTotal());
226
+ $purchase['shippingPrice'] = floatval($order->getShippingAmount());
227
+ $purchase['products'] = $this->getProducts($order);
228
+ $purchase['paymentGateway'] = $payment->getMethod();
229
+ $purchase['transactionId'] = $this->getTransactionId($payment);
230
+
231
+ $purchase['avsResponseCode'] = $this->getAvsResponse($payment);
232
+ $purchase['cvvResponseCode'] = $this->getCvvResponse($payment);
233
+
234
+ return $purchase;
235
+ }
236
+
237
+ public function isPaymentCC($payment)
238
+ {
239
+ // Although the payment structure only has the entity data for the payment
240
+ // the original payment method object is stored within the entity data.
241
+ // It's not a requirement, but every CC handler I've found subclasses
242
+ // from Mage_Payment_Model_Method_Cc, so we are using that as an
243
+ // assumption for whether a method is based on CC data
244
+ $method = $payment->getData('method_instance');
245
+ if($method)
246
+ {
247
+ return is_subclass_of($method, 'Mage_Payment_Model_Method_Cc');
248
+ }
249
+ return false;
250
+ }
251
+
252
+ public function getCard($order, $payment)
253
+ {
254
+ $billing = $order->getBillingAddress();
255
+
256
+ $card = array();
257
+
258
+ $card['cardHolderName'] = null;
259
+ $card['bin'] = null;
260
+ $card['last4'] = null;
261
+ $card['expiryMonth'] = null;
262
+ $card['expiryYear'] = null;
263
+ $card['hash'] = null;
264
+
265
+ $card['billingAddress'] = $this->getSignifydAddress($billing);
266
+
267
+ if ($payment->getCcOwner()) {
268
+ $card['cardHolderName'] = $payment->getCcOwner();
269
+ } else {
270
+ $card['cardHolderName'] = $billing->getFirstname() . ' ' . $billing->getLastname();
271
+ }
272
+
273
+ // Card data may be set on payment even if payment was not with card.
274
+ // If it is, we want to ignore the data
275
+ if(!$this->isPaymentCC($payment)) return $card;
276
+
277
+ if ($payment->getData('cc_last4')) {
278
+ $card['last4'] = $payment->getData('cc_last4');
279
+ }
280
+
281
+ if ($payment->getData('cc_exp_year')) {
282
+ $card['expiryYear'] = $payment->getData('cc_exp_year');
283
+ }
284
+
285
+ if ($payment->getData('cc_exp_month')) {
286
+ $card['expiryMonth'] = $payment->getData('cc_exp_month');
287
+ }
288
+
289
+ if ($payment->getData('cc_number_enc')) {
290
+ $card['hash'] = $payment->getData('cc_number_enc');
291
+ }
292
+
293
+ if ($payment->getData('cc_number') && is_numeric($payment->getData('cc_number')) && strlen((string)$payment->getData('cc_number')) > 6) {
294
+ $card['bin'] = substr((string)$payment->getData('cc_number'), 0, 6);
295
+ }
296
+
297
+ return $card;
298
+ }
299
+
300
+ public function getSignifydAddress($address_object)
301
+ {
302
+ $address = array();
303
+
304
+ $address['streetAddress'] = $address_object->getStreet1();
305
+ $address['unit'] = null;
306
+
307
+ if ($address_object->getStreet2()) {
308
+ $address['unit'] = $address_object->getStreet2();
309
+ }
310
+
311
+ $address['city'] = $address_object->getCity();
312
+
313
+ $address['provinceCode'] = $address_object->getRegionCode();
314
+ $address['postalCode'] = $address_object->getPostcode();
315
+ $address['countryCode'] = $address_object->getCountryId();
316
+
317
+ $address['latitude'] = null;
318
+ $address['longitude'] = null;
319
+
320
+ return $address;
321
+ }
322
+
323
+ public function getRecipient($order)
324
+ {
325
+ $recipient = array();
326
+
327
+ // In the case of non-shipped (ex: downloadable) orders, shipping address will be null so
328
+ // in that case, we need to avoid the exception.
329
+ $shipping_address = $order->getShippingAddress();
330
+ if($shipping_address) {
331
+ $recipient['deliveryAddress'] = $this->getSignifydAddress($shipping_address);
332
+ $recipient['fullName'] = $shipping_address->getFirstname() . ' ' . $shipping_address->getLastname();
333
+ $recipient['confirmationPhone'] = $shipping_address->getTelephone();
334
+ // Email: Note that this field is always the same for both addresses
335
+ $recipient['confirmationEmail'] = $shipping_address->getEmail();
336
+ }
337
+ // Some customers have reported seeing "n/a@na.na" come through instead of a valid or null address
338
+ // We suspect that it is due to an older version of Magento. If it becomes unnecessary, do remove the extra check.
339
+ if (!$recipient['confirmationEmail'] || $recipient['confirmationEmail'] == 'n/a@na.na') {
340
+ $recipient['confirmationEmail'] = $order->getCustomerEmail();
341
+ }
342
+
343
+ return $recipient;
344
+ }
345
+
346
+ public function getUserAccount($customer, $order)
347
+ {
348
+ $user = array(
349
+ "emailAddress" => null,
350
+ "username" => null,
351
+ "phone" => null,
352
+ "createdDate" => null,
353
+ "accountNumber" => null,
354
+ "lastOrderId" => null,
355
+ "aggregateOrderCount" => null,
356
+ "aggregateOrderDollars" => null,
357
+ "lastUpdateDate" => null
358
+ );
359
+
360
+ if ($customer && $customer->getId()) {
361
+ $user['emailAddress'] = $customer->getEmail();
362
+
363
+ $user['phone'] = $order->getBillingAddress()->getTelephone();
364
+
365
+ $user['createdDate'] = date('c', strtotime($customer->getCreatedAt()));
366
+ $user['lastUpdateDate'] = date('c', strtotime($customer->getUpdatedAt()));
367
+
368
+ $user['accountNumber'] = $customer->getId();
369
+
370
+ $last_order_id = null;
371
+
372
+ $orders = Mage::getModel('sales/order')->getCollection()->addFieldToFilter('customer_id', $customer->getId());
373
+ $orders->getSelect()->order('created_at DESC');
374
+
375
+ $aggregate_total = 0.;
376
+ $order_count = 0;
377
+
378
+ foreach ($orders as $order) {
379
+ if ($last_order_id === null) {
380
+ $last_order_id = $order->getIncrementId();
381
+ }
382
+
383
+ $aggregate_total += floatval($order->getGrandTotal());
384
+ $order_count += 1;
385
+ }
386
+
387
+ $user['lastOrderId'] = $last_order_id;
388
+ $user['aggregateOrderCount'] = $order_count;
389
+ $user['aggregateOrderDollars'] = floatval($aggregate_total);
390
+ }
391
+
392
+ return $user;
393
+ }
394
+
395
+ public function generateCase($order, $payment, $customer)
396
+ {
397
+ $case = array();
398
+
399
+ $case['purchase'] = $this->getPurchase($order);
400
+ $case['recipient'] = $this->getRecipient($order);
401
+ $case['card'] = $this->getCard($order, $payment);
402
+ $case['userAccount'] = $this->getUserAccount($customer, $order);
403
+ $case['clientVersion'] = $this->getVersions();
404
+
405
+ return $case;
406
+ }
407
+
408
+ public function submitCase($case, $url, $auth)
409
+ {
410
+ $case = json_encode($case);
411
+
412
+ return $this->request($url, $case, $auth, 'application/json');
413
+ }
414
+
415
+ public function getUrl()
416
+ {
417
+ // return Mage::getStoreConfig('signifyd_connect/settings/url') . '/cases';
418
+ return 'https://api.signifyd.com/v2/cases/';
419
+ }
420
+
421
+ public function getAuth()
422
+ {
423
+ return Mage::getStoreConfig('signifyd_connect/settings/key');
424
+ }
425
+
426
+ public function sendOrderUpdateToSignifyd($order)
427
+ {
428
+ if ($order && $order->getId() && Mage::getStoreConfig('signifyd_connect/advanced/enable_payment_updates')) {
429
+ $case = Mage::getModel('signifyd_connect/case')->load($order->getIncrementId());
430
+ $caseId = $case->getCode();
431
+
432
+ if (Mage::getStoreConfig('signifyd_connect/log/request')) {
433
+ Mage::log("Created new case: $caseId", null, 'signifyd_connect.log');
434
+ }
435
+
436
+ $updateData = array();
437
+ $payment = $order->getPayment();
438
+
439
+ // These are the only supported update fields
440
+ $purchase = array();
441
+ $purchase['paymentGateway'] = $payment->getMethod();
442
+ $purchase['transactionId'] = $this->getTransactionId($payment);
443
+ $purchase['avsResponseCode'] = $this->getAvsResponse($payment);
444
+ $purchase['cvvResponseCode'] = $this->getCvvResponse($payment);
445
+
446
+ // Do not make request if there is no data to send
447
+ if( $purchase['transactionId'] == null &&
448
+ $purchase['avsResponseCode'] == null &&
449
+ $purchase['cvvResponseCode'] == null)
450
+ {
451
+ return "nodata";
452
+ }
453
+ Mage::register('signifyd_action', 1); // Work will now take place
454
+
455
+ $updateData['purchase'] = $purchase;
456
+
457
+ $data = json_encode($updateData);
458
+
459
+ $response = $this->request($this->getUrl() . "/$caseId", $data, $this->getAuth(), 'application/json', null, true);
460
+
461
+ try {
462
+ $response_code = $response->getHttpCode();
463
+
464
+ if (substr($response_code, 0, 1) == '2') {
465
+ // Reload in case a substantial amount of time has passed
466
+ $case = Mage::getModel('signifyd_connect/case')->load($order->getIncrementId());
467
+ $case->setUpdated(strftime('%Y-%m-%d %H:%M:%S', time()));
468
+ $case->setTransactionId($updateData['purchase']['transactionId']);
469
+ $case->save();
470
+ if (Mage::getStoreConfig('signifyd_connect/log/request')) {
471
+ Mage::log("Wrote case to database: $caseId", null, 'signifyd_connect.log');
472
+ }
473
+ return "sent";
474
+ }
475
+ } catch (Exception $e) {
476
+ Mage::log($e->__toString(), null, 'signifyd_connect.log');
477
+ return "error";
478
+ }
479
+ }
480
+ }
481
+
482
+ public function buildAndSendOrderToSignifyd($order, $forceSend = false)
483
+ {
484
+ if ($order && $order->getId()) {
485
+ $processStatus = $this->processedStatus($order);
486
+ if ($processStatus > 0 && !$forceSend) {
487
+ if($processStatus == self::TRANSACTION_SENT_STATUS) return "exists";
488
+ else return $this->sendOrderUpdateToSignifyd($order);
489
+ }
490
+
491
+ $payments = $order->getPaymentsCollection();
492
+ $last_payment = null;
493
+ foreach ($payments as $payment) {
494
+ $last_payment = $payment;
495
+ }
496
+
497
+ $state = $order->getState();
498
+
499
+ if (!$state || $state == Mage_Sales_Model_Order::STATE_PENDING_PAYMENT) {
500
+ return "notready"; // Note: would not be in the order grid if this were the case
501
+ }
502
+
503
+ if(is_null(Mage::registry('signifyd_action'))) {
504
+ Mage::register('signifyd_action', 1); // Work will now take place
505
+ }
506
+
507
+ $customer = null;
508
+ if ($order->getCustomer()) {
509
+ $customer = $order->getCustomer();
510
+ }
511
+
512
+ $case = $this->generateCase($order, $last_payment, $customer);
513
+
514
+ $case_object = $this->markProcessed($order);
515
+
516
+ $response = $this->submitCase($case, $this->getUrl(), $this->getAuth());
517
+
518
+ try {
519
+ $response_code = $response->getHttpCode();
520
+
521
+ if (substr($response_code, 0, 1) == '2') {
522
+ $response_data = json_decode($response->getRawResponse(), true);
523
+
524
+ $caseId = $response_data['investigationId'];
525
+ $case_object = Mage::getModel('signifyd_connect/case')->load($case_object->getOrderIncrement());
526
+ $case_object->setUpdated(strftime('%Y-%m-%d %H:%M:%S', time()));
527
+ $case_object->setCode($caseId);
528
+ $case_object->setTransactionId($case['purchase']['transactionId']);
529
+ $case_object->setMagentoStatus(self::IN_REVIEW_STATUS);
530
+ $case_object->save();
531
+
532
+ $order->addStatusHistoryComment("Signifyd: case $caseId created for order");
533
+ $order->save(); // Note: this will trigger recursion
534
+
535
+ return "sent";
536
+ }
537
+ } catch (Exception $e) {
538
+ Mage::log($e->__toString(), null, 'signifyd_connect.log');
539
+ }
540
+ //$this->unmarkProcessed($order);
541
+ return "error";
542
+ }
543
+ }
544
+
545
+ public function getProductUrl($product)
546
+ {
547
+ $url = null;
548
+
549
+ try {
550
+ $url = $product->getUrlModel()->getProductUrl($product);
551
+ } catch (Exception $e) {
552
+ $url = null;
553
+ }
554
+
555
+ return $url;
556
+ }
557
+
558
+ public function getCaseUrl($order_id)
559
+ {
560
+ $case = Mage::getModel('signifyd_connect/case')->load($order_id);
561
+
562
+ if ($case->getCode()) {
563
+ return "https://www.signifyd.com/cases/" . $case->getCode();
564
+ }
565
+ Mage::log('Case URL not found: '.$order_id, null, 'signifyd_connect.log');
566
+ return '';
567
+ }
568
+
569
+ public function getProductImage($product, $size="150")
570
+ {
571
+ $image = null;
572
+
573
+ try {
574
+ $image = (string)Mage::helper('catalog/image')->init($product, 'image')->resize($size, $size)->keepFrame(true)->keepAspectRatio(true);
575
+ } catch (Exception $e) {
576
+ $image = null;
577
+ }
578
+
579
+ return $image;
580
+ }
581
+
582
+ public function getStoreName()
583
+ {
584
+ return Mage::getStoreConfig('trans_email/ident_general/name', 0);
585
+ }
586
+
587
+ public function getStoreEmail()
588
+ {
589
+ return Mage::getStoreConfig('trans_email/ident_general/email', 0);
590
+ }
591
+
592
+ public function getStoreUrl()
593
+ {
594
+ return Mage::getBaseUrl();
595
+ }
596
+
597
+ public function processedStatus($order)
598
+ {
599
+ $case = Mage::getModel('signifyd_connect/case')->load($order->getIncrementId());
600
+
601
+ if ($case->getTransactionId())
602
+ {
603
+ return self::TRANSACTION_SENT_STATUS;
604
+ }
605
+ else if ($case->getCode())
606
+ {
607
+ return self::CASE_CREATED_STATUS;
608
+ }
609
+ else if ($case->getId())
610
+ {
611
+ return self::ENTITY_CREATED_STATUS;
612
+ }
613
+
614
+ return self::UNPROCESSED_STATUS;
615
+ }
616
+
617
+ public function markProcessed($order)
618
+ {
619
+ $case = Mage::getModel('signifyd_connect/case');
620
+ $case->setOrderIncrement($order->getIncrementId());
621
+ $case->setCreated(strftime('%Y-%m-%d %H:%M:%S', time()));
622
+ $case->setUpdated(strftime('%Y-%m-%d %H:%M:%S', time()));
623
+ $case->save();
624
+
625
+ return $case;
626
+ }
627
+
628
+ public function unmarkProcessed($order)
629
+ {
630
+ $case = Mage::getModel('signifyd_connect/case')->load($order->getIncrementId());
631
+ if($case && !$case->isObjectNew())
632
+ {
633
+ Mage::register('isSecureArea', true);
634
+ $case->delete();
635
+ Mage::unregister('isSecureArea');
636
+ }
637
+ }
638
+
639
+ public function cancelGuarantee($case)
640
+ {
641
+ $caseId = $case->getCode();
642
+ $url = $this->getUrl() . "/$caseId/guarantee";
643
+ $body = json_encode(array("guaranteeDisposition" => "CANCELED"));
644
+ $response = $this->request($url, $body, $this->getAuth(), 'application/json', null, true);
645
+ $code = $response->getHttpCode();
646
+ if(substr($code, 0, 1) == '2') {
647
+ $case->setGuarantee('CANCELED');
648
+ $case->save();
649
+ } else {
650
+ $this->logError("Guarantee cancel failed");
651
+ }
652
+ $this->logResponse("Received $code from guarantee cancel");
653
+ }
654
+
655
+ public function request($url, $data = null, $auth = null, $contenttype = "application/x-www-form-urlencoded",
656
+ $accept = null, $is_update = false)
657
+ {
658
+ if (Mage::getStoreConfig('signifyd_connect/log/request')) {
659
+ $authMask = preg_replace ( "/\S/", "*", $auth, strlen($auth) - 4 );
660
+ Mage::log("Request:\nURL: $url \nAuth: $authMask\nData: $data", null, 'signifyd_connect.log');
661
+ }
662
+
663
+ $curl = curl_init();
664
+ $response = new Varien_Object;
665
+ $headers = array();
666
+
667
+ curl_setopt($curl, CURLOPT_URL, $url);
668
+
669
+ if (stripos($url, 'https://') === 0) {
670
+ curl_setopt($curl, CURLOPT_PORT, 443);
671
+ curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
672
+ }
673
+
674
+ curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
675
+
676
+ if ($auth) {
677
+ curl_setopt($curl, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
678
+ curl_setopt($curl, CURLOPT_USERPWD, $auth);
679
+ }
680
+
681
+ if ($accept) {
682
+ $headers[] = 'Accept: ' . $accept;
683
+ }
684
+
685
+ if ($data) {
686
+ if($is_update) curl_setopt($curl, CURLOPT_CUSTOMREQUEST, "PUT");
687
+ else curl_setopt($curl, CURLOPT_POST, 1);
688
+
689
+ $headers[] = "Content-Type: $contenttype";
690
+ $headers[] = "Content-length: " . strlen($data);
691
+ curl_setopt($curl, CURLOPT_POSTFIELDS, $data);
692
+ }
693
+
694
+ if (count($headers)) {
695
+ curl_setopt($curl, CURLOPT_HTTPHEADER, $headers);
696
+ }
697
+
698
+ curl_setopt($curl, CURLOPT_TIMEOUT, 4);
699
+ curl_setopt($curl, CURLOPT_CONNECTTIMEOUT, 4);
700
+
701
+ $raw_response = curl_exec($curl);
702
+ $response->setRawResponse($raw_response);
703
+
704
+ $response_data = curl_getinfo($curl);
705
+ $response->addData($response_data);
706
+
707
+ if (Mage::getStoreConfig('signifyd_connect/log/response')) {
708
+ Mage::log("Response ($url):\n " . print_r($response, true), null, 'signifyd_connect.log');
709
+ }
710
+
711
+ if ($raw_response === false || curl_errno($curl)) {
712
+ $error = curl_error($curl);
713
+
714
+ if (Mage::getStoreConfig('signifyd_connect/log/error')) {
715
+ Mage::log("ERROR ($url):\n$error", null, 'signifyd_connect.log');
716
+ }
717
+
718
+ $response->setData('error', $error);
719
+ }
720
+
721
+ curl_close($curl);
722
+
723
+ return $response;
724
+ }
725
+
726
+ /**
727
+ * Get the order payment status
728
+ * @param $order
729
+ * @return array
730
+ */
731
+ public function getOrderPaymentStatus($order)
732
+ {
733
+ $status = array('authorize' => false, 'capture' => false, 'credit_memo' => false);
734
+ $logger = Mage::helper('signifyd_connect/log');
735
+ $paymentMethod = $order->getPayment();
736
+ $paymentAuthorized = $paymentMethod->getBaseAmountAuthorized();
737
+ $baseTotalPaid = $order->getBaseTotalPaid();
738
+ $baseTotalRefunded = $order->getBaseTotalRefunded();
739
+ // Maybe used in the future
740
+ // $canVoid = $paymentMethod->canVoid($order);
741
+ // $amountPayed = $paymentMethod->getAmountPaid();
742
+ // $baseTotalCanceled = $order->getBaseTotalCanceled();
743
+ // $baseTotalInvoiced = $order->getBaseTotalInvoiced();
744
+
745
+ // Check authorization
746
+ if(!empty($paymentAuthorized)){
747
+ $status['authorize'] = true;
748
+ }
749
+
750
+ // Special case for Paypal payment type "order"
751
+ if($this->isPaypalOrder($paymentMethod)){
752
+ $paymentAdditional = $paymentMethod->getData('additional_information');
753
+ if(isset($paymentAdditional['is_order_action']) && $paymentAdditional['is_order_action']){
754
+ $status['authorize'] = true;
755
+ }
756
+ }
757
+
758
+ // Check capture
759
+ if(!empty($baseTotalPaid)){
760
+ $status['capture'] = true;
761
+ }
762
+
763
+ // Check credit memo
764
+ if(!empty($baseTotalRefunded)){
765
+ $status['credit_memo'] = true;
766
+ }
767
+
768
+ // Log status
769
+ $logger->addLog("Order: {$order->getIncrementId()} has a status of " . json_encode($status));
770
+
771
+ return $status;
772
+ }
773
+
774
+ /**
775
+ * Checking if the payment method si paypal_express
776
+ * @param $paymentMethod
777
+ * @return bool
778
+ */
779
+ public function isPaypalOrder($paymentMethod)
780
+ {
781
+ $code = $paymentMethod->getMethodInstance()->getCode();
782
+ return (stripos($code, 'paypal_express') !== false)? true : false;
783
+ }
784
+
785
+ public function isGuarantyDeclined($order)
786
+ {
787
+ $case = Mage::getModel('signifyd_connect/case')->load($order->getIncrementId());
788
+ return ($case->getGuarantee() == 'DECLINED')? true : false;
789
+ }
790
+ }
 
 
 
 
app/code/community/Signifyd/Connect/Helper/Log.php ADDED
@@ -0,0 +1,25 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Log Helper
4
+ *
5
+ * @category Signifyd Connect
6
+ * @package Signifyd_Connect
7
+ * @author Signifyd
8
+ */
9
+ class Signifyd_Connect_Helper_Log extends Mage_Core_Helper_Abstract
10
+ {
11
+ protected $logFile;
12
+
13
+ public function __construct()
14
+ {
15
+ $this->logFile = 'signifyd_connect.log';
16
+ }
17
+
18
+ public function addLog($msg)
19
+ {
20
+ return Mage::log($msg, null, $this->logFile);
21
+ }
22
+ }
23
+
24
+ /* Filename: Log.php */
25
+ /* Location: ../app/code/Community/Signifyd/Connect/Helper/Log.php */
app/code/community/Signifyd/Connect/Model/Authnet.php CHANGED
@@ -1,17 +1,17 @@
1
- <?php
2
-
3
- class Signifyd_Connect_Model_Authnet extends Mage_Paygate_Model_Authorizenet
4
- {
5
- protected function _registercard(varien_object $response, mage_sales_model_order_payment $payment)
6
- {
7
- Mage::log(">: ".$response->getTransactionId(), null, 'signifyd_connect.log');
8
- $card = parent::_registercard($response,$payment);
9
- $card->setCcAvsResultCode($response->getAvsResultCode());
10
- $card->setCcResponseCode($response->getCardCodeResponseCode());
11
- $payment->setCcAvsStatus($response->getAvsResultCode());
12
- $payment->setCcCidStatus($response->getCardCodeResponseCode());
13
- $payment->setCcTransId($response->getTransactionId());
14
- $payment->getCcTransId();
15
- return $card;
16
- }
17
- }
1
+ <?php
2
+
3
+ class Signifyd_Connect_Model_Authnet extends Mage_Paygate_Model_Authorizenet
4
+ {
5
+ protected function _registercard(varien_object $response, mage_sales_model_order_payment $payment)
6
+ {
7
+ Mage::log(">: ".$response->getTransactionId(), null, 'signifyd_connect.log');
8
+ $card = parent::_registercard($response,$payment);
9
+ $card->setCcAvsResultCode($response->getAvsResultCode());
10
+ $card->setCcResponseCode($response->getCardCodeResponseCode());
11
+ $payment->setCcAvsStatus($response->getAvsResultCode());
12
+ $payment->setCcCidStatus($response->getCardCodeResponseCode());
13
+ $payment->setCcTransId($response->getTransactionId());
14
+ $payment->getCcTransId();
15
+ return $card;
16
+ }
17
+ }
app/code/community/Signifyd/Connect/Model/Case.php CHANGED
@@ -1,10 +1,29 @@
1
- <?php
2
-
3
- class Signifyd_Connect_Model_Case extends Mage_Core_Model_Abstract
4
- {
5
- protected function _construct()
6
- {
7
- $this->_init('signifyd_connect/case');
8
- $this->_isPkAutoIncrement = false;
9
- }
10
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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)
15
+ {
16
+ $id = (is_array($case))? $case['order_increment'] : $case->getId();
17
+ $caseLoaded = Mage::getModel('signifyd_connect/case')->load($id);
18
+ try {
19
+ $caseLoaded->setMagentoStatus($status);
20
+ $caseLoaded->save();
21
+ $this->logger->addLog("Signifyd: Case no:{$caseLoaded->getId()} status set to {$status}");
22
+ } catch (Exception $e){
23
+ $this->logger->addLog("Signifyd: Error setting case no:{$caseLoaded->getId()} status to {$status}");
24
+ return false;
25
+ }
26
+
27
+ return true;
28
+ }
29
+ }
app/code/community/Signifyd/Connect/Model/Cron.php CHANGED
@@ -1,9 +1,136 @@
1
- <?php
2
-
3
- class Signifyd_Connect_Model_Cron
4
- {
5
- public function update()
6
- {
7
- return; // Deprecated
8
- }
9
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Cron Model
4
+ *
5
+ * @category Signifyd Connect
6
+ * @package Signifyd_Connect
7
+ * @author Signifyd
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
+ /**
31
+ * Method to reprocessing the cases than did not fully complete
32
+ */
33
+ public function retry()
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'];
41
+ $current_order = Mage::getModel('sales/order')->loadByIncrementId($current_order_id);
42
+ Mage::helper('signifyd_connect')->buildAndSendOrderToSignifyd($current_order,true);
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");
65
+ return;
66
+ }
67
+
68
+ /**
69
+ * Getting the retry cases by the status of the case
70
+ * @param $status
71
+ * @return mixed
72
+ */
73
+ public function getRetryCasesByStatus($status)
74
+ {
75
+
76
+ $time = time();
77
+ $lastTime = $time - 60*60*24*7; // not longer than 7 days
78
+ $firstTime = $time - 60*30; // longer than last 30 minuted
79
+ $from = date('Y-m-d H:i:s', $lastTime);
80
+ $to = date('Y-m-d H:i:s', $firstTime);
81
+
82
+ $cases = Mage::getModel('signifyd_connect/case')->getCollection()
83
+ ->addFieldToFilter('updated', array('from' => $from, 'to' => $to))
84
+ ->addFieldToFilter('magento_status', $status);
85
+
86
+ return $cases->getData();
87
+
88
+ }
89
+
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 */
136
+ /* Location: ../app/code/Community/Signifyd/Connect/Model/Cron.php */
app/code/community/Signifyd/Connect/Model/Link.php CHANGED
@@ -1,9 +1,9 @@
1
- <?php
2
-
3
- class Signifyd_Connect_Model_Link
4
- {
5
- public function getCommentText()
6
- {
7
- return "Turn this on if you would like to receive Signifyd scores. Visit this url to confirm the callback functionality is working: <a href=\"" . Mage::getUrl('signifyd/connect/api') . "\" target=\"_blank\">" . Mage::getUrl('signifyd/connect/api') . "</a>";
8
- }
9
- }
1
+ <?php
2
+
3
+ class Signifyd_Connect_Model_Link
4
+ {
5
+ public function getCommentText()
6
+ {
7
+ return "<a href=\"" . Mage::getUrl('signifyd/connect/api') . "\" target=\"_blank\">" . Mage::getUrl('signifyd/connect/api') . "</a>";
8
+ }
9
+ }
app/code/community/Signifyd/Connect/Model/Observer.php CHANGED
@@ -1,316 +1,299 @@
1
- <?php
2
-
3
- class Signifyd_Connect_Model_Observer extends Varien_Object
4
- {
5
- public $joins = 0;
6
-
7
- public function openCase($observer)
8
- {
9
- try {
10
- if (!Mage::getStoreConfig('signifyd_connect/settings/enabled') && !$this->getEnabled()) {
11
- return;
12
- }
13
-
14
- $event = $observer->getEvent();
15
-
16
- if ($event->hasOrder()) {
17
- $order = $event->getOrder();
18
- } else if ($event->hasObject()) {
19
- $order = $event->getObject();
20
- }
21
-
22
- $order_model = get_class(Mage::getModel('sales/order'));
23
-
24
- if (!($order instanceof $order_model)) {
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)
53
- {
54
- // Used to capture data for testing with
55
-
56
- $order_data = json_encode($order->getData());
57
- $billing_data = json_encode($order->getBillingAddress()->getData());
58
- $shipping_data = json_encode($order->getShippingAddress()->getData());
59
- $customer_data = json_encode($order->getCustomer()->getData());
60
- $payment_data = json_encode($payment->getData());
61
- $quote_data = json_encode($quote->getData());
62
- $items = array();
63
- $products = array();
64
-
65
- foreach ($quote->getAllItems() as $item) {
66
- $items[$item->getId()] = $item->getData();
67
- $product = Mage::getModel('catalog/product')->load($item->getProductId());
68
- $products[$item->getId()] = $product->getData();
69
- }
70
-
71
- $items = json_encode($items);
72
- $products = json_encode($products);
73
-
74
- Mage::log("Order:\n $order_data", null, 'signifyd_connect_objects.log');
75
- Mage::log("Billing:\n $billing_data", null, 'signifyd_connect_objects.log');
76
- Mage::log("Shipping:\n $shipping_data", null, 'signifyd_connect_objects.log');
77
- Mage::log("Customer:\n $customer_data", null, 'signifyd_connect_objects.log');
78
- Mage::log("Payment:\n $payment_data", null, 'signifyd_connect_objects.log');
79
- Mage::log("Quote:\n $quote_data", null, 'signifyd_connect_objects.log');
80
- Mage::log("Items:\n $items", null, 'signifyd_connect_objects.log');
81
- Mage::log("Products:\n $products", null, 'signifyd_connect_objects.log');
82
- }
83
-
84
- public function getAdminRoute()
85
- {
86
- $route = false;
87
-
88
- try {
89
- // 1.4.0.0 support means we need to hard code these paths
90
- if ((bool)(string)Mage::getConfig()->getNode('default/admin/url/use_custom_path')) {
91
- $route = Mage::getConfig()->getNode('default/admin/url/custom_path');
92
- } else {
93
- $route = Mage::getConfig()->getNode('admin/routers/adminhtml/args/frontName');
94
- }
95
- } catch (Exception $e) {
96
-
97
- }
98
-
99
- if (!$route) {
100
- $route = 'admin';
101
- }
102
-
103
- return $route;
104
- }
105
-
106
- public function eavCollectionAbstractLoadBefore($observer)
107
- {
108
- $x = $observer->getCollection();
109
-
110
- $request = Mage::app()->getRequest();
111
- $module = $request->getModuleName();
112
- $controller = $request->getControllerName();
113
-
114
- if ($module != $this->getAdminRoute() || $controller != 'sales_order') {
115
- return;
116
- }
117
-
118
- $clss = get_class($x);
119
- if ($clss == 'Mage_Sales_Model_Mysql4_Order_Collection' || $clss == 'Mage_Sales_Model_Mysql4_Order_Grid_Collection') {
120
- $observer->setOrderGridCollection($x);
121
- return $this->salesOrderGridCollectionLoadBefore($observer);
122
- }
123
- }
124
-
125
- public function coreCollectionAbstractLoadBefore($observer)
126
- {
127
- $x = $observer->getCollection();
128
-
129
- $request = Mage::app()->getRequest();
130
- $module = $request->getModuleName();
131
- $controller = $request->getControllerName();
132
-
133
- if ($module != $this->getAdminRoute() || $controller != 'sales_order') {
134
- return;
135
- }
136
-
137
- $clss = get_class($x);
138
-
139
- if ($clss == 'Mage_Sales_Model_Mysql4_Order_Collection' || $clss == 'Mage_Sales_Model_Mysql4_Order_Grid_Collection') {
140
- $observer->setOrderGridCollection($x);
141
- return $this->salesOrderGridCollectionLoadBefore($observer);
142
- }
143
- }
144
-
145
- public function isCe()
146
- {
147
- return !@class_exists('Enterprise_Cms_Helper_Data');
148
- }
149
-
150
- public function oldSupport()
151
- {
152
- $version = Mage::getVersion();
153
-
154
- if ($this->isCe()) {
155
- return version_compare($version, '1.4.1.0', '<');
156
- } else {
157
- return version_compare($version, '1.10.0.0', '<');
158
- }
159
-
160
- return false;
161
- }
162
-
163
- public function belowSix()
164
- {
165
- $version = Mage::getVersion();
166
-
167
- if ($this->isCe()) {
168
- return version_compare($version, '1.6.0.0', '<');
169
- } else {
170
- return version_compare($version, '1.11.0.0', '<');
171
- }
172
-
173
- return false;
174
- }
175
-
176
- public function salesOrderGridCollectionLoadBefore($observer)
177
- {
178
- $request = Mage::app()->getRequest();
179
- $module = $request->getModuleName();
180
- $controller = $request->getControllerName();
181
-
182
- if ($module != $this->getAdminRoute() || $controller != 'sales_order') {
183
- return;
184
- }
185
-
186
- $collection = $observer->getOrderGridCollection();
187
- $select = $collection->getSelect();
188
-
189
- // This will prevent us from rejoining.
190
- if(strchr($select, 'signifyd')) {
191
- return;
192
- }
193
-
194
- $show_scores = Mage::getStoreConfig('signifyd_connect/advanced/show_scores');
195
- $show_guarantee = Mage::getStoreConfig('signifyd_connect/advanced/show_guarantee');
196
- if ($show_scores || $show_guarantee) {
197
- if ($this->oldSupport()) {
198
- $select->joinLeft(array('signifyd'=>$collection->getTable('signifyd_connect/case')), 'signifyd.order_increment=e.increment_id', array('score'=>'score'));
199
- $this->joins++;
200
- } else {
201
- $select->joinLeft(array('signifyd'=>$collection->getTable('signifyd_connect/case')), 'signifyd.order_increment=main_table.increment_id', array('score'=>'score',
202
- 'guarantee' => 'guarantee'));
203
- $this->joins++;
204
- }
205
- }
206
- }
207
-
208
- public function coreBlockAbstractPrepareLayoutBefore(Varien_Event_Observer $observer)
209
- {
210
- if (!Mage::getStoreConfig('signifyd_connect/settings/enabled') && !$this->getEnabled()) {
211
- return;
212
- }
213
-
214
- $block = $observer->getEvent()->getBlock();
215
- if((get_class($block) =='Mage_Adminhtml_Block_Widget_Grid_Massaction'
216
- || get_class($block) == 'Enterprise_SalesArchive_Block_Adminhtml_Sales_Order_Grid_Massaction')
217
- && $block->getRequest()->getControllerName() == 'sales_order')
218
- {
219
- $url = Mage::helper("adminhtml")->getUrl('signifyd_connect/adminhtml_signifyd/send');
220
- if(Mage::getStoreConfig('signifyd_connect/advanced/use_unsecure_requests')){
221
- $url = Mage::getUrl('signifyd/connect/send');
222
- }
223
- $block->setFormFieldName('increment_id');
224
- $block->addItem('signifyd_connect', array(
225
- 'label' => 'Send order(s) to Signifyd',
226
- 'url' => $url,
227
- ));
228
- }
229
- }
230
-
231
- public function coreBlockAbstractToHtmlBefore(Varien_Event_Observer $observer)
232
- {
233
- $show_scores = Mage::getStoreConfig('signifyd_connect/advanced/show_scores');
234
- $show_guarantee = Mage::getStoreConfig('signifyd_connect/advanced/show_guarantee');
235
- if ($show_scores || $show_guarantee) {
236
- $request = Mage::app()->getRequest();
237
- $module = $request->getModuleName();
238
- $controller = $request->getControllerName();
239
-
240
- if ($module != $this->getAdminRoute() || $controller != 'sales_order') {
241
- return;
242
- }
243
-
244
- $helper = Mage::helper('signifyd_connect');
245
- $block = $observer->getEvent()->getBlock();
246
-
247
- if ($block->getId() == 'sales_order_grid') {
248
- if($show_scores) {
249
- $block->addColumnAfter(
250
- 'score',
251
- array(
252
- 'header' => $helper->__('Signifyd Score'),
253
- 'align' => 'left',
254
- 'type' => 'text',
255
- 'index' => 'score',
256
- 'filter' => false,
257
- 'renderer' => 'signifyd_connect/renderer',
258
- 'width' => '100px',
259
- ),
260
- 'status'
261
- );
262
- }
263
- if($show_guarantee) {
264
- $block->addColumnAfter(
265
- 'guarantee',
266
- array(
267
- 'header' => $helper->__('Guarantee Status'),
268
- 'align' => 'left',
269
- 'type' => 'text',
270
- 'index' => 'guarantee',
271
- 'filter' => false,
272
- 'renderer' => 'signifyd_connect/renderer',
273
- 'width' => '100px',
274
- ),
275
- 'status'
276
- );
277
- }
278
- $block->sortColumnsByOrder();
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' || $case->getGuarantee() == 'DECLINED') {
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
- }
1
+ <?php
2
+
3
+ class Signifyd_Connect_Model_Observer extends Varien_Object
4
+ {
5
+ public $joins = 0;
6
+ protected $helper;
7
+
8
+ public function _construct()
9
+ {
10
+ $this->helper = Mage::helper('signifyd_connect');
11
+ }
12
+
13
+
14
+ public function openCase($observer)
15
+ {
16
+ try {
17
+ if (!Mage::getStoreConfig('signifyd_connect/settings/enabled') && !$this->getEnabled()) {
18
+ return;
19
+ }
20
+ if(Mage::registry('signifyd_action') == 1)
21
+ {
22
+ return;
23
+ }
24
+
25
+ $event = $observer->getEvent();
26
+
27
+ if ($event->hasOrder()) {
28
+ $order = $event->getOrder();
29
+ } else if ($event->hasObject()) {
30
+ $order = $event->getObject();
31
+ }
32
+
33
+ $order_model = get_class(Mage::getModel('sales/order'));
34
+
35
+ if (!($order instanceof $order_model)) {
36
+ return;
37
+ }
38
+
39
+ Mage::helper('signifyd_connect')->buildAndSendOrderToSignifyd($order);
40
+ } catch (Exception $e) {
41
+ Mage::log($e->__toString(), null, 'signifyd_connect.log');
42
+ }
43
+ // If we get here, then we have failed to create the case.
44
+
45
+ }
46
+
47
+ public function logData($order, $payment, $quote)
48
+ {
49
+ // Used to capture data for testing with
50
+
51
+ $order_data = json_encode($order->getData());
52
+ $billing_data = json_encode($order->getBillingAddress()->getData());
53
+ $shipping_data = json_encode($order->getShippingAddress()->getData());
54
+ $customer_data = json_encode($order->getCustomer()->getData());
55
+ $payment_data = json_encode($payment->getData());
56
+ $quote_data = json_encode($quote->getData());
57
+ $items = array();
58
+ $products = array();
59
+
60
+ foreach ($quote->getAllItems() as $item) {
61
+ $items[$item->getId()] = $item->getData();
62
+ $product = Mage::getModel('catalog/product')->load($item->getProductId());
63
+ $products[$item->getId()] = $product->getData();
64
+ }
65
+
66
+ $items = json_encode($items);
67
+ $products = json_encode($products);
68
+
69
+ Mage::log("Order:\n $order_data", null, 'signifyd_connect_objects.log');
70
+ Mage::log("Billing:\n $billing_data", null, 'signifyd_connect_objects.log');
71
+ Mage::log("Shipping:\n $shipping_data", null, 'signifyd_connect_objects.log');
72
+ Mage::log("Customer:\n $customer_data", null, 'signifyd_connect_objects.log');
73
+ Mage::log("Payment:\n $payment_data", null, 'signifyd_connect_objects.log');
74
+ Mage::log("Quote:\n $quote_data", null, 'signifyd_connect_objects.log');
75
+ Mage::log("Items:\n $items", null, 'signifyd_connect_objects.log');
76
+ Mage::log("Products:\n $products", null, 'signifyd_connect_objects.log');
77
+ }
78
+
79
+ public function getAdminRoute()
80
+ {
81
+ $route = false;
82
+
83
+ try {
84
+ // 1.4.0.0 support means we need to hard code these paths
85
+ if ((bool)(string)Mage::getConfig()->getNode('default/admin/url/use_custom_path')) {
86
+ $route = Mage::getConfig()->getNode('default/admin/url/custom_path');
87
+ } else {
88
+ $route = Mage::getConfig()->getNode('admin/routers/adminhtml/args/frontName');
89
+ }
90
+ } catch (Exception $e) {
91
+
92
+ }
93
+
94
+ if (!$route) {
95
+ $route = 'admin';
96
+ }
97
+
98
+ return $route;
99
+ }
100
+
101
+ public function eavCollectionAbstractLoadBefore($observer)
102
+ {
103
+ $x = $observer->getCollection();
104
+
105
+ $request = Mage::app()->getRequest();
106
+ $module = $request->getModuleName();
107
+ $controller = $request->getControllerName();
108
+
109
+ if ($module != $this->getAdminRoute() || $controller != 'sales_order') {
110
+ return;
111
+ }
112
+
113
+ $clss = get_class($x);
114
+ if ($clss == 'Mage_Sales_Model_Mysql4_Order_Collection' || $clss == 'Mage_Sales_Model_Mysql4_Order_Grid_Collection') {
115
+ $observer->setOrderGridCollection($x);
116
+ return $this->salesOrderGridCollectionLoadBefore($observer);
117
+ }
118
+ }
119
+
120
+ public function coreCollectionAbstractLoadBefore($observer)
121
+ {
122
+ $x = $observer->getCollection();
123
+
124
+ $request = Mage::app()->getRequest();
125
+ $module = $request->getModuleName();
126
+ $controller = $request->getControllerName();
127
+
128
+ if ($module != $this->getAdminRoute() || $controller != 'sales_order') {
129
+ return;
130
+ }
131
+
132
+ $clss = get_class($x);
133
+
134
+ if ($clss == 'Mage_Sales_Model_Mysql4_Order_Collection' || $clss == 'Mage_Sales_Model_Mysql4_Order_Grid_Collection') {
135
+ $observer->setOrderGridCollection($x);
136
+ return $this->salesOrderGridCollectionLoadBefore($observer);
137
+ }
138
+ }
139
+
140
+ public function isCe()
141
+ {
142
+ return !@class_exists('Enterprise_Cms_Helper_Data');
143
+ }
144
+
145
+ public function oldSupport()
146
+ {
147
+ $version = Mage::getVersion();
148
+
149
+ if ($this->isCe()) {
150
+ return version_compare($version, '1.4.1.0', '<');
151
+ } else {
152
+ return version_compare($version, '1.10.0.0', '<');
153
+ }
154
+
155
+ return false;
156
+ }
157
+
158
+ public function belowSix()
159
+ {
160
+ $version = Mage::getVersion();
161
+
162
+ if ($this->isCe()) {
163
+ return version_compare($version, '1.6.0.0', '<');
164
+ } else {
165
+ return version_compare($version, '1.11.0.0', '<');
166
+ }
167
+
168
+ return false;
169
+ }
170
+
171
+ public function salesOrderGridCollectionLoadBefore($observer)
172
+ {
173
+ $request = Mage::app()->getRequest();
174
+ $module = $request->getModuleName();
175
+ $controller = $request->getControllerName();
176
+
177
+ if ($module != $this->getAdminRoute() || $controller != 'sales_order') {
178
+ return;
179
+ }
180
+
181
+ $collection = $observer->getOrderGridCollection();
182
+ $select = $collection->getSelect();
183
+
184
+ // This will prevent us from rejoining.
185
+ if(strchr($select, 'signifyd')) {
186
+ return;
187
+ }
188
+
189
+ if ($this->oldSupport()) {
190
+ $select->joinLeft(array('signifyd'=>$collection->getTable('signifyd_connect/case')), 'signifyd.order_increment=e.increment_id', array('score'=>'score'));
191
+ $this->joins++;
192
+ } else {
193
+ $select->joinLeft(array('signifyd'=>$collection->getTable('signifyd_connect/case')), 'signifyd.order_increment=main_table.increment_id', array('score'=>'score',
194
+ 'guarantee' => 'guarantee'));
195
+ $this->joins++;
196
+ }
197
+ }
198
+
199
+ public function coreBlockAbstractToHtmlBefore(Varien_Event_Observer $observer)
200
+ {
201
+ $request = Mage::app()->getRequest();
202
+ $module = $request->getModuleName();
203
+ $controller = $request->getControllerName();
204
+
205
+ if ($module != $this->getAdminRoute() || $controller != 'sales_order') {
206
+ return;
207
+ }
208
+
209
+ $helper = Mage::helper('signifyd_connect');
210
+ $block = $observer->getEvent()->getBlock();
211
+
212
+ if ($block->getId() == 'sales_order_grid') {
213
+ $block->addColumnAfter(
214
+ 'score',
215
+ array(
216
+ 'header' => $helper->__('Signifyd Score'),
217
+ 'align' => 'left',
218
+ 'type' => 'text',
219
+ 'index' => 'score',
220
+ 'filter' => false,
221
+ 'renderer' => 'signifyd_connect/renderer',
222
+ 'width' => '100px',
223
+ ),
224
+ 'status'
225
+ );
226
+ $block->addColumnAfter(
227
+ 'guarantee',
228
+ array(
229
+ 'header' => $helper->__('Guarantee Status'),
230
+ 'align' => 'left',
231
+ 'type' => 'text',
232
+ 'index' => 'guarantee',
233
+ 'filter' => false,
234
+ 'renderer' => 'signifyd_connect/renderer',
235
+ 'width' => '100px',
236
+ ),
237
+ 'status'
238
+ );
239
+ $block->sortColumnsByOrder();
240
+ }
241
+ }
242
+
243
+ public function handleCancel($order)
244
+ {
245
+ $helper = Mage::helper('signifyd_connect');
246
+ $case = Mage::getModel('signifyd_connect/case')->load($order);
247
+ if($case->isObjectNew()) {
248
+ $helper->logError("Guarantee cancel: Signifyd case for order $order does not exist in DB");
249
+ return;
250
+ }
251
+ if($case->getGuarantee() == 'N/A' || $case->getGuarantee() == 'DECLINED') {
252
+ $helper->logRequest("Guarantee cancel: Skipped. No guarantee active");
253
+ return;
254
+ }
255
+
256
+ $helper->logRequest("Guarantee cancel for case " . $case->getCode());
257
+ $helper->cancelGuarantee($case);
258
+ }
259
+
260
+ public function salesOrderPaymentCancel($observer)
261
+ {
262
+ $helper = Mage::helper('signifyd_connect');
263
+ try {
264
+ $event = $observer->getEvent();
265
+ if($event->getPayment()->getOrder()) {
266
+ $order = $event->getPayment()->getOrder()->getIncrementId();
267
+ } else {
268
+ $helper->logError("Event salesOrderPaymentCancel has no order");
269
+ return;
270
+ }
271
+ $this->handleCancel($order);
272
+ } catch(Exception $ex) {
273
+ $helper->logError("Guarantee cancel: $ex");
274
+ }
275
+ }
276
+
277
+ /**
278
+ * Putting an order on hold after the order was placed until the response comes back and an action can be taken.
279
+ * @param Varien_Event_Observer $observer
280
+ * @return $this
281
+ */
282
+ public function putOrderOnHold(Varien_Event_Observer $observer)
283
+ {
284
+ $order = $observer->getEvent()->getOrder();
285
+ if($order->canHold() === false){
286
+ $this->helper->logError("Order {$order->getIncrementId()} could not be held because Magento returned false for canHold");
287
+ }
288
+
289
+ try {
290
+ $order->hold();
291
+ $order->addStatusHistoryComment("Signifyd: order held after order place");
292
+ $order->save();
293
+ } catch (Exception $e){
294
+ $this->helper->logError("PutOrderOnHold Error: $e");
295
+ }
296
+
297
+ return $this;
298
+ }
299
+ }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Signifyd/Connect/Model/Order.php ADDED
@@ -0,0 +1,412 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Order Model
4
+ *
5
+ * @category Signifyd Connect
6
+ * @package Signifyd_Connect
7
+ * @author Signifyd
8
+ */
9
+ class Signifyd_Connect_Model_Order extends Mage_Core_Model_Abstract
10
+ {
11
+ /* Property for instance of the log helper */
12
+ protected $logger;
13
+
14
+ /* Property for instance of the data helper */
15
+ protected $dataHelper;
16
+
17
+ /* Property for configuration */
18
+ protected $logRequest;
19
+
20
+ /**
21
+ * Internal magento constructor
22
+ */
23
+ public function _construct()
24
+ {
25
+ $this->logger = Mage::helper('signifyd_connect/log');
26
+ $this->dataHelper = Mage::helper('signifyd_connect');
27
+ $this->logRequest = Mage::getStoreConfig('signifyd_connect/log/request');
28
+ parent::_construct();
29
+ }
30
+
31
+ /**
32
+ * Method to authorize an order after order place
33
+ * @param $order
34
+ * @return bool
35
+ */
36
+ public function authorizeOrder($order)
37
+ {
38
+ // Get the payment status for this order
39
+ $status = $this->dataHelper->getOrderPaymentStatus($order);
40
+ if($status['authorize']){
41
+ $this->logger->addLog("Order {$order->getIncrementId()} is already authorize");
42
+ return true;
43
+ }
44
+ $payment = $order->getPayment();
45
+ $method = $payment->getMethodInstance();
46
+ if(!$method->canAuthorize()){
47
+ $this->logger->addLog("Order {$order->getIncrementId()} can not be authorize");
48
+ return true;
49
+ }
50
+
51
+ $amount = $order->getData('grand_total');
52
+
53
+ try{
54
+ // check if method authorize returns anything usefully
55
+ $method->authorize($payment, $amount);
56
+ $this->logger->addLog("Authorize order {$order->getIncrementId()} was successful");
57
+ } catch (Exception $e) {
58
+ $this->logger->addLog("Authorize order {$order->getIncrementId()} was not authorized:");
59
+ $this->logger->addLog($e->__toString());
60
+ return false;
61
+ }
62
+
63
+ return true;
64
+ }
65
+
66
+ /**
67
+ * Method to generate the invoice after a order was placed
68
+ * @param $order
69
+ * @return bool
70
+ */
71
+ public function generateInvoice($order)
72
+ {
73
+ if(!$order->canInvoice()){
74
+ $this->logger->addLog("Order {$order->getIncrementId()} can not be invoiced");
75
+ return false;
76
+ }
77
+
78
+ try {
79
+
80
+ $invoice = Mage::getModel('sales/service_order', $order)->prepareInvoice();
81
+
82
+ $invoice->setRequestedCaptureCase(Mage_Sales_Model_Order_Invoice::CAPTURE_ONLINE);
83
+ $invoice->register();
84
+ $transactionSave = Mage::getModel('core/resource_transaction')
85
+ ->addObject($invoice)
86
+ ->addObject($invoice->getOrder());
87
+ $transactionSave->save();
88
+ $this->logger->addLog("Invoice was created for order: {$order->getIncrementId()}");
89
+
90
+ $invoice->addComment('Automatic Invoice', false);
91
+ $invoice->sendEmail();
92
+ $invoice->setEmailSent(true);
93
+ $invoice->save();
94
+
95
+ $order->addStatusHistoryComment('Automatic Invoice: '.$invoice->getIncrementId());
96
+ $order->save();
97
+ } catch (Exception $e) {
98
+ $this->logger->addLog('Exception while creating invoice: ' . $e->__toString());
99
+ return false;
100
+ }
101
+
102
+ return true;
103
+ }
104
+
105
+ /**
106
+ * Method to walk the flow for an order when the config is set to unhold, invoice and capture.
107
+ * When guaranty is approved
108
+ * @param $order
109
+ * @param $reason
110
+ * @return bool
111
+ */
112
+ public function unholdOrderAndCapture($order, $reason)
113
+ {
114
+ if(is_null($order->getId())){
115
+ $this->logger->addLog("Order was not found");
116
+ return false;
117
+ }
118
+
119
+ if(!$order->canUnhold()){
120
+ $this->logger->addLog("Order {$order->getIncrementId()} can not be unheld");
121
+ return false;
122
+ }
123
+ $status = $this->dataHelper->getOrderPaymentStatus($order);
124
+
125
+ try {
126
+ $order->unhold();
127
+ $order->addStatusHistoryComment("Signifyd: order unheld because $reason");
128
+ $order->save();
129
+
130
+ if ($this->logRequest) {
131
+ $this->logger->addLog("Order {$order->getIncrementId()} unheld because {$reason}");
132
+ }
133
+
134
+ // Authorize the order
135
+ $result = $this->authorizeOrder($order);
136
+ if($result === false){
137
+ $this->holdOrder($order, 'Fail to Authorize Order');
138
+ }
139
+
140
+ // Generate the invoice
141
+ if($status['capture'] !== true){
142
+ $result = $this->generateInvoice($order);
143
+ if($result === false){
144
+ $this->holdOrder($order, 'Fail to generate Invoice');
145
+ }
146
+ }
147
+ } catch (Exception $e) {
148
+ $this->logger->addLog("Order {$order->getIncrementId()} unable to be saved because {$e->getMessage()}");
149
+ $this->logger->addLog("Order {$order->getIncrementId()} was not unheld.");
150
+ return false;
151
+ }
152
+
153
+ return true;
154
+ }
155
+
156
+ /**
157
+ * Method to walk the flow for an order when the config is set to unhold only.
158
+ * When guaranty is approved
159
+ * @param $order
160
+ * @param $reason
161
+ * @return bool
162
+ */
163
+ public function unholdOrder($order, $reason)
164
+ {
165
+ if(is_null($order->getId())){
166
+ $this->logger->addLog("Order was not found");
167
+ return false;
168
+ }
169
+
170
+ if(!$order->canUnhold()){
171
+ $this->logger->addLog("Order {$order->getIncrementId()} can not be unheld");
172
+ return false;
173
+ }
174
+
175
+ try {
176
+ $order->unhold();
177
+ $order->addStatusHistoryComment("Signifyd: order unheld because $reason");
178
+ $order->save();
179
+
180
+ // Authorize the order
181
+ // $result = $this->authorizeOrder($order);
182
+ // if($result === false){
183
+ // $this->holdOrder($order, 'Fail to Authorize Order');
184
+ // }
185
+
186
+ if ($this->logRequest) {
187
+ $this->logger->addLog("Order {$order->getIncrementId()} unheld because {$reason}");
188
+ }
189
+ } catch (Exception $e) {
190
+ $this->logger->addLog("Order {$order->getIncrementId()} unable to be saved because {$e->getMessage()}");
191
+ $this->logger->addLog("Order {$order->getIncrementId()} was not unheld.");
192
+ return false;
193
+ }
194
+ return true;
195
+ }
196
+
197
+ /**
198
+ * Method to hold the order whe the guaranty is declined
199
+ * @param $order
200
+ * @param $reason
201
+ * @return bool
202
+ */
203
+ public function holdOrder($order, $reason)
204
+ {
205
+ if(is_null($order->getId())){
206
+ $this->logger->addLog("Order was not found");
207
+ return false;
208
+ }
209
+
210
+ if(!$order->canHold()){
211
+ $this->logger->addLog("Order {$order->getIncrementId()} can not be held");
212
+ return false;
213
+ }
214
+
215
+ try {
216
+ $order->hold();
217
+ $order->addStatusHistoryComment("Signifyd: order held because {$reason}");
218
+ $order->save();
219
+
220
+ if ($this->logRequest) {
221
+ $this->logger->addLog("Order {$order->getIncrementId()} held because {$reason}");
222
+ }
223
+ } catch (Exception $e){
224
+ $this->logger->addLog("Order {$order->getIncrementId()} unable to be saved because {$e->getMessage()}");
225
+ $this->logger->addLog("Order {$order->getIncrementId()} was not held.");
226
+ return false;
227
+ }
228
+
229
+ return true;
230
+ }
231
+
232
+ /**
233
+ * Method to hold the order whe the guaranty is declined and magento config is set to cancel the order
234
+ * @param $order
235
+ * @param $reason
236
+ * @return bool
237
+ */
238
+ public function cancelOrder($order, $reason)
239
+ {
240
+ if(is_null($order->getId())){
241
+ $this->logger->addLog("Order was not found");
242
+ return false;
243
+ }
244
+
245
+ if ($order->getState() === $order::STATE_HOLDED) {
246
+ $this->unholdOrder($order, $reason);
247
+ }
248
+
249
+ if(!$order->canCancel()){
250
+ $this->logger->addLog("Order {$order->getIncrementId()} can not be canceled");
251
+ return false;
252
+ }
253
+
254
+ try {
255
+ $order->cancel();
256
+ $order->addStatusHistoryComment("Signifyd: order canceled because $reason");
257
+ $order->save();
258
+
259
+ if ($this->logRequest) {
260
+ $this->logger->addLog("Order {$order->getIncrementId()} cancelled because {$reason}");
261
+ }
262
+ } catch (Exception $e){
263
+ $this->logger->addLog("Order {$order->getIncrementId()} unable to be saved because {$e->getMessage()}");
264
+ $this->logger->addLog("Order {$order->getIncrementId()} was not canceled.");
265
+ return false;
266
+ }
267
+
268
+ return true;
269
+ }
270
+ /*
271
+ public function voidOrderPayment($order, $reason)
272
+ {
273
+ if(is_null($order->getId())){
274
+ $this->logger->addLog("Order was not found");
275
+ return false;
276
+ }
277
+ $payment = $order->getPayment();
278
+ $method = $payment->getMethodInstance();
279
+
280
+ if(!$method->canVoid($payment)){
281
+ $this->logger->addLog("Payment for order {$order->getIncrementId()} can not be voided");
282
+ return false;
283
+ }
284
+
285
+ try{
286
+ $method->void($payment);
287
+ $order->save();
288
+ $this->cancelOrder($order, $reason);
289
+ $this->logger->addLog("Void order payment {$order->getIncrementId()} was successful");
290
+ } catch (Exception $e) {
291
+ $this->holdOrder($order, 'Signifyd: Failed to void order payment');
292
+ $this->logger->addLog("Void order payment {$order->getIncrementId()} was not authorized:");
293
+ $this->logger->addLog($e->__toString());
294
+ return false;
295
+ }
296
+
297
+ return true;
298
+ }
299
+ */
300
+
301
+ public function keepOrderOnHold($order, $reason)
302
+ {
303
+ if(is_null($order->getId())){
304
+ $this->logger->addLog("Order was not found");
305
+ return false;
306
+ }
307
+
308
+ if($order->getStatus() != Mage_Sales_Model_Order::STATE_HOLDED){
309
+ try{
310
+ $this->holdOrder($order, $reason);
311
+ }catch (Exception $e){
312
+ $this->logger->addLog($e->__toString());
313
+ }
314
+ }
315
+ $this->logger->addLog("Order {$order->getIncrementId()} was kept on hold because {$reason}");
316
+
317
+ return true;
318
+ }
319
+
320
+ public function cancelCloseOrder($order, $reason)
321
+ {
322
+ $status = $this->dataHelper->getOrderPaymentStatus($order);
323
+ if(is_null($order->getId())){
324
+ $this->logger->addLog("Order was not found");
325
+ return false;
326
+ }
327
+ if(!$order->canUnhold()){
328
+ $this->logger->addLog("Order {$order->getIncrementId()} can not be unheld");
329
+ return false;
330
+ }
331
+ try {
332
+ $order->unhold();
333
+ $order->addStatusHistoryComment("Signifyd: order unheld because $reason");
334
+ $order->save();
335
+ $this->logger->addLog("Order {$order->getIncrementId()} unheld in order to cancel it");
336
+ } catch (Exception $e){
337
+
338
+ $this->logger->addLog("Order {$order->getIncrementId()} can not be unheld");
339
+ $this->logger->addLog($e->__toString());
340
+ return false;
341
+ }
342
+
343
+ // if($status['authorize'] === true && $status['capture'] === false) {
344
+ // $this->logger->addLog("cancel close order5");
345
+ // $this->voidOrderPayment($order, $reason);
346
+ if($status['authorize'] === true && $status['capture'] === true) {
347
+ $result = $this->canNotCancel($order, $reason);
348
+ } else {
349
+ $result = $this->cancelOrder($order, $reason);
350
+ }
351
+ if($result === false){
352
+ $this->holdOrder($order, 'Fail to Cancel/Close Order');
353
+ }
354
+ return true;
355
+ }
356
+
357
+ public function checkStatus($order, $status)
358
+ {
359
+ $theOrder = Mage::getModel('sales/order')->load($order->getId());
360
+ return ($theOrder->getStatus() == $status)? true : false;
361
+ }
362
+
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');
369
+ // type refers to the need to by held or not held: 1 needs to be held, 2 needs to be not held
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
+
390
+ return true;
391
+ }
392
+
393
+ public function canNotCancel($order, $reason)
394
+ {
395
+ try {
396
+ $order->hold();
397
+ $order->addStatusHistoryComment("Signifyd: order held because $reason");
398
+ $order->addStatusHistoryComment("Signifyd: order can not be canceled because it has a sum already captured, Please do a manual refund.");
399
+ $order->save();
400
+ $this->logger->addLog("Order {$order->getIncrementId()} was held because {$reason}");
401
+ } catch (Exception $e){
402
+ $this->logger->addLog("Order {$order->getIncrementId()} could not be held: " . $e->__toString());
403
+ return false;
404
+ }
405
+
406
+ return true;
407
+ }
408
+
409
+ }
410
+
411
+ /* Filename: Order.php */
412
+ /* Location: ../app/code/Community/Signifyd/Connect/Model/Order.php */
app/code/community/Signifyd/Connect/Model/Order/Payment.php ADDED
@@ -0,0 +1,29 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+ /**
3
+ * Payment Model
4
+ *
5
+ * @category Signifyd Connect
6
+ * @package Signifyd_Connect
7
+ * @author Signifyd
8
+ */
9
+ class Signifyd_Connect_Model_Order_Payment extends Mage_Sales_Model_Order_Payment
10
+ {
11
+ public function registerCaptureNotification($amount, $skipFraudDetection = false)
12
+ {
13
+ Mage::log("Signifyd: Register capture notification", null, 'signifyd_connect.log');
14
+ parent::registerCaptureNotification($amount, $skipFraudDetection = false);
15
+ $order = $this->getOrder();
16
+ $isDeclined = Mage::helper('signifyd_connect')->isGuarantyDeclined($order);
17
+ if($isDeclined){
18
+ Mage::log("Signifyd: Register capture notification execute hold status and state: order {$order->getIncrementId()}", null, 'signifyd_connect.log');
19
+ $order->setState(Mage_Sales_Model_Order::STATE_HOLDED);
20
+ $order->setStatus(Mage_Sales_Model_Order::STATE_HOLDED);
21
+ $order->addStatusHistoryComment("Signifyd: order held because guarantee declined");
22
+ }
23
+
24
+ return $this;
25
+ }
26
+ }
27
+
28
+ /* Filename: Cron.php */
29
+ /* Location: ../app/code/Community/Signifyd/Connect/Model/Cron.php */
app/code/community/Signifyd/Connect/Model/Resource/Case.php CHANGED
@@ -1,10 +1,10 @@
1
- <?php
2
-
3
- class Signifyd_Connect_Model_Resource_Case extends Mage_Core_Model_Mysql4_Abstract
4
- {
5
- protected function _construct()
6
- {
7
- $this->_init('signifyd_connect/case', 'order_increment');
8
- $this->_isPkAutoIncrement = false;
9
- }
10
- }
1
+ <?php
2
+
3
+ class Signifyd_Connect_Model_Resource_Case extends Mage_Core_Model_Mysql4_Abstract
4
+ {
5
+ protected function _construct()
6
+ {
7
+ $this->_init('signifyd_connect/case', 'order_increment');
8
+ $this->_isPkAutoIncrement = false;
9
+ }
10
+ }
app/code/community/Signifyd/Connect/Model/Resource/Case/Collection.php CHANGED
@@ -1,9 +1,9 @@
1
- <?php
2
-
3
- class Signifyd_Connect_Model_Resource_Case_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
- {
5
- public function _construct()
6
- {
7
- $this->_init('signifyd_connect/case');
8
- }
9
- }
1
+ <?php
2
+
3
+ class Signifyd_Connect_Model_Resource_Case_Collection extends Mage_Core_Model_Mysql4_Collection_Abstract
4
+ {
5
+ public function _construct()
6
+ {
7
+ $this->_init('signifyd_connect/case');
8
+ }
9
+ }
app/code/community/Signifyd/Connect/Model/Resource/Retries.php CHANGED
@@ -1,10 +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
- }
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 CHANGED
@@ -1,9 +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
- }
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 CHANGED
@@ -1,10 +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
- }
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/Model/Setup.php CHANGED
@@ -1,53 +1,53 @@
1
- <?php
2
-
3
- class Signifyd_Connect_Model_Setup extends Mage_Core_Model_Resource_Setup
4
- {
5
- const REGISTER_URL = 'https://signifyd.com/magento/installs';
6
-
7
- public function register()
8
- {
9
- try {
10
- $helper = Mage::helper('signifyd_connect');
11
- Mage::getConfig()->reinit();
12
- $data = array(
13
- 'url' => $helper->getStoreUrl(),
14
- 'email' => $helper->getStoreEmail()
15
- );
16
-
17
- $helper->request(self::REGISTER_URL, json_encode($data), null, 'application/json');
18
- } catch (Exception $e) {}
19
- }
20
-
21
- public function checkColumns()
22
- {
23
- /* Attempt to add commonly missing columns, allow silent failure if present */
24
-
25
- try {
26
- $this->run("ALTER TABLE `{$this->getTable('signifyd_connect_case')}` CHANGE `status` `signifyd_status` VARCHAR( 64 ) NOT NULL DEFAULT 'PENDING'");
27
- } catch (Exception $e) {};
28
-
29
- try {
30
- $this->run("ALTER TABLE `{$this->getTable('signifyd_connect_case')}` ADD `signifyd_status` VARCHAR( 64 ) NOT NULL DEFAULT 'PENDING';");
31
- } catch (Exception $e) {};
32
-
33
- try {
34
- $this->run("ALTER TABLE `{$this->getTable('signifyd_connect_case')}` ADD `code` VARCHAR(255) NOT NULL;");
35
- } catch (Exception $e) {};
36
-
37
- try {
38
- $this->run("ALTER TABLE `{$this->getTable('signifyd_connect_case')}` ADD `score` FLOAT NULL DEFAULT NULL;");
39
- } catch (Exception $e) {};
40
-
41
- try {
42
- $this->run("ALTER TABLE `{$this->getTable('signifyd_connect_case')}` ADD `entries` TEXT NULL DEFAULT NULL;");
43
- } catch (Exception $e) {};
44
-
45
- try {
46
- $this->run("ALTER TABLE `{$this->getTable('signifyd_connect_case')}` ADD `created_at` TIMESTAMP NULL DEFAULT NULL;");
47
- } catch (Exception $e) {};
48
-
49
- try {
50
- $this->run("ALTER TABLE `{$this->getTable('signifyd_connect_case')}` ADD `updated_at` TIMESTAMP NULL DEFAULT NULL;");
51
- } catch (Exception $e) {};
52
- }
53
- }
1
+ <?php
2
+
3
+ class Signifyd_Connect_Model_Setup extends Mage_Core_Model_Resource_Setup
4
+ {
5
+ const REGISTER_URL = 'https://signifyd.com/magento/installs';
6
+
7
+ public function register()
8
+ {
9
+ try {
10
+ $helper = Mage::helper('signifyd_connect');
11
+ Mage::getConfig()->reinit();
12
+ $data = array(
13
+ 'url' => $helper->getStoreUrl(),
14
+ 'email' => $helper->getStoreEmail()
15
+ );
16
+
17
+ $helper->request(self::REGISTER_URL, json_encode($data), null, 'application/json');
18
+ } catch (Exception $e) {}
19
+ }
20
+
21
+ public function checkColumns()
22
+ {
23
+ /* Attempt to add commonly missing columns, allow silent failure if present */
24
+
25
+ try {
26
+ $this->run("ALTER TABLE `{$this->getTable('signifyd_connect_case')}` CHANGE `status` `signifyd_status` VARCHAR( 64 ) NOT NULL DEFAULT 'PENDING'");
27
+ } catch (Exception $e) {};
28
+
29
+ try {
30
+ $this->run("ALTER TABLE `{$this->getTable('signifyd_connect_case')}` ADD `signifyd_status` VARCHAR( 64 ) NOT NULL DEFAULT 'PENDING';");
31
+ } catch (Exception $e) {};
32
+
33
+ try {
34
+ $this->run("ALTER TABLE `{$this->getTable('signifyd_connect_case')}` ADD `code` VARCHAR(255) NOT NULL;");
35
+ } catch (Exception $e) {};
36
+
37
+ try {
38
+ $this->run("ALTER TABLE `{$this->getTable('signifyd_connect_case')}` ADD `score` FLOAT NULL DEFAULT NULL;");
39
+ } catch (Exception $e) {};
40
+
41
+ try {
42
+ $this->run("ALTER TABLE `{$this->getTable('signifyd_connect_case')}` ADD `entries` TEXT NULL DEFAULT NULL;");
43
+ } catch (Exception $e) {};
44
+
45
+ try {
46
+ $this->run("ALTER TABLE `{$this->getTable('signifyd_connect_case')}` ADD `created_at` TIMESTAMP NULL DEFAULT NULL;");
47
+ } catch (Exception $e) {};
48
+
49
+ try {
50
+ $this->run("ALTER TABLE `{$this->getTable('signifyd_connect_case')}` ADD `updated_at` TIMESTAMP NULL DEFAULT NULL;");
51
+ } catch (Exception $e) {};
52
+ }
53
+ }
app/code/community/Signifyd/Connect/Model/System/Config/Source/Options/Accepted.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Signifyd_Connect_Model_System_Config_Source_Options_Accepted
5
+ {
6
+ public function toOptionArray()
7
+ {
8
+ return array(
9
+ array(
10
+ 'value' => 1,
11
+ 'label' => 'Do nothing'
12
+ ),
13
+ array(
14
+ 'value' => 2,
15
+ 'label' => 'Capture and Invoice'
16
+ )
17
+ );
18
+ }
19
+ }
app/code/community/Signifyd/Connect/Model/System/Config/Source/Options/Declined.php ADDED
@@ -0,0 +1,19 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+
4
+ class Signifyd_Connect_Model_System_Config_Source_Options_Declined
5
+ {
6
+ public function toOptionArray()
7
+ {
8
+ return array(
9
+ array(
10
+ 'value' => 1,
11
+ 'label' => 'Do nothing'
12
+ ),
13
+ array(
14
+ 'value' => 2,
15
+ 'label' => 'Cancel and Void'
16
+ )
17
+ );
18
+ }
19
+ }
app/code/community/Signifyd/Connect/Model/System/Config/Source/Options/Negative.php DELETED
@@ -1,22 +0,0 @@
1
- <?php
2
-
3
- class Signifyd_Connect_Model_System_Config_Source_Options_Negative
4
- {
5
- public function toOptionArray()
6
- {
7
- return array(
8
- array(
9
- 'value' => 'nothing',
10
- 'label' => 'Nothing',
11
- ),
12
- array(
13
- 'value' => 'hold',
14
- 'label' => 'Hold Order',
15
- ),
16
- array(
17
- 'value' => 'cancel',
18
- 'label' => 'Cancel Order',
19
- ),
20
- );
21
- }
22
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Signifyd/Connect/Model/System/Config/Source/Options/Positive.php DELETED
@@ -1,18 +0,0 @@
1
- <?php
2
-
3
- class Signifyd_Connect_Model_System_Config_Source_Options_Positive
4
- {
5
- public function toOptionArray()
6
- {
7
- return array(
8
- array(
9
- 'value' => 'nothing',
10
- 'label' => 'Nothing',
11
- ),
12
- array(
13
- 'value' => 'unhold',
14
- 'label' => 'Unhold Order',
15
- ),
16
- );
17
- }
18
- }
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Signifyd/Connect/controllers/Adminhtml/SignifydController.php CHANGED
@@ -1,27 +1,22 @@
1
- <?php
2
-
3
- class Signifyd_Connect_Adminhtml_SignifydController extends Mage_Adminhtml_Controller_Action
4
- {
5
- public function indexAction()
6
- {
7
- $this->_title($this->__('Sales'))->_title($this->__('Signifyd Scores'));
8
- $this->loadLayout();
9
- $this->_setActiveMenu('sales/sales');
10
- $this->_addContent($this->getLayout()->createBlock('signifyd_connect/adminhtml_sales_order'));
11
- $this->renderLayout();
12
- }
13
-
14
- public function gridAction()
15
- {
16
- $this->loadLayout();
17
- $this->getResponse()->setBody(
18
- $this->getLayout()->createBlock('signifyd_connect/adminhtml_sales_order_grid')->toHtml()
19
- );
20
- }
21
-
22
- public function sendAction()
23
- {
24
- Mage::helper('signifyd_connect')->bulkSend($this);
25
- $this->_redirectReferer();
26
- }
27
- }
1
+ <?php
2
+
3
+ class Signifyd_Connect_Adminhtml_SignifydController extends Mage_Adminhtml_Controller_Action
4
+ {
5
+ public function indexAction()
6
+ {
7
+ $this->_title($this->__('Sales'))->_title($this->__('Signifyd Scores'));
8
+ $this->loadLayout();
9
+ $this->_setActiveMenu('sales/sales');
10
+ $this->_addContent($this->getLayout()->createBlock('signifyd_connect/adminhtml_sales_order'));
11
+ $this->renderLayout();
12
+ }
13
+
14
+ public function gridAction()
15
+ {
16
+ $this->loadLayout();
17
+ $this->getResponse()->setBody(
18
+ $this->getLayout()->createBlock('signifyd_connect/adminhtml_sales_order_grid')->toHtml()
19
+ );
20
+ }
21
+
22
+ }
 
 
 
 
 
app/code/community/Signifyd/Connect/controllers/ConnectController.php CHANGED
@@ -1,593 +1,523 @@
1
- <?php
2
-
3
- class Signifyd_Connect_ConnectController extends Mage_Core_Controller_Front_Action
4
- {
5
- public $_request = array();
6
- public $_topic = false;
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
- {
15
- return Mage::getStoreConfig('signifyd_connect/settings/key');
16
- }
17
-
18
- public function holdThreshold()
19
- {
20
- return (int)Mage::getStoreConfig('signifyd_connect/advanced/hold_orders_threshold', $this->_store_id);
21
- }
22
-
23
- public function canReviewHold()
24
- {
25
- return Mage::getStoreConfig('signifyd_connect/advanced/hold_orders', $this->_store_id);
26
- }
27
-
28
- public function canInvoice()
29
- {
30
- return Mage::getStoreConfig('signifyd_connect/advanced/invoice_orders', $this->_store_id);
31
- }
32
-
33
- public function notifyCustomer()
34
- {
35
- return Mage::getStoreConfig('signifyd_connect/advanced/invoice_orders_notify', $this->_store_id);
36
- }
37
-
38
- public function negativeGuaranteeAction()
39
- {
40
- return Mage::getStoreConfig('signifyd_connect/advanced/guarantee_negative_action', $this->_store_id);
41
- }
42
-
43
- public function positiveGuaranteeAction()
44
- {
45
- return Mage::getStoreConfig('signifyd_connect/advanced/guarantee_positive_action', $this->_store_id);
46
- }
47
-
48
- public function enabled()
49
- {
50
- $retrieve_scores = Mage::getStoreConfig('signifyd_connect/advanced/retrieve_score');
51
- $enabled = Mage::getStoreConfig('signifyd_connect/settings/enabled');
52
-
53
- return $enabled && $retrieve_scores;
54
- }
55
-
56
- public function getUrl($code)
57
- {
58
- return Mage::getStoreConfig('signifyd_connect/settings/url', $this->_store_id) . '/cases/' . $code;
59
- }
60
-
61
- public function logErrors()
62
- {
63
- return Mage::getStoreConfig('signifyd_connect/log/error');
64
- }
65
-
66
- public function logRequest()
67
- {
68
- return Mage::getStoreConfig('signifyd_connect/log/request');
69
- }
70
-
71
- public function getRawPost()
72
- {
73
- if (isset($HTTP_RAW_POST_DATA) && $HTTP_RAW_POST_DATA) {
74
- return $HTTP_RAW_POST_DATA;
75
- }
76
-
77
- $post = file_get_contents("php://input");
78
-
79
- if ($post) {
80
- return $post;
81
- }
82
-
83
- return '';
84
- }
85
-
86
- public function getDefaultMessage()
87
- {
88
- 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';
89
- }
90
-
91
- public function getDisabledMessage()
92
- {
93
- 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.';
94
- }
95
-
96
- public function unsupported()
97
- {
98
- Mage::app()->getResponse()
99
- ->setHeader('HTTP/1.1', '403 Forbidden')
100
- ->sendResponse();
101
- echo 'This request type is currently unsupported';
102
- exit;
103
- }
104
-
105
- public function complete()
106
- {
107
- Mage::app()->getResponse()
108
- ->setHeader('HTTP/1.1', '200 Ok')
109
- ->sendResponse();
110
-
111
- exit;
112
- }
113
-
114
- public function conflict()
115
- {
116
- Mage::app()->getResponse()
117
- ->setHeader('HTTP/1.1', '409 Conflict')
118
- ->sendResponse();
119
- exit;
120
- }
121
-
122
- private function updateScore($case)
123
- {
124
- if (isset($this->_request['score'])) {
125
- $case->setScore($this->_request['score']);
126
-
127
- if ($this->logRequest()) {
128
- Mage::log('Set score to ' . $this->_request['score'], null, 'signifyd_connect.log');
129
- }
130
- } else {
131
- if ($this->logRequest()) {
132
- Mage::log('No score value available', null, 'signifyd_connect.log');
133
- }
134
- }
135
- }
136
-
137
- private function updateStatus($case)
138
- {
139
- if (isset($this->_request['status'])) {
140
- $case->setSignifydStatus($this->_request['status']);
141
-
142
- if ($this->logRequest()) {
143
- Mage::log('Set status to ' . $this->_request['status'], null, 'signifyd_connect.log');
144
- }
145
- } else {
146
- if ($this->logRequest()) {
147
- Mage::log('No status value available', null, 'signifyd_connect.log');
148
- }
149
- }
150
- }
151
-
152
- private function updateGuarantee($case)
153
- {
154
- if (isset($this->_request['guaranteeDisposition'])) {
155
- $case->setGuarantee($this->_request['guaranteeDisposition']);
156
-
157
- if ($this->logRequest()) {
158
- Mage::log('Set guarantee to ' . $this->_request['guaranteeDisposition'], null, 'signifyd_connect.log');
159
- }
160
- } else {
161
- if ($this->logRequest()) {
162
- Mage::log('No guarantee available', null, 'signifyd_connect.log');
163
- }
164
- }
165
- }
166
-
167
- public function validRequest($request, $hash)
168
- {
169
- $check = base64_encode(hash_hmac('sha256', $request, $this->getApiKey(), true));
170
-
171
- if ($this->logRequest()) {
172
- Mage::log('API request hash check: ' . $check, null, 'signifyd_connect.log');
173
- }
174
-
175
- if ($check == $hash) {
176
- return true;
177
- }
178
- else if ($this->getHeader('X-SIGNIFYD-TOPIC') == "cases/test"){
179
- // In the case that this is a webhook test, the encoding ABCDE is allowed
180
- $check = base64_encode(hash_hmac('sha256', $request, 'ABCDE', true));
181
- if ($check == $hash) {
182
- return true;
183
- }
184
- }
185
-
186
- return false;
187
- }
188
-
189
- public function initCase($order_increment)
190
- {
191
- $case = false;
192
-
193
- if (isset($this->_request['orderId']))
194
- {
195
- $case = Mage::getModel('signifyd_connect/case')->load($this->_request['orderId']);
196
- if($case->isObjectNew()) {
197
- if ($this->logErrors()) {
198
- Mage::log('Case not yet in DB. Likely timing issue. order_increment: ' . $this->_request['orderId'], null, 'signifyd_connect.log');
199
- }
200
- $this->conflict();
201
- }
202
- }
203
-
204
- return $case;
205
- }
206
-
207
- public function initRequest($request)
208
- {
209
- $this->_request = json_decode($request, true);
210
-
211
- $topic = $this->getHeader('X-SIGNIFYD-TOPIC');
212
-
213
- $this->_topic = $topic;
214
-
215
- // For the webhook test, all of the request data will be invalid
216
- if ($topic == "cases/test") return;
217
-
218
- $this->_case = $this->initCase($this->_request['orderId']);
219
- $this->_previousGuarantee = $this->_case->getGuarantee();
220
- $this->_previousScore = $this->_case->getScore();
221
-
222
- $this->_order = Mage::getModel('sales/order')->loadByIncrementId($this->_request['orderId']);
223
-
224
- if ($this->_order && $this->_order->getId()) {
225
- $this->_store_id = $this->_order->getStoreId();
226
- }
227
-
228
- if (!$this->_case && $this->logRequest()) {
229
- Mage::log('No matching case was found for this request. order_increment: ' . $this->_request['orderId'], null, 'signifyd_connect.log');
230
- }
231
- }
232
-
233
- public function holdOrder($order, $reason)
234
- {
235
- if ($order && $order->getId() && $order->canHold()) {
236
- $order->hold();
237
- $order->addStatusHistoryComment("Signifyd: order held because $reason");
238
- $order->save();
239
-
240
- if ($this->logRequest()) {
241
- Mage::log('Order ' . $order->getId() . ' held', null, 'signifyd_connect.log');
242
- }
243
- }
244
- }
245
-
246
- public function unholdOrder($order, $reason)
247
- {
248
- if ($order && $order->getId() && $order->canUnhold()) {
249
- $order->unhold();
250
- $order->addStatusHistoryComment("Signifyd: order unheld because $reason");
251
- $order->save();
252
-
253
- if ($this->logRequest()) {
254
- Mage::log('Order ' . $order->getId() . ' unheld', null, 'signifyd_connect.log');
255
- }
256
- }
257
- }
258
-
259
- public function cancelOrder($order, $reason)
260
- {
261
- if ($order && $order->getId() && $order->canCancel()) {
262
- $order->cancel();
263
- $order->addStatusHistoryComment("Signifyd: order canceled because $reason");
264
- $order->save();
265
-
266
- if ($this->logRequest()) {
267
- Mage::log('Order ' . $order->getId() . ' cancelled', null, 'signifyd_connect.log');
268
- }
269
- }
270
- }
271
-
272
- public function invoiceOrder($order)
273
- {
274
- if ($order && $order->getId() && $order->canInvoice() && $this->canInvoice()) {
275
- $items = array();
276
- foreach ($order->getAllItems() as $item) {
277
- $items[$item->getId()] = $item->getQtyOrdered();
278
- }
279
-
280
- $invoice_api = Mage::getModel('sales/order_invoice_api');
281
-
282
- try {
283
- $invoice_id = $invoice_api->create($order->getIncrementId(), $items, null, false, true);
284
-
285
- $invoice_api->capture($invoice_id);
286
- } catch (Exception $e) {
287
- if ($this->logErrors()) {
288
- Mage::log('Exception while creating invoice: ' . $e->__toString(), null, 'signifyd_connect.log');
289
- }
290
- }
291
- }
292
- }
293
-
294
- public function processAdditional($case, $original_status = false)
295
- {
296
- $order = $this->_order;
297
-
298
- if ($order && $order->getId()) {
299
- $threshold = $this->holdThreshold();
300
-
301
- $negativeAction = $this->negativeGuaranteeAction();
302
- $positiveAction = $this->positiveGuaranteeAction();
303
- $newGuarantee = $this->_request ['guaranteeDisposition'];
304
- $newScore = $case->getScore();
305
-
306
- // If a guarantee has been set, we no longer care about other actions
307
- if (isset($newGuarantee) && $newGuarantee != $this->_previousGuarantee) {
308
- if ($newGuarantee == 'DECLINED' && $negativeAction != 'nothing') {
309
- if ($negativeAction == 'hold') {
310
- $this->holdOrder($order, "guarantee declined");
311
- } else if ($negativeAction == 'cancel') {
312
- $this->cancelOrder($order, "guarantee declined");
313
- } else {
314
- Mage::log("Unknown action $negativeAction", null, 'signifyd_connect.log');
315
- }
316
- } else if ($newGuarantee == 'APPROVED' && $positiveAction != 'nothing') {
317
- if ($positiveAction == 'unhold') {
318
- $this->unholdOrder($order, "guarantee approved");
319
- } else {
320
- Mage::log("Unknown action $positiveAction", null, 'signifyd_connect.log');
321
- }
322
- }
323
- } else if($this->_previousGuarantee == "N/A") {
324
- if (!$original_status || $original_status == 'PENDING') {
325
- if ($threshold && $this->_previousScore != $newScore
326
- && $newScore <= $threshold
327
- && $this->canReviewHold())
328
- {
329
- $this->holdOrder($order, "score below threshold");
330
- }
331
- } else if ($original_status) {
332
- if ($this->_request['reviewDisposition'] == 'FRAUDULENT') {
333
- if ($this->canReviewHold()) {
334
- $this->holdOrder($order, "case review fraudulent");
335
- }
336
- } else if ($this->_request['reviewDisposition'] == 'GOOD') {
337
- if ($this->canReviewHold()) {
338
- $this->unholdOrder($order, "case review good");
339
- }
340
- }
341
- }
342
- }
343
- }
344
- }
345
-
346
- public function processCreation()
347
- {
348
- $case = $this->_case;
349
-
350
- if (!$case) {
351
- return;
352
- }
353
-
354
- $this->updateScore($case);
355
- $this->updateStatus($case);
356
-
357
- $case->setUpdated(strftime('%Y-%m-%d %H:%M:%S', time()));
358
- $case->save();
359
-
360
- if ($this->logRequest()) {
361
- Mage::log('Case ' . $case->getId() . ' created with status ' . $case->getSignifydStatus() . ' and score ' . $case->getScore(), null, 'signifyd_connect.log');
362
- }
363
-
364
- $this->processAdditional($case);
365
- }
366
-
367
- public function processReview()
368
- {
369
- $case = $this->_case;
370
-
371
- if (!$case) {
372
- return;
373
- }
374
-
375
- $original_status = $case->getSignifydStatus();
376
-
377
- $this->updateScore($case);
378
- $this->updateStatus($case);
379
-
380
- $case->setUpdated(strftime('%Y-%m-%d %H:%M:%S', time()));
381
- $case->save();
382
-
383
- $this->processAdditional($case, $original_status);
384
- }
385
-
386
- public function processGuarantee()
387
- {
388
- $case = $this->_case;
389
-
390
- if (!$case) {
391
- return;
392
- }
393
-
394
- $original_status = $case->getSignifydStatus();
395
-
396
- $this->updateScore($case);
397
- $this->updateStatus($case);
398
- $this->updateGuarantee($case);
399
-
400
- $case->setUpdated(strftime('%Y-%m-%d %H:%M:%S', time()));
401
- $case->save();
402
-
403
- $this->processAdditional($case, $original_status);
404
- }
405
-
406
- public function caseLookup()
407
- {
408
- $result = false;
409
- $case = $this->_case;
410
-
411
- try {
412
- $url = $this->getUrl($case->getCode());
413
-
414
- $response = Mage::helper('signifyd_connect')->request($url, null, $this->getApiKey(), null, 'application/json');
415
-
416
- $response_code = $response->getHttpCode();
417
-
418
- if (substr($response_code, 0, 1) == '2') {
419
- $result = json_decode($response->getRawResponse(), true);
420
- } else {
421
- if ($this->logRequest()) {
422
- Mage::log('Fallback request received a ' . $response_code . ' response from Signifyd', null, 'signifyd_connect.log');
423
- }
424
- }
425
- } catch (Exception $e) {
426
- if ($this->logErrors()) {
427
- Mage::log('Fallback issue: ' . $e->__toString(), null, 'signifyd_connect.log');
428
- }
429
- }
430
-
431
- return $result;
432
- }
433
-
434
- public function processFallback($request)
435
- {
436
- if ($this->logRequest()) {
437
- Mage::log('Attempting auth via fallback request', null, 'signifyd_connect.log');
438
- }
439
-
440
- $request = json_decode($request, true);
441
-
442
- $this->_topic = "cases/review"; // Topic header is most likely not available
443
-
444
- if (is_array($request) && isset($request['orderId']))
445
- {
446
- $this->_case = Mage::getModel('signifyd_connect/case')->load($request['orderId']);
447
- }
448
-
449
- $this->_order = Mage::getModel('sales/order')->loadByIncrementId($this->_request['orderId']);
450
-
451
- if ($this->_order && $this->_order->getId()) {
452
- $this->_store_id = $this->_order->getStoreId();
453
- }
454
-
455
- if ($this->_case) {
456
- $lookup = $this->caseLookup();
457
-
458
- if ($lookup && is_array($lookup)) {
459
- $this->_request = $lookup;
460
-
461
- $this->processReview();
462
- } else {
463
- if ($this->logRequest()) {
464
- Mage::log('Fallback failed with an invalid response from Signifyd', null, 'signifyd_connect.log');
465
- }
466
- }
467
- } else {
468
- if ($this->logRequest()) {
469
- Mage::log('Fallback failed with no matching case found', null, 'signifyd_connect.log');
470
- }
471
- }
472
- }
473
-
474
- public function getHeader($header)
475
- {
476
- // T379: Some frameworks add an extra HTTP_ before the header, so check for both names
477
- // Header values stored in the $_SERVER variable have dashes converted to underscores, hence str_replace
478
- $direct = strtoupper(str_replace('-', '_', $header));
479
- $extraHttp = 'HTTP_' . $direct;
480
-
481
- // Check the $_SERVER global
482
- if (isset($_SERVER[$direct])) {
483
- return $_SERVER[$direct];
484
- } else if (isset($_SERVER[$extraHttp])) {
485
- return $_SERVER[$extraHttp];
486
- }
487
-
488
- Mage::log('Valid Header Not Found: ' . $header, null, 'signifyd_connect.log');
489
- return '';
490
-
491
- }
492
-
493
- public function retriesAction()
494
- {
495
- Mage::helper('signifyd_connect')->processRetryQueue();
496
- }
497
-
498
- public function sendAction()
499
- {
500
- try {
501
- // This request handles the send action only if we are using an unsecured
502
- // connection. Otherwise, it does nothing
503
- if (!Mage::getStoreConfig('signifyd_connect/settings/enabled') ||
504
- !Mage::getStoreConfig('signifyd_connect/advanced/use_unsecure_requests')
505
- ) {
506
- Mage::log("Attempting to access send endpoint from frontend when it is currently disabled.", null, 'signifyd_connect.log');
507
- return;
508
- }
509
- Mage::helper('signifyd_connect')->bulkSend($this);
510
- } catch (Exception $e) {
511
- Mage::log('Exception while sending: ' . $e->__toString(), null, 'signifyd_connect.log');
512
- }
513
- $this->_redirectReferer();
514
- }
515
-
516
- public function apiAction()
517
- {
518
- if (!$this->enabled()) {
519
- echo $this->getDisabledMessage();
520
-
521
- return;
522
- }
523
-
524
- $request = $this->getRawPost();
525
-
526
- $hash = $this->getHeader('X-SIGNIFYD-SEC-HMAC-SHA256');
527
-
528
- if ($this->logRequest()) {
529
- Mage::log('API request: ' . $request, null, 'signifyd_connect.log');
530
- Mage::log('API request hash: ' . $hash, null, 'signifyd_connect.log');
531
- }
532
-
533
- if ($request) {
534
- if ($this->validRequest($request, $hash)) {
535
- $this->initRequest($request);
536
-
537
- $topic = $this->_topic;
538
-
539
- if ($this->logRequest()) {
540
- Mage::log('API request topic: ' . $topic, null, 'signifyd_connect.log');
541
- }
542
-
543
- switch ($topic) {
544
- case "cases/creation":
545
- try {
546
- $this->processCreation($request);
547
- } catch (Exception $e) {
548
- if ($this->logErrors()) {
549
- Mage::log('Case scoring issue: ' . $e->__toString(), null, 'signifyd_connect.log');
550
- }
551
- }
552
- break;
553
- case "cases/rescore":
554
- case "cases/review":
555
- try {
556
- $this->processReview($request);
557
- } catch (Exception $e) {
558
- if ($this->logErrors()) {
559
- Mage::log('Case review issue: ' . $e->__toString(), null, 'signifyd_connect.log');
560
- }
561
- }
562
- break;
563
- case "guarantees/completion":
564
- try {
565
- $this->processGuarantee($request);
566
- } catch (Exception $ex) {
567
- if ($this->logErrors()) {
568
- Mage::log('Case guarantee issue: ' . $ex->__toString(), null, 'signifyd_connect.log');
569
- }
570
- }
571
- break;
572
- case "cases/test":
573
- // Test is only verifying that the endpoint is reachable. So we just complete here
574
- break;
575
-
576
- default:
577
- $this->unsupported();
578
- }
579
- } else {
580
- if ($this->logRequest()) {
581
- Mage::log('API request failed auth', null, 'signifyd_connect.log');
582
- }
583
-
584
- $this->processFallback($request);
585
- }
586
- } else {
587
- echo $this->getDefaultMessage();
588
- }
589
-
590
- $this->complete();
591
- }
592
-
593
- }
1
+ <?php
2
+ /**
3
+ * Connect Controller
4
+ *
5
+ * @category Signifyd Connect
6
+ * @package Signifyd_Connect
7
+ * @author Signifyd
8
+ */
9
+ class Signifyd_Connect_ConnectController extends Mage_Core_Controller_Front_Action
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/error');
52
+ }
53
+
54
+ public function logRequest()
55
+ {
56
+ return Mage::getStoreConfig('signifyd_connect/log/request');
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()
87
+ ->setHeader('HTTP/1.1', '403 Forbidden')
88
+ ->sendResponse();
89
+ echo 'This request type is currently unsupported';
90
+ exit;
91
+ }
92
+
93
+ public function complete()
94
+ {
95
+ Mage::app()->getResponse()
96
+ ->setHeader('HTTP/1.1', '200 Ok')
97
+ ->sendResponse();
98
+
99
+ exit;
100
+ }
101
+
102
+ public function conflict()
103
+ {
104
+ Mage::app()->getResponse()
105
+ ->setHeader('HTTP/1.1', '409 Conflict')
106
+ ->sendResponse();
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
+ }
195
+
196
+ return $case;
197
+ }
198
+
199
+ public function initRequest($request)
200
+ {
201
+ $this->_request = json_decode($request, true);
202
+
203
+ $topic = $this->getHeader('X-SIGNIFYD-TOPIC');
204
+
205
+ $this->_topic = $topic;
206
+
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
415
+ // Header values stored in the $_SERVER variable have dashes converted to underscores, hence str_replace
416
+ $direct = strtoupper(str_replace('-', '_', $header));
417
+ $extraHttp = 'HTTP_' . $direct;
418
+
419
+ // Check the $_SERVER global
420
+ if (isset($_SERVER[$direct])) {
421
+ return $_SERVER[$direct];
422
+ } else if (isset($_SERVER[$extraHttp])) {
423
+ return $_SERVER[$extraHttp];
424
+ }
425
+
426
+ Mage::log('Valid Header Not Found: ' . $header, null, 'signifyd_connect.log');
427
+ return '';
428
+
429
+ }
430
+
431
+ /**
432
+ * Main entry point for the signifyd callback
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
496
+ break;
497
+
498
+ default:
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();
510
+ }
511
+
512
+ $this->complete();
513
+ }
514
+
515
+ public function cronAction()
516
+ {
517
+ Mage::getModel('signifyd_connect/cron')->retry();
518
+ }
519
+
520
+ }
521
+
522
+ /* Filename: ConnectController.php */
523
+ /* Location: ../app/code/Community/Signifyd/Connect/controllers/ConnectController.php */
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Signifyd/Connect/etc/adminhtml.xml CHANGED
@@ -1,16 +1,16 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <!--
4
- <menu>
5
- <sales>
6
- <children>
7
- <signifyd_connect translate="title" module="signifyd_connect">
8
- <sort_order>50</sort_order>
9
- <title>Signifyd Scores</title>
10
- <action>adminhtml/signifyd/</action>
11
- </signifyd_connect>
12
- </children>
13
- </sales>
14
- </menu>
15
- -->
16
- </config>
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <!--
4
+ <menu>
5
+ <sales>
6
+ <children>
7
+ <signifyd_connect translate="title" module="signifyd_connect">
8
+ <sort_order>50</sort_order>
9
+ <title>Signifyd Scores</title>
10
+ <action>adminhtml/signifyd/</action>
11
+ </signifyd_connect>
12
+ </children>
13
+ </sales>
14
+ </menu>
15
+ -->
16
+ </config>
app/code/community/Signifyd/Connect/etc/config.xml CHANGED
@@ -1,199 +1,214 @@
1
- <?xml version="1.0"?>
2
-
3
- <config>
4
- <modules>
5
- <Signifyd_Connect>
6
- <version>3.13.1</version>
7
- </Signifyd_Connect>
8
- </modules>
9
- <global>
10
- <models>
11
- <paygate>
12
- <rewrite>
13
- <authorizenet>Signifyd_Connect_Model_Authnet</authorizenet>
14
- </rewrite>
15
- </paygate>
16
- <signifyd_connect>
17
- <class>Signifyd_Connect_Model</class>
18
- <resourceModel>signifyd_connect_resource</resourceModel>
19
- </signifyd_connect>
20
- <signifyd_connect_resource>
21
- <class>Signifyd_Connect_Model_Resource</class>
22
- <entities>
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>
32
- <resources>
33
- <signifyd_connect_setup>
34
- <setup>
35
- <module>Signifyd_Connect</module>
36
- <class>Signifyd_Connect_Model_Setup</class>
37
- </setup>
38
- <connection>
39
- <use>core_setup</use>
40
- </connection>
41
- </signifyd_connect_setup>
42
- <signifyd_connect_write>
43
- <connection>
44
- <use>core_write</use>
45
- </connection>
46
- </signifyd_connect_write>
47
- <signifyd_connect_read>
48
- <connection>
49
- <use>core_read</use>
50
- </connection>
51
- </signifyd_connect_read>
52
- </resources>
53
- <helpers>
54
- <signifyd_connect>
55
- <class>Signifyd_Connect_Helper</class>
56
- </signifyd_connect>
57
- </helpers>
58
- <blocks>
59
- <signifyd_connect>
60
- <class>Signifyd_Connect_Block</class>
61
- </signifyd_connect>
62
- </blocks>
63
- <events>
64
- <model_save_after>
65
- <observers>
66
- <signifyd_connect>
67
- <class>signifyd_connect/observer</class>
68
- <method>openCase</method>
69
- </signifyd_connect>
70
- </observers>
71
- </model_save_after>
72
- </events>
73
- </global>
74
- <frontend>
75
- <routers>
76
- <signifyd_connect>
77
- <use>standard</use>
78
- <args>
79
- <module>Signifyd_Connect</module>
80
- <frontName>signifyd</frontName>
81
- </args>
82
- </signifyd_connect>
83
- </routers>
84
- </frontend>
85
- <default>
86
- <signifyd_connect>
87
- <settings>
88
- <enabled>0</enabled>
89
- <url>https://api.signifyd.com/v2</url>
90
- </settings>
91
- <advanced>
92
- <retrieve_score>0</retrieve_score>
93
- <show_scores>0</show_scores>
94
- <hold_orders>0</hold_orders>
95
- <hold_orders_threshold>500</hold_orders_threshold>
96
- <invoice_orders>0</invoice_orders>
97
- </advanced>
98
- <log>
99
- <request>1</request>
100
- <response>1</response>
101
- <error>1</error>
102
- </log>
103
- </signifyd_connect>
104
- </default>
105
- <admin>
106
- <routers>
107
- <adminhtml>
108
- <args>
109
- <modules>
110
- <signifyd_connect before="Mage_Adminhtml">Signifyd_Connect_Adminhtml</signifyd_connect>
111
- </modules>
112
- </args>
113
- </adminhtml>
114
- </routers>
115
- </admin>
116
- <adminhtml>
117
- <acl>
118
- <resources>
119
- <all>
120
- <title>Allow Everything</title>
121
- </all>
122
- <admin>
123
- <children>
124
- <system>
125
- <children>
126
- <config>
127
- <children>
128
- <signifyd_connect>
129
- <title>Signifyd</title>
130
- <sort_order>9999</sort_order>
131
- </signifyd_connect>
132
- </children>
133
- </config>
134
- </children>
135
- </system>
136
- <sales>
137
- <children>
138
- <signifyd_connect>
139
- <sort_order>50</sort_order>
140
- <title>Signifyd Scores</title>
141
- </signifyd_connect>
142
- </children>
143
- </sales>
144
- </children>
145
- </admin>
146
- </resources>
147
- </acl>
148
- <events>
149
- <eav_collection_abstract_load_before>
150
- <observers>
151
- <signifyd_connect>
152
- <model>signifyd_connect/observer</model>
153
- <method>coreCollectionAbstractLoadBefore</method>
154
- </signifyd_connect>
155
- </observers>
156
- </eav_collection_abstract_load_before>
157
- <core_collection_abstract_load_before>
158
- <observers>
159
- <signifyd_connect>
160
- <model>signifyd_connect/observer</model>
161
- <method>coreCollectionAbstractLoadBefore</method>
162
- </signifyd_connect>
163
- </observers>
164
- </core_collection_abstract_load_before>
165
- <sales_order_grid_collection_load_before>
166
- <observers>
167
- <signifyd_connect>
168
- <model>signifyd_connect/observer</model>
169
- <method>salesOrderGridCollectionLoadBefore</method>
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>
184
- <model>signifyd_connect/observer</model>
185
- <method>coreBlockAbstractToHtmlBefore</method>
186
- </signifyd_connect>
187
- </observers>
188
- </core_block_abstract_to_html_before>
189
- <core_block_abstract_prepare_layout_before>
190
- <observers>
191
- <signifyd_connect>
192
- <model>signifyd_connect/observer</model>
193
- <method>coreBlockAbstractPrepareLayoutBefore</method>
194
- </signifyd_connect>
195
- </observers>
196
- </core_block_abstract_prepare_layout_before>
197
- </events>
198
- </adminhtml>
199
- </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ <?xml version="1.0"?>
2
+
3
+ <config>
4
+ <modules>
5
+ <Signifyd_Connect>
6
+ <version>3.15.0</version>
7
+ </Signifyd_Connect>
8
+ </modules>
9
+ <global>
10
+ <models>
11
+ <paygate>
12
+ <rewrite>
13
+ <authorizenet>Signifyd_Connect_Model_Authnet</authorizenet>
14
+ </rewrite>
15
+ </paygate>
16
+ <sales>
17
+ <rewrite>
18
+ <order_payment>Signifyd_Connect_Model_Order_Payment</order_payment>
19
+ </rewrite>
20
+ </sales>
21
+ <signifyd_connect>
22
+ <class>Signifyd_Connect_Model</class>
23
+ <resourceModel>signifyd_connect_resource</resourceModel>
24
+ </signifyd_connect>
25
+ <signifyd_connect_resource>
26
+ <class>Signifyd_Connect_Model_Resource</class>
27
+ <entities>
28
+ <case>
29
+ <table>signifyd_connect_case</table>
30
+ </case>
31
+ <retries>
32
+ <table>signifyd_connect_retries</table>
33
+ </retries>
34
+ </entities>
35
+ </signifyd_connect_resource>
36
+ </models>
37
+ <resources>
38
+ <signifyd_connect_setup>
39
+ <setup>
40
+ <module>Signifyd_Connect</module>
41
+ <class>Signifyd_Connect_Model_Setup</class>
42
+ </setup>
43
+ <connection>
44
+ <use>core_setup</use>
45
+ </connection>
46
+ </signifyd_connect_setup>
47
+ <signifyd_connect_write>
48
+ <connection>
49
+ <use>core_write</use>
50
+ </connection>
51
+ </signifyd_connect_write>
52
+ <signifyd_connect_read>
53
+ <connection>
54
+ <use>core_read</use>
55
+ </connection>
56
+ </signifyd_connect_read>
57
+ </resources>
58
+ <helpers>
59
+ <signifyd_connect>
60
+ <class>Signifyd_Connect_Helper</class>
61
+ </signifyd_connect>
62
+ </helpers>
63
+ <blocks>
64
+ <signifyd_connect>
65
+ <class>Signifyd_Connect_Block</class>
66
+ </signifyd_connect>
67
+ </blocks>
68
+ <events>
69
+ <model_save_after>
70
+ <observers>
71
+ <signifyd_connect>
72
+ <class>signifyd_connect/observer</class>
73
+ <method>openCase</method>
74
+ </signifyd_connect>
75
+ </observers>
76
+ </model_save_after>
77
+ <sales_order_place_after>
78
+ <observers>
79
+ <signifyd_connect>
80
+ <class>signifyd_connect/observer</class>
81
+ <method>putOrderOnHold</method>
82
+ </signifyd_connect>
83
+ </observers>
84
+ </sales_order_place_after>
85
+ </events>
86
+ </global>
87
+ <crontab>
88
+ <jobs>
89
+ <signifyd_retry>
90
+ <schedule>
91
+ <cron_expr>*/30 * * * *</cron_expr>
92
+ </schedule>
93
+ <run>
94
+ <model>signifyd_connect/cron::retry</model>
95
+ </run>
96
+ </signifyd_retry>
97
+ </jobs>
98
+ </crontab>
99
+ <frontend>
100
+ <routers>
101
+ <signifyd_connect>
102
+ <use>standard</use>
103
+ <args>
104
+ <module>Signifyd_Connect</module>
105
+ <frontName>signifyd</frontName>
106
+ </args>
107
+ </signifyd_connect>
108
+ </routers>
109
+ </frontend>
110
+ <default>
111
+ <signifyd_connect>
112
+ <settings>
113
+ <enabled>0</enabled>
114
+ <url>https://api.signifyd.com/v2</url>
115
+ </settings>
116
+ <advanced>
117
+ <hold_orders>0</hold_orders>
118
+ <hold_orders_threshold>500</hold_orders_threshold>
119
+ <invoice_orders>0</invoice_orders>
120
+ </advanced>
121
+ <log>
122
+ <request>1</request>
123
+ <response>1</response>
124
+ <error>1</error>
125
+ </log>
126
+ </signifyd_connect>
127
+ </default>
128
+ <admin>
129
+ <routers>
130
+ <adminhtml>
131
+ <args>
132
+ <modules>
133
+ <signifyd_connect before="Mage_Adminhtml">Signifyd_Connect_Adminhtml</signifyd_connect>
134
+ </modules>
135
+ </args>
136
+ </adminhtml>
137
+ </routers>
138
+ </admin>
139
+ <adminhtml>
140
+ <acl>
141
+ <resources>
142
+ <all>
143
+ <title>Allow Everything</title>
144
+ </all>
145
+ <admin>
146
+ <children>
147
+ <system>
148
+ <children>
149
+ <config>
150
+ <children>
151
+ <signifyd_connect>
152
+ <title>Signifyd</title>
153
+ <sort_order>9999</sort_order>
154
+ </signifyd_connect>
155
+ </children>
156
+ </config>
157
+ </children>
158
+ </system>
159
+ <sales>
160
+ <children>
161
+ <signifyd_connect>
162
+ <sort_order>50</sort_order>
163
+ <title>Signifyd Scores</title>
164
+ </signifyd_connect>
165
+ </children>
166
+ </sales>
167
+ </children>
168
+ </admin>
169
+ </resources>
170
+ </acl>
171
+ <events>
172
+ <eav_collection_abstract_load_before>
173
+ <observers>
174
+ <signifyd_connect>
175
+ <model>signifyd_connect/observer</model>
176
+ <method>coreCollectionAbstractLoadBefore</method>
177
+ </signifyd_connect>
178
+ </observers>
179
+ </eav_collection_abstract_load_before>
180
+ <core_collection_abstract_load_before>
181
+ <observers>
182
+ <signifyd_connect>
183
+ <model>signifyd_connect/observer</model>
184
+ <method>coreCollectionAbstractLoadBefore</method>
185
+ </signifyd_connect>
186
+ </observers>
187
+ </core_collection_abstract_load_before>
188
+ <sales_order_grid_collection_load_before>
189
+ <observers>
190
+ <signifyd_connect>
191
+ <model>signifyd_connect/observer</model>
192
+ <method>salesOrderGridCollectionLoadBefore</method>
193
+ </signifyd_connect>
194
+ </observers>
195
+ </sales_order_grid_collection_load_before>
196
+ <sales_order_payment_cancel>
197
+ <observers>
198
+ <signifyd_connect>
199
+ <model>signifyd_connect/observer</model>
200
+ <method>salesOrderPaymentCancel</method>
201
+ </signifyd_connect>
202
+ </observers>
203
+ </sales_order_payment_cancel>
204
+ <core_block_abstract_to_html_before>
205
+ <observers>
206
+ <signifyd_connect>
207
+ <model>signifyd_connect/observer</model>
208
+ <method>coreBlockAbstractToHtmlBefore</method>
209
+ </signifyd_connect>
210
+ </observers>
211
+ </core_block_abstract_to_html_before>
212
+ </events>
213
+ </adminhtml>
214
+ </config>
app/code/community/Signifyd/Connect/etc/system.xml CHANGED
@@ -1,222 +1,133 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <tabs>
4
- <signifyd translate="label" module="signifyd_connect">
5
- <label>Signifyd</label>
6
- <sort_order>999999</sort_order>
7
- </signifyd>
8
- </tabs>
9
- <sections>
10
- <signifyd_connect translate="label" module="signifyd_connect">
11
- <label>Signifyd</label>
12
- <tab>signifyd</tab>
13
- <frontend_type>text</frontend_type>
14
- <sort_order>99999</sort_order>
15
- <show_in_default>1</show_in_default>
16
- <show_in_website>1</show_in_website>
17
- <show_in_store>1</show_in_store>
18
- <groups>
19
- <settings translate="label">
20
- <label>General Settings</label>
21
- <frontend_type>text</frontend_type>
22
- <sort_order>2</sort_order>
23
- <show_in_default>1</show_in_default>
24
- <show_in_website>1</show_in_website>
25
- <show_in_store>1</show_in_store>
26
- <fields>
27
- <enabled translate="label">
28
- <label>Enable extension</label>
29
- <frontend_type>select</frontend_type>
30
- <source_model>adminhtml/system_config_source_yesno</source_model>
31
- <sort_order>10</sort_order>
32
- <show_in_default>1</show_in_default>
33
- <show_in_website>0</show_in_website>
34
- <show_in_store>0</show_in_store>
35
- <comment><![CDATA[This enables or disables the Signifyd extension]]></comment>
36
- </enabled>
37
- <key translate="label">
38
- <label>Signifyd API Key</label>
39
- <frontend_type>text</frontend_type>
40
- <sort_order>20</sort_order>
41
- <show_in_default>1</show_in_default>
42
- <show_in_website>0</show_in_website>
43
- <show_in_store>0</show_in_store>
44
- <comment><![CDATA[You will find this in <a href="http://signifyd.com/settings/teams">http://signifyd.com/settings/teams</a> after you create a Signifyd account]]></comment>
45
- </key>
46
- <url translate="label">
47
- <label>Signifyd API URL</label>
48
- <frontend_type>text</frontend_type>
49
- <sort_order>30</sort_order>
50
- <show_in_default>1</show_in_default>
51
- <show_in_website>0</show_in_website>
52
- <show_in_store>0</show_in_store>
53
- <comment><![CDATA[This is set by default. Don’t change unless asked to do so.]]></comment>
54
- </url>
55
- </fields>
56
- </settings>
57
- <advanced>
58
- <label>Advanced</label>
59
- <frontend_type>text</frontend_type>
60
- <sort_order>2</sort_order>
61
- <show_in_default>1</show_in_default>
62
- <show_in_website>0</show_in_website>
63
- <show_in_store>0</show_in_store>
64
- <fields>
65
- <retrieve_score translate="label">
66
- <label>Retrieve Signifyd scores</label>
67
- <frontend_type>select</frontend_type>
68
- <source_model>adminhtml/system_config_source_yesno</source_model>
69
- <sort_order>50</sort_order>
70
- <show_in_default>1</show_in_default>
71
- <show_in_website>0</show_in_website>
72
- <show_in_store>0</show_in_store>
73
- <comment><model>signifyd_connect/link</model></comment>
74
- </retrieve_score>
75
- <show_scores translate="label">
76
- <label>Show Scores in Magento Order Grid</label>
77
- <frontend_type>select</frontend_type>
78
- <source_model>adminhtml/system_config_source_yesno</source_model>
79
- <sort_order>55</sort_order>
80
- <show_in_default>1</show_in_default>
81
- <show_in_website>0</show_in_website>
82
- <show_in_store>0</show_in_store>
83
- <depends><retrieve_score>1</retrieve_score></depends>
84
- <comment><![CDATA[Your scores will show in the Magento Order Grid once enabled]]></comment>
85
- </show_scores>
86
- <hold_orders translate="label">
87
- <label>Place hold on orders below score threshold</label>
88
- <frontend_type>select</frontend_type>
89
- <source_model>adminhtml/system_config_source_yesno</source_model>
90
- <sort_order>60</sort_order>
91
- <show_in_default>1</show_in_default>
92
- <show_in_website>1</show_in_website>
93
- <show_in_store>1</show_in_store>
94
- <depends><retrieve_score>1</retrieve_score></depends>
95
- <comment><![CDATA[Orders will be placed on hold below a threshold specified by you. We recommend a threshold of 500. Clicking Thumbs Up will Unhold the Order and Thumbs down will leave the Order on Hold. ]]></comment>
96
- </hold_orders>
97
- <hold_orders_threshold translate="label">
98
- <label>Hold score threshold</label>
99
- <frontend_type>text</frontend_type>
100
- <sort_order>70</sort_order>
101
- <show_in_default>1</show_in_default>
102
- <show_in_website>1</show_in_website>
103
- <show_in_store>1</show_in_store>
104
- <comment><![CDATA[0-1000. Threshold at which orders get put on HOLD. Default is 500.]]></comment>
105
- <depends><hold_orders>1</hold_orders></depends>
106
- </hold_orders_threshold>
107
- <show_guarantee translate="label">
108
- <label>Show Guarantee status in Magento Order Grid</label>
109
- <frontend_type>select</frontend_type>
110
- <source_model>adminhtml/system_config_source_yesno</source_model>
111
- <sort_order>80</sort_order>
112
- <show_in_default>1</show_in_default>
113
- <show_in_website>0</show_in_website>
114
- <show_in_store>0</show_in_store>
115
- <comment><![CDATA[You will be able to view current guarantee status in the Magento Order Grid when enabled]]></comment>
116
- </show_guarantee>
117
- <guarantee_negative_action translate="label">
118
- <label>Action on Guarantee Decline</label>
119
- <frontend_type>select</frontend_type>
120
- <source_model>signifyd_connect/system_config_source_options_negative</source_model>
121
- <sort_order>85</sort_order>
122
- <show_in_default>1</show_in_default>
123
- <show_in_website>1</show_in_website>
124
- <show_in_store>1</show_in_store>
125
- <comment><![CDATA[Which action to take on orders when the guarantee is declined]]></comment>
126
- </guarantee_negative_action>
127
- <guarantee_positive_action translate="label">
128
- <label>Action on Guarantee Approve</label>
129
- <frontend_type>select</frontend_type>
130
- <source_model>signifyd_connect/system_config_source_options_positive</source_model>
131
- <sort_order>86</sort_order>
132
- <show_in_default>1</show_in_default>
133
- <show_in_website>1</show_in_website>
134
- <show_in_store>1</show_in_store>
135
- <comment><![CDATA[Which action to take on orders when the guarantee is approved]]></comment>
136
- </guarantee_positive_action>
137
- <invoice_orders translate="label">
138
- <label>Invoice orders after receiving Signifyd Scores</label>
139
- <frontend_type>select</frontend_type>
140
- <source_model>adminhtml/system_config_source_yesno</source_model>
141
- <sort_order>90</sort_order>
142
- <show_in_default>0</show_in_default>
143
- <show_in_website>0</show_in_website>
144
- <show_in_store>0</show_in_store>
145
- <depends><retrieve_score>1</retrieve_score></depends>
146
- <comment><![CDATA[Attempt to invoice (and capture) orders after receiving a Signifyd score where the order has not been held. If the order cannot be invoiced, no action will be taken. This will invoice the whole order, so is not suitable for workflows where partial invoices are needed.]]></comment>
147
- </invoice_orders>
148
- <invoice_orders_notify translate="label">
149
- <label>Notify customer</label>
150
- <frontend_type>select</frontend_type>
151
- <source_model>adminhtml/system_config_source_yesno</source_model>
152
- <sort_order>95</sort_order>
153
- <show_in_default>1</show_in_default>
154
- <show_in_website>1</show_in_website>
155
- <show_in_store>1</show_in_store>
156
- <comment><![CDATA[Send email notification to customers after invoicing orders]]></comment>
157
- <depends><invoice_orders>1</invoice_orders></depends>
158
- </invoice_orders_notify>
159
- <use_unsecure_requests>
160
- <label>Use Unsecure Requests</label>
161
- <frontend_type>select</frontend_type>
162
- <source_model>adminhtml/system_config_source_yesno</source_model>
163
- <sort_order>100</sort_order>
164
- <show_in_default>1</show_in_default>
165
- <show_in_website>1</show_in_website>
166
- <show_in_store>1</show_in_store>
167
- <comment><![CDATA[For backend actions (such as bulk-send from the order grid), use the frontend controller instead of the secure backend controller. This is intended to work around some potential issues. Use only when necessary, and set it back once the actions are completed]]></comment>
168
- </use_unsecure_requests>
169
- <enable_payment_updates>
170
- <label>Enable payment updates</label>
171
- <frontend_type>select</frontend_type>
172
- <source_model>adminhtml/system_config_source_yesno</source_model>
173
- <sort_order>110</sort_order>
174
- <show_in_default>1</show_in_default>
175
- <show_in_website>1</show_in_website>
176
- <show_in_store>1</show_in_store>
177
- <comment><![CDATA[Enable update request when new payment information is received by a payment service]]></comment>
178
- </enable_payment_updates>
179
- </fields>
180
- </advanced>
181
- <log translate="label">
182
- <label>Log Settings</label>
183
- <frontend_type>text</frontend_type>
184
- <sort_order>3</sort_order>
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>
192
- <frontend_type>select</frontend_type>
193
- <source_model>adminhtml/system_config_source_yesno</source_model>
194
- <sort_order>1</sort_order>
195
- <show_in_default>1</show_in_default>
196
- <show_in_website>0</show_in_website>
197
- <show_in_store>0</show_in_store>
198
- </request>
199
- <response>
200
- <label>Log responses</label>
201
- <frontend_type>select</frontend_type>
202
- <source_model>adminhtml/system_config_source_yesno</source_model>
203
- <sort_order>2</sort_order>
204
- <show_in_default>1</show_in_default>
205
- <show_in_website>0</show_in_website>
206
- <show_in_store>0</show_in_store>
207
- </response>
208
- <error>
209
- <label>Log errors</label>
210
- <frontend_type>select</frontend_type>
211
- <source_model>adminhtml/system_config_source_yesno</source_model>
212
- <sort_order>3</sort_order>
213
- <show_in_default>1</show_in_default>
214
- <show_in_website>0</show_in_website>
215
- <show_in_store>0</show_in_store>
216
- </error>
217
- </fields>
218
- </log>
219
- </groups>
220
- </signifyd_connect>
221
- </sections>
222
- </config>
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <tabs>
4
+ <signifyd translate="label" module="signifyd_connect">
5
+ <label>Signifyd</label>
6
+ <sort_order>999999</sort_order>
7
+ </signifyd>
8
+ </tabs>
9
+ <sections>
10
+ <signifyd_connect translate="label" module="signifyd_connect">
11
+ <label>Signifyd</label>
12
+ <tab>signifyd</tab>
13
+ <frontend_type>text</frontend_type>
14
+ <sort_order>99999</sort_order>
15
+ <show_in_default>1</show_in_default>
16
+ <show_in_website>1</show_in_website>
17
+ <show_in_store>1</show_in_store>
18
+ <groups>
19
+ <settings translate="label">
20
+ <label>General</label>
21
+ <frontend_type>text</frontend_type>
22
+ <sort_order>2</sort_order>
23
+ <show_in_default>1</show_in_default>
24
+ <show_in_website>1</show_in_website>
25
+ <show_in_store>1</show_in_store>
26
+ <fields>
27
+ <enabled translate="label">
28
+ <label>Enable extension</label>
29
+ <frontend_type>select</frontend_type>
30
+ <source_model>adminhtml/system_config_source_yesno</source_model>
31
+ <sort_order>10</sort_order>
32
+ <show_in_default>1</show_in_default>
33
+ <show_in_website>1</show_in_website>
34
+ <show_in_store>1</show_in_store>
35
+ </enabled>
36
+ <key translate="label">
37
+ <label>API Key</label>
38
+ <frontend_type>text</frontend_type>
39
+ <sort_order>20</sort_order>
40
+ <show_in_default>1</show_in_default>
41
+ <show_in_website>1</show_in_website>
42
+ <show_in_store>1</show_in_store>
43
+ </key>
44
+ </fields>
45
+ </settings>
46
+ <advanced>
47
+ <label>Order Workflow</label>
48
+ <frontend_type>text</frontend_type>
49
+ <sort_order>2</sort_order>
50
+ <show_in_default>1</show_in_default>
51
+ <show_in_website>1</show_in_website>
52
+ <show_in_store>1</show_in_store>
53
+ <fields>
54
+ <accepted_from_guaranty translate="label">
55
+ <label>When an order is approved for Guarantee:</label>
56
+ <frontend_type>select</frontend_type>
57
+ <source_model>signifyd_connect/system_config_source_options_accepted</source_model>
58
+ <sort_order>20</sort_order>
59
+ <show_in_default>1</show_in_default>
60
+ <show_in_website>1</show_in_website>
61
+ <show_in_store>1</show_in_store>
62
+ </accepted_from_guaranty>
63
+ <declined_from_guaranty translate="label">
64
+ <label>When an order is declined for Guarantee:</label>
65
+ <frontend_type>select</frontend_type>
66
+ <source_model>signifyd_connect/system_config_source_options_declined</source_model>
67
+ <sort_order>30</sort_order>
68
+ <show_in_default>1</show_in_default>
69
+ <show_in_website>1</show_in_website>
70
+ <show_in_store>1</show_in_store>
71
+ </declined_from_guaranty>
72
+ </fields>
73
+ </advanced>
74
+ <webhook>
75
+ <label>Webhook URL</label>
76
+ <frontend_type>text</frontend_type>
77
+ <sort_order>3</sort_order>
78
+ <show_in_default>1</show_in_default>
79
+ <show_in_website>1</show_in_website>
80
+ <show_in_store>1</show_in_store>
81
+ <fields>
82
+ <url translate="label">
83
+ <label>Webhook URL</label>
84
+ <frontend_type>label</frontend_type>
85
+ <sort_order>30</sort_order>
86
+ <show_in_default>1</show_in_default>
87
+ <show_in_website>1</show_in_website>
88
+ <show_in_store>1</show_in_store>
89
+ <comment><model>signifyd_connect/link</model></comment>
90
+ </url>
91
+ </fields>
92
+ </webhook>
93
+ <log translate="label">
94
+ <label>Logging</label>
95
+ <frontend_type>text</frontend_type>
96
+ <sort_order>4</sort_order>
97
+ <show_in_default>1</show_in_default>
98
+ <show_in_website>1</show_in_website>
99
+ <show_in_store>1</show_in_store>
100
+ <fields>
101
+ <request>
102
+ <label>Log requests</label>
103
+ <frontend_type>select</frontend_type>
104
+ <source_model>adminhtml/system_config_source_yesno</source_model>
105
+ <sort_order>1</sort_order>
106
+ <show_in_default>1</show_in_default>
107
+ <show_in_website>1</show_in_website>
108
+ <show_in_store>1</show_in_store>
109
+ </request>
110
+ <response>
111
+ <label>Log responses</label>
112
+ <frontend_type>select</frontend_type>
113
+ <source_model>adminhtml/system_config_source_yesno</source_model>
114
+ <sort_order>2</sort_order>
115
+ <show_in_default>1</show_in_default>
116
+ <show_in_website>1</show_in_website>
117
+ <show_in_store>1</show_in_store>
118
+ </response>
119
+ <error>
120
+ <label>Log errors</label>
121
+ <frontend_type>select</frontend_type>
122
+ <source_model>adminhtml/system_config_source_yesno</source_model>
123
+ <sort_order>3</sort_order>
124
+ <show_in_default>1</show_in_default>
125
+ <show_in_website>1</show_in_website>
126
+ <show_in_store>1</show_in_store>
127
+ </error>
128
+ </fields>
129
+ </log>
130
+ </groups>
131
+ </signifyd_connect>
132
+ </sections>
133
+ </config>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-install-3.1.1.php CHANGED
@@ -1,13 +1,13 @@
1
- <?php
2
-
3
- $this->startSetup();
4
- $this->register();
5
- $this->run("
6
- DROP TABLE IF EXISTS `{$this->getTable('signifyd_connect_case')}`;
7
- CREATE TABLE IF NOT EXISTS `{$this->getTable('signifyd_connect_case')}` (
8
- `case_id` int(10) unsigned NOT NULL auto_increment,
9
- `order_increment` varchar(255) NOT NULL,
10
- PRIMARY KEY (`case_id`)
11
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
12
- ");
13
- $this->endSetup();
1
+ <?php
2
+
3
+ $this->startSetup();
4
+ $this->register();
5
+ $this->run("
6
+ DROP TABLE IF EXISTS `{$this->getTable('signifyd_connect_case')}`;
7
+ CREATE TABLE IF NOT EXISTS `{$this->getTable('signifyd_connect_case')}` (
8
+ `case_id` int(10) unsigned NOT NULL auto_increment,
9
+ `order_increment` varchar(255) NOT NULL,
10
+ PRIMARY KEY (`case_id`)
11
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
12
+ ");
13
+ $this->endSetup();
app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-install-3.12.0.php CHANGED
@@ -1,26 +1,26 @@
1
- <?php
2
-
3
- $this->startSetup();
4
- $this->register();
5
- $this->run("
6
- DROP TABLE IF EXISTS `{$this->getTable('signifyd_connect_case')}`;
7
- DROP TABLE IF EXISTS `{$this->getTable('signifyd_connect_retries')}`;
8
- CREATE TABLE IF NOT EXISTS `{$this->getTable('signifyd_connect_case')}` (
9
- `order_increment` varchar(255) NOT NULL,
10
- `signifyd_status` varchar(64) NOT NULL DEFAULT 'PENDING',
11
- `code` varchar(255) NOT NULL,
12
- `score` float DEFAULT NULL,
13
- `guarantee` VARCHAR( 64 ) NOT NULL DEFAULT 'N/A',
14
- `entries` text NOT NULL,
15
- `transaction_id` varchar(64) NULL,
16
- `created` timestamp NULL DEFAULT NULL,
17
- `updated` timestamp NULL DEFAULT NULL,
18
- PRIMARY KEY (`order_increment`)
19
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
20
- CREATE TABLE IF NOT EXISTS `{$this->getTable('signifyd_connect_retries')}` (
21
- `order_increment` varchar(255) NOT NULL,
22
- `created` timestamp NULL DEFAULT NULL,
23
- PRIMARY KEY (`order_increment`)
24
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
25
- ");
26
- $this->endSetup();
1
+ <?php
2
+
3
+ $this->startSetup();
4
+ $this->register();
5
+ $this->run("
6
+ DROP TABLE IF EXISTS `{$this->getTable('signifyd_connect_case')}`;
7
+ DROP TABLE IF EXISTS `{$this->getTable('signifyd_connect_retries')}`;
8
+ CREATE TABLE IF NOT EXISTS `{$this->getTable('signifyd_connect_case')}` (
9
+ `order_increment` varchar(255) NOT NULL,
10
+ `signifyd_status` varchar(64) NOT NULL DEFAULT 'PENDING',
11
+ `code` varchar(255) NOT NULL,
12
+ `score` float DEFAULT NULL,
13
+ `guarantee` VARCHAR( 64 ) NOT NULL DEFAULT 'N/A',
14
+ `entries` text NOT NULL,
15
+ `transaction_id` varchar(64) NULL,
16
+ `created` timestamp NULL DEFAULT NULL,
17
+ `updated` timestamp NULL DEFAULT NULL,
18
+ PRIMARY KEY (`order_increment`)
19
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
20
+ CREATE TABLE IF NOT EXISTS `{$this->getTable('signifyd_connect_retries')}` (
21
+ `order_increment` varchar(255) NOT NULL,
22
+ `created` timestamp NULL DEFAULT NULL,
23
+ PRIMARY KEY (`order_increment`)
24
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
25
+ ");
26
+ $this->endSetup();
app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-install-3.3.0.php CHANGED
@@ -1,19 +1,19 @@
1
- <?php
2
-
3
- $this->startSetup();
4
- $this->register();
5
- $this->run("
6
- DROP TABLE IF EXISTS `{$this->getTable('signifyd_connect_case')}`;
7
- CREATE TABLE IF NOT EXISTS `{$this->getTable('signifyd_connect_case')}` (
8
- `case_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
9
- `order_increment` varchar(255) NOT NULL,
10
- `signifyd_status` varchar(64) NOT NULL DEFAULT 'PENDING',
11
- `code` varchar(255) NOT NULL,
12
- `score` float DEFAULT NULL,
13
- `entries` text NOT NULL,
14
- `created_at` timestamp NULL DEFAULT NULL,
15
- `updated_at` timestamp NULL DEFAULT NULL,
16
- PRIMARY KEY (`case_id`)
17
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=8 ;
18
- ");
19
- $this->endSetup();
1
+ <?php
2
+
3
+ $this->startSetup();
4
+ $this->register();
5
+ $this->run("
6
+ DROP TABLE IF EXISTS `{$this->getTable('signifyd_connect_case')}`;
7
+ CREATE TABLE IF NOT EXISTS `{$this->getTable('signifyd_connect_case')}` (
8
+ `case_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
9
+ `order_increment` varchar(255) NOT NULL,
10
+ `signifyd_status` varchar(64) NOT NULL DEFAULT 'PENDING',
11
+ `code` varchar(255) NOT NULL,
12
+ `score` float DEFAULT NULL,
13
+ `entries` text NOT NULL,
14
+ `created_at` timestamp NULL DEFAULT NULL,
15
+ `updated_at` timestamp NULL DEFAULT NULL,
16
+ PRIMARY KEY (`case_id`)
17
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=8 ;
18
+ ");
19
+ $this->endSetup();
app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-install-3.4.0.php CHANGED
@@ -1,21 +1,21 @@
1
- <?php
2
-
3
- $this->startSetup();
4
- $this->register();
5
- $this->run("
6
- DROP TABLE IF EXISTS `{$this->getTable('signifyd_connect_case')}`;
7
- CREATE TABLE IF NOT EXISTS `{$this->getTable('signifyd_connect_case')}` (
8
- `case_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
9
- `order_increment` varchar(255) NOT NULL,
10
- `signifyd_status` varchar(64) NOT NULL DEFAULT 'PENDING',
11
- `code` varchar(255) NOT NULL,
12
- `score` float DEFAULT NULL,
13
- `entries` text NOT NULL,
14
- `created_at` timestamp NULL DEFAULT NULL,
15
- `updated_at` timestamp NULL DEFAULT NULL,
16
- PRIMARY KEY (`case_id`)
17
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=8 ;
18
-
19
- CREATE INDEX signifyd_connect_case_order ON `{$this->getTable('signifyd_connect_case')}` (order_increment);
20
- ");
21
- $this->endSetup();
1
+ <?php
2
+
3
+ $this->startSetup();
4
+ $this->register();
5
+ $this->run("
6
+ DROP TABLE IF EXISTS `{$this->getTable('signifyd_connect_case')}`;
7
+ CREATE TABLE IF NOT EXISTS `{$this->getTable('signifyd_connect_case')}` (
8
+ `case_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
9
+ `order_increment` varchar(255) NOT NULL,
10
+ `signifyd_status` varchar(64) NOT NULL DEFAULT 'PENDING',
11
+ `code` varchar(255) NOT NULL,
12
+ `score` float DEFAULT NULL,
13
+ `entries` text NOT NULL,
14
+ `created_at` timestamp NULL DEFAULT NULL,
15
+ `updated_at` timestamp NULL DEFAULT NULL,
16
+ PRIMARY KEY (`case_id`)
17
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=8 ;
18
+
19
+ CREATE INDEX signifyd_connect_case_order ON `{$this->getTable('signifyd_connect_case')}` (order_increment);
20
+ ");
21
+ $this->endSetup();
app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-install-3.4.5.php CHANGED
@@ -1,21 +1,21 @@
1
- <?php
2
-
3
- $this->startSetup();
4
- $this->register();
5
- $this->run("
6
- DROP TABLE IF EXISTS `{$this->getTable('signifyd_connect_case')}`;
7
- CREATE TABLE IF NOT EXISTS `{$this->getTable('signifyd_connect_case')}` (
8
- `case_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
9
- `order_increment` varchar(255) NOT NULL,
10
- `signifyd_status` varchar(64) NOT NULL DEFAULT 'PENDING',
11
- `code` varchar(255) NOT NULL,
12
- `score` float DEFAULT NULL,
13
- `entries` text NOT NULL,
14
- `created` timestamp NULL DEFAULT NULL,
15
- `updated` timestamp NULL DEFAULT NULL,
16
- PRIMARY KEY (`case_id`)
17
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=8 ;
18
-
19
- CREATE INDEX signifyd_connect_case_order ON `{$this->getTable('signifyd_connect_case')}` (order_increment);
20
- ");
21
- $this->endSetup();
1
+ <?php
2
+
3
+ $this->startSetup();
4
+ $this->register();
5
+ $this->run("
6
+ DROP TABLE IF EXISTS `{$this->getTable('signifyd_connect_case')}`;
7
+ CREATE TABLE IF NOT EXISTS `{$this->getTable('signifyd_connect_case')}` (
8
+ `case_id` int(10) unsigned NOT NULL AUTO_INCREMENT,
9
+ `order_increment` varchar(255) NOT NULL,
10
+ `signifyd_status` varchar(64) NOT NULL DEFAULT 'PENDING',
11
+ `code` varchar(255) NOT NULL,
12
+ `score` float DEFAULT NULL,
13
+ `entries` text NOT NULL,
14
+ `created` timestamp NULL DEFAULT NULL,
15
+ `updated` timestamp NULL DEFAULT NULL,
16
+ PRIMARY KEY (`case_id`)
17
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 AUTO_INCREMENT=8 ;
18
+
19
+ CREATE INDEX signifyd_connect_case_order ON `{$this->getTable('signifyd_connect_case')}` (order_increment);
20
+ ");
21
+ $this->endSetup();
app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-install-3.7.0.php CHANGED
@@ -1,18 +1,18 @@
1
- <?php
2
-
3
- $this->startSetup();
4
- $this->register();
5
- $this->run("
6
- DROP TABLE IF EXISTS `{$this->getTable('signifyd_connect_case')}`;
7
- CREATE TABLE IF NOT EXISTS `{$this->getTable('signifyd_connect_case')}` (
8
- `order_increment` varchar(255) NOT NULL,
9
- `signifyd_status` varchar(64) NOT NULL DEFAULT 'PENDING',
10
- `code` varchar(255) NOT NULL,
11
- `score` float DEFAULT NULL,
12
- `entries` text NOT NULL,
13
- `created` timestamp NULL DEFAULT NULL,
14
- `updated` timestamp NULL DEFAULT NULL,
15
- PRIMARY KEY (`order_increment`)
16
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
17
- ");
18
- $this->endSetup();
1
+ <?php
2
+
3
+ $this->startSetup();
4
+ $this->register();
5
+ $this->run("
6
+ DROP TABLE IF EXISTS `{$this->getTable('signifyd_connect_case')}`;
7
+ CREATE TABLE IF NOT EXISTS `{$this->getTable('signifyd_connect_case')}` (
8
+ `order_increment` varchar(255) NOT NULL,
9
+ `signifyd_status` varchar(64) NOT NULL DEFAULT 'PENDING',
10
+ `code` varchar(255) NOT NULL,
11
+ `score` float DEFAULT NULL,
12
+ `entries` text NOT NULL,
13
+ `created` timestamp NULL DEFAULT NULL,
14
+ `updated` timestamp NULL DEFAULT NULL,
15
+ PRIMARY KEY (`order_increment`)
16
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
17
+ ");
18
+ $this->endSetup();
app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-install-3.8.0.php CHANGED
@@ -1,19 +1,19 @@
1
- <?php
2
-
3
- $this->startSetup();
4
- $this->register();
5
- $this->run("
6
- DROP TABLE IF EXISTS `{$this->getTable('signifyd_connect_case')}`;
7
- CREATE TABLE IF NOT EXISTS `{$this->getTable('signifyd_connect_case')}` (
8
- `order_increment` varchar(255) NOT NULL,
9
- `signifyd_status` varchar(64) NOT NULL DEFAULT 'PENDING',
10
- `code` varchar(255) NOT NULL,
11
- `score` float DEFAULT NULL,
12
- `guarantee` VARCHAR( 64 ) NOT NULL DEFAULT 'N/A',
13
- `entries` text NOT NULL,
14
- `created` timestamp NULL DEFAULT NULL,
15
- `updated` timestamp NULL DEFAULT NULL,
16
- PRIMARY KEY (`order_increment`)
17
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
18
- ");
19
- $this->endSetup();
1
+ <?php
2
+
3
+ $this->startSetup();
4
+ $this->register();
5
+ $this->run("
6
+ DROP TABLE IF EXISTS `{$this->getTable('signifyd_connect_case')}`;
7
+ CREATE TABLE IF NOT EXISTS `{$this->getTable('signifyd_connect_case')}` (
8
+ `order_increment` varchar(255) NOT NULL,
9
+ `signifyd_status` varchar(64) NOT NULL DEFAULT 'PENDING',
10
+ `code` varchar(255) NOT NULL,
11
+ `score` float DEFAULT NULL,
12
+ `guarantee` VARCHAR( 64 ) NOT NULL DEFAULT 'N/A',
13
+ `entries` text NOT NULL,
14
+ `created` timestamp NULL DEFAULT NULL,
15
+ `updated` timestamp NULL DEFAULT NULL,
16
+ PRIMARY KEY (`order_increment`)
17
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
18
+ ");
19
+ $this->endSetup();
app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.10.0-3.10.1.php CHANGED
@@ -1,8 +1,8 @@
1
- <?php
2
-
3
- try {
4
- $this->startSetup();
5
- $this->endSetup();
6
- } catch (Exception $e) {
7
- Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
8
- }
1
+ <?php
2
+
3
+ try {
4
+ $this->startSetup();
5
+ $this->endSetup();
6
+ } catch (Exception $e) {
7
+ Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
8
+ }
app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.10.1-3.11.0.php CHANGED
@@ -1,8 +1,8 @@
1
- <?php
2
-
3
- try {
4
- $this->startSetup();
5
- $this->endSetup();
6
- } catch (Exception $e) {
7
- Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
8
- }
1
+ <?php
2
+
3
+ try {
4
+ $this->startSetup();
5
+ $this->endSetup();
6
+ } catch (Exception $e) {
7
+ Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
8
+ }
app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.11.0-3.11.1.php CHANGED
@@ -1,8 +1,8 @@
1
- <?php
2
-
3
- try {
4
- $this->startSetup();
5
- $this->endSetup();
6
- } catch (Exception $e) {
7
- Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
8
- }
1
+ <?php
2
+
3
+ try {
4
+ $this->startSetup();
5
+ $this->endSetup();
6
+ } catch (Exception $e) {
7
+ Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
8
+ }
app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.11.1-3.12.0.php CHANGED
@@ -1,17 +1,17 @@
1
- <?php
2
-
3
- try {
4
- $this->startSetup();
5
- $this->run("
6
- ALTER TABLE `{$this->getTable('signifyd_connect_case')}` ADD `transaction_id` VARCHAR(64) NULL;
7
-
8
- CREATE TABLE IF NOT EXISTS `{$this->getTable('signifyd_connect_retries')}` (
9
- `order_increment` varchar(255) NOT NULL,
10
- `created` timestamp NULL DEFAULT NULL,
11
- PRIMARY KEY (`order_increment`)
12
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
13
- ");
14
- $this->endSetup();
15
- } catch (Exception $e) {
16
- Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
17
- }
1
+ <?php
2
+
3
+ try {
4
+ $this->startSetup();
5
+ $this->run("
6
+ ALTER TABLE `{$this->getTable('signifyd_connect_case')}` ADD `transaction_id` VARCHAR(64) NULL;
7
+
8
+ CREATE TABLE IF NOT EXISTS `{$this->getTable('signifyd_connect_retries')}` (
9
+ `order_increment` varchar(255) NOT NULL,
10
+ `created` timestamp NULL DEFAULT NULL,
11
+ PRIMARY KEY (`order_increment`)
12
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
13
+ ");
14
+ $this->endSetup();
15
+ } catch (Exception $e) {
16
+ Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
17
+ }
app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.12.0-3.13.0.php CHANGED
@@ -1,15 +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
- }
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
+ }
app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.14.0-3.15.0.php ADDED
@@ -0,0 +1,10 @@
 
 
 
 
 
 
 
 
 
 
1
+ <?php
2
+
3
+ try {
4
+ $this->startSetup();
5
+ $this->register();
6
+ $this->run("ALTER TABLE `{$this->getTable('signifyd_connect_case')}` ADD `magento_status` VARCHAR( 64 ) NOT NULL DEFAULT 'waiting_submission'");
7
+ $this->endSetup();
8
+ } catch (Exception $e) {
9
+ Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
10
+ }
app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.2.0-3.2.1.php CHANGED
@@ -1,5 +1,5 @@
1
- <?php
2
-
3
- $this->startSetup();
4
- Mage::getConfig()->saveConfig('signifyd_connect/settings/url', "https://api.signifyd.com/v2", 'default', 0);
5
- $this->endSetup();
1
+ <?php
2
+
3
+ $this->startSetup();
4
+ Mage::getConfig()->saveConfig('signifyd_connect/settings/url', "https://api.signifyd.com/v2", 'default', 0);
5
+ $this->endSetup();
app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.2.1-3.2.2.php CHANGED
@@ -1,17 +1,17 @@
1
- <?php
2
-
3
- try {
4
- $this->startSetup();
5
- $this->register();
6
- $this->run("
7
- ALTER TABLE `{$this->getTable('signifyd_connect_case')}` ADD `status` VARCHAR( 64 ) NOT NULL DEFAULT 'PENDING',
8
- ADD `code` varchar(255) NOT NULL,
9
- ADD `score` FLOAT NULL DEFAULT NULL ,
10
- ADD `entries` TEXT NOT NULL ,
11
- ADD `created_at` TIMESTAMP NULL DEFAULT NULL ,
12
- ADD `updated_at` TIMESTAMP NULL DEFAULT NULL ;
13
- ");
14
- $this->endSetup();
15
- } catch (Exception $e) {
16
- Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
17
- }
1
+ <?php
2
+
3
+ try {
4
+ $this->startSetup();
5
+ $this->register();
6
+ $this->run("
7
+ ALTER TABLE `{$this->getTable('signifyd_connect_case')}` ADD `status` VARCHAR( 64 ) NOT NULL DEFAULT 'PENDING',
8
+ ADD `code` varchar(255) NOT NULL,
9
+ ADD `score` FLOAT NULL DEFAULT NULL ,
10
+ ADD `entries` TEXT NOT NULL ,
11
+ ADD `created_at` TIMESTAMP NULL DEFAULT NULL ,
12
+ ADD `updated_at` TIMESTAMP NULL DEFAULT NULL ;
13
+ ");
14
+ $this->endSetup();
15
+ } catch (Exception $e) {
16
+ Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
17
+ }
app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.2.2-3.2.3.php CHANGED
@@ -1,8 +1,8 @@
1
- <?php
2
-
3
- try {
4
- $this->startSetup();
5
- $this->endSetup();
6
- } catch (Exception $e) {
7
- Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
8
- }
1
+ <?php
2
+
3
+ try {
4
+ $this->startSetup();
5
+ $this->endSetup();
6
+ } catch (Exception $e) {
7
+ Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
8
+ }
app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.2.3-3.3.0.php CHANGED
@@ -1,10 +1,10 @@
1
- <?php
2
-
3
- try {
4
- $this->startSetup();
5
- $this->register();
6
- $this->run("ALTER TABLE `{$this->getTable('signifyd_connect_case')}` CHANGE `status` `signifyd_status` VARCHAR( 64 ) NOT NULL DEFAULT 'PENDING'");
7
- $this->endSetup();
8
- } catch (Exception $e) {
9
- Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
10
- }
1
+ <?php
2
+
3
+ try {
4
+ $this->startSetup();
5
+ $this->register();
6
+ $this->run("ALTER TABLE `{$this->getTable('signifyd_connect_case')}` CHANGE `status` `signifyd_status` VARCHAR( 64 ) NOT NULL DEFAULT 'PENDING'");
7
+ $this->endSetup();
8
+ } catch (Exception $e) {
9
+ Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
10
+ }
app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.3.0-3.4.0.php CHANGED
@@ -1,11 +1,11 @@
1
- <?php
2
-
3
- try {
4
- $this->startSetup();
5
- $this->register();
6
- $this->checkColumns();
7
- $this->run("ALTER TABLE `{$this->getTable('signifyd_connect_case')}` ADD INDEX ( `order_increment` );");
8
- $this->endSetup();
9
- } catch (Exception $e) {
10
- Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
11
- }
1
+ <?php
2
+
3
+ try {
4
+ $this->startSetup();
5
+ $this->register();
6
+ $this->checkColumns();
7
+ $this->run("ALTER TABLE `{$this->getTable('signifyd_connect_case')}` ADD INDEX ( `order_increment` );");
8
+ $this->endSetup();
9
+ } catch (Exception $e) {
10
+ Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
11
+ }
app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.4.0-3.4.1.php CHANGED
@@ -1,10 +1,10 @@
1
- <?php
2
-
3
- try {
4
- $this->startSetup();
5
- $this->register();
6
- $this->checkColumns();
7
- $this->endSetup();
8
- } catch (Exception $e) {
9
- Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
10
- }
1
+ <?php
2
+
3
+ try {
4
+ $this->startSetup();
5
+ $this->register();
6
+ $this->checkColumns();
7
+ $this->endSetup();
8
+ } catch (Exception $e) {
9
+ Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
10
+ }
app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.4.1-3.4.2.php CHANGED
@@ -1,8 +1,8 @@
1
- <?php
2
-
3
- try {
4
- $this->startSetup();
5
- $this->endSetup();
6
- } catch (Exception $e) {
7
- Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
8
- }
1
+ <?php
2
+
3
+ try {
4
+ $this->startSetup();
5
+ $this->endSetup();
6
+ } catch (Exception $e) {
7
+ Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
8
+ }
app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.4.2-3.4.3.php CHANGED
@@ -1,8 +1,8 @@
1
- <?php
2
-
3
- try {
4
- $this->startSetup();
5
- $this->endSetup();
6
- } catch (Exception $e) {
7
- Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
8
- }
1
+ <?php
2
+
3
+ try {
4
+ $this->startSetup();
5
+ $this->endSetup();
6
+ } catch (Exception $e) {
7
+ Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
8
+ }
app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.4.3-3.4.4.php CHANGED
@@ -1,8 +1,8 @@
1
- <?php
2
-
3
- try {
4
- $this->startSetup();
5
- $this->endSetup();
6
- } catch (Exception $e) {
7
- Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
8
- }
1
+ <?php
2
+
3
+ try {
4
+ $this->startSetup();
5
+ $this->endSetup();
6
+ } catch (Exception $e) {
7
+ Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
8
+ }
app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.4.4-3.4.5.php CHANGED
@@ -1,13 +1,13 @@
1
- <?php
2
-
3
- try {
4
- $this->startSetup();
5
- $this->run("ALTER TABLE `{$this->getTable('signifyd_connect_case')}` CHANGE `created_at` `created` timestamp NULL DEFAULT NULL");
6
- $this->run("ALTER TABLE `{$this->getTable('signifyd_connect_case')}` CHANGE `updated_at` `updated` timestamp NULL DEFAULT NULL");
7
- Mage::getConfig()->saveConfig('signifyd_connect/advanced/retrieve_score', 0, 'default', 0);
8
- Mage::getConfig()->saveConfig('signifyd_connect/advanced/show_scores', 0, 'default', 0);
9
- Mage::getConfig()->saveConfig('signifyd_connect/advanced/hold_orders', 0, 'default', 0);
10
- $this->endSetup();
11
- } catch (Exception $e) {
12
- Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
13
- }
1
+ <?php
2
+
3
+ try {
4
+ $this->startSetup();
5
+ $this->run("ALTER TABLE `{$this->getTable('signifyd_connect_case')}` CHANGE `created_at` `created` timestamp NULL DEFAULT NULL");
6
+ $this->run("ALTER TABLE `{$this->getTable('signifyd_connect_case')}` CHANGE `updated_at` `updated` timestamp NULL DEFAULT NULL");
7
+ Mage::getConfig()->saveConfig('signifyd_connect/advanced/retrieve_score', 0, 'default', 0);
8
+ Mage::getConfig()->saveConfig('signifyd_connect/advanced/show_scores', 0, 'default', 0);
9
+ Mage::getConfig()->saveConfig('signifyd_connect/advanced/hold_orders', 0, 'default', 0);
10
+ $this->endSetup();
11
+ } catch (Exception $e) {
12
+ Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
13
+ }
app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.4.5-3.4.6.php CHANGED
@@ -1,8 +1,8 @@
1
- <?php
2
-
3
- try {
4
- $this->startSetup();
5
- $this->endSetup();
6
- } catch (Exception $e) {
7
- Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
8
- }
1
+ <?php
2
+
3
+ try {
4
+ $this->startSetup();
5
+ $this->endSetup();
6
+ } catch (Exception $e) {
7
+ Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
8
+ }
app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.4.6-3.4.7.php CHANGED
@@ -1,8 +1,8 @@
1
- <?php
2
-
3
- try {
4
- $this->startSetup();
5
- $this->endSetup();
6
- } catch (Exception $e) {
7
- Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
8
- }
1
+ <?php
2
+
3
+ try {
4
+ $this->startSetup();
5
+ $this->endSetup();
6
+ } catch (Exception $e) {
7
+ Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
8
+ }
app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.4.7-3.4.8.php CHANGED
@@ -1,8 +1,8 @@
1
- <?php
2
-
3
- try {
4
- $this->startSetup();
5
- $this->endSetup();
6
- } catch (Exception $e) {
7
- Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
8
- }
1
+ <?php
2
+
3
+ try {
4
+ $this->startSetup();
5
+ $this->endSetup();
6
+ } catch (Exception $e) {
7
+ Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
8
+ }
app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.4.8-3.5.0.php CHANGED
@@ -1,8 +1,8 @@
1
- <?php
2
-
3
- try {
4
- $this->startSetup();
5
- $this->endSetup();
6
- } catch (Exception $e) {
7
- Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
8
- }
1
+ <?php
2
+
3
+ try {
4
+ $this->startSetup();
5
+ $this->endSetup();
6
+ } catch (Exception $e) {
7
+ Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
8
+ }
app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.5.0-3.5.1.php CHANGED
@@ -1,8 +1,8 @@
1
- <?php
2
-
3
- try {
4
- $this->startSetup();
5
- $this->endSetup();
6
- } catch (Exception $e) {
7
- Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
8
- }
1
+ <?php
2
+
3
+ try {
4
+ $this->startSetup();
5
+ $this->endSetup();
6
+ } catch (Exception $e) {
7
+ Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
8
+ }
app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.5.1-3.5.2.php CHANGED
@@ -1,8 +1,8 @@
1
- <?php
2
-
3
- try {
4
- $this->startSetup();
5
- $this->endSetup();
6
- } catch (Exception $e) {
7
- Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
8
- }
1
+ <?php
2
+
3
+ try {
4
+ $this->startSetup();
5
+ $this->endSetup();
6
+ } catch (Exception $e) {
7
+ Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
8
+ }
app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.5.2-3.5.3.php CHANGED
@@ -1,8 +1,8 @@
1
- <?php
2
-
3
- try {
4
- $this->startSetup();
5
- $this->endSetup();
6
- } catch (Exception $e) {
7
- Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
8
- }
1
+ <?php
2
+
3
+ try {
4
+ $this->startSetup();
5
+ $this->endSetup();
6
+ } catch (Exception $e) {
7
+ Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
8
+ }
app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.5.3-3.6.0.php CHANGED
@@ -1,8 +1,8 @@
1
- <?php
2
-
3
- try {
4
- $this->startSetup();
5
- $this->endSetup();
6
- } catch (Exception $e) {
7
- Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
8
- }
1
+ <?php
2
+
3
+ try {
4
+ $this->startSetup();
5
+ $this->endSetup();
6
+ } catch (Exception $e) {
7
+ Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
8
+ }
app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.6.0-3.7.0.php CHANGED
@@ -1,31 +1,31 @@
1
- <?php
2
-
3
- try {
4
- $this->startSetup();
5
- $this->run("ALTER TABLE `{$this->getTable('signifyd_connect_case')}` RENAME TO temp_signifyd;");
6
- $this->run("
7
- CREATE TABLE `{$this->getTable('signifyd_connect_case')}` (
8
- `order_increment` varchar(255) NOT NULL,
9
- `signifyd_status` varchar(64) NOT NULL DEFAULT 'PENDING',
10
- `code` varchar(255) NOT NULL,
11
- `score` float DEFAULT NULL,
12
- `entries` text NOT NULL,
13
- `created` timestamp NULL DEFAULT NULL,
14
- `updated` timestamp NULL DEFAULT NULL,
15
- PRIMARY KEY (`order_increment`)
16
- ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
17
- ");
18
- $this->run("
19
- INSERT INTO `{$this->getTable('signifyd_connect_case')}` (`order_increment`, `signifyd_status`, `code`, `score`, `entries`,
20
- `created`, `updated`)
21
- SELECT `order_increment`, `signifyd_status`, `code`, `score`, `entries`,
22
- MIN(`created`) as `created`, MAX(`updated`) as `updated`
23
- FROM (SELECT `order_increment`, `signifyd_status`, `code`, `score`, `entries`,
24
- `created`, `updated` FROM temp_signifyd ORDER BY updated DESC) as temp_by_updated
25
- GROUP BY `order_increment`;
26
- ");
27
- $this->run("DROP TABLE temp_signifyd");
28
- $this->endSetup();
29
- } catch (Exception $e) {
30
- Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
31
- }
1
+ <?php
2
+
3
+ try {
4
+ $this->startSetup();
5
+ $this->run("ALTER TABLE `{$this->getTable('signifyd_connect_case')}` RENAME TO temp_signifyd;");
6
+ $this->run("
7
+ CREATE TABLE `{$this->getTable('signifyd_connect_case')}` (
8
+ `order_increment` varchar(255) NOT NULL,
9
+ `signifyd_status` varchar(64) NOT NULL DEFAULT 'PENDING',
10
+ `code` varchar(255) NOT NULL,
11
+ `score` float DEFAULT NULL,
12
+ `entries` text NOT NULL,
13
+ `created` timestamp NULL DEFAULT NULL,
14
+ `updated` timestamp NULL DEFAULT NULL,
15
+ PRIMARY KEY (`order_increment`)
16
+ ) ENGINE=InnoDB DEFAULT CHARSET=utf8 ;
17
+ ");
18
+ $this->run("
19
+ INSERT INTO `{$this->getTable('signifyd_connect_case')}` (`order_increment`, `signifyd_status`, `code`, `score`, `entries`,
20
+ `created`, `updated`)
21
+ SELECT `order_increment`, `signifyd_status`, `code`, `score`, `entries`,
22
+ MIN(`created`) as `created`, MAX(`updated`) as `updated`
23
+ FROM (SELECT `order_increment`, `signifyd_status`, `code`, `score`, `entries`,
24
+ `created`, `updated` FROM temp_signifyd ORDER BY updated DESC) as temp_by_updated
25
+ GROUP BY `order_increment`;
26
+ ");
27
+ $this->run("DROP TABLE temp_signifyd");
28
+ $this->endSetup();
29
+ } catch (Exception $e) {
30
+ Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
31
+ }
app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.7.0-3.8.0.php CHANGED
@@ -1,10 +1,10 @@
1
- <?php
2
-
3
- try {
4
- $this->startSetup();
5
- $this->register();
6
- $this->run("ALTER TABLE `{$this->getTable('signifyd_connect_case')}` ADD `guarantee` VARCHAR( 64 ) NOT NULL DEFAULT 'N/A'");
7
- $this->endSetup();
8
- } catch (Exception $e) {
9
- Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
10
- }
1
+ <?php
2
+
3
+ try {
4
+ $this->startSetup();
5
+ $this->register();
6
+ $this->run("ALTER TABLE `{$this->getTable('signifyd_connect_case')}` ADD `guarantee` VARCHAR( 64 ) NOT NULL DEFAULT 'N/A'");
7
+ $this->endSetup();
8
+ } catch (Exception $e) {
9
+ Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
10
+ }
app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.8.0-3.9.0.php CHANGED
@@ -1,8 +1,8 @@
1
- <?php
2
-
3
- try {
4
- $this->startSetup();
5
- $this->endSetup();
6
- } catch (Exception $e) {
7
- Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
8
- }
1
+ <?php
2
+
3
+ try {
4
+ $this->startSetup();
5
+ $this->endSetup();
6
+ } catch (Exception $e) {
7
+ Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
8
+ }
app/code/community/Signifyd/Connect/sql/signifyd_connect_setup/mysql4-upgrade-3.9.0-3.10.0.php CHANGED
@@ -1,8 +1,8 @@
1
- <?php
2
-
3
- try {
4
- $this->startSetup();
5
- $this->endSetup();
6
- } catch (Exception $e) {
7
- Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
8
- }
1
+ <?php
2
+
3
+ try {
4
+ $this->startSetup();
5
+ $this->endSetup();
6
+ } catch (Exception $e) {
7
+ Mage::log('Signifyd_Connect upgrade: ' . $e->__toString(), null, 'signifyd_connect.log');
8
+ }
app/etc/modules/Signifyd_Connect.xml CHANGED
@@ -1,9 +1,9 @@
1
- <?xml version="1.0"?>
2
- <config>
3
- <modules>
4
- <Signifyd_Connect>
5
- <active>true</active>
6
- <codePool>community</codePool>
7
- </Signifyd_Connect>
8
- </modules>
9
- </config>
1
+ <?xml version="1.0"?>
2
+ <config>
3
+ <modules>
4
+ <Signifyd_Connect>
5
+ <active>true</active>
6
+ <codePool>community</codePool>
7
+ </Signifyd_Connect>
8
+ </modules>
9
+ </config>
package.xml CHANGED
@@ -1,7 +1,7 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Signifyd_Connect</name>
4
- <version>3.13.1</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
7
  <channel>community</channel>
@@ -9,10 +9,10 @@
9
  <summary>Signifyd protects e-commerce merchants from fraudulent buyers.</summary>
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-19</date>
14
- <time>13:34:26</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="9f58af2735daff8e4908de4f26ed32bc"/></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="5e65612906ecaac69aaea8183762a979"/><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="8d521e6b99ae4c251fba6911a98bdefa"/></dir><dir name="etc"><file name="adminhtml.xml" hash="894bd3f5ac76e9f602ab6ab592648b03"/><file name="config.xml" hash="4c5eb9c0748016fa6e1a0fc868985cee"/><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>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Signifyd_Connect</name>
4
+ <version>3.15.0</version>
5
  <stability>stable</stability>
6
  <license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
7
  <channel>community</channel>
9
  <summary>Signifyd protects e-commerce merchants from fraudulent buyers.</summary>
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-09-07</date>
14
+ <time>12:07:40</time>
15
+ <contents><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="eed53eab290b65da639e22fe195f9fcb"/></dir><file name="Order.php" hash="89619b9c5c9795e98e7637b4c5396888"/></dir></dir><file name="Renderer.php" hash="dce3cc400745afa31806e7de6dbf9d02"/><file name="Url.php" hash="dbe3e967879a69a2c943056f820e4688"/></dir><dir name="Helper"><file name="Data.php" hash="e4584d73cb17e75f871759c47daabb53"/><file name="Log.php" hash="96f1286eb9c273f637178ffd94a04d42"/></dir><dir name="Model"><file name="Authnet.php" hash="876c96e26693d26adf194e889c1a802e"/><file name="Case.php" hash="db5387f02172996e6ee83b00a687820f"/><file name="Cron.php" hash="fddfc61904a2d844c35a78593a6712b8"/><file name="Link.php" hash="989876b57bd340597372e20570086abe"/><file name="Observer.php" hash="46b0b3d8908ce19f81bd9f381b14d96c"/><dir name="Order"><file name="Payment.php" hash="a0ad3107170b7bae94b8402960b5cf48"/></dir><file name="Order.php" hash="9c7a8fa528a95fbcf42b7231909a4496"/><dir name="Resource"><dir name="Case"><file name="Collection.php" hash="a1ed45e9bde8f823384009c6d1a6be64"/></dir><file name="Case.php" hash="19ae43ac4339a6efa4c5399b7524c61a"/><dir name="Retries"><file name="Collection.php" hash="04e0aa690b9887b7c24c48c92adc62b5"/></dir><file name="Retries.php" hash="ab59ce50d0b089a0b001250d49377719"/></dir><file name="Retries.php" hash="3a945234c76244d2d8cccf8a2b67309c"/><file name="Setup.php" hash="89df3e016fa0a582f9eb94c55dee1ede"/><dir name="System"><dir name="Config"><dir name="Source"><dir name="Options"><file name="Accepted.php" hash="1dcb358d451c75f297921bbf84e9bd3b"/><file name="Declined.php" hash="ed2441579a7bad4e7505a6f0a3f530ac"/></dir></dir></dir></dir></dir><dir name="controllers"><dir name="Adminhtml"><file name="SignifydController.php" hash="145877221ca9e5b0fd3adbefb1b42315"/></dir><file name="ConnectController.php" hash="c3eed72ff1b813ffda0b4ac69c11271f"/></dir><dir name="etc"><file name="adminhtml.xml" hash="bfe6943cf5eab707f64694f555b9f2c1"/><file name="config.xml" hash="266f892e6d108970a9be55a9577df1d0"/><file name="system.xml" hash="bc12ac0cc5f189d95b2127e2414a25a4"/></dir><dir name="sql"><dir name="signifyd_connect_setup"><file name="mysql4-install-3.1.1.php" hash="119e423f67c7e47c345374eddbb1dfe5"/><file name="mysql4-install-3.12.0.php" hash="3dd59c1e20105629157dfe134193dcb9"/><file name="mysql4-install-3.3.0.php" hash="455c92d22c1e5c55661f050ca19f82f6"/><file name="mysql4-install-3.4.0.php" hash="383226cc656aa9e0db194178be7dfc10"/><file name="mysql4-install-3.4.5.php" hash="f8eaec5f235b7bb16777720e0e999268"/><file name="mysql4-install-3.7.0.php" hash="cdc3701ad0793bc360addfec51466605"/><file name="mysql4-install-3.8.0.php" hash="f74e65329444df9b088c00d5837f4593"/><file name="mysql4-upgrade-3.10.0-3.10.1.php" hash="51c0d94a292f36f373d1a14eb1ce6468"/><file name="mysql4-upgrade-3.10.1-3.11.0.php" hash="51c0d94a292f36f373d1a14eb1ce6468"/><file name="mysql4-upgrade-3.11.0-3.11.1.php" hash="51c0d94a292f36f373d1a14eb1ce6468"/><file name="mysql4-upgrade-3.11.1-3.12.0.php" hash="703ddd745468f40c75758cd8066d63fe"/><file name="mysql4-upgrade-3.12.0-3.13.0.php" hash="333f7116c34aa765f4e7efaf8be5feda"/><file name="mysql4-upgrade-3.14.0-3.15.0.php" hash="7cde716fe0e3e849c1f82bbd7bf8ec3a"/><file name="mysql4-upgrade-3.2.0-3.2.1.php" hash="26f702c9c4d38873e0050657b003ffd4"/><file name="mysql4-upgrade-3.2.1-3.2.2.php" hash="4a5fe35d03268d0a8448a1accaf64958"/><file name="mysql4-upgrade-3.2.2-3.2.3.php" hash="51c0d94a292f36f373d1a14eb1ce6468"/><file name="mysql4-upgrade-3.2.3-3.3.0.php" hash="7b5c5ae2ac87cc7fef2ac99bc28b27ae"/><file name="mysql4-upgrade-3.3.0-3.4.0.php" hash="8faecf3097eaf538fece8fe91b575356"/><file name="mysql4-upgrade-3.4.0-3.4.1.php" hash="11ad4be0af110283e2ce34b1315721f1"/><file name="mysql4-upgrade-3.4.1-3.4.2.php" hash="51c0d94a292f36f373d1a14eb1ce6468"/><file name="mysql4-upgrade-3.4.2-3.4.3.php" hash="51c0d94a292f36f373d1a14eb1ce6468"/><file name="mysql4-upgrade-3.4.3-3.4.4.php" hash="51c0d94a292f36f373d1a14eb1ce6468"/><file name="mysql4-upgrade-3.4.4-3.4.5.php" hash="5320d366b6f72258f4e27a046ba04c3c"/><file name="mysql4-upgrade-3.4.5-3.4.6.php" hash="51c0d94a292f36f373d1a14eb1ce6468"/><file name="mysql4-upgrade-3.4.6-3.4.7.php" hash="51c0d94a292f36f373d1a14eb1ce6468"/><file name="mysql4-upgrade-3.4.7-3.4.8.php" hash="51c0d94a292f36f373d1a14eb1ce6468"/><file name="mysql4-upgrade-3.4.8-3.5.0.php" hash="51c0d94a292f36f373d1a14eb1ce6468"/><file name="mysql4-upgrade-3.5.0-3.5.1.php" hash="51c0d94a292f36f373d1a14eb1ce6468"/><file name="mysql4-upgrade-3.5.1-3.5.2.php" hash="51c0d94a292f36f373d1a14eb1ce6468"/><file name="mysql4-upgrade-3.5.2-3.5.3.php" hash="51c0d94a292f36f373d1a14eb1ce6468"/><file name="mysql4-upgrade-3.5.3-3.6.0.php" hash="51c0d94a292f36f373d1a14eb1ce6468"/><file name="mysql4-upgrade-3.6.0-3.7.0.php" hash="1462d8ccaf0d0480d31a47afb3a00f63"/><file name="mysql4-upgrade-3.7.0-3.8.0.php" hash="758799806d039277d8d509e017c64535"/><file name="mysql4-upgrade-3.8.0-3.9.0.php" hash="51c0d94a292f36f373d1a14eb1ce6468"/><file name="mysql4-upgrade-3.9.0-3.10.0.php" hash="51c0d94a292f36f373d1a14eb1ce6468"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Signifyd_Connect.xml" hash="0f6a1fe90c078db114746aa381208982"/></dir></target></contents>
16
  <compatible/>
17
+ <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>