/**
  * Build the Payment params
  */
 public function get_payment_params($method, $payment_type, $cart = NULL, $country_currency_code = '')
 {
     if (!class_exists('CurrencyDisplay')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'currencydisplay.php';
     }
     if (!class_exists('KlarnaAPI')) {
         require JPATH_VMKLARNAPLUGIN . DS . 'klarna' . DS . 'helpers' . DS . 'klarnaapi.php';
     }
     $payment_params = array();
     $invoice_fee = 0;
     if (!isset($this->klarna) || !$this->klarna instanceof Klarna_virtuemart) {
         return NULL;
     }
     $payment_params['payment_currency_info'] = "";
     if ($cart->pricesCurrency != $this->virtuemart_currency_id) {
         $payment_params['payment_currency_info'] = JText::_('VMPAYMENT_KLARNA_PAYMENT_CURRENCY_INFO');
     }
     if ($payment_type == 'invoice') {
         KlarnaHandler::getInvoiceFeeInclTax($method, $this->country_code_3, $cart->pricesCurrency, $this->virtuemart_currency_id, $display_invoice_fee, $invoice_fee);
         $billTotalInCountryCurrency = 0;
         $aTypes = NULL;
         $payment_params['pClasses'] = NULL;
     } else {
         $display_fee = 0;
         $billTotalInCountryCurrency = 0;
         if (isset($cart->pricesUnformatted['billTotal'])) {
             $billTotalInCountryCurrency = KlarnaHandler::convertPrice($cart->pricesUnformatted['billTotal'], $cart->pricesCurrency, $country_currency_code);
         }
         if ($billTotalInCountryCurrency <= 0) {
             return NULL;
         }
         $aTypes = array(KlarnaPClass::ACCOUNT, KlarnaPClass::CAMPAIGN, KlarnaPClass::FIXED);
     }
     $payment_params['sType'] = $payment_type;
     $kCheckout = new KlarnaAPI($this->country, $this->lang, $payment_type, $billTotalInCountryCurrency, KlarnaFlags::CHECKOUT_PAGE, $this->klarna, $aTypes, JPATH_VMKLARNAPLUGIN);
     if ($payment_type == 'invoice') {
         if ($invoice_fee) {
             $payment_params['module'] = JText::sprintf('VMPAYMENT_KLARNA_INVOICE_TITLE', $display_invoice_fee);
         } else {
             $payment_params['module'] = JText::_('VMPAYMENT_KLARNA_INVOICE_TITLE_NO_PRICE');
         }
         $payment_params['pClasses'] = NULL;
         $payment_params['id'] = 'klarna_invoice';
     } elseif ($payment_type == 'part') {
         $pclasses = $kCheckout->aPClasses;
         if (empty($pclasses)) {
             return NULL;
         }
         $cheapest = 0;
         $minimum = '';
         foreach ($pclasses as $pclass) {
             if ($cheapest == 0 || $pclass['monthlyCost'] < $cheapest) {
                 $cheapest = $pclass['monthlyCost'];
             }
             if ($pclass['pclass']->getMinAmount() < $minimum || $minimum === '') {
                 $minimum = $pclass['pclass']->getMinAmount();
             }
         }
         if ($billTotalInCountryCurrency < $minimum) {
             return NULL;
         }
         if (!class_exists('VirtueMartModelCurrency')) {
             require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'currency.php';
         }
         // Cheapest is in the Klarna country currency, convert it to the current currency display
         //$currencyDisplay = CurrencyDisplay::getInstance( );
         //$countryCurrencyId = $this->virtuemart_currency_id;
         //$sFee = $currencyDisplay->priceDisplay($cheapest, 0, 1,false);
         $sFee = $kCheckout->getPresentableValuta($cheapest);
         $payment_params['module'] = JText::sprintf('VMPAYMENT_KLARNA_PARTPAY_TITLE', $sFee);
         $payment_params['pClasses'] = $kCheckout->getPClassesInfo();
         $payment_params['id'] = 'klarna_partPayment';
     } else {
         $pclasses = $kCheckout->aPClasses;
         if (empty($pclasses)) {
             return NULL;
         }
         $payment_params['module'] = JText::_('VMPAYMENT_KLARNA_SPEC_TITLE');
         $payment_params['pClasses'] = $kCheckout->getPClassesInfo();
         $payment_params['id'] = 'klarna_SpecCamp';
     }
     $payment_params['payment_link'] = "https://online.klarna.com/villkor.yaws?eid=" . $this->eid . "&charge=" . $invoice_fee;
     if (strtolower($this->country) == 'de') {
         $vendor_id = 1;
         $payment_params['agb_link'] = JRoute::_('index.php?option=com_virtuemart&view=vendor&layout=tos&virtuemart_vendor_id=' . $vendor_id);
     }
     //$lang = KlarnaHandler::getLanguageForCountry($method, $this->country);
     $symbol = KlarnaHandler::getCurrencySymbolForCountry($method, $this->country);
     if (KlarnaHandler::getKlarnaError($klarnaError, $klarnaOption)) {
         if ($klarnaOption == 'klarna_' . $payment_type) {
             $payment_params['red_baloon_content'] = $klarnaError;
             $payment_params['red_baloon_paymentBox'] = 'klarna_box_' . $klarnaOption;
             //KlarnaHandler::clearKlarnaError ();
         }
     }
     // Something went wrong, refill what we can.
     $session = JFactory::getSession();
     $sessionKlarna = $session->get('Klarna', 0, 'vm');
     if (!empty($sessionKlarna)) {
         $sessionKlarnaData = unserialize($sessionKlarna);
         if (isset($sessionKlarnaData->KLARNA_DATA)) {
             $klarnaData = $sessionKlarnaData->KLARNA_DATA;
             $this->setPreviouslyFilledIn($klarnaData);
         }
     }
     $payment_params['paymentPlan'] = '';
     if (is_array($kCheckout->aPClasses)) {
         foreach ($kCheckout->aPClasses as $pclass) {
             if ($pclass['default'] === TRUE) {
                 $payment_params['paymentPlan'] = $pclass['pclass']->getId();
                 break;
             }
         }
     }
     if ($payment_type != "spec") {
         //$payment_params['conditionsLink'] = $aTemplateData['conditions'];
     }
     $payment_params['fields'] = $this->shipTo;
     $payment_params['payment_id'] = 'virtuemart_paymentmethod_id';
     $payment_params['checkout'] = $this->klarna->checkoutHTML();
     $payment_params['eid'] = $this->eid;
     $payment_params['year_salary'] = $this->klarna_year_salary;
     $payment_params['agreement_link'] = $this->payment_charge_link;
     $payment_params['sum'] = $invoice_fee;
     $payment_params['fee'] = $invoice_fee;
     $payment_params['invoice_fee'] = $invoice_fee;
     $payment_params['langISO'] = $this->lang;
     $payment_params['countryCode'] = $this->country;
     $payment_params['flag'] = KlarnaFlags::CHECKOUT_PAGE;
     $payment_params['payment_id'] = "payment";
     $payment_params['invoice_name'] = 'klarna_invoice';
     $payment_params['part_name'] = 'klarna_partPayment';
     $payment_params['spec_name'] = 'klarna_SpecCamp';
     return $payment_params;
 }