Version Notes
- Different Bugfixes
- Compatibility with AuthorizeNetCim Payment Extension
- Compatibility with virtual products
- Request to eye4fraud service moved to cron to avoid influence on order placing process
- Compatibility with Magento 1.9.2.4
Download this release
Release Info
Developer | Shloimy Stauber |
Extension | Eye4Fraud_Connector_integration |
Version | 1.2.0 |
Comparing to | |
See all releases |
Code changes from version 1.1.4 to 1.2.0
- app/code/local/Eye4Fraud/Connector/Block/Sales/Order/Grid.php +34 -0
- app/code/local/Eye4Fraud/Connector/Helper/Curl.php +105 -0
- app/code/local/Eye4Fraud/Connector/Helper/Data.php +571 -0
- app/code/local/Eye4Fraud/Connector/Model/Authorizenet.php +42 -0
- app/code/local/Eye4Fraud/Connector/Model/Config/Backend/Data.php +38 -0
- app/code/local/Eye4Fraud/Connector/Model/Config/Frontend/Authorizenet.php +25 -0
- app/code/local/Eye4Fraud/Connector/Model/Config/Frontend/Grid.php +25 -0
- app/code/local/Eye4Fraud/Connector/Model/Config/Frontend/Payflowpro.php +25 -0
- app/code/local/Eye4Fraud/Connector/Model/Config/Frontend/Paypaluk.php +25 -0
- app/code/local/Eye4Fraud/Connector/Model/Observer.php +548 -0
- app/code/local/Eye4Fraud/Connector/Model/Payflowpro.php +45 -0
- app/code/local/Eye4Fraud/Connector/Model/PaypalUk/Api/Nvp.php +16 -0
- app/code/local/Eye4Fraud/Connector/Model/Request.php +17 -0
- app/code/local/Eye4Fraud/Connector/Model/Resource/Requests/Cache.php +18 -0
- app/code/local/Eye4Fraud/Connector/Model/Resource/Requests/Cache/Collection.php +46 -0
- app/code/local/Eye4Fraud/Connector/Model/Resource/Status.php +28 -0
- app/code/local/Eye4Fraud/Connector/Model/Resource/Status/Collection.php +181 -0
- app/code/local/Eye4Fraud/Connector/Model/Status.php +74 -0
- app/code/local/Eye4Fraud/Connector/etc/adminhtml.xml +33 -0
- app/code/local/Eye4Fraud/Connector/etc/config.xml +148 -0
- app/code/local/Eye4Fraud/Connector/etc/system.xml +156 -0
- app/code/local/Eye4Fraud/Connector/sql/eye4fraud_setup/install-1.0.4.php +21 -0
- app/code/local/Eye4Fraud/Connector/sql/eye4fraud_setup/upgrade-1.0.6-1.0.7.php +21 -0
- app/code/local/Eye4Fraud/Connector/sql/eye4fraud_setup/upgrade-1.1.1-1.1.2.php +23 -0
- app/code/local/Eye4Fraud/Connector/sql/eye4fraud_setup/upgrade-1.1.2-1.1.3.php +23 -0
- app/code/local/Eye4Fraud/Connector/sql/eye4fraud_setup/upgrade-1.1.3-1.1.4.php +24 -0
- app/code/local/Eye4Fraud/Connector/sql/eye4fraud_setup/upgrade-1.1.6-1.1.7.php +47 -0
- app/code/local/Eye4Fraud/Connector/sql/eye4fraud_setup/upgrade-1.1.7-1.2.0.php +18 -0
- app/etc/modules/Eye4Fraud_Connector.xml +9 -0
- app/locale/en_US/Eye4Fraud_Connector.csv +27 -0
- app/locale/en_US/template/email/authorizepopulation.html +57 -0
- package.xml +17 -15
app/code/local/Eye4Fraud/Connector/Block/Sales/Order/Grid.php
ADDED
@@ -0,0 +1,34 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Rewritten orders grid with added column of fraud status. Use this class in other class rewrites if needed
|
5 |
+
*
|
6 |
+
* @category Eye4Fraud
|
7 |
+
* @package Eye4fraud_Connector
|
8 |
+
*/
|
9 |
+
if(mageFindClassFile("EM_DeleteOrder_Block_Adminhtml_Sales_Order_Grid")){
|
10 |
+
/** @noinspection PhpUndefinedClassInspection */
|
11 |
+
class _BaseGridClass extends EM_DeleteOrder_Block_Adminhtml_Sales_Order_Grid{}
|
12 |
+
}
|
13 |
+
else{
|
14 |
+
class _BaseGridClass extends Mage_Adminhtml_Block_Sales_Order_Grid{}
|
15 |
+
}
|
16 |
+
|
17 |
+
class Eye4Fraud_Connector_Block_Sales_Order_Grid extends _BaseGridClass
|
18 |
+
|
19 |
+
{
|
20 |
+
protected function _prepareColumns()
|
21 |
+
{
|
22 |
+
if(!Mage::helper('eye4fraud_connector')->isEnabled()) return parent::_prepareColumns();
|
23 |
+
|
24 |
+
$this->addColumnAfter('eye4fraud_status', array(
|
25 |
+
'header' => Mage::helper('eye4fraud_connector')->__('Fraud Status'),
|
26 |
+
'width' => '123',
|
27 |
+
'filter' => false,
|
28 |
+
'sortable' => false,
|
29 |
+
'getter' => array(Mage::getResourceSingleton('eye4fraud_connector/status_collection'),'getOrderStatusLabel'),
|
30 |
+
'frame_callback' => array(Mage::getResourceSingleton('eye4fraud_connector/status_collection'),'addStatusDescription')
|
31 |
+
), 'status');
|
32 |
+
return parent::_prepareColumns();
|
33 |
+
}
|
34 |
+
}
|
app/code/local/Eye4Fraud/Connector/Helper/Curl.php
ADDED
@@ -0,0 +1,105 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Eye4fraud Connector Magento Module
|
4 |
+
*
|
5 |
+
* @category Eye4fraud
|
6 |
+
* @package Eye4fraud_Connector
|
7 |
+
*/
|
8 |
+
|
9 |
+
class Eye4Fraud_Connector_Helper_Curl
|
10 |
+
extends Mage_Core_Helper_Abstract
|
11 |
+
{
|
12 |
+
const HTTP_STATUS_BAD_RESPONSE = -1; // Not an HTTP response code
|
13 |
+
const HTTP_STATUS_OK = 200;
|
14 |
+
const HTTP_STATUS_BAD_REQUEST = 400;
|
15 |
+
const HTTP_STATUS_UNAUTHORIZED = 401;
|
16 |
+
const HTTP_STATUS_FORBIDDEN = 403;
|
17 |
+
const HTTP_STATUS_NOT_FOUND = 404;
|
18 |
+
const HTTP_STATUS_NOT_ACCEPTABLE = 406;
|
19 |
+
const HTTP_STATUS_INTERNAL_SERVER_ERROR = 500;
|
20 |
+
const HTTP_STATUS_SERVICE_UNAVAILABLE = 503;
|
21 |
+
|
22 |
+
const COOKIES_FILE = 'cookies.txt';
|
23 |
+
|
24 |
+
/**
|
25 |
+
* @param int $timeout Timeout in seconds. Default value is 10 minutes
|
26 |
+
*/
|
27 |
+
function __construct($timeout = 600) {
|
28 |
+
$this->curlHandle = curl_init();
|
29 |
+
curl_setopt($this->curlHandle, CURLOPT_COOKIEJAR, self::COOKIES_FILE);
|
30 |
+
curl_setopt($this->curlHandle, CURLOPT_COOKIEFILE, self::COOKIES_FILE);
|
31 |
+
curl_setopt($this->curlHandle, CURLOPT_FOLLOWLOCATION, 1);
|
32 |
+
curl_setopt($this->curlHandle, CURLOPT_RETURNTRANSFER, 1);
|
33 |
+
curl_setopt($this->curlHandle, CURLOPT_SSL_VERIFYPEER, false);
|
34 |
+
curl_setopt($this->curlHandle, CURLOPT_TIMEOUT, $timeout);
|
35 |
+
}
|
36 |
+
|
37 |
+
function close() {
|
38 |
+
if ($this->curlHandle) {
|
39 |
+
curl_close($this->curlHandle);
|
40 |
+
}
|
41 |
+
}
|
42 |
+
|
43 |
+
public function get($url, $get_data = array(), $headers = array())
|
44 |
+
{
|
45 |
+
// Build url
|
46 |
+
if ($get_data) {
|
47 |
+
$url = $url.'/?'.http_build_query($get_data);
|
48 |
+
}
|
49 |
+
curl_setopt($this->curlHandle, CURLOPT_URL, $url);
|
50 |
+
|
51 |
+
// Add headers
|
52 |
+
if ($headers) {
|
53 |
+
curl_setopt($this->curlHandle, CURLOPT_HTTPHEADER, $headers);
|
54 |
+
}
|
55 |
+
$response = curl_exec($this->curlHandle);
|
56 |
+
|
57 |
+
// make sure there's no errors
|
58 |
+
$errno = curl_errno($this->curlHandle);
|
59 |
+
if ($errno !== 0) {
|
60 |
+
$error = curl_error($this->curlHandle);
|
61 |
+
trigger_error("CURL error: $errno - $error, url: $url");
|
62 |
+
}
|
63 |
+
|
64 |
+
// make sure we got a 200
|
65 |
+
$code = (int)curl_getinfo($this->curlHandle, CURLINFO_HTTP_CODE);
|
66 |
+
if ($code != self::HTTP_STATUS_OK) {
|
67 |
+
trigger_error("HTTP status code: $code, response=$response, url=$url");
|
68 |
+
}
|
69 |
+
return $response;
|
70 |
+
}
|
71 |
+
|
72 |
+
public function post($url, $post_data = array(), $headers = array())
|
73 |
+
{
|
74 |
+
|
75 |
+
|
76 |
+
|
77 |
+
|
78 |
+
|
79 |
+
curl_setopt($this->curlHandle, CURLOPT_URL, $url);
|
80 |
+
if ($post_data) {
|
81 |
+
curl_setopt($this->curlHandle, CURLOPT_POST, 1);
|
82 |
+
curl_setopt($this->curlHandle, CURLOPT_POSTFIELDS, http_build_query($post_data));
|
83 |
+
}
|
84 |
+
if ($headers) {
|
85 |
+
curl_setopt($this->curlHandle, CURLOPT_HTTPHEADER, $headers);
|
86 |
+
}
|
87 |
+
$response = curl_exec($this->curlHandle);
|
88 |
+
|
89 |
+
// make sure there's no errors
|
90 |
+
$errno = curl_errno($this->curlHandle);
|
91 |
+
if ($errno !== 0) {
|
92 |
+
$error = curl_error($this->curlHandle);
|
93 |
+
trigger_error("CURL error: $errno - $error, url: $url");
|
94 |
+
}
|
95 |
+
|
96 |
+
// make sure we got a 200
|
97 |
+
$code = (int)curl_getinfo($this->curlHandle, CURLINFO_HTTP_CODE);
|
98 |
+
if ($code != self::HTTP_STATUS_OK) {
|
99 |
+
trigger_error("HTTP status code: $code, response=$response, url=$url");
|
100 |
+
}
|
101 |
+
|
102 |
+
|
103 |
+
return $response;
|
104 |
+
}
|
105 |
+
}
|
app/code/local/Eye4Fraud/Connector/Helper/Data.php
ADDED
@@ -0,0 +1,571 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Eye4fraud Connector Magento Module
|
4 |
+
*
|
5 |
+
* @category Eye4fraud
|
6 |
+
* @package Eye4fraud_Connector
|
7 |
+
*/
|
8 |
+
|
9 |
+
class Eye4Fraud_Connector_Helper_Data
|
10 |
+
extends Mage_Core_Helper_Abstract
|
11 |
+
{
|
12 |
+
protected $_config = null;
|
13 |
+
protected $_logFile = "eye4fraud_debug.log";
|
14 |
+
|
15 |
+
/** @var int Request sending attempts */
|
16 |
+
protected $_request_attempts = 30;
|
17 |
+
/** @var int Repeat request sending delay */
|
18 |
+
protected $_request_sent_delay = 25;//minutes
|
19 |
+
|
20 |
+
const PAYMENT_METHOD_USAEPAY = 'usaepay';
|
21 |
+
const MAGENTO_VERSION_1_7 = '1.7'; //This is run through version_compare()
|
22 |
+
|
23 |
+
/**
|
24 |
+
* List of statuses allowed to save in DB
|
25 |
+
* @var array
|
26 |
+
*/
|
27 |
+
protected $finalStatuses = array('A','D','I','C','F','M','INV','ALW');
|
28 |
+
|
29 |
+
/**
|
30 |
+
* Returns store config item
|
31 |
+
* @param string $str
|
32 |
+
* @param null $store_id
|
33 |
+
* @return string
|
34 |
+
*/
|
35 |
+
public function getConfig($str='', $store_id=null)
|
36 |
+
{
|
37 |
+
if($str) return Mage::getStoreConfig('eye4fraud_connector/'.$str, $store_id);
|
38 |
+
if (empty($this->_config)){
|
39 |
+
$this->_config = Mage::getStoreConfig('eye4fraud_connector', $store_id);
|
40 |
+
}
|
41 |
+
return $this->_config;
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Final fraud statuses, which not require update from remote
|
46 |
+
* @return array
|
47 |
+
*/
|
48 |
+
public function getFinalStatuses(){
|
49 |
+
return $this->finalStatuses;
|
50 |
+
}
|
51 |
+
|
52 |
+
/**
|
53 |
+
* Write log on debug
|
54 |
+
* @param mixed $txt Item to log
|
55 |
+
* @param bool $force Force log write
|
56 |
+
*/
|
57 |
+
public function log($txt, $force = false){
|
58 |
+
if (!$this->isDebug() && !$force) return;
|
59 |
+
if($this->isDebug()) $force = true;
|
60 |
+
Mage::log($txt, null, $this->_logFile, $force);
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Checks config to see if module is enabled
|
65 |
+
* @return boolean
|
66 |
+
*/
|
67 |
+
public function isEnabled(){
|
68 |
+
// Check if soap client exists - if not, we cannot enable the module
|
69 |
+
if (!$this->hasSoapClient()){
|
70 |
+
return false;
|
71 |
+
}
|
72 |
+
|
73 |
+
$config = $this->getConfig();
|
74 |
+
return !isset($config['api_settings']['enabled']) ? false : (bool)$config['api_settings']['enabled'];
|
75 |
+
}
|
76 |
+
|
77 |
+
/**
|
78 |
+
* Check if we have the Soap Client enabled on this server
|
79 |
+
* @return boolean
|
80 |
+
*/
|
81 |
+
public function hasSoapClient(){
|
82 |
+
return class_exists("SoapClient");
|
83 |
+
}
|
84 |
+
|
85 |
+
/**
|
86 |
+
* Checks config to see if module is debug_mode
|
87 |
+
* @return boolean
|
88 |
+
*/
|
89 |
+
public function isDebug(){
|
90 |
+
$config = $this->getConfig();
|
91 |
+
return !isset($config['api_settings']['debug_mode']) ? false : (bool)$config['api_settings']['debug_mode'];
|
92 |
+
}
|
93 |
+
|
94 |
+
/**
|
95 |
+
* Replace empty array values with empty string
|
96 |
+
* @param array $x
|
97 |
+
* @return array|string
|
98 |
+
*/
|
99 |
+
public function cleanArray(array $x)
|
100 |
+
{
|
101 |
+
if(is_array($x))
|
102 |
+
{
|
103 |
+
$array = array();
|
104 |
+
foreach($x as $key => $val)
|
105 |
+
{
|
106 |
+
$array[$key] = is_array($val) ? $this->cleanArray($val) : $val;
|
107 |
+
}
|
108 |
+
|
109 |
+
return $array ? $array : '';
|
110 |
+
}
|
111 |
+
|
112 |
+
return trim($x);
|
113 |
+
}
|
114 |
+
|
115 |
+
/**
|
116 |
+
* Convert objects or arrays of objects into pure array
|
117 |
+
* @param [type] $x [description]
|
118 |
+
* @return array|string
|
119 |
+
*/
|
120 |
+
public function makeArray($x)
|
121 |
+
{
|
122 |
+
$array = array();
|
123 |
+
|
124 |
+
if(is_array($x) || is_object($x))
|
125 |
+
{
|
126 |
+
foreach((array) $x as $key => $val)
|
127 |
+
{
|
128 |
+
$array[$key] = $this->makeArray($val);
|
129 |
+
}
|
130 |
+
|
131 |
+
return $array;
|
132 |
+
}
|
133 |
+
|
134 |
+
return $x;
|
135 |
+
}
|
136 |
+
|
137 |
+
/**
|
138 |
+
* Runs both makeArray and CleanArray on parameter $x
|
139 |
+
* @param array $x
|
140 |
+
* @return array
|
141 |
+
*/
|
142 |
+
public function makeCleanArray($x)
|
143 |
+
{
|
144 |
+
return $this->cleanArray($this->makeArray($x));
|
145 |
+
}
|
146 |
+
|
147 |
+
/**
|
148 |
+
* Converts falsey values to empty string
|
149 |
+
* @param mixed $value
|
150 |
+
* @return mixed|string
|
151 |
+
*/
|
152 |
+
public function nullToEmpty($value) {
|
153 |
+
return $value ? $value : '';
|
154 |
+
}
|
155 |
+
|
156 |
+
/**
|
157 |
+
* Returns value from array by key
|
158 |
+
* @param array $map
|
159 |
+
* @param string $key
|
160 |
+
* @return mixed|null
|
161 |
+
*/
|
162 |
+
public function mapGet($map, $key) {
|
163 |
+
return array_key_exists($key, $map) ? $map[$key] : null;
|
164 |
+
}
|
165 |
+
|
166 |
+
/**
|
167 |
+
* Returns false if transaction id is bad
|
168 |
+
* @param mixed $transId
|
169 |
+
* @return bool
|
170 |
+
*/
|
171 |
+
public function badTransId($transId) {
|
172 |
+
return $transId == '0' || empty($transId);
|
173 |
+
}
|
174 |
+
|
175 |
+
/**
|
176 |
+
* Converts credit card type
|
177 |
+
* @param string $type
|
178 |
+
* @return string
|
179 |
+
*/
|
180 |
+
public function convertCcType($type) {
|
181 |
+
switch ($type) {
|
182 |
+
case "AE": return "AMEX";
|
183 |
+
case "VI": return "VISA";
|
184 |
+
case "MC": return "MC";
|
185 |
+
case "DI": return "DISC";
|
186 |
+
}
|
187 |
+
return "OTHER";
|
188 |
+
}
|
189 |
+
|
190 |
+
/**
|
191 |
+
* Returns the mapper shipping method
|
192 |
+
* @param string $method
|
193 |
+
* @return string
|
194 |
+
*/
|
195 |
+
public function mapShippingMethod($method) {
|
196 |
+
if (!$method) {
|
197 |
+
return '';
|
198 |
+
}
|
199 |
+
list($carrier, $method) = explode('_', $method, 2);
|
200 |
+
|
201 |
+
$map = array(
|
202 |
+
'freeshipping' => array(
|
203 |
+
'freeshipping' => 'Other',
|
204 |
+
),
|
205 |
+
'ups' => array(
|
206 |
+
'1DM' => '1D', // Next Day Air Early AM
|
207 |
+
'1DML' => '1D', // Next Day Air Early AM Letter
|
208 |
+
'1DA' => '1D', // Next Day Air
|
209 |
+
'1DAL' => '1D', // Next Day Air Letter
|
210 |
+
'1DAPI' => '1D', // Next Day Air Intra (Puerto Rico)
|
211 |
+
'1DP' => '1D', // Next Day Air Saver
|
212 |
+
'1DPL' => '1D', // Next Day Air Saver Letter
|
213 |
+
'2DM' => '2D', // 2nd Day Air AM
|
214 |
+
'2DML' => '2D', // 2nd Day Air AM Letter
|
215 |
+
'2DA' => '2D', // 2nd Day Air
|
216 |
+
'2DAL' => '2D', // 2nd Day Air Letter
|
217 |
+
'3DS' => '3D', // 3 Day Select
|
218 |
+
'GND' => 'Other', // Ground
|
219 |
+
'GNDCOM' => 'Other', // Ground Commercial
|
220 |
+
'GNDRES' => 'Other', // Ground Residential
|
221 |
+
'STD' => 'Other', // Canada Standard
|
222 |
+
'XPR' => '1D', // Worldwide Express
|
223 |
+
'WXS' => '2D', // Worldwide Express Saver
|
224 |
+
'XPRL' => '1D', // Worldwide Express Letter
|
225 |
+
'XDM' => '1D', // Worldwide Express Plus
|
226 |
+
'XDML' => '2D', // Worldwide Express Plus Letter
|
227 |
+
'XPD' => '2D', // Worldwide Expedited
|
228 |
+
),
|
229 |
+
'usps' => array(
|
230 |
+
'FIRST CLASS' => 'Other', // First-Class
|
231 |
+
'PRIORITY' => '2D', // Priority Mail
|
232 |
+
'EXPRESS' => '1D', // Express Mail
|
233 |
+
'BPM' => 'Other', // Bound Printed Matter
|
234 |
+
'PARCEL' => 'Other', // Parcel Post
|
235 |
+
'MEDIA' => 'Other', // Media Mail
|
236 |
+
'LIBRARY' => 'Other', // Library
|
237 |
+
),
|
238 |
+
'dhl' => array(
|
239 |
+
'IE' => '3D', // International Express
|
240 |
+
'E SAT' => '3D', // Express Saturday
|
241 |
+
'E 10:30AM' => '1D', // Express 10:30 AM
|
242 |
+
'E' => '3D', // Express
|
243 |
+
'N' => '1D', // Next Afternoon
|
244 |
+
'S' => '2D', // Second Day Service
|
245 |
+
'G' => 'Other', // Ground
|
246 |
+
),
|
247 |
+
'fedex' => array(
|
248 |
+
'EUROPE_FIRST_INTERNATIONAL_PRIORITY' => '1D', // Europe First Priority
|
249 |
+
'FEDEX_1_DAY_FREIGHT' => '1D', // 1 Day Freight
|
250 |
+
'FEDEX_2_DAY_FREIGHT' => '2D', // 2 Day Freight
|
251 |
+
'FEDEX_2_DAY' => '2D', // 2 Day
|
252 |
+
'FEDEX_3_DAY_FREIGHT' => '3D', // 3 Day Freight
|
253 |
+
'FEDEX_EXPRESS_SAVER' => '3D', // Express Saver
|
254 |
+
'FEDEX_GROUND' => 'Other', // Ground
|
255 |
+
'FIRST_OVERNIGHT' => '1D', // First Overnight
|
256 |
+
'GROUND_HOME_DELIVERY' => 'Other', // Home Delivery
|
257 |
+
'INTERNATIONAL_ECONOMY' => 'Other', // International Economy
|
258 |
+
'INTERNATIONAL_ECONOMY_FREIGHT' => 'Other', // Intl Economy Freight
|
259 |
+
'INTERNATIONAL_FIRST' => '1D', // International First
|
260 |
+
'INTERNATIONAL_GROUND' => 'Other', // International Ground
|
261 |
+
'INTERNATIONAL_PRIORITY' => '3D', // International Priority
|
262 |
+
'INTERNATIONAL_PRIORITY_FREIGHT' => '3D', // Intl Priority Freight
|
263 |
+
'PRIORITY_OVERNIGHT' => '1D', // Priority Overnight
|
264 |
+
'SMART_POST' => 'Other', // Smart Post
|
265 |
+
'STANDARD_OVERNIGHT' => '1D', // Standard Overnight
|
266 |
+
'FEDEX_FREIGHT' => 'Other', // Freight
|
267 |
+
'FEDEX_NATIONAL_FREIGHT' => 'Other', // National Freight
|
268 |
+
)
|
269 |
+
);
|
270 |
+
|
271 |
+
$carrier_e4f_codes = $this->mapGet($map, $carrier);
|
272 |
+
if (!$carrier_e4f_codes) {
|
273 |
+
return 'Other';
|
274 |
+
}
|
275 |
+
$e4f_method_code = $this->mapGet($carrier_e4f_codes, $method);
|
276 |
+
return $e4f_method_code;
|
277 |
+
}
|
278 |
+
|
279 |
+
/**
|
280 |
+
* Returns state code from State Name
|
281 |
+
* @param string $stateName
|
282 |
+
* @return string
|
283 |
+
*/
|
284 |
+
public function getStateCode($stateName) {
|
285 |
+
$stateName = strtolower($stateName);
|
286 |
+
$US_STATES = array(
|
287 |
+
'AK' => 'Alaska',
|
288 |
+
'AL' => 'Alabama',
|
289 |
+
'AR' => 'Arkansas',
|
290 |
+
'AZ' => 'Arizona',
|
291 |
+
'CA' => 'California',
|
292 |
+
'CO' => 'Colorado',
|
293 |
+
'CT' => 'Connecticut',
|
294 |
+
'DE' => 'Delaware',
|
295 |
+
'FL' => 'Florida',
|
296 |
+
'GA' => 'Georgia',
|
297 |
+
'HI' => 'Hawaii',
|
298 |
+
'IA' => 'Iowa',
|
299 |
+
'ID' => 'Idaho',
|
300 |
+
'IL' => 'Illinois',
|
301 |
+
'IN' => 'Indiana',
|
302 |
+
'KS' => 'Kansas',
|
303 |
+
'KY' => 'Kentucky',
|
304 |
+
'LA' => 'Louisiana',
|
305 |
+
'MA' => 'Massachusetts',
|
306 |
+
'ME' => 'Maine',
|
307 |
+
'MD' => 'Maryland',
|
308 |
+
'MI' => 'Michigan',
|
309 |
+
'MN' => 'Minnesota',
|
310 |
+
'MO' => 'Missouri',
|
311 |
+
'MS' => 'Mississippi',
|
312 |
+
'MT' => 'Montana',
|
313 |
+
'NC' => 'North Carolina',
|
314 |
+
'ND' => 'North Dakota',
|
315 |
+
'NE' => 'Nebraska',
|
316 |
+
'NH' => 'New Hampshire',
|
317 |
+
'NJ' => 'New Jersey',
|
318 |
+
'NM' => 'New Mexico',
|
319 |
+
'NV' => 'Nevada',
|
320 |
+
'NY' => 'New York',
|
321 |
+
'OH' => 'Ohio',
|
322 |
+
'OK' => 'Oklahoma',
|
323 |
+
'OR' => 'Oregon',
|
324 |
+
'PA' => 'Pennsylvania',
|
325 |
+
'RI' => 'Rhode Island',
|
326 |
+
'SC' => 'South Carolina',
|
327 |
+
'SD' => 'South Dakota',
|
328 |
+
'TN' => 'Tennessee',
|
329 |
+
'TX' => 'Texas',
|
330 |
+
'UT' => 'Utah',
|
331 |
+
'VT' => 'Vermont',
|
332 |
+
'VA' => 'Virginia',
|
333 |
+
'WA' => 'Washington',
|
334 |
+
'WI' => 'Wisconsin',
|
335 |
+
'WV' => 'West Virginia',
|
336 |
+
'WY' => 'Wyoming',
|
337 |
+
// Armed Forces
|
338 |
+
'AA' => 'Armed Forces Americas (except Canada)',
|
339 |
+
'AE' => 'Armed Forces Africa,Canada,Europe,Middle East',
|
340 |
+
'AP' => 'Armed Forces Pacific',
|
341 |
+
// Commonwealth/Territory: Abbreviation:
|
342 |
+
'AS' => 'American Samoa',
|
343 |
+
'DC' => 'District of Columbia',
|
344 |
+
'FM' => 'Federated States of Micronesia',
|
345 |
+
'GU' => 'Guam',
|
346 |
+
'MH' => 'Marshall Islands',
|
347 |
+
'MP' => 'Northern Mariana Islands',
|
348 |
+
'PW' => 'Palau',
|
349 |
+
'PR' => 'Puerto Rico',
|
350 |
+
'VI' => 'Virgin Islands',
|
351 |
+
);
|
352 |
+
foreach ($US_STATES as $code => $name) {
|
353 |
+
if (strtolower($name) == $stateName) {
|
354 |
+
return $code;
|
355 |
+
}
|
356 |
+
}
|
357 |
+
return $stateName; // probably it is not USA so returning unchanged
|
358 |
+
}
|
359 |
+
/*
|
360 |
+
'X' => 'X - Street and 9-digit ZIP match',
|
361 |
+
'Y' => 'Y - Street and 5-digit ZIP match',
|
362 |
+
'A' => "A - Street matches, 5 & 9-digit ZIP no match",
|
363 |
+
'W' => 'W - Street not match, 9-digit ZIP matches',
|
364 |
+
'Z' => 'Z - Street not match, 5-digit ZIP matches',
|
365 |
+
'N' => "N - Street, 5 & 9-digit ZIP don't match",
|
366 |
+
'U' => "U - Address unavailable",
|
367 |
+
'R' => "R - Retry. Issuer's System Unavailable",
|
368 |
+
'E' => 'E - AVS data is invalid',
|
369 |
+
'S' => 'S - U.S. issuing bank does not support AVS',
|
370 |
+
'D' => 'D - Street and ZIP match for Intern. Trans.',
|
371 |
+
'M' => 'M - Street and ZIP match for Intern. Trans',
|
372 |
+
'B' => 'B - Street Match for Intern. Trans. ZIP unverified',
|
373 |
+
'P' => 'P - ZIP match for Intern. Trans. Street unverified',
|
374 |
+
'C' => 'C - Street, ZIP not verified for Intern. Trans.',
|
375 |
+
'I' => 'I - Address not verified by International issuer',
|
376 |
+
'G' => 'G - Non-US. Issuer does not participate',
|
377 |
+
*/
|
378 |
+
|
379 |
+
/**
|
380 |
+
* Converts usaePayAvs to Avs
|
381 |
+
* @param string $avs
|
382 |
+
* @return string
|
383 |
+
*/
|
384 |
+
public function usaePayAvsToAvs($avs) {
|
385 |
+
$avs_code = array(
|
386 |
+
'' => 'E', // AVS Data is invalid
|
387 |
+
// Domestic Response Codes
|
388 |
+
'YYY' => 'Y', // Address and 5-digit Zip Code match
|
389 |
+
'YYA' => 'Y',
|
390 |
+
'YYD' => 'Y',
|
391 |
+
'Y' => 'Y',
|
392 |
+
'NYZ' => 'Z', // 5-digit Zip Code matches only
|
393 |
+
'Z' => 'Z',
|
394 |
+
'YNA' => 'A', // Address matches only
|
395 |
+
'YNY' => 'A',
|
396 |
+
'A' => 'A',
|
397 |
+
'NNN' => 'N', // Neither Address nor Zip Code match<br />
|
398 |
+
'NN' => 'N',
|
399 |
+
'N' => 'N',
|
400 |
+
'YYX' => 'X', // Address and 9-digit Zip Code match
|
401 |
+
'X' => 'X',
|
402 |
+
'NYW' => 'W', // 9-digit Zip Code matches only
|
403 |
+
'W' => 'W',
|
404 |
+
'XXW' => '?', // Card Number Not On File
|
405 |
+
'XXU' => 'U', // Address info not verified for domestic transaction
|
406 |
+
'XXR' => 'R', //Retry / System Unavailable
|
407 |
+
'R' => 'R',
|
408 |
+
'U' => 'R',
|
409 |
+
'E' => 'R',
|
410 |
+
'XXS' => 'S', // Service not supported
|
411 |
+
'S' => 'S',
|
412 |
+
'XXE' => 'E', // Address verification not allowed for card type
|
413 |
+
'XXG' => 'G', // Global non-AVS participant
|
414 |
+
'G' => 'G',
|
415 |
+
'C' => 'G',
|
416 |
+
'I' => 'G',
|
417 |
+
// International Response Codes
|
418 |
+
'YYG' => 'B', // Address: Match & Zip: Not Compatible
|
419 |
+
'B' => 'B',
|
420 |
+
'M' => 'B',
|
421 |
+
'GGG' => 'D', // International Address: Match & Zip: Match<br />
|
422 |
+
'YYF' => 'D',
|
423 |
+
'D' => 'D',
|
424 |
+
'YGG' => 'P', //International Address: No Compatible & Zip: Match
|
425 |
+
'NYP' => 'P',
|
426 |
+
'P' => 'P',
|
427 |
+
);
|
428 |
+
return isset($avs_code[$avs]) ? $avs_code[$avs] : 'R';
|
429 |
+
}
|
430 |
+
|
431 |
+
/**
|
432 |
+
* Send request to eye4fraud servers
|
433 |
+
* @param array $post_array
|
434 |
+
* @return string
|
435 |
+
*/
|
436 |
+
public function send($post_array) {
|
437 |
+
|
438 |
+
$response = "";
|
439 |
+
//Log $post_array if in debug mode
|
440 |
+
$this->log("Sendig post:");
|
441 |
+
$this->log($post_array);
|
442 |
+
|
443 |
+
$post_query = http_build_query($post_array);
|
444 |
+
$ch = curl_init('https://www.eye4fraud.com/api/');
|
445 |
+
curl_setopt($ch, CURLOPT_POST, 1);
|
446 |
+
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
|
447 |
+
curl_setopt($ch, CURLOPT_POSTFIELDS, $post_query);
|
448 |
+
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
|
449 |
+
$response = curl_exec($ch);
|
450 |
+
|
451 |
+
//Log $response if in debug mode
|
452 |
+
$this->log("Response:");
|
453 |
+
$this->log($response);
|
454 |
+
|
455 |
+
$code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
|
456 |
+
curl_close($ch);
|
457 |
+
|
458 |
+
//Log $code for bad response if in debug mode
|
459 |
+
if ($response != 'ok') {
|
460 |
+
$this->log("=== E4F Observer::send() Error, \$response NOT ok ===");
|
461 |
+
$this->log("Code: $code");
|
462 |
+
}
|
463 |
+
|
464 |
+
return $response;
|
465 |
+
}
|
466 |
+
|
467 |
+
/**
|
468 |
+
* Prepare request to send later
|
469 |
+
* @param $post_array
|
470 |
+
*/
|
471 |
+
public function prepareRequest($post_array, $payment_method){
|
472 |
+
/** @var Eye4Fraud_Connector_Model_Request $request */
|
473 |
+
$request = Mage::getModel('eye4fraud_connector/request');
|
474 |
+
$request->setData('request_data', serialize($post_array));
|
475 |
+
$request->setData('increment_id', $post_array['OrderNumber']);
|
476 |
+
$request->setData('payment_method', $payment_method);
|
477 |
+
$request->setData('sent_time', Mage::getModel('core/date')->date('Y-m-d H:i:s',time() - $this->_request_sent_delay*60));
|
478 |
+
$request->save();
|
479 |
+
}
|
480 |
+
|
481 |
+
/**
|
482 |
+
* Send requests
|
483 |
+
* @throws Exception
|
484 |
+
*/
|
485 |
+
public function sendRequests(){
|
486 |
+
/** @var Eye4Fraud_Connector_Model_Resource_Requests_Cache_Collection $cache */
|
487 |
+
$cache = Mage::getResourceModel('eye4fraud_connector/requests_cache_collection');
|
488 |
+
$cache->addFieldToFilter('attempts',array('lt'=>$this->_request_attempts));
|
489 |
+
$cache->addFieldToFilter('sent_time', array('lt'=>Mage::getModel('core/date')->date('Y-m-d H:i:s',time() - $this->_request_sent_delay*60)));
|
490 |
+
$cache->load();
|
491 |
+
|
492 |
+
$this->log('Requests to send found: '.$cache->count());
|
493 |
+
foreach($cache as $request){
|
494 |
+
/** @var Eye4Fraud_Connector_Model_Request $request */
|
495 |
+
$result = $this->send(unserialize($request->getData('request_data')));
|
496 |
+
if($result=='ok'){
|
497 |
+
$request->delete();
|
498 |
+
}
|
499 |
+
else{
|
500 |
+
$this->log('Schedule request resend for order '.$request->getData('increment_id'));
|
501 |
+
$request->setData('attempts', $request->getData('attempts')+1);
|
502 |
+
$request->setData('sent_time', Mage::getModel('core/date')->date('Y-m-d H:i:s'));
|
503 |
+
$request->save();
|
504 |
+
}
|
505 |
+
}
|
506 |
+
}
|
507 |
+
|
508 |
+
/**
|
509 |
+
* @param $orderId
|
510 |
+
* @return array
|
511 |
+
*/
|
512 |
+
public function getOrderStatus($orderId){
|
513 |
+
$postData = array(
|
514 |
+
'ApiLogin' => $this->getConfig('api_settings/api_login'),
|
515 |
+
'ApiKey' => $this->getConfig('api_settings/api_key'),
|
516 |
+
'Action' => 'getOrderStatus',
|
517 |
+
'OrderNumber' => $orderId
|
518 |
+
);
|
519 |
+
$response = $this->send($postData);
|
520 |
+
// $response = '<response>
|
521 |
+
// <keyvalue>
|
522 |
+
// <key>OrderNumber</key>
|
523 |
+
// <value>'.$orderId.'</value>
|
524 |
+
// </keyvalue>
|
525 |
+
// <keyvalue>
|
526 |
+
// <key>StatusCode</key>
|
527 |
+
// <value>D</value>
|
528 |
+
// </keyvalue>
|
529 |
+
// <keyvalue>
|
530 |
+
// <key>Description</key>
|
531 |
+
// <value>Declined</value>
|
532 |
+
// </keyvalue>
|
533 |
+
//</response>';
|
534 |
+
$result = array();
|
535 |
+
if($response!==false){
|
536 |
+
$dom = new DOMDocument();
|
537 |
+
$dom->loadXML($response);
|
538 |
+
$nodesList = $dom->getElementsByTagName("keyvalue");
|
539 |
+
$result['error'] = true;
|
540 |
+
$result['StatusCode'] = 'IER';
|
541 |
+
$result['Description'] = 'Unknown Error';
|
542 |
+
if($nodesList->length) {
|
543 |
+
foreach($nodesList as $node){
|
544 |
+
$item = array();
|
545 |
+
foreach($node->childNodes as $node2){
|
546 |
+
if(in_array($node2->nodeName, array('key','value'))) $item[$node2->nodeName] = $node2->nodeValue;
|
547 |
+
}
|
548 |
+
$result[$item['key']] = $item['value'];
|
549 |
+
}
|
550 |
+
$result['error'] = false;
|
551 |
+
$result['Description'] = trim($result['Description']);
|
552 |
+
}
|
553 |
+
else{
|
554 |
+
$nodesList = $dom->getElementsByTagName("errors");
|
555 |
+
if($nodesList->length) {
|
556 |
+
$item = array();
|
557 |
+
foreach ($nodesList as $node) {
|
558 |
+
foreach($node->childNodes as $node2){
|
559 |
+
if(in_array($node2->nodeName, array('error'))) $item[$node2->nodeName] = $node2->nodeValue;
|
560 |
+
}
|
561 |
+
}
|
562 |
+
if($item['error']){
|
563 |
+
$result['StatusCode'] = 'RER';
|
564 |
+
$result['Description'] = $item['error'];
|
565 |
+
}
|
566 |
+
}
|
567 |
+
}
|
568 |
+
}
|
569 |
+
return $result;
|
570 |
+
}
|
571 |
+
}
|
app/code/local/Eye4Fraud/Connector/Model/Authorizenet.php
ADDED
@@ -0,0 +1,42 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(mageFindClassFile("Some_Other_Class")){
|
4 |
+
/** @noinspection PhpUndefinedClassInspection */
|
5 |
+
class Eye4Fraud_Connector_Model_Authorizenet_Parent extends Some_Other_Class{}
|
6 |
+
}
|
7 |
+
else{
|
8 |
+
class Eye4Fraud_Connector_Model_Authorizenet_Parent extends Mage_Paygate_Model_Authorizenet{}
|
9 |
+
}
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Extend Authorize.net payment instance to keep access to response data
|
13 |
+
|
14 |
+
* @category Eye4Fraud
|
15 |
+
* @package Eye4Fraud_Connector
|
16 |
+
* @author Mikhail Valiushko
|
17 |
+
*/
|
18 |
+
class Eye4Fraud_Connector_Model_Authorizenet extends Eye4Fraud_Connector_Model_Authorizenet_Parent
|
19 |
+
{
|
20 |
+
/** @var Mage_Paygate_Model_Authorizenet_Result */
|
21 |
+
protected $_responseData = null;
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Post request to gateway and return responce
|
25 |
+
*
|
26 |
+
* @param Mage_Paygate_Model_Authorizenet_Request|Varien_Object $request
|
27 |
+
* @return Mage_Paygate_Model_Authorizenet_Result
|
28 |
+
*/
|
29 |
+
protected function _postRequest(Varien_Object $request)
|
30 |
+
{
|
31 |
+
$this->_responseData = parent::_postRequest($request);
|
32 |
+
return $this->_responseData;
|
33 |
+
}
|
34 |
+
|
35 |
+
/**
|
36 |
+
* Return response data
|
37 |
+
* @return array
|
38 |
+
*/
|
39 |
+
public function getResponseData(){
|
40 |
+
return $this->_responseData;
|
41 |
+
}
|
42 |
+
}
|
app/code/local/Eye4Fraud/Connector/Model/Config/Backend/Data.php
ADDED
@@ -0,0 +1,38 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Backend model of system variable
|
5 |
+
* @category Eye4fraud
|
6 |
+
* @package Eye4fraud_Connector
|
7 |
+
*/
|
8 |
+
class Eye4Fraud_Connector_Model_Config_Backend_Data extends Mage_Core_Model_Config_Data
|
9 |
+
{
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Add availability call after load as public
|
13 |
+
*/
|
14 |
+
public function afterLoad()
|
15 |
+
{
|
16 |
+
$this->setData('checked','1');
|
17 |
+
$this->setData('value','2');
|
18 |
+
$this->_afterLoad();
|
19 |
+
}
|
20 |
+
|
21 |
+
/**
|
22 |
+
* Disable load
|
23 |
+
* @param int $id
|
24 |
+
* @param null $field
|
25 |
+
* @return $this
|
26 |
+
*/
|
27 |
+
public function load($id, $field=null){
|
28 |
+
return $this;
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Disable save
|
33 |
+
* @return $this
|
34 |
+
*/
|
35 |
+
public function save(){
|
36 |
+
return $this;
|
37 |
+
}
|
38 |
+
}
|
app/code/local/Eye4Fraud/Connector/Model/Config/Frontend/Authorizenet.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Check order grid rewrite
|
5 |
+
* @category Eye4fraud
|
6 |
+
* @package Eye4fraud_Connector
|
7 |
+
*/
|
8 |
+
class Eye4Fraud_Connector_Model_Config_Frontend_Authorizenet extends Mage_Adminhtml_Block_System_Config_Form_Field
|
9 |
+
{
|
10 |
+
/**
|
11 |
+
* Render config field
|
12 |
+
*
|
13 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
14 |
+
* @return string
|
15 |
+
*/
|
16 |
+
public function render(Varien_Data_Form_Element_Abstract $element){
|
17 |
+
$model = Mage::helper('payment')->getMethodInstance('authorizenet');
|
18 |
+
$element->setData('checked', is_a($model, 'Eye4Fraud_Connector_Model_Authorizenet'));
|
19 |
+
$element->setData('disabled', 'disabled');
|
20 |
+
$html = parent::render($element);
|
21 |
+
if(!is_a($model, 'Eye4Fraud_Connector_Model_Authorizenet')) $html .= '<td colspan="3">Final model class '.get_class($model).'</td>';
|
22 |
+
return $html;
|
23 |
+
}
|
24 |
+
|
25 |
+
}
|
app/code/local/Eye4Fraud/Connector/Model/Config/Frontend/Grid.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Check order grid rewrite
|
5 |
+
* @category Eye4fraud
|
6 |
+
* @package Eye4fraud_Connector
|
7 |
+
*/
|
8 |
+
class Eye4Fraud_Connector_Model_Config_Frontend_Grid extends Mage_Adminhtml_Block_System_Config_Form_Field
|
9 |
+
{
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Render config field
|
13 |
+
*
|
14 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
15 |
+
* @return string
|
16 |
+
*/
|
17 |
+
public function render(Varien_Data_Form_Element_Abstract $element){
|
18 |
+
$order_grid = Mage::getBlockSingleton('adminhtml/sales_order_grid');
|
19 |
+
$element->setData('checked', is_a($order_grid, 'Eye4Fraud_Connector_Block_Sales_Order_Grid'));
|
20 |
+
$element->setData('disabled', 'disabled');
|
21 |
+
$html = parent::render($element);;
|
22 |
+
if(!is_a($order_grid, 'Eye4Fraud_Connector_Block_Sales_Order_Grid')) $html .= '<td colspan="3">Final model class '.get_class($order_grid).'</td>';
|
23 |
+
return $html;
|
24 |
+
}
|
25 |
+
}
|
app/code/local/Eye4Fraud/Connector/Model/Config/Frontend/Payflowpro.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Check order grid rewrite
|
5 |
+
* @category Eye4fraud
|
6 |
+
* @package Eye4fraud_Connector
|
7 |
+
*/
|
8 |
+
class Eye4Fraud_Connector_Model_Config_Frontend_Payflowpro extends Mage_Adminhtml_Block_System_Config_Form_Field
|
9 |
+
{
|
10 |
+
/**
|
11 |
+
* Render config field
|
12 |
+
*
|
13 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
14 |
+
* @return string
|
15 |
+
*/
|
16 |
+
public function render(Varien_Data_Form_Element_Abstract $element){
|
17 |
+
$model = Mage::helper('payment')->getMethodInstance('verisign');
|
18 |
+
$element->setData('checked', is_a($model, 'Eye4Fraud_Connector_Model_Payflowpro'));
|
19 |
+
$element->setData('disabled', 'disabled');
|
20 |
+
$html = parent::render($element);
|
21 |
+
if(!is_a($model, 'Eye4Fraud_Connector_Model_Payflowpro')) $html .= '<td colspan="3">Final model class '.get_class($model).'</td>';
|
22 |
+
return $html;
|
23 |
+
}
|
24 |
+
|
25 |
+
}
|
app/code/local/Eye4Fraud/Connector/Model/Config/Frontend/Paypaluk.php
ADDED
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Check order grid rewrite
|
5 |
+
* @category Eye4fraud
|
6 |
+
* @package Eye4fraud_Connector
|
7 |
+
*/
|
8 |
+
class Eye4Fraud_Connector_Model_Config_Frontend_Paypaluk extends Mage_Adminhtml_Block_System_Config_Form_Field
|
9 |
+
{
|
10 |
+
/**
|
11 |
+
* Render config field
|
12 |
+
*
|
13 |
+
* @param Varien_Data_Form_Element_Abstract $element
|
14 |
+
* @return string
|
15 |
+
*/
|
16 |
+
public function render(Varien_Data_Form_Element_Abstract $element){
|
17 |
+
$model = Mage::getModel('paypaluk/api_nvp');
|
18 |
+
$element->setData('checked', is_a($model, 'Eye4Fraud_Connector_Model_PaypalUk_Api_Nvp'));
|
19 |
+
$element->setData('disabled', 'disabled');
|
20 |
+
$html = parent::render($element);
|
21 |
+
if(!is_a($model, 'Eye4Fraud_Connector_Model_PaypalUk_Api_Nvp')) $html .= '<td colspan="3">Final model class '.get_class($model).'</td>';
|
22 |
+
return $html;
|
23 |
+
}
|
24 |
+
|
25 |
+
}
|
app/code/local/Eye4Fraud/Connector/Model/Observer.php
ADDED
@@ -0,0 +1,548 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Eye4fraud Connector Magento Module
|
4 |
+
*
|
5 |
+
* @category Eye4fraud
|
6 |
+
* @package Eye4fraud_Connector
|
7 |
+
*/
|
8 |
+
|
9 |
+
class Eye4Fraud_Connector_Model_Observer
|
10 |
+
extends Mage_Core_Model_Mysql4_Abstract
|
11 |
+
{
|
12 |
+
protected $_helper = null;
|
13 |
+
|
14 |
+
/**
|
15 |
+
* Cache fraud statuses for orders grid
|
16 |
+
* @var array
|
17 |
+
*/
|
18 |
+
protected $ordersStatuses = array();
|
19 |
+
|
20 |
+
/**
|
21 |
+
* Magento class constructor
|
22 |
+
* @return void
|
23 |
+
*/
|
24 |
+
protected function _construct()
|
25 |
+
{
|
26 |
+
}
|
27 |
+
|
28 |
+
/**
|
29 |
+
* Checks if the soap client is enabled.
|
30 |
+
* Shows an error message in the admin panel if it's not.
|
31 |
+
* @return [type] [description]
|
32 |
+
*/
|
33 |
+
public function checkSoapClient()
|
34 |
+
{
|
35 |
+
$helper = $this->_getHelper();
|
36 |
+
if (!$helper->hasSoapClient()) {
|
37 |
+
Mage::getSingleton('core/session')->addError('Your server does not have SoapClient enabled. The EYE4FRAUD extension will not function until the SoapClient is installed/enabled in your server configuration.');
|
38 |
+
return false;
|
39 |
+
}
|
40 |
+
return true;
|
41 |
+
}
|
42 |
+
|
43 |
+
/**
|
44 |
+
* Order placed after; called from sales_order_place_after event
|
45 |
+
* @param $observer
|
46 |
+
* @throws Exception
|
47 |
+
* @internal param \Varien_Event_Observer $observer
|
48 |
+
* @return $this
|
49 |
+
*/
|
50 |
+
public function orderPlacedAfter(&$observer)
|
51 |
+
{
|
52 |
+
$order = $observer->getEvent()->getOrder();
|
53 |
+
$payment = $order->getPayment();
|
54 |
+
if (empty($payment)) {
|
55 |
+
$this->_getHelper()->log('EYE4FRAUD: Invalid payment passed to callback.');
|
56 |
+
return $this;
|
57 |
+
}
|
58 |
+
$this->_processOrder($order, $payment, 'orderPlacedAfter');
|
59 |
+
|
60 |
+
return $this;
|
61 |
+
}
|
62 |
+
|
63 |
+
/**
|
64 |
+
* Function to process order; called from orderPlacedAfter method
|
65 |
+
* @param Mage_Sales_Model_Order $order
|
66 |
+
* @param Mage_Sales_Model_Order_Payment $payment
|
67 |
+
* @param string $methodName
|
68 |
+
* @return void
|
69 |
+
*/
|
70 |
+
protected function _processOrder(\Mage_Sales_Model_Order $order, \Mage_Sales_Model_Order_Payment $payment, $methodName)
|
71 |
+
{
|
72 |
+
/**
|
73 |
+
* Someone write this very long text
|
74 |
+
* @todo move this to separate model, create separate model for each supported payment method
|
75 |
+
* @todo getModel('eye4fraud_connector/payment_{payment_code}')
|
76 |
+
*/
|
77 |
+
try {
|
78 |
+
$helper = $this->_getHelper();
|
79 |
+
$config = $helper->getConfig('', $order->getStoreId());
|
80 |
+
|
81 |
+
//Make sure we have a config array, and that we're enabled
|
82 |
+
if (empty($config) || !$helper->isEnabled()) {
|
83 |
+
return;
|
84 |
+
}
|
85 |
+
|
86 |
+
$method_instance = $payment->getMethodInstance();
|
87 |
+
$payment_method = $method_instance->getCode();
|
88 |
+
$helper->log("Payment method name: ".$payment_method);
|
89 |
+
|
90 |
+
if(!in_array($payment_method,array(
|
91 |
+
$helper::PAYMENT_METHOD_USAEPAY,
|
92 |
+
Mage_Paypal_Model_Config::METHOD_PAYFLOWPRO,
|
93 |
+
Mage_Paypal_Model_Config::METHOD_WPP_DIRECT,
|
94 |
+
Mage_Paypal_Model_Config::METHOD_WPP_PE_EXPRESS,
|
95 |
+
Mage_Paypal_Model_Config::METHOD_WPP_EXPRESS,
|
96 |
+
Mage_Paygate_Model_Authorizenet::METHOD_CODE,
|
97 |
+
'sfc_cim_core', // StoreFront Authorize.Net CIM Tokenized Payment Extension
|
98 |
+
'cls_splitpayment', // Modified version of Authorize.Net payment
|
99 |
+
'authnetcim' //ParadoxLabs AuthorizeNetCim Payment Extension
|
100 |
+
))) {
|
101 |
+
$this->_getHelper()->log("Payment method not supported: ".$payment_method);
|
102 |
+
return;
|
103 |
+
}
|
104 |
+
|
105 |
+
$version = Mage::getVersion();
|
106 |
+
|
107 |
+
/** @var \Mage_Customer_Model_Address $billing */
|
108 |
+
$billing = $order->getBillingAddress();
|
109 |
+
/** @var \Mage_Customer_Model_Address $shipping */
|
110 |
+
$shipping = $order->getShippingAddress();
|
111 |
+
/** Make empty shipping object if it not exists */
|
112 |
+
if ($shipping === false){
|
113 |
+
$shipping = new Varien_Object();
|
114 |
+
}
|
115 |
+
else if (!$shipping->getPostcode() && !$shipping->getData('city')){
|
116 |
+
/** Shipping match billing if not specified */
|
117 |
+
$shipping = $billing;
|
118 |
+
}
|
119 |
+
|
120 |
+
$items = $order->getAllItems();
|
121 |
+
$line_items = array();
|
122 |
+
foreach ($items as $i => $item) {
|
123 |
+
/** @var \Mage_Sales_Model_Order_Item $item */;
|
124 |
+
$line_items[$i + 1] = array(
|
125 |
+
'ProductName' => $item->getSku(),
|
126 |
+
'ProductDescription' => $item->getName(),
|
127 |
+
'ProductSellingPrice' => round($item->getRowTotal(),2),
|
128 |
+
'ProductQty' => round($item->getQtyOrdered(),2),
|
129 |
+
'ProductCostPrice' => round($item->getBasePrice(),2),
|
130 |
+
// todo convert currency
|
131 |
+
);
|
132 |
+
}
|
133 |
+
|
134 |
+
$transInfo = $payment->getTransactionAdditionalInfo();
|
135 |
+
|
136 |
+
$additional_information = $payment->additional_information;
|
137 |
+
|
138 |
+
//file_put_contents(Mage::getBaseDir("log")."/debug.log",print_r($payment->debug(), true)."\n",FILE_APPEND);
|
139 |
+
//file_put_contents(Mage::getBaseDir("log")."/debug.log",print_r($method_instance->debug(), true)."\n",FILE_APPEND);
|
140 |
+
|
141 |
+
$transId = null;
|
142 |
+
switch ($payment_method) {
|
143 |
+
case 'authnetcim':{
|
144 |
+
$cc_number = $payment->getData('cc_number');
|
145 |
+
if(!$cc_number) $cc_number = $additional_information['acc_number'];
|
146 |
+
$card_type_raw = $additional_information['card_type'];
|
147 |
+
//Visa, MasterCard, AmericanExpress, Discover, JCB, DinersClub
|
148 |
+
switch($card_type_raw){
|
149 |
+
case 'Visa': $card_type = 'VI'; break;
|
150 |
+
case 'MasterCard': $card_type = 'MC'; break;
|
151 |
+
case 'AmericanExpress': $card_type = 'AE'; break;
|
152 |
+
case 'Discover': $card_type = 'DI'; break;
|
153 |
+
default: $card_type = 'other'; break;
|
154 |
+
}
|
155 |
+
$payment->setData('cc_cid_status', $additional_information['card_code_response_code']);
|
156 |
+
$payment->setdata('cc_avs_status', $additional_information['avs_result_code']);
|
157 |
+
break;
|
158 |
+
}
|
159 |
+
case 'sfc_cim_core':{
|
160 |
+
require_once(Mage::getBaseDir('lib') . '/anet_php_sdk/AuthorizeNet.php');
|
161 |
+
|
162 |
+
if(Mage::getStoreConfig('payment/sfc_cim_core/test')==1){
|
163 |
+
$login_enc = Mage::getStoreConfig('payment/sfc_cim_core/test_login');
|
164 |
+
$pass_enc = Mage::getStoreConfig('payment/sfc_cim_core/test_trans_key');
|
165 |
+
}
|
166 |
+
else{
|
167 |
+
$login_enc = Mage::getStoreConfig('payment/sfc_cim_core/login');
|
168 |
+
$pass_enc = Mage::getStoreConfig('payment/sfc_cim_core/trans_key');
|
169 |
+
}
|
170 |
+
$login = Mage::helper('core')->decrypt($login_enc);
|
171 |
+
$pass = Mage::helper('core')->decrypt($pass_enc);
|
172 |
+
|
173 |
+
define("AUTHORIZENET_API_LOGIN_ID", $login);
|
174 |
+
define("AUTHORIZENET_TRANSACTION_KEY", $pass);
|
175 |
+
$request = new AuthorizeNetTD();
|
176 |
+
$transId = $payment->getData('transaction_id');
|
177 |
+
$response = $request->getTransactionDetails($transId);
|
178 |
+
//file_put_contents(Mage::getBaseDir("log")."/debug.log",print_r($response, true)."\n",FILE_APPEND);
|
179 |
+
if($response->xml->messages->resultCode == 'Error'){
|
180 |
+
$helper->log('Error in transaction details request: '.$response->xml->messages->message->text, true);
|
181 |
+
if($response->xml->messages->message->code=='E00011'){
|
182 |
+
$helper->log('Enable transaction details API in your Authorize.net account. Path: Account/Security settings/Transaction details API', true);
|
183 |
+
}
|
184 |
+
}
|
185 |
+
else{
|
186 |
+
$cc_number = $payment->getData('cc_number');
|
187 |
+
if(!$cc_number) $cc_number = $response->xml->transaction->payment->creditCard->cardNumber;
|
188 |
+
$card_type_raw = $response->xml->transaction->payment->creditCard->cardType;
|
189 |
+
//Visa, MasterCard, AmericanExpress, Discover, JCB, DinersClub
|
190 |
+
switch($card_type_raw){
|
191 |
+
case 'Visa': $card_type = 'VI'; break;
|
192 |
+
case 'MasterCard': $card_type = 'MC'; break;
|
193 |
+
case 'AmericanExpress': $card_type = 'AE'; break;
|
194 |
+
case 'Discover': $card_type = 'DI'; break;
|
195 |
+
default: $card_type = 'other'; break;
|
196 |
+
}
|
197 |
+
$payment->setData('cc_cid_status', (string)$response->xml->transaction->cardCodeResponse);
|
198 |
+
$payment->setdata('cc_avs_status', (string)$response->xml->transaction->AVSResponse);
|
199 |
+
}
|
200 |
+
|
201 |
+
break;
|
202 |
+
}
|
203 |
+
case Mage_Paygate_Model_Authorizenet::METHOD_CODE:
|
204 |
+
$transId = isset($transInfo['real_transaction_id']) ? $transInfo['real_transaction_id'] : 0;
|
205 |
+
if ($helper->badTransId($transId)) {
|
206 |
+
$transId = $payment->getLastTransId();
|
207 |
+
}
|
208 |
+
if ($helper->badTransId($transId)) {
|
209 |
+
$transId = $payment->getCcTransId();
|
210 |
+
}
|
211 |
+
$cc_number = version_compare($version, $helper::MAGENTO_VERSION_1_7, '<') ? $payment->getData('cc_number_enc') : $payment->getData('cc_number');
|
212 |
+
$card_type = "";
|
213 |
+
if (version_compare($version, $helper::MAGENTO_VERSION_1_7, ">=")) {
|
214 |
+
$card_type = $payment->getData('cc_type');
|
215 |
+
}
|
216 |
+
if ($helper->convertCcType($card_type) === 'OTHER') {
|
217 |
+
$authorize_cards = $additional_information['authorize_cards'];
|
218 |
+
if ($authorize_cards) {
|
219 |
+
foreach ($authorize_cards as $card) {
|
220 |
+
if ($card["cc_type"]) {
|
221 |
+
$card_type = $card["cc_type"];
|
222 |
+
}
|
223 |
+
}
|
224 |
+
}
|
225 |
+
}
|
226 |
+
break;
|
227 |
+
// Redundant switch branches are here to emphasize which
|
228 |
+
// payment methods are known as compatible with the following code
|
229 |
+
case Mage_Paypal_Model_Config::METHOD_PAYFLOWPRO:
|
230 |
+
$transId = $payment->getLastTransId();
|
231 |
+
if ($helper->badTransId($transId)) {
|
232 |
+
$transId = $payment->getCcTransId();
|
233 |
+
}
|
234 |
+
$cc_number = $payment->getData('cc_number');
|
235 |
+
$card_type = $payment->getData('cc_type');
|
236 |
+
break;
|
237 |
+
case $helper::PAYMENT_METHOD_USAEPAY:{
|
238 |
+
$transId = $payment->getData('cc_trans_id');
|
239 |
+
// if ($helper->badTransId($transId)) {
|
240 |
+
// $transId = $payment->getCcTransId();
|
241 |
+
// }
|
242 |
+
$cc_number = $payment->getData('cc_number');
|
243 |
+
$card_type = $payment->getData('cc_type');
|
244 |
+
break;
|
245 |
+
}
|
246 |
+
default:
|
247 |
+
$transId = $payment->getLastTransId();
|
248 |
+
if ($helper->badTransId($transId)) {
|
249 |
+
$transId = $payment->getCcTransId();
|
250 |
+
}
|
251 |
+
$cc_number = $payment->getData('cc_number');
|
252 |
+
$card_type = $payment->getData('cc_type');
|
253 |
+
break;
|
254 |
+
}
|
255 |
+
$remoteIp = $order->getRemoteIp() ? $order->getRemoteIp() : false;
|
256 |
+
|
257 |
+
//Double check we have CC number
|
258 |
+
if (empty($cc_number)) {
|
259 |
+
//Try getting CC number from post array...
|
260 |
+
$cc_number = isset($_POST['payment']['cc_number']) ? $_POST['payment']['cc_number'] : null;
|
261 |
+
}
|
262 |
+
//Double check we have CC type
|
263 |
+
if (empty($card_type)) {
|
264 |
+
//Try getting CC type from post array...
|
265 |
+
$card_type = isset($_POST['payment']['cc_type']) ? $_POST['payment']['cc_type'] : null;
|
266 |
+
}
|
267 |
+
|
268 |
+
// Getting emails. In different versions of magento, different methods can return emails.
|
269 |
+
$semail = $order->getCustomerEmail();
|
270 |
+
$bemail = $order->getCustomerEmail();
|
271 |
+
if (!$semail && !$bemail) {
|
272 |
+
$customer = Mage::getSingleton('customer/session')->getCustomer();
|
273 |
+
$bemail = $customer->getEmail(); // To get Email Address of a customer.
|
274 |
+
$semail = $customer->getEmail(); // To get Email Address of a customer.
|
275 |
+
}
|
276 |
+
if (!$bemail) {
|
277 |
+
$bemail = $billing->getEmail();
|
278 |
+
}
|
279 |
+
if (!$semail) {
|
280 |
+
$semail = $shipping->getEmail();
|
281 |
+
}
|
282 |
+
if ($semail && !$bemail) {
|
283 |
+
$bemail = $semail;
|
284 |
+
}
|
285 |
+
if ($bemail && !$semail) {
|
286 |
+
$semail = $bemail;
|
287 |
+
}
|
288 |
+
|
289 |
+
$shippingMethod = $order->getShippingMethod(false);
|
290 |
+
$post_array = array(
|
291 |
+
'SiteName' => $config["api_settings"]['api_site_name'],
|
292 |
+
'ApiLogin' => $config["api_settings"]['api_login'],
|
293 |
+
'ApiKey' => $config["api_settings"]['api_key'],
|
294 |
+
'TransactionId' => $transId,
|
295 |
+
'OrderDate' => $order->getCreatedAt(),
|
296 |
+
'OrderNumber' => $order->getIncrementId(),
|
297 |
+
'IPAddress' => !empty($remoteIp) ? $remoteIp : $_SERVER['REMOTE_ADDR'],
|
298 |
+
|
299 |
+
'BillingFirstName' => $helper->nullToEmpty($billing->getFirstname()),
|
300 |
+
'BillingMiddleName' => $helper->nullToEmpty($billing->getMiddlename()),
|
301 |
+
'BillingLastName' => $helper->nullToEmpty($billing->getLastname()),
|
302 |
+
'BillingCompany' => '',// todo
|
303 |
+
'BillingAddress1' => $billing->getStreet(1),
|
304 |
+
'BillingAddress2' => $billing->getStreet(2),
|
305 |
+
'BillingCity' => $billing->getCity(),
|
306 |
+
'BillingState' => $helper->getStateCode($billing->getRegion()),
|
307 |
+
'BillingZip' => $billing->getPostcode(),
|
308 |
+
'BillingCountry' => $billing->getCountry(),
|
309 |
+
'BillingEveningPhone' => $billing->getTelephone(),
|
310 |
+
'BillingEmail' => $bemail,
|
311 |
+
|
312 |
+
'ShippingFirstName' => $helper->nullToEmpty($shipping->getFirstname()),
|
313 |
+
'ShippingMiddleName' => $helper->nullToEmpty($shipping->getMiddlename()),
|
314 |
+
'ShippingLastName' => $helper->nullToEmpty($shipping->getLastname()),
|
315 |
+
'ShippingCompany' => '',// todo
|
316 |
+
'ShippingAddress1' => $shipping->getStreet(1),
|
317 |
+
'ShippingAddress2' => $shipping->getStreet(2),
|
318 |
+
'ShippingCity' => $shipping->getCity(),
|
319 |
+
'ShippingState' => $helper->getStateCode($shipping->getRegion()),
|
320 |
+
'ShippingZip' => $shipping->getPostcode(),
|
321 |
+
'ShippingCountry' => $shipping->getCountry(),
|
322 |
+
'ShippingEveningPhone' => $shipping->getTelephone(),
|
323 |
+
'ShippingEmail' => $semail,
|
324 |
+
|
325 |
+
'ShippingCost' => round($order->getShippingAmount(),2),
|
326 |
+
'GrandTotal' => round($order->getGrandTotal(),2), // todo convert currency if e4f will be used outside of USA
|
327 |
+
'CCType' => $helper->convertCcType($card_type),
|
328 |
+
'RawCCType' => $card_type,
|
329 |
+
'CCFirst6' => substr($cc_number, 0, 6),
|
330 |
+
'CCLast4' => substr($cc_number, -4),
|
331 |
+
'CIDResponse' => $payment->cc_cid_status, //'M',
|
332 |
+
'AVSCode' => $payment->cc_avs_status, //'Y',
|
333 |
+
'LineItems' => $line_items,
|
334 |
+
|
335 |
+
'ShippingMethod' => $helper->mapShippingMethod($shippingMethod),
|
336 |
+
'RawShippingMethod' => $shippingMethod,
|
337 |
+
);
|
338 |
+
|
339 |
+
|
340 |
+
$ordersCollection = Mage::getResourceModel('sales/order_collection');
|
341 |
+
$ordersCollection->addFieldToFilter('customer_id', $order->getCustomerId());
|
342 |
+
$ordersCollection->addFieldToFilter('status', array('in'=>array(
|
343 |
+
Mage_Sales_Model_Order::STATE_PROCESSING,
|
344 |
+
Mage_Sales_Model_Order::STATE_COMPLETE,
|
345 |
+
Mage_Sales_Model_Order::STATE_CLOSED,
|
346 |
+
)));
|
347 |
+
$ordersCollection->addFieldToFilter('grand_total', array('gt'=> 0));
|
348 |
+
$ordersCollection->getSelect()->order('created_at ASC');
|
349 |
+
$ordersCollection->getSelect()->limit(1);
|
350 |
+
$ordersCollection->load();
|
351 |
+
|
352 |
+
$post_array['RepeatCustomer'] = 'No';
|
353 |
+
if($ordersCollection->count()){
|
354 |
+
$firstOrder = $ordersCollection->getFirstItem();
|
355 |
+
$post_array['FirstOrdered'] = date('Y-m-d', strtotime($firstOrder->getData('created_at')));
|
356 |
+
if($order->getIncrementId()!=$firstOrder->getIncrementId()) $post_array['RepeatCustomer'] = 'Yes';
|
357 |
+
if($order->getCustomerEmail()!=$firstOrder->getData('customer_email')) $post_array['CustomerComments'] = 'EmailChanged:'.$firstOrder->getData('customer_email');
|
358 |
+
}
|
359 |
+
|
360 |
+
|
361 |
+
switch($payment_method){
|
362 |
+
case 'authnetcim':
|
363 |
+
case 'sfc_cim_core':{
|
364 |
+
if(strpos($post_array["CCFirst6"],'X')!==false) $post_array["CCFirst6"] = '000000';
|
365 |
+
break;
|
366 |
+
}
|
367 |
+
case $helper::PAYMENT_METHOD_USAEPAY:{
|
368 |
+
$post_array["AVSCode"] = $helper->usaePayAvsToAvs($payment->getData('cc_avs_status'));
|
369 |
+
$post_array["CIDResponse"] = $payment->getData('cc_cid_status');
|
370 |
+
break;
|
371 |
+
}
|
372 |
+
case Mage_Paypal_Model_Config::METHOD_PAYFLOWPRO:{
|
373 |
+
if(method_exists($method_instance,'getResponseData')){
|
374 |
+
/** @var Eye4Fraud_Connector_Model_Payflowpro $method_instance */
|
375 |
+
$details = $method_instance->getResponseData();
|
376 |
+
$post_array["AVSCode"] = $details->getData('procavs');
|
377 |
+
$post_array["CIDResponse"] = $details->getData('proccvv2');
|
378 |
+
}
|
379 |
+
else{
|
380 |
+
$helper->log('Payflow class is wrong: '.get_class($payment).'; Required method not exists', true);
|
381 |
+
$helper->log('Please resolve class rewrite conflict for paypal/payflowpro', true);
|
382 |
+
$helper->log('You can use https://github.com/firegento/firegento-debug/blob/master/src/firegento.php for this', true);
|
383 |
+
}
|
384 |
+
break;
|
385 |
+
}
|
386 |
+
case Mage_Paypal_Model_Config::METHOD_WPP_DIRECT:{
|
387 |
+
$post_array['PayPalPayerID'] = $payment->getData('additional_information','paypal_payer_id');
|
388 |
+
$post_array["AVSCode"] = $payment->getData('additional_information','paypal_avs_code');
|
389 |
+
$post_array["CIDResponse"] = $payment->getData('additional_information','paypal_cvv2_match');;
|
390 |
+
break;
|
391 |
+
}
|
392 |
+
case Mage_Paypal_Model_Config::METHOD_WPP_PE_EXPRESS:{
|
393 |
+
$post_array['PayPalPayerID'] = $payment->getData('additional_information','paypal_payer_id');
|
394 |
+
$post_array['PayPalPayerStatus'] = strtolower($payment->getData('additional_information','paypal_payer_status'));
|
395 |
+
$address_status_description = array('Y'=>'confirmed','N'=>'unconfirmed');
|
396 |
+
/** @var string $address_status_code */
|
397 |
+
$address_status_code = $payment->getData('additional_information','paypal_address_status');
|
398 |
+
if(isset($address_status_description[$address_status_code])) $address_status = $address_status_description[$address_status_code];
|
399 |
+
else $address_status = 'none';
|
400 |
+
$post_array['PayPalAddressStatus'] = $address_status;
|
401 |
+
$post_array['CCFirst6'] = '';
|
402 |
+
$post_array['CCLast4'] = '';
|
403 |
+
$post_array['CCType'] = 'PAYPAL';
|
404 |
+
break;
|
405 |
+
}
|
406 |
+
case Mage_Paypal_Model_Config::METHOD_WPP_EXPRESS:{
|
407 |
+
$post_array['PayPalPayerID'] = $payment->getData('additional_information','paypal_payer_id');
|
408 |
+
$post_array['PayPalPayerStatus'] = strtolower($payment->getData('additional_information','paypal_payer_status'));
|
409 |
+
$post_array['PayPalAddressStatus'] = strtolower($payment->getData('additional_information','paypal_address_status'));
|
410 |
+
$post_array['CCFirst6'] = '';
|
411 |
+
$post_array['CCLast4'] = '';
|
412 |
+
$post_array['CCType'] = 'PAYPAL';
|
413 |
+
break;
|
414 |
+
}
|
415 |
+
case Mage_Paygate_Model_Authorizenet::METHOD_CODE:{
|
416 |
+
/** @var Eye4Fraud_Connector_Model_Authorizenet $method_instance */
|
417 |
+
if(method_exists($method_instance,'getResponseData')){
|
418 |
+
/** @var Mage_Paygate_Model_Authorizenet_Result|array $details */
|
419 |
+
$details = $method_instance->getResponseData();
|
420 |
+
if(is_null($details) or (is_array($details) and !count($details))){
|
421 |
+
$helper->log('Object '.get_class($method_instance).' return empty response, that should not happen', true);
|
422 |
+
break;
|
423 |
+
}
|
424 |
+
$post_array["AVSCode"] = $details->getData('avs_result_code');
|
425 |
+
$post_array["CIDResponse"] = $details->getData('card_code_response_code');
|
426 |
+
if(!$post_array["AVSCode"] or !$post_array["CIDResponse"]){
|
427 |
+
$helper->log('AVS code or CIDResponse empty: '.print_r($details->getData(), true), true);
|
428 |
+
}
|
429 |
+
}
|
430 |
+
else{
|
431 |
+
$helper->log('Payflow class is wrong: '.get_class($method_instance).'; Required method not exists', true);
|
432 |
+
$helper->log('Please resolve class rewrite conflict for paygate/authorizenet', true);
|
433 |
+
$helper->log('You can use https://github.com/firegento/firegento-debug/blob/master/src/firegento.php for this', true);
|
434 |
+
}
|
435 |
+
break;
|
436 |
+
}
|
437 |
+
}
|
438 |
+
|
439 |
+
if($payment_method == 'cls_splitpayment'){
|
440 |
+
/** @var CLS_SplitPayment_Model_Splitpayment $method_instance */
|
441 |
+
if(method_exists($method_instance,'getResponseData')){
|
442 |
+
/** @var array $details */
|
443 |
+
$multiple_details = $method_instance->getResponseData();
|
444 |
+
if(is_null($multiple_details) or (is_array($multiple_details) and !count($multiple_details))){
|
445 |
+
$helper->log('Object '.get_class($method_instance).' return empty response, that should not happen', true);
|
446 |
+
}
|
447 |
+
else{
|
448 |
+
for($i=0; $i<count($multiple_details);$i++){
|
449 |
+
$details = $multiple_details[$i];
|
450 |
+
$card_type = $payment->getData('cc_type'.($i+1));
|
451 |
+
$cc_number = $payment->getData('cc_number'.($i+1));
|
452 |
+
$post_array["AVSCode"] = $details->getData('avs_result_code');
|
453 |
+
$post_array["CIDResponse"] = $details->getData('card_code_response_code');
|
454 |
+
$post_array["TransactionId"] = $details->getData('transaction_id');
|
455 |
+
$post_array['CCType'] = $helper->convertCcType($card_type);
|
456 |
+
$post_array['RawCCType'] = $card_type;
|
457 |
+
$post_array['CCFirst6'] = substr($cc_number, 0, 6);
|
458 |
+
$post_array['CCLast4'] = substr($cc_number, -4);
|
459 |
+
|
460 |
+
if(!$post_array["AVSCode"] or !$post_array["CIDResponse"]){
|
461 |
+
$helper->log('AVS code or CIDResponse empty: '.print_r($details->getData(), true), true);
|
462 |
+
}
|
463 |
+
$this->_getHelper()->prepareRequest($post_array, $payment_method);
|
464 |
+
}
|
465 |
+
}
|
466 |
+
}
|
467 |
+
else{
|
468 |
+
$helper->log('CLS_SplitPayment_Model_Splitpayment class is wrong: required method not exists', true);
|
469 |
+
}
|
470 |
+
}
|
471 |
+
else{
|
472 |
+
$this->_getHelper()->prepareRequest($post_array, $payment_method);
|
473 |
+
}
|
474 |
+
} catch (Exception $e) {
|
475 |
+
$this->_getHelper()->log($e->getMessage() . "\n" . $e->getTraceAsString());
|
476 |
+
//file_put_contents(Mage::getBaseDir("log")."/debug.log",'Exception'."\n\n",FILE_APPEND);
|
477 |
+
}
|
478 |
+
}
|
479 |
+
|
480 |
+
/**
|
481 |
+
* Returns the module helper. Initializes one if not already set.
|
482 |
+
* @return Eye4fraud_Connector_Helper_Data $this->_helper
|
483 |
+
*/
|
484 |
+
protected function _getHelper()
|
485 |
+
{
|
486 |
+
if (empty($this->_helper)) {
|
487 |
+
$this->_helper = Mage::helper("eye4fraud_connector");
|
488 |
+
}
|
489 |
+
return $this->_helper;
|
490 |
+
}
|
491 |
+
|
492 |
+
/**
|
493 |
+
* Prepare fraud statuses to display in orders grid
|
494 |
+
* @param array $event
|
495 |
+
*/
|
496 |
+
public function prepareFraudStatuses($event)
|
497 |
+
{
|
498 |
+
if (!Mage::helper('core/data')->isModuleOutputEnabled('Eye4Fraud_Connector')) return;
|
499 |
+
if (!$this->_getHelper()->isEnabled()) return;
|
500 |
+
|
501 |
+
/** @var Mage_Sales_Model_Resource_Order_Grid_Collection $collectiong */
|
502 |
+
$ordersCollection = $event['order_grid_collection'];
|
503 |
+
$statuses = array();
|
504 |
+
foreach ($ordersCollection as $order) $statuses[$order['increment_id']] = 0;
|
505 |
+
/** @var Eye4Fraud_Connector_Model_Resource_Status_Collection $statusesCollection */
|
506 |
+
$statusesCollection = Mage::getResourceSingleton('eye4fraud_connector/status_collection');
|
507 |
+
$statusesCollection->setStatuses($statuses)->load();
|
508 |
+
}
|
509 |
+
|
510 |
+
/**
|
511 |
+
* Refresh fraud status in cron job
|
512 |
+
*/
|
513 |
+
public function cronRefreshStatus(){
|
514 |
+
if (!Mage::helper('core/data')->isModuleOutputEnabled('Eye4Fraud_Connector')) return;
|
515 |
+
if (!$this->_getHelper()->isEnabled()) return;
|
516 |
+
|
517 |
+
$helper = Mage::helper('eye4fraud_connector');
|
518 |
+
$helper->log("Start cron job ".date("d-m-Y H:i"));
|
519 |
+
|
520 |
+
$helper->sendRequests();
|
521 |
+
|
522 |
+
if(!$helper->getConfig("cron_settings/enabled")) return;
|
523 |
+
|
524 |
+
$finalStatuses = $helper->getFinalStatuses();
|
525 |
+
$requestInterval = $helper->getConfig("cron_settings/update_interval");
|
526 |
+
$requestInterval || $requestInterval = 60;
|
527 |
+
$maxDate = Mage::getModel('core/date')->date('Y-m-d H:i:s', time() - $requestInterval*60);
|
528 |
+
|
529 |
+
$statusesCollection = Mage::getResourceSingleton('eye4fraud_connector/status_collection');
|
530 |
+
$statusesCollection->exceptStatuses($finalStatuses)
|
531 |
+
->notOlderThan($maxDate)->limitRecordsCount(50)->setCronFlag(true);
|
532 |
+
$records_count = $statusesCollection->count();
|
533 |
+
$helper->log("Found records to process ".json_encode($records_count));
|
534 |
+
|
535 |
+
$helper->log("Cron job finished ".date("d-m-Y H:i"));
|
536 |
+
}
|
537 |
+
|
538 |
+
/**
|
539 |
+
* Send requests manually from orders page
|
540 |
+
*/
|
541 |
+
public function sendRequestsManual(){
|
542 |
+
$helper = Mage::helper('eye4fraud_connector');
|
543 |
+
$helper->log("Send request manually");
|
544 |
+
|
545 |
+
$helper->sendRequests();
|
546 |
+
}
|
547 |
+
|
548 |
+
}
|
app/code/local/Eye4Fraud/Connector/Model/Payflowpro.php
ADDED
@@ -0,0 +1,45 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
if(mageFindClassFile("Some_Other_Class")){
|
4 |
+
/** @noinspection PhpUndefinedClassInspection */
|
5 |
+
class Eye4Fraud_Connector_Model_Payflowpro_Parent extends Some_Other_Class{}
|
6 |
+
}
|
7 |
+
else{
|
8 |
+
class Eye4Fraud_Connector_Model_Payflowpro_Parent extends Mage_Paypal_Model_Payflowpro{}
|
9 |
+
}
|
10 |
+
|
11 |
+
/**
|
12 |
+
* Payflow Pro payment gateway model
|
13 |
+
*
|
14 |
+
* @category Eye4Fraud
|
15 |
+
* @package Eye4Fraud_Connector
|
16 |
+
* @author Mikhail Valiushko
|
17 |
+
*/
|
18 |
+
|
19 |
+
class Eye4Fraud_Connector_Model_Payflowpro extends Eye4Fraud_Connector_Model_Payflowpro_Parent
|
20 |
+
{
|
21 |
+
protected $_responseData = array();
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Post request to gateway and return response
|
25 |
+
*
|
26 |
+
*
|
27 |
+
* @param Varien_Object $request
|
28 |
+
* @return Varien_Object
|
29 |
+
*/
|
30 |
+
protected function _postRequest(Varien_Object $request)
|
31 |
+
{
|
32 |
+
$this->_responseData = parent::_postRequest($request);
|
33 |
+
|
34 |
+
return $this->_responseData;
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Return response data
|
39 |
+
* @return array
|
40 |
+
*/
|
41 |
+
public function getResponseData(){
|
42 |
+
return $this->_responseData;
|
43 |
+
}
|
44 |
+
|
45 |
+
}
|
app/code/local/Eye4Fraud/Connector/Model/PaypalUk/Api/Nvp.php
ADDED
@@ -0,0 +1,16 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Rewrite class to catch PAYERSTATUS and ADDRESSSTATUS into payment additional info array.
|
5 |
+
* @category Eye4fraud
|
6 |
+
* @package Eye4fraud_Connector
|
7 |
+
*/
|
8 |
+
class Eye4Fraud_Connector_Model_PaypalUk_Api_Nvp extends Mage_PaypalUk_Model_Api_Nvp
|
9 |
+
{
|
10 |
+
public function _construct(){
|
11 |
+
parent::_construct();
|
12 |
+
$this->_globalMap['PAYERSTATUS'] = 'payer_status';
|
13 |
+
$this->_globalMap['ADDRESSSTATUS'] = 'address_status';
|
14 |
+
$this->_paymentInformationResponse[] = 'PAYERSTATUS';
|
15 |
+
}
|
16 |
+
}
|
app/code/local/Eye4Fraud/Connector/Model/Request.php
ADDED
@@ -0,0 +1,17 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Model of single request in cache
|
4 |
+
*
|
5 |
+
* @category Eye4Fraud
|
6 |
+
* @package Eye4fraud_Connector
|
7 |
+
*/
|
8 |
+
class Eye4Fraud_Connector_Model_Request extends Mage_Core_Model_Abstract
|
9 |
+
{
|
10 |
+
protected $_eventPrefix = 'eye4fraud_connector_requests';
|
11 |
+
|
12 |
+
protected function _construct()
|
13 |
+
{
|
14 |
+
$this->_init('eye4fraud_connector/requests_cache');
|
15 |
+
}
|
16 |
+
|
17 |
+
}
|
app/code/local/Eye4Fraud/Connector/Model/Resource/Requests/Cache.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Resource model for single request in cache
|
4 |
+
*
|
5 |
+
* @category Eye4Fraud
|
6 |
+
* @package Eye4fraud_Connector
|
7 |
+
*/
|
8 |
+
class Eye4Fraud_Connector_Model_Resource_Requests_Cache extends Mage_Core_Model_Resource_Db_Abstract
|
9 |
+
{
|
10 |
+
/**
|
11 |
+
* Initialize main table and table id field
|
12 |
+
*/
|
13 |
+
protected function _construct()
|
14 |
+
{
|
15 |
+
$this->_init('eye4fraud_connector/requests_cache', 'request_id');
|
16 |
+
}
|
17 |
+
|
18 |
+
}
|
app/code/local/Eye4Fraud/Connector/Model/Resource/Requests/Cache/Collection.php
ADDED
@@ -0,0 +1,46 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Collection of cached requests
|
5 |
+
*
|
6 |
+
* @category Eye4Fraud
|
7 |
+
* @package Eye4fraud_Connector
|
8 |
+
*/
|
9 |
+
class Eye4Fraud_Connector_Model_Resource_Requests_Cache_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
10 |
+
{
|
11 |
+
/**
|
12 |
+
* Resource initialization
|
13 |
+
*/
|
14 |
+
protected function _construct()
|
15 |
+
{
|
16 |
+
$this->_init('eye4fraud_connector/request','eye4fraud_connector/requests_cache');
|
17 |
+
}
|
18 |
+
|
19 |
+
/**
|
20 |
+
* @return $this
|
21 |
+
*/
|
22 |
+
protected function _afterLoad(){
|
23 |
+
parent::_afterLoad();
|
24 |
+
return $this;
|
25 |
+
}
|
26 |
+
|
27 |
+
/**
|
28 |
+
* Retreive option array
|
29 |
+
*
|
30 |
+
* @return array
|
31 |
+
*/
|
32 |
+
public function toOptionArray()
|
33 |
+
{
|
34 |
+
return parent::_toOptionArray('id', 'request_id');
|
35 |
+
}
|
36 |
+
|
37 |
+
/**
|
38 |
+
* Retreive option hash
|
39 |
+
*
|
40 |
+
* @return array
|
41 |
+
*/
|
42 |
+
public function toOptionHash()
|
43 |
+
{
|
44 |
+
return parent::_toOptionHash('id', 'request_id');
|
45 |
+
}
|
46 |
+
}
|
app/code/local/Eye4Fraud/Connector/Model/Resource/Status.php
ADDED
@@ -0,0 +1,28 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Resource model for single fraud status
|
4 |
+
*
|
5 |
+
* @category Eye4Fraud
|
6 |
+
* @package Eye4fraud_Connector
|
7 |
+
*/
|
8 |
+
class Eye4Fraud_Connector_Model_Resource_Status extends Mage_Core_Model_Resource_Db_Abstract
|
9 |
+
{
|
10 |
+
/**
|
11 |
+
* Primery key auto increment flag
|
12 |
+
*
|
13 |
+
* @var bool
|
14 |
+
*/
|
15 |
+
protected $_isPkAutoIncrement = false;
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Initialize main table and table id field
|
19 |
+
*/
|
20 |
+
protected function _construct()
|
21 |
+
{
|
22 |
+
$this->_init('eye4fraud_connector/status', 'order_id');
|
23 |
+
}
|
24 |
+
|
25 |
+
public function setNewFlag($flag){
|
26 |
+
$this->_useIsObjectNew = $flag;
|
27 |
+
}
|
28 |
+
}
|
app/code/local/Eye4Fraud/Connector/Model/Resource/Status/Collection.php
ADDED
@@ -0,0 +1,181 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/**
|
4 |
+
* Collection of fraud statuses of orders
|
5 |
+
*
|
6 |
+
* @category Eye4Fraud
|
7 |
+
* @package Eye4fraud_Connector
|
8 |
+
*/
|
9 |
+
class Eye4Fraud_Connector_Model_Resource_Status_Collection extends Mage_Core_Model_Resource_Db_Collection_Abstract
|
10 |
+
{
|
11 |
+
/**
|
12 |
+
* All requested statuses
|
13 |
+
* @var array
|
14 |
+
*/
|
15 |
+
protected $statuses = array();
|
16 |
+
|
17 |
+
/**
|
18 |
+
* Collection loaded in cron
|
19 |
+
* @var bool
|
20 |
+
*/
|
21 |
+
protected $_cronFlag = false;
|
22 |
+
|
23 |
+
/**
|
24 |
+
* Resource initialization
|
25 |
+
*/
|
26 |
+
protected function _construct()
|
27 |
+
{
|
28 |
+
$this->_init('eye4fraud_connector/status');
|
29 |
+
}
|
30 |
+
|
31 |
+
/**
|
32 |
+
* Add attribute id to collection
|
33 |
+
*
|
34 |
+
* @param array $statuses Array of order IDs
|
35 |
+
* @return $this
|
36 |
+
*/
|
37 |
+
public function setStatuses($statuses)
|
38 |
+
{
|
39 |
+
$this->statuses = $statuses;
|
40 |
+
$this->addFieldToFilter('order_id', array('in'=>array_keys($statuses)));
|
41 |
+
return $this;
|
42 |
+
}
|
43 |
+
|
44 |
+
/**
|
45 |
+
* Select all statuses except
|
46 |
+
* @param $statuses
|
47 |
+
* @return $this
|
48 |
+
*/
|
49 |
+
public function exceptStatuses($statuses){
|
50 |
+
if(!is_array($statuses)) return $this;
|
51 |
+
$this->getSelect()->where('status NOT IN (?)',$statuses);
|
52 |
+
return $this;
|
53 |
+
}
|
54 |
+
|
55 |
+
/**
|
56 |
+
* Limit collection by update date
|
57 |
+
* @param $timestamp
|
58 |
+
* @return $this
|
59 |
+
*/
|
60 |
+
public function notOlderThan($timestamp){
|
61 |
+
$this->getSelect()->where('updated_at < ?',$timestamp);
|
62 |
+
return $this;
|
63 |
+
}
|
64 |
+
|
65 |
+
public function limitRecordsCount($limit){
|
66 |
+
$this->getSelect()->limit($limit);
|
67 |
+
return $this;
|
68 |
+
}
|
69 |
+
|
70 |
+
/**
|
71 |
+
* Set cron flag
|
72 |
+
* @param bool $flag
|
73 |
+
* @return $this
|
74 |
+
*/
|
75 |
+
public function setCronFlag($flag){
|
76 |
+
$this->_cronFlag = $flag;
|
77 |
+
return $this;
|
78 |
+
}
|
79 |
+
|
80 |
+
/**
|
81 |
+
* @return $this
|
82 |
+
*/
|
83 |
+
protected function _afterLoad(){
|
84 |
+
parent::_afterLoad();
|
85 |
+
$helper = Mage::helper("eye4fraud_connector");
|
86 |
+
$isCronEnabled = $helper->getConfig('cron_settings/enabled');
|
87 |
+
$final_statuses = $helper->getFinalStatuses();
|
88 |
+
foreach ($this->_items as $item) {
|
89 |
+
/** @var Eye4Fraud_Connector_Model_Status $item */
|
90 |
+
if((!$isCronEnabled or $this->_cronFlag) and !in_array($item['status'],$final_statuses)){
|
91 |
+
$this->statuses[$item->getData('order_id')] = 0;
|
92 |
+
}
|
93 |
+
else $this->statuses[$item->getData('order_id')] = 1;
|
94 |
+
}
|
95 |
+
Mage::helper("eye4fraud_connector")->log(json_encode($this->statuses));
|
96 |
+
foreach($this->statuses as $orderId=>$loaded){
|
97 |
+
if(!$loaded){
|
98 |
+
if($item = $this->getItemById($orderId)){
|
99 |
+
$item->retrieveStatus();
|
100 |
+
}
|
101 |
+
else{
|
102 |
+
/** @var Eye4Fraud_Connector_Model_Status $item */
|
103 |
+
$item = Mage::getModel("eye4fraud_connector/status");
|
104 |
+
$item->isObjectNew(true);
|
105 |
+
$item->setData('order_id', $orderId);
|
106 |
+
$item->retrieveStatus();
|
107 |
+
$this->addItem($item);
|
108 |
+
}
|
109 |
+
}
|
110 |
+
}
|
111 |
+
return $this;
|
112 |
+
}
|
113 |
+
|
114 |
+
/**
|
115 |
+
* Get fraud status from status Model
|
116 |
+
* @param Mage_Sales_Model_Order $order
|
117 |
+
* @return string
|
118 |
+
*/
|
119 |
+
public function getOrderStatus($order){
|
120 |
+
$fraudStatusItem = $this->getItemById($order->getData('increment_id'));
|
121 |
+
if($fraudStatusItem==null) return "IER";
|
122 |
+
$status = $fraudStatusItem->getData('status');
|
123 |
+
return $status;
|
124 |
+
}
|
125 |
+
|
126 |
+
public function getOrderStatusLabel($order){
|
127 |
+
$status = $this->getOrderStatus($order);
|
128 |
+
return Mage::helper('eye4fraud_connector')->__("status:".$status);
|
129 |
+
}
|
130 |
+
|
131 |
+
/**
|
132 |
+
* @param $renderedValue
|
133 |
+
* @param Mage_Sales_Model_Order $order
|
134 |
+
* @param $column
|
135 |
+
* @return string
|
136 |
+
*/
|
137 |
+
public function addStatusDescription($renderedValue, $order, $column){
|
138 |
+
$fraudStatusItem = $this->getItemById($order->getData('increment_id'));
|
139 |
+
if($fraudStatusItem==null) return $renderedValue;
|
140 |
+
/** @var Eye4Fraud_Connector_Helper_Data $helper */
|
141 |
+
$helper = Mage::helper('eye4fraud_connector');
|
142 |
+
$description = $fraudStatusItem->getData('description');
|
143 |
+
$updateMinutes = 0;
|
144 |
+
if($helper->getConfig('cron_settings/enabled')=="1" and !in_array($fraudStatusItem->getData('status'), $helper->getFinalStatuses())){
|
145 |
+
$currentTimestamp = Mage::getModel('core/date')->timestamp(time());
|
146 |
+
$updateMinutes = round(($currentTimestamp - strtotime($fraudStatusItem->getData('updated_at')))/60,0);
|
147 |
+
}
|
148 |
+
if(!$description or $renderedValue==$description) {
|
149 |
+
if($updateMinutes and $updateMinutes > intval($helper->getConfig('cron_settings/update_interval'))){
|
150 |
+
if($updateMinutes<60) $text = $updateMinutes."m";
|
151 |
+
else{
|
152 |
+
$updateMinutes = round($updateMinutes/60,2);
|
153 |
+
$text = $updateMinutes."h";
|
154 |
+
}
|
155 |
+
return "<span title='Updated ".$text." ago' style='color: red'>".$renderedValue."</span>";
|
156 |
+
}
|
157 |
+
return $renderedValue;
|
158 |
+
}
|
159 |
+
return '<span>'.$renderedValue.' <img style="vertical-align:middle; margin-top:-3px;" src="'.Mage::getDesign()->getSkinUrl('images/i_question-mark.png').'" title="'.$description.'"/></span>';
|
160 |
+
}
|
161 |
+
|
162 |
+
/**
|
163 |
+
* Retreive option array
|
164 |
+
*
|
165 |
+
* @return array
|
166 |
+
*/
|
167 |
+
public function toOptionArray()
|
168 |
+
{
|
169 |
+
return parent::_toOptionArray('id', 'record_id');
|
170 |
+
}
|
171 |
+
|
172 |
+
/**
|
173 |
+
* Retreive option hash
|
174 |
+
*
|
175 |
+
* @return array
|
176 |
+
*/
|
177 |
+
public function toOptionHash()
|
178 |
+
{
|
179 |
+
return parent::_toOptionHash('id', 'record_id');
|
180 |
+
}
|
181 |
+
}
|
app/code/local/Eye4Fraud/Connector/Model/Status.php
ADDED
@@ -0,0 +1,74 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
/**
|
3 |
+
* Model of single fraud status for one order
|
4 |
+
*
|
5 |
+
* @category Eye4Fraud
|
6 |
+
* @package Eye4fraud_Connector
|
7 |
+
*/
|
8 |
+
class Eye4Fraud_Connector_Model_Status extends Mage_Core_Model_Abstract
|
9 |
+
{
|
10 |
+
protected $_eventPrefix = 'eye4fraud_connector_status';
|
11 |
+
|
12 |
+
protected function _construct()
|
13 |
+
{
|
14 |
+
$this->_init('eye4fraud_connector/status');
|
15 |
+
$this->_dataSaveAllowed = false;
|
16 |
+
}
|
17 |
+
|
18 |
+
/**
|
19 |
+
* Retrieve status from remote server and save model
|
20 |
+
* @return $this
|
21 |
+
*/
|
22 |
+
public function retrieveStatus(){
|
23 |
+
$fraudData = Mage::helper('eye4fraud_connector')->getOrderStatus($this->getData('order_id'));
|
24 |
+
if(empty($fraudData)) {
|
25 |
+
$this->setData('status', 'RER');
|
26 |
+
$this->setData('description', 'Connection Error');
|
27 |
+
$this->setData('updated_at', Mage::getModel('core/date')->date('Y-m-d H:i:s'));
|
28 |
+
return $this;
|
29 |
+
}
|
30 |
+
if(isset($fraudData['error']) and $fraudData['error']){
|
31 |
+
$this->setData('error', true);
|
32 |
+
}
|
33 |
+
|
34 |
+
$this->setData('status', $fraudData['StatusCode']);
|
35 |
+
$this->setData('description', $fraudData['Description']);
|
36 |
+
$this->setData('updated_at', Mage::getModel('core/date')->date('Y-m-d H:i:s'));
|
37 |
+
/**
|
38 |
+
* A little hack to restore order_id field after model was saved
|
39 |
+
*/
|
40 |
+
$tmp_order_id = $this->getData('order_id');
|
41 |
+
$this->save();
|
42 |
+
$this->setData('order_id',$tmp_order_id);
|
43 |
+
return $this;
|
44 |
+
}
|
45 |
+
|
46 |
+
/**
|
47 |
+
* Set or get flag is object new
|
48 |
+
* @param null $flag
|
49 |
+
* @return bool
|
50 |
+
*/
|
51 |
+
public function isObjectNew($flag=null){
|
52 |
+
$this->getResource()->setNewFlag(true);
|
53 |
+
return parent::isObjectNew($flag);
|
54 |
+
}
|
55 |
+
|
56 |
+
protected function _beforeSave(){
|
57 |
+
parent::_beforeSave();
|
58 |
+
$saveStatuses = Mage::helper('eye4fraud_connector')->getFinalStatuses();
|
59 |
+
if(in_array($this->getData('status'), $saveStatuses)) $this->_dataSaveAllowed = true;
|
60 |
+
$cron_enabled = Mage::helper('eye4fraud_connector')->getConfig('cron_settings/enabled');
|
61 |
+
if($cron_enabled) $this->_dataSaveAllowed = true;
|
62 |
+
if($this->isEmpty()){
|
63 |
+
/** @var Eye4Fraud_Connector_Model_Status $statusObject */
|
64 |
+
$statusObject = Mage::getModel('eye4fraud_connector/status');
|
65 |
+
$statusObject->load($this->getData('order_id'));
|
66 |
+
if(!$statusObject->isEmpty()){
|
67 |
+
Mage::helper("eye4fraud_connector")->log('Order #'.$this->getData('order_id').' already inserted');
|
68 |
+
$this->setData($statusObject->getData());
|
69 |
+
$this->_dataSaveAllowed = false;
|
70 |
+
}
|
71 |
+
}
|
72 |
+
return $this;
|
73 |
+
}
|
74 |
+
}
|
app/code/local/Eye4Fraud/Connector/etc/adminhtml.xml
ADDED
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Eye4fraud Connector Magento Module
|
5 |
+
*
|
6 |
+
* @category Eye4fraud
|
7 |
+
* @package Eye4fraud_Connector
|
8 |
+
*/
|
9 |
+
-->
|
10 |
+
<config>
|
11 |
+
<acl>
|
12 |
+
<resources>
|
13 |
+
<all>
|
14 |
+
<title>Allow Everything</title>
|
15 |
+
</all>
|
16 |
+
<admin>
|
17 |
+
<children>
|
18 |
+
<system>
|
19 |
+
<children>
|
20 |
+
<config>
|
21 |
+
<children>
|
22 |
+
<eye4fraud_connector translate="title">
|
23 |
+
<title>Eye4Fraud Connector</title>
|
24 |
+
</eye4fraud_connector>
|
25 |
+
</children>
|
26 |
+
</config>
|
27 |
+
</children>
|
28 |
+
</system>
|
29 |
+
</children>
|
30 |
+
</admin>
|
31 |
+
</resources>
|
32 |
+
</acl>
|
33 |
+
</config>
|
app/code/local/Eye4Fraud/Connector/etc/config.xml
ADDED
@@ -0,0 +1,148 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0" encoding="UTF-8"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Eye4fraud Connector Magento Module
|
5 |
+
*
|
6 |
+
* @category Eye4fraud
|
7 |
+
* @package Eye4fraud_Connector
|
8 |
+
*/
|
9 |
+
-->
|
10 |
+
<config>
|
11 |
+
<modules>
|
12 |
+
<Eye4Fraud_Connector>
|
13 |
+
<version>1.2.0</version>
|
14 |
+
</Eye4Fraud_Connector>
|
15 |
+
</modules>
|
16 |
+
<global>
|
17 |
+
<helpers>
|
18 |
+
<eye4fraud_connector>
|
19 |
+
<class>Eye4Fraud_Connector_Helper</class>
|
20 |
+
</eye4fraud_connector>
|
21 |
+
</helpers>
|
22 |
+
<events>
|
23 |
+
<controller_action_postdispatch_adminhtml_sales_order_index>
|
24 |
+
<observers>
|
25 |
+
<connector_observer>
|
26 |
+
<type>singleton</type>
|
27 |
+
<class>Eye4Fraud_Connector_Model_Observer</class>
|
28 |
+
<method>sendRequestsManual</method>
|
29 |
+
</connector_observer>
|
30 |
+
</observers>
|
31 |
+
</controller_action_postdispatch_adminhtml_sales_order_index>
|
32 |
+
<sales_order_place_after>
|
33 |
+
<observers>
|
34 |
+
<connector_observer>
|
35 |
+
<type>singleton</type>
|
36 |
+
<class>Eye4Fraud_Connector_Model_Observer</class>
|
37 |
+
<method>orderPlacedAfter</method>
|
38 |
+
</connector_observer>
|
39 |
+
</observers>
|
40 |
+
</sales_order_place_after>
|
41 |
+
<admin_system_config_changed_section_eye4fraud_connector>
|
42 |
+
<observers>
|
43 |
+
<mymodule>
|
44 |
+
<type>singleton</type>
|
45 |
+
<class>Eye4Fraud_Connector_Model_Observer</class>
|
46 |
+
<method>checkSoapClient</method>
|
47 |
+
</mymodule>
|
48 |
+
</observers>
|
49 |
+
</admin_system_config_changed_section_eye4fraud_connector>
|
50 |
+
<sales_order_grid_collection_load_after>
|
51 |
+
<observers>
|
52 |
+
<connector_observer>
|
53 |
+
<type>singleton</type>
|
54 |
+
<class>Eye4Fraud_Connector_Model_Observer</class>
|
55 |
+
<method>prepareFraudStatuses</method>
|
56 |
+
</connector_observer>
|
57 |
+
</observers>
|
58 |
+
</sales_order_grid_collection_load_after>
|
59 |
+
</events>
|
60 |
+
<models>
|
61 |
+
<eye4fraud_connector>
|
62 |
+
<class>Eye4Fraud_Connector_Model</class>
|
63 |
+
<resourceModel>eye4fraud_connector_resource</resourceModel>
|
64 |
+
</eye4fraud_connector>
|
65 |
+
<eye4fraud_connector_resource>
|
66 |
+
<class>Eye4Fraud_Connector_Model_Resource</class>
|
67 |
+
<entities>
|
68 |
+
<status>
|
69 |
+
<table>fraud_status</table>
|
70 |
+
</status>
|
71 |
+
<requests_cache>
|
72 |
+
<table>eye4fraud_requests_cache</table>
|
73 |
+
</requests_cache>
|
74 |
+
</entities>
|
75 |
+
</eye4fraud_connector_resource>
|
76 |
+
<paygate>
|
77 |
+
<rewrite>
|
78 |
+
<authorizenet>Eye4Fraud_Connector_Model_Authorizenet</authorizenet>
|
79 |
+
</rewrite>
|
80 |
+
</paygate>
|
81 |
+
<paypal>
|
82 |
+
<rewrite>
|
83 |
+
<payflowpro>Eye4Fraud_Connector_Model_Payflowpro</payflowpro>
|
84 |
+
</rewrite>
|
85 |
+
</paypal>
|
86 |
+
<paypaluk>
|
87 |
+
<rewrite>
|
88 |
+
<api_nvp>Eye4Fraud_Connector_Model_PaypalUk_Api_Nvp</api_nvp>
|
89 |
+
<api_express_nvp>Eye4Fraud_Connector_Model_PaypalUk_Api_Nvp</api_express_nvp>
|
90 |
+
</rewrite>
|
91 |
+
</paypaluk>
|
92 |
+
</models>
|
93 |
+
<resources>
|
94 |
+
<eye4fraud_setup>
|
95 |
+
<setup>
|
96 |
+
<module>Eye4Fraud_Connector</module>
|
97 |
+
</setup>
|
98 |
+
</eye4fraud_setup>
|
99 |
+
</resources>
|
100 |
+
<blocks>
|
101 |
+
<adminhtml>
|
102 |
+
<rewrite>
|
103 |
+
<sales_order_grid>Eye4Fraud_Connector_Block_Sales_Order_Grid</sales_order_grid>
|
104 |
+
</rewrite>
|
105 |
+
</adminhtml>
|
106 |
+
</blocks>
|
107 |
+
<template>
|
108 |
+
<email>
|
109 |
+
<authorizepopulation_email_template translate="label">
|
110 |
+
<label>Credit Card Number</label>
|
111 |
+
<file>authorizepopulation.html</file>
|
112 |
+
<type>html</type>
|
113 |
+
</authorizepopulation_email_template>
|
114 |
+
</email>
|
115 |
+
</template>
|
116 |
+
</global>
|
117 |
+
<default>
|
118 |
+
<eye4fraud_connector>
|
119 |
+
<cron_settings>
|
120 |
+
<enabled>0</enabled>
|
121 |
+
<update_interval>60</update_interval>
|
122 |
+
</cron_settings>
|
123 |
+
</eye4fraud_connector>
|
124 |
+
</default>
|
125 |
+
<adminhtml>
|
126 |
+
<translate>
|
127 |
+
<modules>
|
128 |
+
<eye4fraud_connector>
|
129 |
+
<files>
|
130 |
+
<module>Eye4Fraud_Connector.csv</module>
|
131 |
+
</files>
|
132 |
+
</eye4fraud_connector>
|
133 |
+
</modules>
|
134 |
+
</translate>
|
135 |
+
</adminhtml>
|
136 |
+
<crontab>
|
137 |
+
<jobs>
|
138 |
+
<eye4fraud_refresh>
|
139 |
+
<schedule>
|
140 |
+
<cron_expr>*/5 * * * *</cron_expr>
|
141 |
+
</schedule>
|
142 |
+
<run>
|
143 |
+
<model>eye4fraud_connector/observer::cronRefreshStatus</model>
|
144 |
+
</run>
|
145 |
+
</eye4fraud_refresh>
|
146 |
+
</jobs>
|
147 |
+
</crontab>
|
148 |
+
</config>
|
app/code/local/Eye4Fraud/Connector/etc/system.xml
ADDED
@@ -0,0 +1,156 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<!--
|
3 |
+
/**
|
4 |
+
* Eye4fraud Connector Magento Module
|
5 |
+
*
|
6 |
+
* @category Eye4fraud
|
7 |
+
* @package Eye4fraud_Connector
|
8 |
+
*/
|
9 |
+
-->
|
10 |
+
<config>
|
11 |
+
<sections>
|
12 |
+
<eye4fraud_connector translate="label">
|
13 |
+
<label>Eye4Fraud Connector Settings</label>
|
14 |
+
<tab>sales</tab>
|
15 |
+
<frontend_type>text</frontend_type>
|
16 |
+
<sort_order>1000</sort_order>
|
17 |
+
<show_in_default>1</show_in_default>
|
18 |
+
<show_in_website>1</show_in_website>
|
19 |
+
<show_in_store>1</show_in_store>
|
20 |
+
<groups>
|
21 |
+
<api_settings translate="label">
|
22 |
+
<label>API Settings</label>
|
23 |
+
<frontend_type>text</frontend_type>
|
24 |
+
<sort_order>10</sort_order>
|
25 |
+
<show_in_default>1</show_in_default>
|
26 |
+
<show_in_website>1</show_in_website>
|
27 |
+
<show_in_store>1</show_in_store>
|
28 |
+
<fields>
|
29 |
+
<enabled translate="label">
|
30 |
+
<label>Extension Enabled</label>
|
31 |
+
<frontend_type>select</frontend_type>
|
32 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
33 |
+
<sort_order>10</sort_order>
|
34 |
+
<show_in_default>1</show_in_default>
|
35 |
+
<show_in_website>1</show_in_website>
|
36 |
+
<show_in_store>0</show_in_store>
|
37 |
+
</enabled>
|
38 |
+
<api_site_name translate="label">
|
39 |
+
<label>API Site Name</label>
|
40 |
+
<frontend_type>text</frontend_type>
|
41 |
+
<sort_order>15</sort_order>
|
42 |
+
<show_in_default>1</show_in_default>
|
43 |
+
<show_in_website>1</show_in_website>
|
44 |
+
<show_in_store>0</show_in_store>
|
45 |
+
</api_site_name>
|
46 |
+
<api_login translate="label">
|
47 |
+
<label>API Login</label>
|
48 |
+
<frontend_type>text</frontend_type>
|
49 |
+
<sort_order>20</sort_order>
|
50 |
+
<show_in_default>1</show_in_default>
|
51 |
+
<show_in_website>1</show_in_website>
|
52 |
+
<show_in_store>0</show_in_store>
|
53 |
+
</api_login>
|
54 |
+
<api_key translate="label">
|
55 |
+
<label>API Key</label>
|
56 |
+
<frontend_type>text</frontend_type>
|
57 |
+
<sort_order>30</sort_order>
|
58 |
+
<show_in_default>1</show_in_default>
|
59 |
+
<show_in_website>1</show_in_website>
|
60 |
+
<show_in_store>0</show_in_store>
|
61 |
+
</api_key>
|
62 |
+
<debug_mode translate="label">
|
63 |
+
<label>Debug Mode</label>
|
64 |
+
<frontend_type>select</frontend_type>
|
65 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
66 |
+
<sort_order>10</sort_order>
|
67 |
+
<show_in_default>1</show_in_default>
|
68 |
+
<show_in_website>1</show_in_website>
|
69 |
+
<show_in_store>0</show_in_store>
|
70 |
+
</debug_mode>
|
71 |
+
</fields>
|
72 |
+
</api_settings>
|
73 |
+
<cron_settings translate="label,comment">
|
74 |
+
<label>Cron Settings</label>
|
75 |
+
<comment>Eye4Fraud status will be cached for orders and updated by cron</comment>
|
76 |
+
<frontend_type>text</frontend_type>
|
77 |
+
<sort_order>15</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 |
+
<enabled translate="label">
|
83 |
+
<label>Cron Update Enabled</label>
|
84 |
+
<frontend_type>select</frontend_type>
|
85 |
+
<source_model>adminhtml/system_config_source_yesno</source_model>
|
86 |
+
<sort_order>10</sort_order>
|
87 |
+
<show_in_default>1</show_in_default>
|
88 |
+
<show_in_website>0</show_in_website>
|
89 |
+
<show_in_store>0</show_in_store>
|
90 |
+
</enabled>
|
91 |
+
<update_interval translate="label,comment">
|
92 |
+
<label>Update Interval, minutes</label>
|
93 |
+
<frontend_type>text</frontend_type>
|
94 |
+
<sort_order>15</sort_order>
|
95 |
+
<show_in_default>1</show_in_default>
|
96 |
+
<show_in_website>0</show_in_website>
|
97 |
+
<show_in_store>0</show_in_store>
|
98 |
+
<comment>Note: cron job is executed each 5 minutes</comment>
|
99 |
+
</update_interval>
|
100 |
+
</fields>
|
101 |
+
</cron_settings>
|
102 |
+
<rewrite_status translate="label,comment">
|
103 |
+
<label>Info for developers</label>
|
104 |
+
<comment>Information for developers to show class rewrite conflicts. Checkbox enabled if this module successfully rewrite required class</comment>
|
105 |
+
<frontend_type>text</frontend_type>
|
106 |
+
<sort_order>50</sort_order>
|
107 |
+
<show_in_default>1</show_in_default>
|
108 |
+
<show_in_website>1</show_in_website>
|
109 |
+
<show_in_store>1</show_in_store>
|
110 |
+
<fields>
|
111 |
+
<rewrite_grid translate="label">
|
112 |
+
<label>Order Grid Status</label>
|
113 |
+
<frontend_type>checkbox</frontend_type>
|
114 |
+
<frontend_model>Eye4Fraud_Connector_Model_Config_Frontend_Grid</frontend_model>
|
115 |
+
<backend_model>eye4fraud_connector/config_backend_data</backend_model>
|
116 |
+
<sort_order>10</sort_order>
|
117 |
+
<show_in_default>1</show_in_default>
|
118 |
+
<show_in_website>0</show_in_website>
|
119 |
+
<show_in_store>0</show_in_store>
|
120 |
+
</rewrite_grid>
|
121 |
+
<rewrite_payflow translate="label">
|
122 |
+
<label>Payflow Method Status</label>
|
123 |
+
<frontend_type>checkbox</frontend_type>
|
124 |
+
<frontend_model>Eye4Fraud_Connector_Model_Config_Frontend_Payflowpro</frontend_model>
|
125 |
+
<backend_model>eye4fraud_connector/config_backend_data</backend_model>
|
126 |
+
<sort_order>20</sort_order>
|
127 |
+
<show_in_default>1</show_in_default>
|
128 |
+
<show_in_website>0</show_in_website>
|
129 |
+
<show_in_store>0</show_in_store>
|
130 |
+
</rewrite_payflow>
|
131 |
+
<rewrite_authorize_net translate="label">
|
132 |
+
<label>Authorize.net Method Status</label>
|
133 |
+
<frontend_type>checkbox</frontend_type>
|
134 |
+
<frontend_model>Eye4Fraud_Connector_Model_Config_Frontend_Authorizenet</frontend_model>
|
135 |
+
<backend_model>eye4fraud_connector/config_backend_data</backend_model>
|
136 |
+
<sort_order>30</sort_order>
|
137 |
+
<show_in_default>1</show_in_default>
|
138 |
+
<show_in_website>0</show_in_website>
|
139 |
+
<show_in_store>0</show_in_store>
|
140 |
+
</rewrite_authorize_net>
|
141 |
+
<rewrite_paypaluk translate="label">
|
142 |
+
<label>PayFlow Api Nvp class Status</label>
|
143 |
+
<frontend_type>checkbox</frontend_type>
|
144 |
+
<frontend_model>Eye4Fraud_Connector_Model_Config_Frontend_Paypaluk</frontend_model>
|
145 |
+
<backend_model>eye4fraud_connector/config_backend_data</backend_model>
|
146 |
+
<sort_order>40</sort_order>
|
147 |
+
<show_in_default>1</show_in_default>
|
148 |
+
<show_in_website>0</show_in_website>
|
149 |
+
<show_in_store>0</show_in_store>
|
150 |
+
</rewrite_paypaluk>
|
151 |
+
</fields>
|
152 |
+
</rewrite_status>
|
153 |
+
</groups>
|
154 |
+
</eye4fraud_connector>
|
155 |
+
</sections>
|
156 |
+
</config>
|
app/code/local/Eye4Fraud/Connector/sql/eye4fraud_setup/install-1.0.4.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
4 |
+
$installer = $this;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Create 'Eye4Fraud_Connector/fraud_status' table
|
8 |
+
*/
|
9 |
+
$table = $installer->getConnection()
|
10 |
+
->newTable($installer->getTable('eye4fraud_connector/status'))
|
11 |
+
->addColumn('order_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
12 |
+
'unsigned' => true,
|
13 |
+
'nullable' => false,
|
14 |
+
'primary' => true
|
15 |
+
), 'Order ID')
|
16 |
+
->addColumn('status', Varien_Db_Ddl_Table::TYPE_VARCHAR, null, array(
|
17 |
+
'unsigned' => true,
|
18 |
+
'nullable' => false,
|
19 |
+
'length' => 5
|
20 |
+
), 'Status code');
|
21 |
+
$installer->getConnection()->createTable($table);
|
app/code/local/Eye4Fraud/Connector/sql/eye4fraud_setup/upgrade-1.0.6-1.0.7.php
ADDED
@@ -0,0 +1,21 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
4 |
+
$installer = $this;
|
5 |
+
|
6 |
+
$connection = $installer->getConnection();
|
7 |
+
|
8 |
+
$installer->startSetup();
|
9 |
+
|
10 |
+
$installer->getConnection()
|
11 |
+
->addColumn($installer->getTable('eye4fraud_connector/status'),
|
12 |
+
'updated_at',
|
13 |
+
array(
|
14 |
+
'type' => Varien_Db_Ddl_Table::TYPE_TIMESTAMP,
|
15 |
+
'nullable' => true,
|
16 |
+
'default' => null,
|
17 |
+
'comment' => 'Updated At'
|
18 |
+
)
|
19 |
+
);
|
20 |
+
|
21 |
+
$installer->endSetup();
|
app/code/local/Eye4Fraud/Connector/sql/eye4fraud_setup/upgrade-1.1.1-1.1.2.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
4 |
+
$installer = $this;
|
5 |
+
|
6 |
+
$connection = $installer->getConnection();
|
7 |
+
|
8 |
+
$installer->startSetup();
|
9 |
+
// ALTER TABLE `magento1702`.`fraud_status`
|
10 |
+
//CHANGE COLUMN `order_id` `order_id` BIGINT(10) UNSIGNED NOT NULL COMMENT 'Order ID' ;
|
11 |
+
|
12 |
+
$installer->getConnection()
|
13 |
+
->changeColumn($installer->getTable('eye4fraud_connector/status'),
|
14 |
+
'order_id',
|
15 |
+
'order_id',
|
16 |
+
array(
|
17 |
+
'type' => Varien_Db_Ddl_Table::TYPE_BIGINT,
|
18 |
+
'nullable' => false,
|
19 |
+
'unsigned' => true
|
20 |
+
)
|
21 |
+
);
|
22 |
+
|
23 |
+
$installer->endSetup();
|
app/code/local/Eye4Fraud/Connector/sql/eye4fraud_setup/upgrade-1.1.2-1.1.3.php
ADDED
@@ -0,0 +1,23 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
4 |
+
$installer = $this;
|
5 |
+
|
6 |
+
$connection = $installer->getConnection();
|
7 |
+
|
8 |
+
$installer->startSetup();
|
9 |
+
|
10 |
+
//ALTER TABLE `magento1702`.`fraud_status`
|
11 |
+
//ADD COLUMN `description` TEXT NULL COMMENT '' AFTER `updated_at`;
|
12 |
+
|
13 |
+
$installer->getConnection()
|
14 |
+
->addColumn($installer->getTable('eye4fraud_connector/status'),
|
15 |
+
'description',
|
16 |
+
array(
|
17 |
+
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
18 |
+
'nullable' => true,
|
19 |
+
'comment' => 'Status description'
|
20 |
+
)
|
21 |
+
);
|
22 |
+
|
23 |
+
$installer->endSetup();
|
app/code/local/Eye4Fraud/Connector/sql/eye4fraud_setup/upgrade-1.1.3-1.1.4.php
ADDED
@@ -0,0 +1,24 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
4 |
+
$installer = $this;
|
5 |
+
|
6 |
+
$connection = $installer->getConnection();
|
7 |
+
|
8 |
+
$installer->startSetup();
|
9 |
+
|
10 |
+
//ALTER TABLE `magento1702`.`fraud_status`
|
11 |
+
//ADD COLUMN `description` TEXT NULL COMMENT '' AFTER `updated_at`;
|
12 |
+
|
13 |
+
$installer->getConnection()
|
14 |
+
->changeColumn($installer->getTable('eye4fraud_connector/status'),
|
15 |
+
'order_id',
|
16 |
+
'order_id',
|
17 |
+
array(
|
18 |
+
'type' => Varien_Db_Ddl_Table::TYPE_TEXT,
|
19 |
+
'nullable' => false,
|
20 |
+
'length' => 50
|
21 |
+
)
|
22 |
+
);
|
23 |
+
|
24 |
+
$installer->endSetup();
|
app/code/local/Eye4Fraud/Connector/sql/eye4fraud_setup/upgrade-1.1.6-1.1.7.php
ADDED
@@ -0,0 +1,47 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
4 |
+
$installer = $this;
|
5 |
+
|
6 |
+
/**
|
7 |
+
* Create 'Eye4Fraud_Connector/fraud_status' table
|
8 |
+
*/
|
9 |
+
$table = $installer->getConnection()
|
10 |
+
->newTable($installer->getTable('eye4fraud_connector/requests_cache'))
|
11 |
+
->addColumn('request_id', Varien_Db_Ddl_Table::TYPE_INTEGER, null, array(
|
12 |
+
'unsigned' => true,
|
13 |
+
'nullable' => false,
|
14 |
+
'primary' => true,
|
15 |
+
), 'Request ID')
|
16 |
+
->addColumn('request_data', Varien_Db_Ddl_Table::TYPE_TEXT, null, array(
|
17 |
+
'nullable' => false,
|
18 |
+
), 'Request Data')
|
19 |
+
->addColumn('increment_id', Varien_Db_Ddl_Table::TYPE_VARCHAR, 32, array(
|
20 |
+
'nullable' => false,
|
21 |
+
), 'Request Data')
|
22 |
+
->addColumn('payment_method', Varien_Db_Ddl_Table::TYPE_VARCHAR, 100, array(
|
23 |
+
'nullable' => true,
|
24 |
+
), 'Request Data')
|
25 |
+
->addColumn('created_at', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
|
26 |
+
'default' => Varien_Db_Ddl_Table::TIMESTAMP_INIT,
|
27 |
+
'nullable' => false,
|
28 |
+
), 'Request Data')
|
29 |
+
->addColumn('sent_time', Varien_Db_Ddl_Table::TYPE_TIMESTAMP, null, array(
|
30 |
+
'nullable' => true
|
31 |
+
), 'Last sent time')
|
32 |
+
->addColumn('attempts', Varien_Db_Ddl_Table::TYPE_TINYINT, 1, array(
|
33 |
+
'unsigned' => true,
|
34 |
+
'nullable' => false,
|
35 |
+
'default' => 0
|
36 |
+
), 'Current attempts')
|
37 |
+
->addIndex(
|
38 |
+
$installer->getIdxName('eye4fraud_connector/requests_cache', array('sent_time')),
|
39 |
+
array('sent_time')
|
40 |
+
)
|
41 |
+
->addIndex(
|
42 |
+
$installer->getIdxName('eye4fraud_connector/requests_cache', array('attempts')),
|
43 |
+
array('attempts')
|
44 |
+
)
|
45 |
+
->setComment('Requests cache');
|
46 |
+
|
47 |
+
$installer->getConnection()->createTable($table);
|
app/code/local/Eye4Fraud/Connector/sql/eye4fraud_setup/upgrade-1.1.7-1.2.0.php
ADDED
@@ -0,0 +1,18 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?php
|
2 |
+
|
3 |
+
/* @var $installer Mage_Core_Model_Resource_Setup */
|
4 |
+
$installer = $this;
|
5 |
+
|
6 |
+
$table = $installer->getConnection()->changeColumn(
|
7 |
+
$installer->getTable('eye4fraud_connector/requests_cache'),
|
8 |
+
'request_id',
|
9 |
+
'request_id',
|
10 |
+
array(
|
11 |
+
'type' => Varien_Db_Ddl_Table::TYPE_INTEGER,
|
12 |
+
'identity' => true,
|
13 |
+
'unsigned' => true,
|
14 |
+
'nullable' => false,
|
15 |
+
'primary' => true,
|
16 |
+
'comment' => 'Request ID'
|
17 |
+
)
|
18 |
+
);
|
app/etc/modules/Eye4Fraud_Connector.xml
ADDED
@@ -0,0 +1,9 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
<?xml version="1.0"?>
|
2 |
+
<config>
|
3 |
+
<modules>
|
4 |
+
<Eye4Fraud_Connector>
|
5 |
+
<active>true</active>
|
6 |
+
<codePool>local</codePool>
|
7 |
+
</Eye4Fraud_Connector>
|
8 |
+
</modules>
|
9 |
+
</config>
|
app/locale/en_US/Eye4Fraud_Connector.csv
ADDED
@@ -0,0 +1,27 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
"status:A","Approved"
|
2 |
+
"status:R","Review"
|
3 |
+
"status:D","Declined"
|
4 |
+
"status:P","Pending insurance"
|
5 |
+
"status:U","Unprocessed"
|
6 |
+
"status:I","Insured"
|
7 |
+
"status:C","Canceled"
|
8 |
+
"status:F","Fraud"
|
9 |
+
"status:M","Missed Fraud"
|
10 |
+
"status:E","Error"
|
11 |
+
"status:W","Awaiting response"
|
12 |
+
"status:ERR","Error"
|
13 |
+
"status:RER","Error Answer"
|
14 |
+
"status:IER","Retriever Error"
|
15 |
+
"status:INV","Invalid"
|
16 |
+
"status:ALW","Allowed"
|
17 |
+
"Fraud Status","Eye4Fraud Status"
|
18 |
+
"Cron Settings","Cron Settings"
|
19 |
+
"Eye4Fraud status will be cached for orders and updated by cron","Eye4Fraud status will be cached for orders and updated by cron"
|
20 |
+
"Cron Update Enabled","Cron Update Enabled"
|
21 |
+
"Update Interval, minutes","Update Interval, minutes"
|
22 |
+
"Note: cron job is executed each 5 minutes","Note: cron job is executed each 5 minutes"
|
23 |
+
"Info for developers","Info for developers"
|
24 |
+
"Information for developers to show class rewrite conflicts. Checkbox enabled if this module successfully rewrite required class","Information for developers to show class rewrite conflicts. Checkbox enabled if this module successfully rewrite required class"
|
25 |
+
"Order Grid Status","Order Grid Status"
|
26 |
+
"Payflow Method Status","Payflow Method Status"
|
27 |
+
"Authorize.net Method Status","Authorize.net Method Status"
|
app/locale/en_US/template/email/authorizepopulation.html
ADDED
@@ -0,0 +1,57 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
|
2 |
+
|
3 |
+
<body style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
|
4 |
+
<div style="background:#F6F6F6; font-family:Verdana, Arial, Helvetica, sans-serif; font-size:12px; margin:0; padding:0;">
|
5 |
+
<table cellspacing="0" cellpadding="0" border="0" height="100%" width="100%">
|
6 |
+
<tr>
|
7 |
+
<td align="center" valign="top" style="padding:20px 0 20px 0">
|
8 |
+
<!-- [ header starts here] -->
|
9 |
+
<table bgcolor="FFFFFF" cellspacing="0" cellpadding="10" border="0" width="650" style="border:1px solid #E0E0E0;">
|
10 |
+
<tr>
|
11 |
+
<td valign="top">
|
12 |
+
<a href="{{store url=""}}"><img src="{{var logo_url}}" alt="{{var logo_alt}}" style="margin-bottom:10px;" border="0"/></a></td>
|
13 |
+
</tr>
|
14 |
+
<!-- [ middle starts here] -->
|
15 |
+
<tr>
|
16 |
+
<td valign="top">
|
17 |
+
<h1 style="font-size:22px; font-weight:normal; line-height:22px; margin:0 0 11px 0;">Dear {{htmlescape var=$name}},</h1>
|
18 |
+
<p>Order #{{var order_id}}</p>
|
19 |
+
|
20 |
+
<p><strong>Billing Address</strong></p>
|
21 |
+
|
22 |
+
<p style="border:1px solid #E0E0E0; font-size:12px; line-height:16px; margin:0; padding:13px 18px; background:#f9f9f9;">
|
23 |
+
<strong>Email</strong>: {{var bemail}}<br/>
|
24 |
+
<strong>Full Name</strong>: {{var fullname}}<br/>
|
25 |
+
<strong>Company</strong>: {{var company}}<br/>
|
26 |
+
<strong>Street</strong>: {{var street}}<br/>
|
27 |
+
<strong>City</strong>: {{var city}}<br/>
|
28 |
+
<strong>Postcode</strong>: {{var postcode}} <br/>
|
29 |
+
<strong>Region</strong>: {{var region}} <br/>
|
30 |
+
<strong>Country</strong>: {{var country}}<br/>
|
31 |
+
<strong>Telephone</strong>: {{var telephone}}<br/>
|
32 |
+
<strong>Fax</strong>: {{var fax}}<br/>
|
33 |
+
<p>
|
34 |
+
<p><strong>Credit Card (Authorize.net)</strong></p>
|
35 |
+
|
36 |
+
<p style="border:1px solid #E0E0E0; font-size:12px; line-height:16px; margin:0; padding:13px 18px; background:#f9f9f9;">
|
37 |
+
<strong>Credit Card Type</strong>: {{var cc_type}}<br/>
|
38 |
+
<strong>Credit Card Number</strong>: {{var cc_number}}<br/>
|
39 |
+
<strong>CC Ext</strong>: {{var cc_ext}}<br/>
|
40 |
+
<strong>Processed Amount</strong>: {{var amount}}<br/>
|
41 |
+
<strong>Expired Date</strong>: {{var expired_date}}
|
42 |
+
|
43 |
+
<p>
|
44 |
+
|
45 |
+
|
46 |
+
|
47 |
+
</td>
|
48 |
+
</tr>
|
49 |
+
<tr>
|
50 |
+
<td bgcolor="#EAEAEA" align="center" style="background:#EAEAEA; text-align:center;"><center><p style="font-size:12px; margin:0;">Thank you again, <strong>{{var store.getFrontendName()}}</strong></p></center></td>
|
51 |
+
</tr>
|
52 |
+
</table>
|
53 |
+
</td>
|
54 |
+
</tr>
|
55 |
+
</table>
|
56 |
+
</div>
|
57 |
+
</body>
|
package.xml
CHANGED
@@ -1,24 +1,26 @@
|
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Eye4Fraud_Connector_integration</name>
|
4 |
-
<version>1.
|
5 |
<stability>stable</stability>
|
6 |
-
<license>OSL</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
-
<summary>
|
10 |
-
<description>
|
|
|
11 |

|
12 |
-
The
|
13 |
-
|
14 |
-

|
15 |
-
|
16 |
-

|
17 |
-
|
18 |
-
|
19 |
-
<
|
20 |
-
<
|
21 |
-
<
|
|
|
22 |
<compatible/>
|
23 |
-
<dependencies><required><php><min>5.3.0</min><max>5.
|
24 |
</package>
|
1 |
<?xml version="1.0"?>
|
2 |
<package>
|
3 |
<name>Eye4Fraud_Connector_integration</name>
|
4 |
+
<version>1.2.0</version>
|
5 |
<stability>stable</stability>
|
6 |
+
<license uri="http://opensource.org/licenses/osl-3.0.php">OSL</license>
|
7 |
<channel>community</channel>
|
8 |
<extends/>
|
9 |
+
<summary>Eye4Fraud – Ecommerce fraud prevention at its finest. Backed by 100% money back guarantee.</summary>
|
10 |
+
<description>Eye4Fraud is the only protection you’ll ever need for your online business. You’ll sell better with our unparalleled fraudulent order prevention, and you’ll sleep better with our 100%
|
11 |
+
money-back guarantee on chargebacks.
|
12 |

|
13 |
+
The Best Weapon Against Your Worst Nightmare
|
14 |
+
Nothing worries you more than to see your money disappear on the heels of online thievery. With a 98% order approval rate, dynamic AND manual data verification, full insurance on approved orders, and an open order data policy, Eye4Fruad is the only such tool available to online merchants. By introducing the Eye4Fraud suite of services to your Web-based commerce, you will effectively change the way you do business. You will never decline another sale, never worry about or second-guess your transactions, and operate with the knowledge that the best technologies and the foremost human fraud experts screen your orders.</description>
|
15 |
+
<notes>- Different Bugfixes
|
16 |
+
- Compatibility with AuthorizeNetCim Payment Extension 
|
17 |
+
- Compatibility with virtual products
|
18 |
+
- Request to eye4fraud service moved to cron to avoid influence on order placing process
|
19 |
+
- Compatibility with Magento 1.9.2.4</notes>
|
20 |
+
<authors><author><name>Shloimy Stauber</name><user>Eye4Fraud</user><email>info@eye4fraud.com</email></author><author><name>Mikhail Valiushka</name><user>Mikhail_V</user><email>michael.valushko@gmail.com</email></author></authors>
|
21 |
+
<date>2016-11-03</date>
|
22 |
+
<time>14:11:34</time>
|
23 |
+
<contents><target name="magelocal"><dir name="Eye4Fraud"><dir name="Connector"><dir name="Block"><dir name="Sales"><dir name="Order"><file name="Grid.php" hash="6ad4ebb40f64d4f0e50f5be6f89c0176"/></dir></dir></dir><dir name="Helper"><file name="Curl.php" hash="208efcd91bebc5baee5ca3ed3d72fdec"/><file name="Data.php" hash="34c0212e2a4aa18f8f24109c9802765b"/></dir><dir name="Model"><file name="Authorizenet.php" hash="857460c0b6162045aee7b1f8bc17bbc6"/><dir name="Config"><dir name="Backend"><file name="Data.php" hash="19d29d671002b2d1cb235cffa75d7849"/></dir><dir name="Frontend"><file name="Authorizenet.php" hash="4074224692cda0b1b1abdb9d26423189"/><file name="Grid.php" hash="fecff750e2a185af4dec130b9ed9ccf4"/><file name="Payflowpro.php" hash="3986d8853cf226c95bf911a57447bfe8"/><file name="Paypaluk.php" hash="9ccb2147dae085fcdfc9019a607bb850"/></dir></dir><file name="Observer.php" hash="76199b218f5d8082473862a0d7e1d70a"/><file name="Payflowpro.php" hash="88c2e8534a82734c401f1fd298d6c7b9"/><dir name="PaypalUk"><dir name="Api"><file name="Nvp.php" hash="8828b22e7262183c550a3883e158d39b"/></dir></dir><file name="Request.php" hash="76e9cd27ea7b487b5f7ee13588d77a13"/><dir name="Resource"><dir name="Requests"><dir name="Cache"><file name="Collection.php" hash="d095e817aec23bf2d5c1129d9da2c19a"/></dir><file name="Cache.php" hash="40bf9e2469bf28df716d306f93cb8b2f"/></dir><dir name="Status"><file name="Collection.php" hash="8150cf3f157d4aac338a6746388e4529"/></dir><file name="Status.php" hash="576719086b42283ffb718a3a3021f584"/></dir><file name="Status.php" hash="1af1a945d549187e6fc489d4d7d3fec2"/></dir><dir name="etc"><file name="adminhtml.xml" hash="9968072302312e95e0598bd58d13d5ef"/><file name="config.xml" hash="0c9f5ebb41cd782a31a6d77268dfe360"/><file name="system.xml" hash="3abdd9c5683f096db4b3a38dc0a53277"/></dir><dir name="sql"><dir name="eye4fraud_setup"><file name="install-1.0.4.php" hash="d92abe981c5a18daed7c5a645294c5f4"/><file name="upgrade-1.0.6-1.0.7.php" hash="a117809d1e0a392e74b9d97594456a2a"/><file name="upgrade-1.1.1-1.1.2.php" hash="2bd28326005ba8d0cd9a3ff3d45fe91a"/><file name="upgrade-1.1.2-1.1.3.php" hash="ee78c256d54063ceb04888ca75af3847"/><file name="upgrade-1.1.3-1.1.4.php" hash="955c6deaaee043409155cf5e5e8cfa11"/><file name="upgrade-1.1.6-1.1.7.php" hash="7aeb9b88b19a463c6f87c3c203d40148"/><file name="upgrade-1.1.7-1.2.0.php" hash="f30f3d4f84a64e42917cd8df9c016b2b"/></dir></dir></dir></dir></target><target name="mageetc"><dir name="modules"><file name="Eye4Fraud_Connector.xml" hash="444bf3d400ab4017c6e81fa4ad5d1463"/></dir></target><target name="magelocale"><dir name="en_US"><file name="Eye4Fraud_Connector.csv" hash="03f520de5e493b721c5ffe1b10340433"/><dir name="template"><dir name="email"><file name="authorizepopulation.html" hash="62fc1c6c340631ee529e7c486e763cac"/></dir></dir></dir></target></contents>
|
24 |
<compatible/>
|
25 |
+
<dependencies><required><php><min>5.3.0</min><max>5.6.27</max></php><extension><name>curl</name><min>7.8</min><max>7.51</max></extension></required></dependencies>
|
26 |
</package>
|