Hexasoft_FraudLabsPro - Version 1.1.0

Version Notes

Added custom action for review and rejected transactions.

Download this release

Release Info

Developer Hexasoft
Extension Hexasoft_FraudLabsPro
Version 1.1.0
Comparing to
See all releases


Code changes from version 1.0.11 to 1.1.0

app/code/local/Hexasoft/FraudLabsPro/Controller/Observer.php CHANGED
@@ -38,9 +38,16 @@ class Hexasoft_FraudLabsPro_Controller_Observer{
38
  if(empty($orderId))
39
  return true;
40
 
 
 
 
 
 
41
  if(isset($_SERVER['DEV_MODE'])) $_SERVER['REMOTE_ADDR'] = '175.143.8.154';
42
 
43
  $apiKey = Mage::getStoreConfig('fraudlabspro/basic_settings/api_key');
 
 
44
 
45
  $billingAddress = $order->getBillingAddress();
46
 
@@ -87,29 +94,83 @@ class Hexasoft_FraudLabsPro_Controller_Observer{
87
  $queries['ship_country'] = $shippingAddress->getCountryId();
88
  }
89
 
90
- $query = '';
91
- foreach($queries as $key=>$value){
92
- $query .= $key . '=' . rawurlencode($value) . '&';
93
- }
94
-
95
- for($i=0; $i<3; $i++){
96
- $response = $this->_get('https://api.fraudlabspro.com/v1/order/screen?' . $query);
97
-
98
- if(is_null($result = json_decode($response, true)) === FALSE) break;
99
- }
100
 
101
- if(!$result) return false;
 
102
 
103
  $result['ip_address'] = $queries['ip'];
104
  $result['api_key'] = $apiKey;
105
 
106
  $order->setfraudlabspro_response(serialize($result))->save();
107
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
108
  Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('fraudlabspro')->__('FraudLabs Pro Request sent.'));
109
  return true;
110
  }
111
 
112
- private function _get($url){
113
  $ch = curl_init();
114
 
115
  curl_setopt($ch, CURLOPT_FAILONERROR, 1);
38
  if(empty($orderId))
39
  return true;
40
 
41
+ $data = unserialize($order->getfraudlabspro_response());
42
+
43
+ if($data)
44
+ return true;
45
+
46
  if(isset($_SERVER['DEV_MODE'])) $_SERVER['REMOTE_ADDR'] = '175.143.8.154';
47
 
48
  $apiKey = Mage::getStoreConfig('fraudlabspro/basic_settings/api_key');
49
+ $reviewStatus = Mage::getStoreConfig('fraudlabspro/basic_settings/review_status');
50
+ $rejectStatus = Mage::getStoreConfig('fraudlabspro/basic_settings/reject_status');
51
 
52
  $billingAddress = $order->getBillingAddress();
53
 
94
  $queries['ship_country'] = $shippingAddress->getCountryId();
95
  }
96
 
97
+ $response = $this->http('https://api.fraudlabspro.com/v1/order/screen?' . http_build_query($queries));
 
 
 
 
 
 
 
 
 
98
 
99
+ if(is_null($result = json_decode($response, true)) === TRUE)
100
+ return false;
101
 
102
  $result['ip_address'] = $queries['ip'];
103
  $result['api_key'] = $apiKey;
104
 
105
  $order->setfraudlabspro_response(serialize($result))->save();
106
 
107
+ if($result['fraudlabspro_status'] == 'REVIEW'){
108
+ switch($reviewStatus){
109
+ case 'pending':
110
+ $order->setState(Mage_Sales_Model_Order::STATE_NEW, true)->save();
111
+ break;
112
+
113
+ case 'processing':
114
+ $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true)->save();
115
+ break;
116
+
117
+ case 'complete':
118
+ $order->setState(Mage_Sales_Model_Order::STATE_COMPLETE, true)->save();
119
+ break;
120
+
121
+ case 'closed':
122
+ $order->setState(Mage_Sales_Model_Order::STATE_CLOSED, true)->save();
123
+ break;
124
+
125
+ case 'canceled':
126
+ if($order->canCancel()) {
127
+ $order->cancel()->save();
128
+ }
129
+ break;
130
+
131
+ case 'holded':
132
+ $order->setState(Mage_Sales_Model_Order::STATE_HOLDED, true)->save();
133
+ break;
134
+
135
+ }
136
+ }
137
+
138
+ if($result['fraudlabspro_status'] == 'REJECT'){
139
+ switch($rejectStatus){
140
+ case 'pending':
141
+ $order->setState(Mage_Sales_Model_Order::STATE_NEW, true)->save();
142
+ break;
143
+
144
+ case 'processing':
145
+ $order->setState(Mage_Sales_Model_Order::STATE_PROCESSING, true)->save();
146
+ break;
147
+
148
+ case 'complete':
149
+ $order->setState(Mage_Sales_Model_Order::STATE_COMPLETE, true)->save();
150
+ break;
151
+
152
+ case 'closed':
153
+ $order->setState(Mage_Sales_Model_Order::STATE_CLOSED, true)->save();
154
+ break;
155
+
156
+ case 'canceled':
157
+ if($order->canCancel()) {
158
+ $order->cancel()->save();
159
+ }
160
+ break;
161
+
162
+ case 'holded':
163
+ $order->setState(Mage_Sales_Model_Order::STATE_HOLDED, true)->save();
164
+ break;
165
+
166
+ }
167
+ }
168
+
169
  Mage::getSingleton('adminhtml/session')->addSuccess(Mage::helper('fraudlabspro')->__('FraudLabs Pro Request sent.'));
170
  return true;
171
  }
172
 
173
+ private function http($url){
174
  $ch = curl_init();
175
 
176
  curl_setopt($ch, CURLOPT_FAILONERROR, 1);
app/code/local/Hexasoft/FraudLabsPro/etc/config.xml CHANGED
@@ -2,7 +2,7 @@
2
  <config>
3
  <modules>
4
  <Hexasoft_FraudLabsPro>
5
- <version>1.0.1</version>
6
  </Hexasoft_FraudLabsPro>
7
  </modules>
8
 
@@ -51,7 +51,7 @@
51
  </resources>
52
 
53
  <events>
54
- <sales_order_save_after>
55
  <observers>
56
  <send_request_to_fraudlabspro>
57
  <type>singleton</type>
@@ -59,7 +59,7 @@
59
  <method>sendRequestToFraudLabsPro</method>
60
  </send_request_to_fraudlabspro>
61
  </observers>
62
- </sales_order_save_after>
63
  </events>
64
  </global>
65
 
@@ -90,6 +90,8 @@
90
  <basic_settings>
91
  <active>0</active>
92
  <api_key></api_key>
 
 
93
  </basic_settings>
94
  </fraudlabspro>
95
  </default>
2
  <config>
3
  <modules>
4
  <Hexasoft_FraudLabsPro>
5
+ <version>1.1.0</version>
6
  </Hexasoft_FraudLabsPro>
7
  </modules>
8
 
51
  </resources>
52
 
53
  <events>
54
+ <sales_order_save_commit_after>
55
  <observers>
56
  <send_request_to_fraudlabspro>
57
  <type>singleton</type>
59
  <method>sendRequestToFraudLabsPro</method>
60
  </send_request_to_fraudlabspro>
61
  </observers>
62
+ </sales_order_save_commit_after>
63
  </events>
64
  </global>
65
 
90
  <basic_settings>
91
  <active>0</active>
92
  <api_key></api_key>
93
+ <review_status>holded</review_status>
94
+ <reject_status>canceled</reject_status>
95
  </basic_settings>
96
  </fraudlabspro>
97
  </default>
app/code/local/Hexasoft/FraudLabsPro/etc/system.xml CHANGED
@@ -36,12 +36,32 @@
36
  <api_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
  <comment><![CDATA[You can register for a free license key at <a href="http://www.fraudlabspro.com/sign-up?r=magento" target="_blank">http://www.fraudlabspro.com/sign-up</a> if you do not have one.]]></comment>
44
  </api_key>
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
45
  </fields>
46
  </basic_settings>
47
  </groups>
36
  <api_key translate="label">
37
  <label>API Key</label>
38
  <frontend_type>text</frontend_type>
39
+ <sort_order>2</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
  <comment><![CDATA[You can register for a free license key at <a href="http://www.fraudlabspro.com/sign-up?r=magento" target="_blank">http://www.fraudlabspro.com/sign-up</a> if you do not have one.]]></comment>
44
  </api_key>
45
+ <review_status translate="label">
46
+ <label>When receive Review status, change order status to</label>
47
+ <frontend_type>select</frontend_type>
48
+ <source_model>adminhtml/system_config_source_order_status</source_model>
49
+ <sort_order>3</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
+ <comment><![CDATA[Don't select any option to leave your order unchanged.]]></comment>
54
+ </review_status>
55
+ <reject_status translate="label">
56
+ <label>When receive Reject status, change order status to</label>
57
+ <frontend_type>select</frontend_type>
58
+ <source_model>adminhtml/system_config_source_order_status</source_model>
59
+ <sort_order>4</sort_order>
60
+ <show_in_default>1</show_in_default>
61
+ <show_in_website>1</show_in_website>
62
+ <show_in_store>1</show_in_store>
63
+ <comment><![CDATA[Don't select any option to leave your order unchanged.]]></comment>
64
+ </reject_status>
65
  </fields>
66
  </basic_settings>
67
  </groups>
package.xml CHANGED
@@ -1,18 +1,18 @@
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Hexasoft_FraudLabsPro</name>
4
- <version>1.0.11</version>
5
  <stability>stable</stability>
6
  <license>Open Software License (OSL)</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>This extension screens online transactions for frauds.</summary>
10
  <description>FraudLabs Pro service screens online transactions for frauds. It increases e-commerce merchant profits by reduces chargeback, improves operation efficiency and provides business intelligence.</description>
11
- <notes>Added new parameters.</notes>
12
  <authors><author><name>Hexasoft</name><user>hexasoft</user><email>tech@hexasoft.com.my</email></author></authors>
13
- <date>2015-11-25</date>
14
- <time>07:59:38</time>
15
- <contents><target name="magelocal"><dir name="Hexasoft"><dir name="FraudLabsPro"><dir name="Block"><dir name="Sales"><dir name="Order"><file name="Fraudlabsproresult.php" hash="8d345ebe9d7b8ee3166482a1648fb783"/><dir name="Grid"><dir name="Renderer"><file name="Risk.php" hash="19c8ca6a7656fee2e66b904dc97079a0"/></dir></dir><file name="Grid.php" hash="154790c49632c35af5e301c33a1e3188"/></dir></dir></dir><dir name="Controller"><file name="Observer.php" hash="63b4504bcca74809df23efcdae1a1954"/></dir><dir name="Helper"><file name="Data.php" hash="948a251b0d5415653b1efce1af279b28"/></dir><dir name="controllers"><file name="IndexController.php" hash="92a43627feee95218815cf1aad91f439"/></dir><dir name="etc"><file name="adminhtml.xml" hash="38ccfabe77e18a8f8d9050359d44d13e"/><file name="config.xml" hash="fa0ac7b81625729c72506ea8b63a596a"/><file name="system.xml" hash="5e30289646a3fb03640b7b4bbeb4ab26"/></dir><dir name="sql"><dir name="fraudlabspro_setup"><file name="mysql4-install-1.0.0.php" hash="be13e48218b5120641393e68df201d8b"/></dir></dir></dir></dir></target><target name="mage"><dir name="app"><dir name="etc"><dir name="modules"><file name="Hexasoft_FraudLabsPro.xml" hash="e8bb308243797bda5769209a8b360577"/></dir></dir><dir name="design"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="fraudlabspro.xml" hash="43ae7917d3084744031b90d33f515f87"/></dir><dir name="template"><dir name="fraudlabspro"><dir name="sales"><dir name="order"><dir name="view"><dir name="tab"><file name="info.phtml" hash="25a46ae56e812c120f2125ad32f4bb1c"/></dir></dir></dir></dir></dir></dir></dir></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>
1
  <?xml version="1.0"?>
2
  <package>
3
  <name>Hexasoft_FraudLabsPro</name>
4
+ <version>1.1.0</version>
5
  <stability>stable</stability>
6
  <license>Open Software License (OSL)</license>
7
  <channel>community</channel>
8
  <extends/>
9
  <summary>This extension screens online transactions for frauds.</summary>
10
  <description>FraudLabs Pro service screens online transactions for frauds. It increases e-commerce merchant profits by reduces chargeback, improves operation efficiency and provides business intelligence.</description>
11
+ <notes>Added custom action for review and rejected transactions.</notes>
12
  <authors><author><name>Hexasoft</name><user>hexasoft</user><email>tech@hexasoft.com.my</email></author></authors>
13
+ <date>2015-11-26</date>
14
+ <time>02:17:46</time>
15
+ <contents><target name="magelocal"><dir name="Hexasoft"><dir name="FraudLabsPro"><dir name="Block"><dir name="Sales"><dir name="Order"><file name="Fraudlabsproresult.php" hash="8d345ebe9d7b8ee3166482a1648fb783"/><dir name="Grid"><dir name="Renderer"><file name="Risk.php" hash="19c8ca6a7656fee2e66b904dc97079a0"/></dir></dir><file name="Grid.php" hash="154790c49632c35af5e301c33a1e3188"/></dir></dir></dir><dir name="Controller"><file name="Observer.php" hash="0dccbf8924f27ef8fdda09d2131d65bd"/></dir><dir name="Helper"><file name="Data.php" hash="948a251b0d5415653b1efce1af279b28"/></dir><dir name="controllers"><file name="IndexController.php" hash="92a43627feee95218815cf1aad91f439"/></dir><dir name="etc"><file name="adminhtml.xml" hash="38ccfabe77e18a8f8d9050359d44d13e"/><file name="config.xml" hash="e977b3eab5534d2209401690a4228747"/><file name="system.xml" hash="fbed11ab9291bc1f95112559562df9c7"/></dir><dir name="sql"><dir name="fraudlabspro_setup"><file name="mysql4-install-1.0.0.php" hash="be13e48218b5120641393e68df201d8b"/></dir></dir></dir></dir></target><target name="mage"><dir name="app"><dir name="etc"><dir name="modules"><file name="Hexasoft_FraudLabsPro.xml" hash="e8bb308243797bda5769209a8b360577"/></dir></dir><dir name="design"><dir name="adminhtml"><dir name="default"><dir name="default"><dir name="layout"><file name="fraudlabspro.xml" hash="43ae7917d3084744031b90d33f515f87"/></dir><dir name="template"><dir name="fraudlabspro"><dir name="sales"><dir name="order"><dir name="view"><dir name="tab"><file name="info.phtml" hash="25a46ae56e812c120f2125ad32f4bb1c"/></dir></dir></dir></dir></dir></dir></dir></dir></dir></dir></dir></target></contents>
16
  <compatible/>
17
  <dependencies><required><php><min>5.2.0</min><max>6.0.0</max></php></required></dependencies>
18
  </package>