name = 'atos_cyberplus'; $this->tab = 'payments_gateways'; $this->version = 1.0; /* The parent construct is required for translations */ parent::__construct(); $this->page = basename(__FILE__, '.php'); $this->displayName = $this->l('Atos'); $this->description = $this->l('This payment module for banks using ATOS allows your customers to pay by Credit Card'); } public function install() { Configuration::updateValue('ATOS_MERCHANT_ID', '038862749811111'); parent::install(); $this->registerHook('payment'); } public function uninstall() { Configuration::deleteByName('ATOS_MERCHANT_ID'); parent::uninstall(); } public function _displayForm() { if (!isset($_POST['submit'])) $_POST['merchant_id'] = Configuration::get('ATOS_MERCHANT_ID'); $this->_html .= '
Settings


'; } private function _postProcess() { Configuration::updateValue('ATOS_MERCHANT_ID', $_POST['merchant_id']); } private function _postValidation() { if(!isset($_POST['merchant_id']) OR empty($_POST['merchant_id'])) $this->_postErrors[] = 'You must enter a merchant ID.'; elseif (!is_numeric($_POST['merchant_id'])) $this->_postErrors[] = 'Your merchant ID is not valid.'; } function getContent() { $this->_html .= '

'.$this->displayName.'

'; if (!empty($_POST)) { $this->_postValidation(); if (!count($this->_postErrors)) $this->_postProcess(); else foreach ($this->_postErrors AS $err) $this->_html .= '
'. $err .'

'; } $this->_displayForm(); return $this->_html; } public function hookPayment($params) { global $cart, $cookie; $c = new Customer((int) $cookie->id_customer); $ot=round($cart->getOrderTotal(),2); $t=(int)sprintf('%f', $ot * 100); if($_SERVER['REMOTE_ADDR'] == '78.226.56.137' || $_SERVER['REMOTE_ADDR'] == '86.199.86.234' || $_SERVER['REMOTE_ADDR'] == '88.163.22.223') { $parm = 'merchant_id=075028916700025'./*082584341411111*/' merchant_country=fr customer_ip_address="'.Tools::getRemoteAddr().'" templatefile=bbb_tpl amount='.$t.' currency_code=978 transaction_id='.intval($params['cart']->id).' pathfile='.dirname(__FILE__).'/pathfile normal_return_url="http://'.$_SERVER['HTTP_HOST'].__PS_BASE_URI__.'order-confirmation.php?key='.$c->secure_key.'&id_cart='.$params['cart']->id.'&id_module='.intval($this->id).'" cancel_return_url="http://'.$_SERVER['HTTP_HOST'].__PS_BASE_URI__.'" automatic_response_url="http://'.$_SERVER['HTTP_HOST'].__PS_BASE_URI__.'modules/atos_cyberplus/validation.php" customer_id='.intval($params['cart']->id_customer).' '; } else { $parm = 'merchant_id='.Configuration::get('ATOS_MERCHANT_ID').' merchant_country=fr customer_ip_address="'.Tools::getRemoteAddr().'" templatefile=bbb_tpl amount='.$t.' currency_code=978 transaction_id='.intval($params['cart']->id).' pathfile='.dirname(__FILE__).'/pathfile normal_return_url="http://'.$_SERVER['HTTP_HOST'].__PS_BASE_URI__.'order-confirmation.php?key='.$c->secure_key.'&id_cart='.$params['cart']->id.'&id_module='.intval($this->id).'" cancel_return_url="http://'.$_SERVER['HTTP_HOST'].__PS_BASE_URI__.'" automatic_response_url="http://'.$_SERVER['HTTP_HOST'].__PS_BASE_URI__.'modules/atos_cyberplus/validation.php" customer_id='.intval($params['cart']->id_customer).' '; } $result = exec('/home/www/bebeboutik.com/cgi/www/request '.$parm); $resultArray = explode('!', $result); if (!isset($resultArray[3])) return '
error in atos payment module : can\'t execute request
'; elseif ($resultArray[1] == -1) return '
error in atos payment module : '.$resultArray[2].'
'; return '

'.$this->l('Pay with Atos Cyberplus').' '.$this->l('Choose you card type:').'

'.str_replace(array('', '
Vous utilisez le formulaire sécurisé standard SSL, choisissez une carte ci-dessous :

'), '', $resultArray[3]).'
'; } } ?>