/** * This function outputs the payment method title/text and if required, the * input fields. * * @return array Data to present in page */ public function selection() { global $order, $customer_id, $currencies; $co = KiTT::checkoutController($this->_locale, $this->_totalSum); $view = $co->getOption($this->_option); // Update the enabled variable that xtCommerce needs. $this->enabled = $this->_isEnabled($view); if (!$this->enabled) { return; } // Add CSS and Javascript just once. if (!self::$_hasRun) { $templateLoader = KiTT::templateLoader($this->_locale); $cssLoader = $templateLoader->load('css.mustache'); $jsLoader = $templateLoader->load('javascript.mustache'); $merchantID = KlarnaConstant::merchantID($this->_option, $this->_country); $styles = array(EXTERNAL_KITT . "res/v1.1/checkout.css?eid=" . $merchantID, "includes/modules/payment/klarna/checkout/style.css", "includes/external/klarna/template/css/xtcstyle.css"); self::$_hasRun = true; echo $jsLoader->render(array("scripts" => array(EXTERNAL_KITT . "core/v1.0/js/klarna.min.js", EXTERNAL_KITT . "res/v1.1/js/klarna.lib.min.js", EXTERNAL_KITT . "res/v1.1/js/checkout.min.js"))); echo $cssLoader->render(array('styles' => $styles)); } KiTT::configuration()->set('agb_link', KlarnaConstant::agb($this->_option, $this->_country)); $fee = $this->_utils->getInvoiceFee(); if (KlarnaConstant::showPriceTax() === false && MODULE_KLARNA_FEE_TAX_CLASS > 0) { $feeRate = xtc_get_tax_rate(MODULE_KLARNA_FEE_TAX_CLASS); $fee = $fee / ($feeRate / 100 + 1); } $view->setPaymentFee(round($fee, 2)); $view->setPaymentId($this->code); // Have we returned from a failed purchase? if ($this->_utils->getErrorOption() == $this->_option) { $view->setError(html_entity_decode($this->_utils->getError())); $this->_utils->clearErrors(); if ($this->_option == KiTT::PART && array_key_exists('klarna_paymentPlan', $_SESSION)) { $view->selectPClass(intval($_SESSION['klarna_paymentPlan'])); } } $this->_klarna_data = $this->_utils->collectKlarnaData($order); $this->_klarna_data['country'] = $this->_country; if (isset($_SESSION['klarna_data']) || isset(KlarnaUtils::$prefillData)) { $this->_klarna_data = array_merge($this->_klarna_data, $this->_utils->getValuesFromSession()); } $view->prefill($this->_klarna_data); return array('id' => $this->code, 'module' => KITT_String::decode($view->getTitle(), "UTF-8", "ISO-8859-15"), 'module_cost' => $view->getExtra(), 'fields' => array(array('title' => '', 'field' => $view->show()))); }