Ejemplo n.º 1
0
 /**
  * Show kwixo's payment on payment page
  * 
  * @param type $params
  * @return boolean
  */
 public function hookPayment($params)
 {
     if (!$this->active) {
         return;
     }
     $total_cart = $params['cart']->getOrderTotal(true);
     if (_PS_VERSION_ < '1.5') {
         $kwixo = new KwixoPayment();
     } else {
         $kwixo = new KwixoPayment($params['cart']->id_shop);
     }
     if ($kwixo->getStatus() == 'test') {
         $customer = new Customer((int) $params['cart']->id_customer);
         $customer_mail = $customer->email;
         if (Configuration::get('KWIXO_EMAILS_TEST') != '') {
             $mails_test = explode(',', Configuration::get('KWIXO_EMAILS_TEST'));
             if (!in_array($customer_mail, $mails_test)) {
                 KwixoLogger::insertLogKwixo(__METHOD__ . " : " . __LINE__, "L'adresse {$customer_mail} n'est pas autorisée à utiliser Kwixo en test.");
                 KwixoLogger::insertLogKwixo(__METHOD__ . " : " . __LINE__, "Liste des adresses autorisées : " . implode(', ', $mails_test));
                 return false;
             }
         }
     }
     $mobile_detect = new MobileDetect();
     $mobile = $mobile_detect->isMobile();
     $kwixo_standard = Configuration::get('KWIXO_OPTION_STANDARD') == '1' ? '1' : '0';
     $kwixo_comptant = Configuration::get('KWIXO_OPTION_COMPTANT') == '1' ? '1' : '0';
     $kwixo_facturable = Configuration::get('KWIXO_OPTION_FACTURABLE') == '1' ? '1' : '0';
     $kwixo_credit = Configuration::get('KWIXO_OPTION_CREDIT') == '1' && $total_cart >= 150 && $total_cart <= 4000 && !$mobile ? '1' : '0';
     if (version_compare(_PS_VERSION_, '1.5', '<')) {
         //token security
         $token = Tools::getAdminToken($kwixo->getSiteid() . $kwixo->getAuthkey());
         $kwixo_std_link = __PS_BASE_URI__ . 'modules/' . $this->name . '/sendtoKwixo.php?payment=1&token=' . $token;
         $kwixo_cpt_link = __PS_BASE_URI__ . 'modules/' . $this->name . '/sendtoKwixo.php?payment=2&token=' . $token;
         $kwixo_credit_link = __PS_BASE_URI__ . 'modules/' . $this->name . '/sendtoKwixo.php?payment=3&token=' . $token;
         $kwixo_facturable_link = __PS_BASE_URI__ . 'modules/' . $this->name . '/sendtoKwixo.php?payment=4&token=' . $token;
     } else {
         $link = new Link();
         $kwixo_std_link = $link->getModuleLink('kwixo', 'payment', array('payment' => '1'), true);
         $kwixo_cpt_link = $link->getModuleLink('kwixo', 'payment', array('payment' => '2'), true);
         $kwixo_credit_link = $link->getModuleLink('kwixo', 'payment', array('payment' => '3'), true);
         $kwixo_facturable_link = $link->getModuleLink('kwixo', 'payment', array('payment' => '4'), true);
     }
     $this->smarty->assign(array('kwixo_standard' => $kwixo_standard, 'kwixo_comptant' => $kwixo_comptant, 'kwixo_credit' => $kwixo_credit, 'kwixo_facturable' => $kwixo_facturable, 'kwixo_std_link' => $kwixo_std_link, 'kwixo_cpt_link' => $kwixo_cpt_link, 'kwixo_credit_link' => $kwixo_credit_link, 'kwixo_facturable_link' => $kwixo_facturable_link, 'url_simul' => 'https://secure.kwixo.com/credit/calculator.htm?merchantId=' . $kwixo->getSiteId() . '&amount=' . $total_cart, 'logo_kwixo_standard' => __PS_BASE_URI__ . 'modules/' . $this->name . '/img/kwixo_standard.jpg', 'logo_kwixo_comptant' => __PS_BASE_URI__ . 'modules/' . $this->name . '/img/kwixo_comptant.jpg', 'logo_kwixo_credit' => __PS_BASE_URI__ . 'modules/' . $this->name . '/img/kwixo_credit.jpg'));
     return $this->display(__FILE__, '/views/templates/hook/payment_short_description.tpl');
 }