This commit is contained in:
Michael RICOIS 2017-12-05 16:53:53 +01:00
parent 4990ceb49d
commit 1702e23439

View File

@ -27,7 +27,7 @@ class Fraud extends Module
&& $this->registerHook('adminOrder')
&& $this->registerHook('backBeforePayment')
&& $this->registerHook('afterChangeStatus'))) {
return false;
return false;
}
return true;
}
@ -63,11 +63,12 @@ class Fraud extends Module
{
FraudCore::CartFraudConnexion($params['cart']);
}
public function hookAdminOrder($params)
{
global $currentIndex;
// @todo : Must be exec in postProcess before display
if (Tools::getIsset('validFraud')) {
$id_order = Tools::getValue('id_order');
if (!FraudCore::validOrder($id_order)) {
@ -105,6 +106,7 @@ class Fraud extends Module
public function hookAdminOrderNew($params)
{
global $currentIndex;
$data .= '';
$reputation = FraudCore::getReputationOrder((int) $params['id_order']);
if ($reputation) {
@ -151,13 +153,13 @@ class Fraud extends Module
$order = new Order($id_order);
$authorized = array('FRA','ESP','DEU','ITA','NLD','SWE','GBR','PRT','CHE','LUX','POL','AUT','BEL');
if(!in_array($ip_country, $authorized)) {
if (!in_array($ip_country, $authorized)) {
$total_score = 110;
$fraud_report = array();
$fraud_report[] = 'Pays de paiement hors EU (+110)';
$order_reputation = FraudCore::getReputationOrder((int)$id_order);
if($order_reputation) {
if ($order_reputation) {
$fraud_report = array_merge($fraud_report, json_decode($order_reputation['report']));
$total_score += (int)$order_reputation['score'];
}
@ -223,12 +225,11 @@ class Fraud extends Module
}
}
public function hookafterChangeStatus($params)
{
if($params['newOrderState'] == 2) {
if ($params['newOrderState'] == 2) {
$order = new Order($params['order']['id']);
if ( Validate::isLoadedObject($order) ) {
if (Validate::isLoadedObject($order)) {
if ($order->module != 'paybox') {
return FALSE;
@ -240,7 +241,7 @@ class Fraud extends Module
FROM `ps_order_reputation`
WHERE `id_cart` ='.(int)$order->id_cart
);
if(!empty($already_test)) {
if (!empty($already_test)) {
return true;
}
@ -256,7 +257,7 @@ class Fraud extends Module
FROM `'._DB_PREFIX_.'reputation`
WHERE `id_customer` = '.(int) $order->id_customer);
if($query && count($query) > 0) {
if ($query && count($query) > 0) {
foreach($query as $r) {
$current_reputation += $r['score'] - floor((time() - strtotime($r['date_upd'])) / (86400 * 7)) * 20;
$i++;
@ -286,7 +287,7 @@ class Fraud extends Module
');
// check fraud score
if($total_score < 100) {
if ($total_score < 100) {
Db::getInstance()->ExecuteS('
INSERT INTO `'._DB_PREFIX_.'reputation`
VALUES (