/** * Constructor */ function __construct() { global $order; $this->code = 'ot_klarna_fee'; $this->_country = $order->delivery['country']['iso_code_2']; $this->_utils = new KlarnaUtils($this->_country); $this->_lang = KlarnaUtils::getLanguageCode(); $this->_klarnaDB = new XtcKlarnaDB(); // Configure KiTT $this->_utils->configureKiTT(); $invFee = $this->_utils->translate('ot_klarna_title', $this->_lang); //~ ENT_NOQUOTES, //~ 'ISO-8859-1' //~ ); if (KlarnaConstant::isAdmin() && (!array_key_exists('action', $_GET) || !in_array($_GET['action'], array('install', 'remove')))) { echo "<link href='" . KlarnaUtils::getStaticPath() . "images.css' type='text/css' rel='stylesheet'/>"; $this->title = "<span class='klarna_icon'></span> Klarna - {$invFee}"; } else { $this->title = $invFee; } $this->description .= $this->_utils->translate('ot_klarna_title', $this->_lang); $this->description .= "<br />All invoice fees should be set in that countries currency"; $this->enabled = MODULE_KLARNA_FEE_STATUS; $this->sort_order = MODULE_KLARNA_FEE_SORT_ORDER; $this->tax_class = MODULE_KLARNA_FEE_TAX_CLASS; $this->output = array(); }
/** * The constructor * * @param int|string $country country * * @return void */ public function __construct($country = null) { global $currency; $this->_country = KlarnaUtils::deduceCountry('part'); $this->_language = KlarnaUtils::getLanguageCode(); $this->_currency = $currency; if ($country === null && $this->_country == null) { $this->_country = strtoupper($_SESSION['language_code']); } if ($this->_country === null) { Klarna::printDebug(__METHOD__, array('currency' => $this->_currency, 'language' => $this->_language)); $this->_enabled = false; return; } $this->_utils = new KlarnaUtils($this->_country); $this->_enabled = KlarnaConstant::isEnabled('part', $this->_country); if ($this->_enabled === true && !KlarnaConstant::isActivated('part', $this->_country)) { $this->_enabled = false; } $this->_locale = KiTT::locale($this->_country, $this->_language, $this->_currency); }
/** * The constructor * * @param string $option 'part', 'spec' or 'invoice' * * @return void */ public function __construct($option) { $this->_klarnaDB = new XtcKlarnaDB(); $currency = $_SESSION['currency']; $this->api_version = KlarnaCore::getCurrentVersion(); $this->jQuery = false; $this->enabled = true; $this->_option = $option; $country = KlarnaUtils::deduceCountry($option); $lang = KlarnaUtils::getLanguageCode(); $this->_country = $country; $this->_utils = new KlarnaUtils($country); $this->_locale = KiTT::locale($country, $lang, $currency); if (KlarnaConstant::isAdmin() && (!array_key_exists('action', $_GET) || !in_array($_GET['action'], array('install', 'remove')))) { echo "<link href='" . KlarnaUtils::getStaticPath() . "images.css' type='text/css' rel='stylesheet'/>"; $this->_checkForLatestVersion(); $this->description = $this->_buildDescription(); } //Set the title for the payment method. This will be displayed on the //confirmation page and the backend order view. $this->title = $this->_title(); $merchantID = KlarnaConstant::merchantID($option, $country); $secret = KlarnaConstant::secret($option, $country); if (!$merchantID || !$secret) { $this->enabled = false; return; } try { $this->setupModule(); } catch (KiTT_Exception $e) { if (!KlarnaConstant::isAdmin()) { $this->enabled == false; } } }