public function hookdisplayPayment($params) { if (!Configuration::get('KLARNA_ACTIVE_INVOICE') && !Configuration::get('KLARNA_ACTIVE_PARTPAYMENT')) { return false; } $smarty = $this->context->smarty; $klarna = new Klarna(); $address_invoice = new Address((int) $params['cart']->id_address_invoice); $country = new Country((int) $address_invoice->id_country); $currency = new Currency((int) $params['cart']->id_currency); if (isset($this->countries[$country->iso_code])) { $this->context->cart->deleteProduct((int) Configuration::get('KLARNA_INV_FEE_ID_' . $this->countries[$country->iso_code]['name'])); } if (!$this->verifCountryAndCurrency($country, $currency)) { return false; } if (!$this->_verifRange($params['cart']->getOrderTotal(), $this->countries[$country->iso_code]['name'])) { return false; } try { $klarna->config(Configuration::get('KLARNA_STORE_ID_' . $this->countries[$country->iso_code]['name']), Configuration::get('KLARNA_SECRET_' . $this->countries[$country->iso_code]['name']), $this->countries[$country->iso_code]['code'], $this->countries[$country->iso_code]['langue'], $this->countries[$country->iso_code]['currency'], Configuration::get('KLARNA_MOD'), 'mysql', $this->_getDb()); $pclass = $klarna->getCheapestPClass((double) $this->context->cart->getOrderTotal(), KlarnaFlags::CHECKOUT_PAGE); if ($pclass && $pclass->getMinAmount() < $this->context->cart->getOrderTotal()) { if ($country->iso_code == 'NL' && $this->context->cart->getOrderTotal() > 250) { return false; } else { $value = KlarnaCalc::calc_monthly_cost((double) $this->context->cart->getOrderTotal(), $pclass, KlarnaFlags::CHECKOUT_PAGE); } } $pclassSpec = $klarna->getPClasses(KlarnaPClass::SPECIAL); if (count($pclassSpec) && $pclassSpec[0]->getExpire() > time()) { $smarty->assign('special', $pclassSpec[0]->getDescription()); } } catch (Exception $e) { return false; } $smarty->assign(array('var' => array('path' => $this->_path, 'this_path_ssl' => (_PS_VERSION_ >= 1.4 ? Tools::getShopDomainSsl(true, true) : '') . __PS_BASE_URI__ . 'modules/' . $this->moduleName . '/'), 'iso_code' => strtolower($country->iso_code), 'monthly_amount' => (double) $value, 'invoiceActive' => Configuration::get('KLARNA_ACTIVE_INVOICE'), 'accountActive' => Configuration::get('KLARNA_ACTIVE_PARTPAYMENT'), 'specialActive' => true)); return $this->display(__FILE__, 'tpl/payment.tpl'); }