/**
  * Format a price
  *
  * @param mixed       $price  Raw price
  * @param KiTT_Locale $locale The locale to format the prices for
  *
  * @return string price with currency sign added
  */
 public function formatPrice($price, KiTT_Locale $locale = null)
 {
     if ($locale === null) {
         return $price;
     }
     $before = "";
     $after = "";
     switch ($locale->getCountry()) {
         case KlarnaCountry::SE:
         case KlarnaCountry::NO:
         case KlarnaCountry::DK:
             $after = " kr";
             break;
         case KlarnaCountry::FI:
             $after = '€';
             break;
         case KlarnaCountry::DE:
         case KlarnaCountry::NL:
             $before = "€";
             break;
     }
     return $before . $price . $after;
 }
 /**
  * Assemble all possible paths for the wanted template
  *
  * @param string $name template name
  *
  * @return array
  */
 private function _templatePaths($name)
 {
     $basepaths = array();
     try {
         $basepaths[] = $this->_config->get('paths/extra_templates');
     } catch (KiTT_MissingConfigurationException $e) {
     }
     $basepaths[] = $this->_vfs->join($this->_config->get('paths/kitt'), 'html');
     $paths = array();
     foreach ($basepaths as $index => $basepath) {
         $paths[] = $this->_vfs->join($basepath, strtolower($this->_locale->getCountryCode()), $name);
         $paths[] = $this->_vfs->join($basepath, $name);
     }
     return $paths;
 }
 /**
  * Get the formatted street required for a Klarna Addr
  *
  * @param string $street  The street to split
  * @param mixed  $country The country to split for
  *
  * @return array
  */
 public static function splitStreet($street, $country)
 {
     $country = KiTT_Locale::parseCountry($country);
     $split = KiTT_CountryLogic::getSplit($country);
     $elements = self::splitAddress($street);
     $result = array('street' => $elements[0]);
     if (in_array('house_extension', $split)) {
         $result['house_extension'] = $elements[2];
     } else {
         $elements[1] .= ' ' . $elements[2];
     }
     if (in_array('house_number', $split)) {
         $result['house_number'] = $elements[1];
     } else {
         $result['street'] .= ' ' . $elements[1];
     }
     return array_map('trim', $result);
 }
 /**
  * Get the translation for the specified key
  *
  * @param string $key Translation key
  *
  * @return string
  */
 public function translate($key)
 {
     return $this->_languagePack->fetch($key, $this->_locale->getLanguage());
 }
 /**
  * Get the currency used in a given country
  *
  * @param string|int $country country iso code
  *
  * @return iso-4217 currency code or null if no match was found.
  */
 public function getCurrency($country)
 {
     $country = KiTT_Locale::parseCountry($country);
     foreach (self::$lookup as $currency => $countries) {
         if (array_key_exists($country, $countries)) {
             return $currency;
         }
     }
     return null;
 }
Example #6
0
 /**
  * Factory for the part payment box
  *
  * @param KiTT_Locale $locale locale
  * @param float       $sum    Product cost
  * @param int         $page   KlarnaFlags PRODUCT_PAGE or CHECKOUT_PAGE
  *
  * @return KiTT_Installment_Widget
  */
 public static function partPaymentBox(KiTT_Locale $locale, $sum, $page = KlarnaFlags::PRODUCT_PAGE)
 {
     return new KiTT_Installment_Widget(self::configuration(), $locale, self::pclassCollection(KiTT::PART, $locale->getCountry(), $sum, $page), self::templateLoader($locale), self::translator($locale));
 }