/**
  * @param $product
  * @return array|null
  */
 private function getViewData($product)
 {
     if (!class_exists('KlarnaAPI')) {
         require JPATH_VMKLARNAPLUGIN . DS . 'klarna' . DS . 'helpers' . DS . 'klarnaapi.php';
     }
     if (!class_exists('VirtueMartModelCurrency')) {
         require VMPATH_ADMIN . DS . 'models' . DS . 'currency.php';
     }
     $price = $product->prices['salesPrice'];
     $country = $this->cData['country'];
     $lang = $this->cData['language_code'];
     $types = array(KlarnaPClass::CAMPAIGN, KlarnaPClass::ACCOUNT, KlarnaPClass::FIXED);
     try {
         $kCheckout = new KlarnaAPI($country, $lang, 'part', $price, KlarnaFlags::PRODUCT_PAGE, $this->klarna_virtuemart, $types, $this->path);
     } catch (Exception $e) {
         VmDebug('getViewData', 'Error in ' . __METHOD__ . ': ' . $e->getMessage(), $e->getCode());
         VmError($e->getMessage(), 'getViewData' . 'Error in ' . __METHOD__ . ': ' . $e->getMessage(), $e->getCode());
         return NULL;
     }
     $kCheckout->setCurrency($this->cData['currency']);
     // TODO : Not top to get setup  values here!
     $this->settings = $kCheckout->getSetupValues();
     if ($price > 0 && count($kCheckout->aPClasses) > 0) {
         $currencydisplay = CurrencyDisplay::getInstance();
         $sMonthDefault = NULL;
         $sTableHtml = "";
         $monthTable = array();
         // either in vendor's currency, or shipTo Currency
         $countryCurrencyId = $this->cData['virtuemart_currency_id'];
         $currency = CurrencyDisplay::getInstance($countryCurrencyId);
         $fromCurrency = $currency->getCurrencyForDisplay();
         //$paymentCurrency = CurrencyDisplay::getInstance($this->cart->paymentCurrency);
         //$totalInPaymentCurrency = $paymentCurrency->priceDisplay( $this->cart->cartPrices['billTotal'],$this->cart->paymentCurrency) ;
         //$currencyDisplay = CurrencyDisplay::getInstance($this->cart->pricesCurrency);
         $i = 0;
         foreach ($kCheckout->aPClasses as $pclass) {
             if ($sMonthDefault === NULL || $pclass['monthlyCost'] < $sMonthDefault) {
                 $sMonthDefault = $currency->priceDisplay($pclass['monthlyCost'], $countryCurrencyId);
             }
             if ($pclass['pclass']->getType() == KlarnaPClass::ACCOUNT) {
                 $pp_title = tsmText::_('VMPAYMENT_KLARNA_PPBOX_ACCOUNT');
             } else {
                 $pp_title = $pclass['pclass']->getMonths() . " " . tsmText::_('VMPAYMENT_KLARNA_PPBOX_TH_MONTH');
             }
             $pp_price = $currency->priceDisplay($pclass['monthlyCost'], $countryCurrencyId);
             $monthTable[$i] = array('pp_title' => html_entity_decode($pp_title), 'pp_price' => $pp_price, 'country' => $country);
             $i++;
         }
         $cd = CurrencyDisplay::getInstance($fromCurrency);
         $aInputValues = array();
         $aInputValues['defaultMonth'] = $sMonthDefault;
         $aInputValues['monthTable'] = $monthTable;
         $aInputValues['eid'] = $this->cData['eid'];
         $aInputValues['country'] = KlarnaCountry::getCode($country);
         if ($country == KlarnaCountry::DE) {
             $aInputValues['asterisk'] = '*';
         } else {
             $aInputValues['asterisk'] = '';
         }
         return $aInputValues;
     }
     return NULL;
 }
 /**
  * @param $cData
  * @param $shipTo
  */
 function __construct($cData, $shipTo)
 {
     $this->shipTo = $shipTo;
     $this->country = $cData['country_code'];
     $this->country_code_3 = $cData['country_code_3'];
     $this->currency = $cData['currency_code'];
     $this->virtuemart_currency_id = $cData['virtuemart_currency_id'];
     //$this->currency = $vendor_currency;
     // Get EID and Secret
     $this->eid = $cData['eid'];
     $this->secret = $cData['secret'];
     $this->lang = $cData['language_code'];
     // Is Invoice enabled?
     $this->enabled = TRUE;
     // Set modes
     $this->mode = $cData['mode'];
     $this->ssl = KlarnaHandler::getKlarnaSSL($this->mode);
     $this->web_root = JURI::base();
     try {
         $this->klarna = new Klarna_virtuemart();
         $this->klarna->config($this->eid, $this->secret, $this->country, $this->lang, $this->currency, $this->mode, VMKLARNA_PC_TYPE, KlarnaHandler::getKlarna_pc_type(), $this->ssl);
     } catch (Exception $e) {
         VmDebug('klarna_payments', $e);
         unset($this->klarna);
     }
 }