/** * Create the instance of this payment method translator * * @param string $lang language iso code */ public function __construct($lang) { if ($lang === null) { $lang = 'en'; } KlarnaUtils::configureKITT(); $this->_translator = KiTT::translator(KiTT::locale(null, $lang)); }
/** * Show information * * @return void */ function process() { global $order; $od_amount = $this->calculateInvoiceFee(); //Disable module when $od_amount is <= 0 if ($od_amount <= 0) { $this->enabled = false; return; } $formatter = new XtcFormatter(); $this->output[] = array('title' => $this->title . ':', 'text' => KITT_String::decode($formatter->formatPrice($od_amount, KiTT::locale($this->_country)), "UTF-8", "ISO-8859-15"), 'value' => $od_amount); $order->info['total'] += $od_amount; }
/** * 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); }
/** * Configure available Klarna countries in KiTT * * @param string $option payment option * * @return void */ public static function configureKlarna($option) { foreach (KlarnaConstant::getActivated($option) as $country) { $eid = KlarnaConstant::merchantID($option, $country); $secret = KlarnaConstant::secret($option, $country); // if eid or secret is 0, "" or null, ignore this country. if (!$eid || !$secret) { continue; } $locale = KiTT::locale($country); KiTT::configureKlarna($locale, $eid, $secret); } }
/** * 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; } } }