* @copyright 2007-2011 PrestaShop SA * @version Release: $Revision: 7732 $ * @license http://opensource.org/licenses/afl-3.0.php Academic Free License (AFL 3.0) * International Registered Trademark & Property of PrestaShop SA */ if (!defined('_CAN_LOAD_FILES_')) exit; if ((basename(__FILE__) == 'fianetfraud.php')) require_once(dirname(__FILE__).'/fianet/fianet.php'); class Fianetfraud extends Module { const INSTALL_SQL_FILE = 'install.sql'; private $_html; private $_product_type = array( '1' => 'Alimentation & gastronomie', '2' => 'Auto & moto', '3' => 'Culture & divertissements', '4' => 'Maison & jardin', '5' => 'Electromenager', '6' => 'Enchers et achats groupés', '7' => 'Fleurs & cadeaux', '8' => 'Informatique & logiciels', '9' => 'Santé & beauté', '10' => 'Services aux particuliers', '11' => 'Services aux professionnels', '12' => 'Sport', '13' => 'Vetements & accessoires', '14' => 'Voyage & tourisme', '15' => 'Hifi, photo & videos', '16' => 'Telephonie & communication', '17' => 'Bijoux & Métaux précieux', '18' => 'Articles et Accessoires pour bébé', '19' => 'Sonorisation & Lumière' ); private $_carrier_type = array( 1 => 'Retrait de la marchandise chez le marchand', 2 => 'Utilisation d\'un réseau de points-retrait tiers (type kiala, alveol, etc.)', 3 => 'Retrait dans un aéroport, une gare ou une agence de voyage', 4 => 'Transporteur (La Poste, Colissimo, UPS, DHL... ou tout transporteur privé)', 5 => 'Emission d’un billet électronique, téléchargements' ); private $_payement_type = array( 1 => 'carte', 2 => 'cheque', 3 => 'contre-remboursement', 4 => 'virement', 5 => 'cb en n fois', 6 => 'paypal', 7 => '1euro.com' ); public function __construct() { $this->name = 'fianetfraud'; $this->tab = 'payment_security'; $this->version = '1.1'; $this->limited_countries = array('fr'); parent::__construct(); $this->displayName = 'FIA-NET - Système d\'Analyse des Commandes'; $this->description = "Protégez vous contre la fraude à la carte bancaire sans perturber l'acte d'achat"; } public function install() { if (!parent::install()) return false; if (!file_exists(dirname(__FILE__).'/'.self::INSTALL_SQL_FILE)) return false; elseif (!$sql = file_get_contents(dirname(__FILE__).'/'.self::INSTALL_SQL_FILE)) return false; $sql = str_replace('PREFIX_', _DB_PREFIX_, $sql); $sql = preg_split("/;\s*[\r\n]+/", $sql); foreach ($sql AS $query) if ($query AND sizeof($query) AND !Db::getInstance()->Execute(trim($query))) return false; $langs = Language::getLanguages(); $orderState = new OrderState(); foreach ($langs AS $lang) $orderState->name[$lang['id_lang']] = 'Waiting FIA-NET checking'; $orderState->name[2] = 'Attente validation commande FIA-NET'; $orderState->invoice = false; $orderState->send_email = false; $orderState->logable = false; $orderState->color = '#FF9999'; $orderState->hidden = true; $orderState->save(); Configuration::updateValue('SAC_ID_WAITING', (int)($orderState->id)); $orderState = new OrderState(); foreach ($langs AS $lang) $orderState->name[$lang['id_lang']] = 'Fraud Detected By FIA-NET'; $orderState->name[2] = 'Fraude détectée par FIA-NET'; $orderState->invoice = false; $orderState->send_email = false; $orderState->logable = false; $orderState->color = '#FF6666'; $orderState->hidden = true; $orderState->save(); Configuration::updateValue('SAC_ID_FRAUD', (int)($orderState->id)); if (!$this->registerHook('updateCarrier')) return false; if (!Configuration::updateValue('SAC_SITEID', '') OR !Configuration::updateValue('SAC_LOGIN', '') OR !Configuration::updateValue('SAC_PASSWORD', '') OR !Configuration::updateValue('SAC_MINIMAL_ORDER', 0)) return false; return ($this->registerHook('cart') AND $this->registerHook('newOrder') AND $this->registerHook('adminOrder') AND $this->registerHook('updateOrderStatus') ); } public function uninstall() { $orderState = new OrderState((int)(Configuration::get('SAC_ID_FRAUD')), Configuration::get('PS_LANG_DEFAULT')); if (!$orderState->delete()) return false; $orderState = new OrderState((int)(Configuration::get('SAC_ID_WAITING')), Configuration::get('PS_LANG_DEFAULT')); if (!$orderState->delete()) return false; return parent::uninstall(); } private function _postProcess() { global $cookie; $error = false; Configuration::updateValue('SAC_PRODUCTION', ((Tools::getValue('fianetfraud_production') == 1 ) ? 1 : 0)); Configuration::updateValue('SAC_LOGIN', Tools::getValue('fianetfraud_login')); Configuration::updateValue('SAC_PASSWORD', Tools::getValue('fianetfraud_password')); Configuration::updateValue('SAC_SITEID', Tools::getValue('fianetfraud_siteid')); Configuration::updateValue('SAC_DEFAULT_PRODUCT_TYPE', Tools::getValue('fianetfraud_product_type')); Configuration::updateValue('SAC_DEFAULT_CARRIER_TYPE', Tools::getValue('fianetfraud_default_carrier')); Configuration::updateValue('SAC_MINIMAL_ORDER', Tools::getValue('fianetfraud_minimal_order')); if (isset($_POST['payementBox'])) { Configuration::updateValue('SAC_PAYMENT_MODULE', implode(',', $_POST['payementBox'])); foreach ($_POST['payementBox'] as $payment) Configuration::updateValue('SAC_PAYMENT_TYPE_'.$payment,Tools::getValue($payment)); } $categories = Category::getSimpleCategories($cookie->id_lang); foreach ($categories AS $category) Configuration::updateValue('SAC_CATEGORY_TYPE_'.$category['id_category'],Tools::getValue('cat_'.$category['id_category'])); $carriers = Carrier::getCarriers($cookie->id_lang); foreach ($carriers as $carrier) { if (isset($_POST['carrier_'.$carrier['id_carrier']])) Configuration::updateValue('SAC_CARRIER_TYPE_'.$carrier['id_carrier'], $_POST['carrier_'.$carrier['id_carrier']]); else { $error = true; $this->_html .= '