Version Notes
Notes: uses cURL to send information to NoFraud Service.
Requires NoFraud service account in order to work.
Configure is set in System > Configuration > Payment Services
---------
v1.0.4
Moved where the invoice number from magento lives in the request made out to NoFraud thus allowing us to have better reference between magento and NoFraud. Added Company to the billing and shipping objects for NoFraud. changes due to the misplaced hotfix in 1.0.3.
Added Logs for Developers. [breaks PCI, remove before making stable]
v1.0.3
Hotfix for a issue we are seeing in our Portal with the Gateway Response even when transaction is in fact successful.
v1.0.2
Changes to Description other minor details
v1.0.1
Hotfix for Custom Error message.
Download this release
Release Info
Developer | Blumi Gross |
Extension | NoFraud_TegraDirect |
Version | 1.0.4 |
Comparing to | |
See all releases |
Code changes from version 1.0.3 to 1.0.4
app/code/community/NoFraud/TegraDirect/Model/Observer.php
CHANGED
@@ -20,7 +20,7 @@ class NoFraud_TegraDirect_Model_Observer {
|
|
20 |
$response = $this->_sendRequest($request,$this->getURL('gateway_response'));
|
21 |
//Mage::log(var_export($response,true),null,'tegra-direct.log');
|
22 |
$this->last_transaction = "";
|
23 |
-
Mage::getSingleton('core/session')->unsNfLastTransaction();
|
24 |
} else {
|
25 |
Mage::log("\$this->last_transaction is empty. Skipping.",null,'tegra-direct.log');
|
26 |
}
|
@@ -48,7 +48,7 @@ class NoFraud_TegraDirect_Model_Observer {
|
|
48 |
$this->last_transaction = "";
|
49 |
Mage::getSingleton('core/session')->unsNfLastTransaction();
|
50 |
$message = ($result['message'] || "Declined")? $result['message']:"Declined";
|
51 |
-
Mage::log(var_export($result,true),null,'tegra-direct.log');
|
52 |
Mage::throwException(Mage::helper('paygate')->__($message));
|
53 |
}
|
54 |
}
|
@@ -63,6 +63,9 @@ class NoFraud_TegraDirect_Model_Observer {
|
|
63 |
|
64 |
if(!empty($this->last_transaction)){
|
65 |
$request = $this->_buildGatewayResponseRequest($this->last_transaction['id'],$payment);
|
|
|
|
|
|
|
66 |
//Mage::log(var_export($request,true),null,'tegra-direct.log');
|
67 |
$response = $this->_sendRequest($request,$this->getURL("gateway_response"));
|
68 |
|
@@ -78,7 +81,36 @@ class NoFraud_TegraDirect_Model_Observer {
|
|
78 |
|
79 |
$this->last_transaction = "";
|
80 |
Mage::getSingleton('core/session')->unsNfLastTransaction();
|
81 |
-
Mage::log(var_export($this->last_transaction,true),null,'tegra-direct.log');
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
82 |
}
|
83 |
}
|
84 |
}
|
@@ -86,10 +118,13 @@ class NoFraud_TegraDirect_Model_Observer {
|
|
86 |
private function _buildGatewayResponseRequest($id,$payment){
|
87 |
$order = $payment->getOrder();
|
88 |
|
89 |
-
$gateway_status = "
|
90 |
if($payment->getIsFraudDetected()){
|
91 |
$gateway_status = "review";
|
92 |
}
|
|
|
|
|
|
|
93 |
|
94 |
$params = [];
|
95 |
$params['nf-token'] = $this->getConfigData('nftoken');
|
@@ -137,6 +172,10 @@ class NoFraud_TegraDirect_Model_Observer {
|
|
137 |
$params['billTo']['country'] = $billing->getCountry();
|
138 |
$params['billTo']['phoneNumber'] = $billing->getTelephone();
|
139 |
|
|
|
|
|
|
|
|
|
140 |
if(!empty($shipping)){
|
141 |
$params['shipTo'] = [];
|
142 |
$params['shipTo']['firstName'] = $shipping->getFirstname();
|
@@ -146,6 +185,10 @@ class NoFraud_TegraDirect_Model_Observer {
|
|
146 |
$params['shipTo']['state'] = $shipping_region->getCode();
|
147 |
$params['shipTo']['zip'] = $shipping->getPostcode();
|
148 |
$params['shipTo']['country'] = $shipping->getCountry();
|
|
|
|
|
|
|
|
|
149 |
}
|
150 |
|
151 |
$params['customer'] = [];
|
@@ -176,12 +219,8 @@ class NoFraud_TegraDirect_Model_Observer {
|
|
176 |
}
|
177 |
}
|
178 |
|
179 |
-
|
180 |
-
|
181 |
-
//$params['order']['invoiceNumber'] = $order->getIncrementId();
|
182 |
-
|
183 |
-
$params['userFields'] = [];
|
184 |
-
$params['userFields']['orderId'] = $order->getIncrementId();
|
185 |
|
186 |
return $params;
|
187 |
}
|
@@ -197,9 +236,13 @@ class NoFraud_TegraDirect_Model_Observer {
|
|
197 |
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
|
198 |
|
199 |
$result = curl_exec($ch);
|
200 |
-
|
201 |
-
|
|
|
|
|
|
|
202 |
$res_obj = json_decode($result,true);
|
|
|
203 |
|
204 |
return $res_obj;
|
205 |
}
|
@@ -211,19 +254,16 @@ class NoFraud_TegraDirect_Model_Observer {
|
|
211 |
$data = Mage::helper('core')->decrypt($data);
|
212 |
}
|
213 |
|
214 |
-
//Mage::log("{$datapoint} == {$data}",null,'tegra-direct.log');
|
215 |
return $data;
|
216 |
}
|
217 |
|
218 |
private function getURL($addition = ""){
|
219 |
$url = 'https://api.nofraud.com/'.$addition;
|
220 |
-
//$url = 'https://60c64d03.ngrok.io/'.$addition;
|
221 |
|
222 |
if($this->getConfigData('sandbox')){
|
223 |
$url = 'https://apitest.nofraud.com/'.$addition;
|
224 |
}
|
225 |
|
226 |
-
//Mage::log(var_export($url,true),null,'tegra-direct.log');
|
227 |
return $url;
|
228 |
}
|
229 |
}
|
20 |
$response = $this->_sendRequest($request,$this->getURL('gateway_response'));
|
21 |
//Mage::log(var_export($response,true),null,'tegra-direct.log');
|
22 |
$this->last_transaction = "";
|
23 |
+
//Mage::getSingleton('core/session')->unsNfLastTransaction();
|
24 |
} else {
|
25 |
Mage::log("\$this->last_transaction is empty. Skipping.",null,'tegra-direct.log');
|
26 |
}
|
48 |
$this->last_transaction = "";
|
49 |
Mage::getSingleton('core/session')->unsNfLastTransaction();
|
50 |
$message = ($result['message'] || "Declined")? $result['message']:"Declined";
|
51 |
+
//Mage::log(var_export($result,true),null,'tegra-direct.log');
|
52 |
Mage::throwException(Mage::helper('paygate')->__($message));
|
53 |
}
|
54 |
}
|
63 |
|
64 |
if(!empty($this->last_transaction)){
|
65 |
$request = $this->_buildGatewayResponseRequest($this->last_transaction['id'],$payment);
|
66 |
+
if(strcmp($request['gateway-response']['result'],'review') != 0){
|
67 |
+
$request['gateway-response']['result'] = 'pass';
|
68 |
+
}
|
69 |
//Mage::log(var_export($request,true),null,'tegra-direct.log');
|
70 |
$response = $this->_sendRequest($request,$this->getURL("gateway_response"));
|
71 |
|
81 |
|
82 |
$this->last_transaction = "";
|
83 |
Mage::getSingleton('core/session')->unsNfLastTransaction();
|
84 |
+
//Mage::log(var_export($this->last_transaction,true),null,'tegra-direct.log');
|
85 |
+
}
|
86 |
+
}
|
87 |
+
}
|
88 |
+
|
89 |
+
public function salesModelServiceQuoteSubmitFailure(Varien_Event_Observer $observer){
|
90 |
+
$is_active = $this->getConfigData('active');
|
91 |
+
|
92 |
+
if($is_active){
|
93 |
+
$order = $observer->getEvent()->getOrder();
|
94 |
+
$payment = $order->getPayment();
|
95 |
+
|
96 |
+
if(!empty($this->last_transaction)){
|
97 |
+
$request = $this->_buildGatewayResponseRequest($this->last_transaction['id'],$payment);
|
98 |
+
//Mage::log(var_export($request,true),null,'tegra-direct.log');
|
99 |
+
$response = $this->_sendRequest($request,$this->getURL("gateway_response"));
|
100 |
+
|
101 |
+
if($this->last_transaction['decision'] == "review"){
|
102 |
+
if(!$payment->getIsFraudDetected()){
|
103 |
+
$payment->setIsTransactionPending(true);
|
104 |
+
$payment->setIsFraudDetected(true);
|
105 |
+
$order->setState($order->getState(),Mage_Sales_Model_Order::STATUS_FRAUD);
|
106 |
+
$payment->save();
|
107 |
+
$order->save();
|
108 |
+
}
|
109 |
+
}
|
110 |
+
|
111 |
+
$this->last_transaction = "";
|
112 |
+
Mage::getSingleton('core/session')->unsNfLastTransaction();
|
113 |
+
//Mage::log(var_export($this->last_transaction,true),null,'tegra-direct.log');
|
114 |
}
|
115 |
}
|
116 |
}
|
118 |
private function _buildGatewayResponseRequest($id,$payment){
|
119 |
$order = $payment->getOrder();
|
120 |
|
121 |
+
$gateway_status = "fail";
|
122 |
if($payment->getIsFraudDetected()){
|
123 |
$gateway_status = "review";
|
124 |
}
|
125 |
+
if($order->getBaseTotalDue() == 0){
|
126 |
+
$gateway_status = "pass";
|
127 |
+
}
|
128 |
|
129 |
$params = [];
|
130 |
$params['nf-token'] = $this->getConfigData('nftoken');
|
172 |
$params['billTo']['country'] = $billing->getCountry();
|
173 |
$params['billTo']['phoneNumber'] = $billing->getTelephone();
|
174 |
|
175 |
+
if(!is_null($billing->getCompany())){
|
176 |
+
$params['billTo']['company'] = $billing->getCompany();
|
177 |
+
}
|
178 |
+
|
179 |
if(!empty($shipping)){
|
180 |
$params['shipTo'] = [];
|
181 |
$params['shipTo']['firstName'] = $shipping->getFirstname();
|
185 |
$params['shipTo']['state'] = $shipping_region->getCode();
|
186 |
$params['shipTo']['zip'] = $shipping->getPostcode();
|
187 |
$params['shipTo']['country'] = $shipping->getCountry();
|
188 |
+
|
189 |
+
if(!is_null($shipping->getCompany())){
|
190 |
+
$params['shipTo']['company'] = $shipping->getCompany();
|
191 |
+
}
|
192 |
}
|
193 |
|
194 |
$params['customer'] = [];
|
219 |
}
|
220 |
}
|
221 |
|
222 |
+
$params['order'] = [];
|
223 |
+
$params['order']['invoiceNumber'] = $order->getIncrementId();
|
|
|
|
|
|
|
|
|
224 |
|
225 |
return $params;
|
226 |
}
|
236 |
curl_setopt($ch, CURLOPT_POSTFIELDS, $body);
|
237 |
|
238 |
$result = curl_exec($ch);
|
239 |
+
//Mage::log(var_export($result,true),null,'tegra-direct.log');
|
240 |
+
$info = curl_getinfo($ch);
|
241 |
+
//Mage::log(var_export($info,true),null,'tegra-direct.log');
|
242 |
+
curl_close($ch);
|
243 |
+
|
244 |
$res_obj = json_decode($result,true);
|
245 |
+
//Mage::log(var_export($res_obj,true),null,'tegra-direct.log');
|
246 |
|
247 |
return $res_obj;
|
248 |
}
|
254 |
$data = Mage::helper('core')->decrypt($data);
|
255 |
}
|
256 |
|
|
|
257 |
return $data;
|
258 |
}
|
259 |
|
260 |
private function getURL($addition = ""){
|
261 |
$url = 'https://api.nofraud.com/'.$addition;
|
|
|
262 |
|
263 |
if($this->getConfigData('sandbox')){
|
264 |
$url = 'https://apitest.nofraud.com/'.$addition;
|
265 |
}
|
266 |
|
|
|
267 |
return $url;
|
268 |
}
|
269 |
}
|
app/code/community/NoFraud/TegraDirect/etc/config.xml
CHANGED
@@ -2,7 +2,7 @@
|
|
2 |
<config>
|
3 |
<modules>
|
4 |
<NoFraud_TegraDirect>
|
5 |
-
<version>1.0.
|
6 |
</NoFraud_TegraDirect>
|
7 |
</modules>
|
8 |
|
@@ -54,6 +54,14 @@
|
|
54 |
</NoFraud_TegraDirect_Model_Observer>
|
55 |
</observers>
|
56 |
</checkout_submit_all_after>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
57 |
</events>
|
58 |
</global>
|
59 |
|
2 |
<config>
|
3 |
<modules>
|
4 |
<NoFraud_TegraDirect>
|
5 |
+
<version>1.0.4</version>
|
6 |
</NoFraud_TegraDirect>
|
7 |
</modules>
|
8 |
|
54 |
</NoFraud_TegraDirect_Model_Observer>
|
55 |
</observers>
|
56 |
</checkout_submit_all_after>
|
57 |
+
<sales_model_service_quote_submit_failure>
|
58 |
+
<observers>
|
59 |
+
<NoFraud_TegraDirect_Model_Observer>
|
60 |
+
<class>NoFraud_TegraDirect/observer</class>
|
61 |
+
<method>salesModelServiceQuoteSubmitFailure</method>
|
62 |
+
</NoFraud_TegraDirect_Model_Observer>
|
63 |
+
</observers>
|
64 |
+
</sales_model_service_quote_submit_failure>
|
65 |
</events>
|
66 |
</global>
|
67 |
|
package.xml
CHANGED
@@ -1,7 +1,7 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>NoFraud_TegraDirect</name>
|
4 |
-
<version>1.0.
|
5 |
<stability>stable</stability>
|
6 |
<license uri="https://opensource.org/licenses/afl-3.0">Academic Free License</license>
|
7 |
<channel>community</channel>
|
@@ -56,6 +56,10 @@ Requires NoFraud service account in order to work.
|
|
56 |
Configure is set in System > Configuration > Payment Services
|
57 |

|
58 |
---------
|
|
|
|
|
|
|
|
|
59 |
v1.0.3
|
60 |
Hotfix for a issue we are seeing in our Portal with the Gateway Response even when transaction is in fact successful.
|
61 |

|
@@ -65,9 +69,9 @@ Changes to Description other minor details
|
|
65 |
v1.0.1
|
66 |
Hotfix for Custom Error message.</notes>
|
67 |
<authors><author><name>Blumi Gross</name><user>BlumiNoFraud</user><email>blumi@nofraud.com</email></author><author><name>Michael Esposito</name><user>mesposito</user><email>mesposito@nofraud.com</email></author></authors>
|
68 |
-
<date>2016-07-
|
69 |
-
<time>
|
70 |
-
<contents><target name="magecommunity"><dir name="NoFraud"><dir name="TegraDirect"><dir name="Helper"><file name="Data.php" hash="9575aac8a692bf4f66c5fb62a14a2167"/></dir><dir name="Model"><file name="Observer.php" hash="
|
71 |
<compatible/>
|
72 |
<dependencies><required><php><min>5.0.0</min><max>5.6.0</max></php><extension><name>curl</name><min>7.35.0</min><max/></extension></required></dependencies>
|
73 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>NoFraud_TegraDirect</name>
|
4 |
+
<version>1.0.4</version>
|
5 |
<stability>stable</stability>
|
6 |
<license uri="https://opensource.org/licenses/afl-3.0">Academic Free License</license>
|
7 |
<channel>community</channel>
|
56 |
Configure is set in System > Configuration > Payment Services
|
57 |

|
58 |
---------
|
59 |
+
v1.0.4
|
60 |
+
Moved where the invoice number from magento lives in the request made out to NoFraud thus allowing us to have better reference between magento and NoFraud. Added Company to the billing and shipping objects for NoFraud. changes due to the misplaced hotfix in 1.0.3.
|
61 |
+
Added Logs for Developers. [breaks PCI, remove before making stable]
|
62 |
+

|
63 |
v1.0.3
|
64 |
Hotfix for a issue we are seeing in our Portal with the Gateway Response even when transaction is in fact successful.
|
65 |

|
69 |
v1.0.1
|
70 |
Hotfix for Custom Error message.</notes>
|
71 |
<authors><author><name>Blumi Gross</name><user>BlumiNoFraud</user><email>blumi@nofraud.com</email></author><author><name>Michael Esposito</name><user>mesposito</user><email>mesposito@nofraud.com</email></author></authors>
|
72 |
+
<date>2016-07-11</date>
|
73 |
+
<time>20:55:19</time>
|
74 |
+
<contents><target name="magecommunity"><dir name="NoFraud"><dir name="TegraDirect"><dir name="Helper"><file name="Data.php" hash="9575aac8a692bf4f66c5fb62a14a2167"/></dir><dir name="Model"><file name="Observer.php" hash="0d6eed705c5a5f7162ead5867978b004"/></dir><dir name="etc"><file name="config.xml" hash="c46080e1af6442b5ce48e3b72cf35510"/><file name="system.xml" hash="57d0d0d658acf9aad00e13377f53d061"/></dir><dir name="sql"><dir name="tegradirect_setup"><file name="install-1.0.0.php" hash="e894527bb612d9748cf8212f1e38f459"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="NoFraud_TegraDirect.xml" hash="5611cb98606f5f733e0820bb47d8418e"/></dir></target></contents>
|
75 |
<compatible/>
|
76 |
<dependencies><required><php><min>5.0.0</min><max>5.6.0</max></php><extension><name>curl</name><min>7.35.0</min><max/></extension></required></dependencies>
|
77 |
</package>
|