Example #1
0
	function plgVmOnCheckoutAdvertise ($cart, &$payment_advertise) {

		$vendorId = 1;
		$loadScriptAndCss = FALSE;
		if (!class_exists ('Klarna_payments')) {
			require (JPATH_VMKLARNAPLUGIN . DS . 'klarna' . DS . 'helpers' . DS . 'klarna_payments.php');
		}
		$country_code = NULL;
		$countryId = 0;
		if ($this->getPluginMethods ($cart->vendorId) === 0) {
			return FALSE;
		}

		$this->_getCountryCode ($cart, $country_code, $countryId);
		foreach ($this->methods as $method) {
			if ($cart->virtuemart_paymentmethod_id == $method->virtuemart_paymentmethod_id) {
				continue;
			}
			if (!($cData = $this->checkCountryCondition ($method, $country_code, $cart))) {
				return NULL;
			}
			if (strtolower ($country_code) == 'nld') {
				//  Since 12/09/12: merchants can sell goods with Klarna Invoice up to thousands of euros. So the price check has been moved here
				if (!KlarnaHandler::checkPartNLpriceCondition ($cart)) {
					// We can't show our payment options for Dutch customers
					// if price exceeds 250 euro. Will be replaced with ILT in
					// the future.
					return NULL;
				}
			}
			if (in_array ('part', $cData['payments_activated'])) {
				$payments = new klarna_payments($cData, KlarnaHandler::getShipToAddress ($cart));

				// TODO: change to there is a function in the API
				$sFee = $payments->getCheapestMonthlyCost ($cart, $cData);
				if ($sFee) {
					$payment_advertise[] = $this->renderByLayout ('cart_advertisement',
						array("sFee"   => $sFee,
							  "eid"    => $cData['eid'],
							  "country"=> $cData['country_code']
						));
				}
			}
		}

	}
Example #2
0
 function displayKlarnaLogos($method, $virtuemart_country_id, $shipTo, $total)
 {
     $session = JFactory::getSession();
     $sessionKlarna = $session->get('Klarna', 0, 'vm');
     if (empty($sessionKlarna)) {
         return '';
     }
     $sessionKlarnaData = unserialize($sessionKlarna);
     $address['virtuemart_country_id'] = $virtuemart_country_id;
     $cData = KlarnaHandler::getcData($method, $address);
     $country2 = strtolower(shopFunctions::getCountryByID($virtuemart_country_id, 'country_2_code'));
     switch ($sessionKlarnaData->klarna_option) {
         case 'invoice':
             $image = '/klarna_invoice_' . $country2 . '.png';
             $klarna_invoice_fee = KlarnaHandler::getInvoiceFeeInclTax($method, $cData['country_code_3']);
             $currency = CurrencyDisplay::getInstance();
             $display_fee = $currency->priceDisplay($klarna_invoice_fee);
             $text = JText::sprintf('VMPAYMENT_KLARNA_INVOICE_TITLE_NO_PRICE', $display_fee);
             break;
         case 'partpayment':
         case 'part':
             $image = '/klarna_part_' . $country2 . '.png';
             $address['virtuemart_country_id'] = $virtuemart_country_id;
             $pclasses = KlarnaHandler::getPClasses(NULL, $country2, KlarnaHandler::getKlarnaMode($method), $cData);
             if (!class_exists('Klarna_payments')) {
                 require JPATH_VMKLARNAPLUGIN . DS . 'klarna' . DS . 'helpers' . DS . 'klarna_payments.php';
             }
             if (!class_exists('KlarnaVm2API')) {
                 require JPATH_VMKLARNAPLUGIN . DS . 'klarna' . DS . 'helpers' . DS . 'klarna_vm2api.php';
             }
             $payments = new klarna_payments($cData, $shipTo);
             //vmdebug('displaylogos',$cart_prices);
             $totalInPaymentCurrency = KlarnaHandler::convertPrice($total, $cData['currency_code']);
             $text = $payments->displayPclass($sessionKlarnaData->KLARNA_DATA['pclass'], $totalInPaymentCurrency);
             // .' '.$total;
             break;
         case 'speccamp':
             $image = 'klarna_logo.png';
             $text = JText::_('VMPAYMENT_KLARNA_SPEC_TITLE');
             break;
         default:
             $image = '';
             $text = '';
             break;
     }
     $html = $this->renderByLayout('payment_cart', array('logo' => $image, 'description' => $text));
     return $html;
 }
 /**
  * @param $method
  * @param $virtuemart_country_id
  * @param $shipTo
  * @param $total
  * @return string
  */
 protected function renderKlarnaPluginName($method, $virtuemart_country_id, $shipTo, $total, $cartPricesCurrency)
 {
     $session = JFactory::getSession();
     $sessionKlarna = $session->get('Klarna', 0, 'vm');
     if (empty($sessionKlarna)) {
         return '';
     }
     $sessionKlarnaData = unserialize($sessionKlarna);
     $address['virtuemart_country_id'] = $virtuemart_country_id;
     $cData = KlarnaHandler::getcData($method, $address);
     $country2 = strtolower(shopFunctions::getCountryByID($virtuemart_country_id, 'country_2_code'));
     $text = "";
     if (isset($sessionKlarnaData->klarna_option)) {
         switch ($sessionKlarnaData->klarna_option) {
             case 'invoice':
                 $image = '/klarna_invoice_' . $country2 . '.png';
                 KlarnaHandler::getInvoiceFeeInclTax($method, $cData['country_code_3'], $cartPricesCurrency, $cData['virtuemart_currency_id'], $display_invoice_fee, $invoice_fee);
                 $text = JText::sprintf('VMPAYMENT_KLARNA_INVOICE_TITLE_NO_PRICE', $display_invoice_fee);
                 break;
             case 'partpayment':
             case 'part':
                 $image = '/klarna_part_' . $country2 . '.png';
                 $address['virtuemart_country_id'] = $virtuemart_country_id;
                 //$pclasses                         = KlarnaHandler::getPClasses(NULL,   KlarnaHandler::getKlarnaMode($method), $cData);
                 if (!class_exists('Klarna_payments')) {
                     require JPATH_VMKLARNAPLUGIN . DS . 'klarna' . DS . 'helpers' . DS . 'klarna_payments.php';
                 }
                 $payments = new klarna_payments($cData, $shipTo);
                 //vmdebug('displaylogos',$cart_prices);
                 $totalInPaymentCurrency = KlarnaHandler::convertPrice($total, $cartPricesCurrency, $cData['currency_code']);
                 vmdebug('totalInPaymentCurrency', $totalInPaymentCurrency);
                 if (isset($sessionKlarnaData->KLARNA_DATA)) {
                     $text = $payments->displayPclass($sessionKlarnaData->KLARNA_DATA['pclass'], $totalInPaymentCurrency);
                     // .' '.$total;
                 }
                 break;
             case 'speccamp':
                 $image = 'klarna_logo.png';
                 $text = JText::_('VMPAYMENT_KLARNA_SPEC_TITLE');
                 break;
             default:
                 $image = '';
                 $text = '';
                 break;
         }
         $plugin_name = $this->_psType . '_name';
         $plugin_desc = $this->_psType . '_desc';
         $payment_description = '';
         if (!empty($method->{$plugin_desc})) {
             $payment_description = $method->{$plugin_desc};
         }
         $payment_name = $method->{$plugin_name};
         $html = $this->renderByLayout('payment_cart', array('logo' => $image, 'text' => $text, 'payment_description' => $payment_description, 'payment_name' => $payment_name));
         return $html;
     }
 }