示例#1
0
 function plgVmOnSelfCallFE($type, $name, &$render)
 {
     //Klarna Ajax
     require JPATH_VMKLARNAPLUGIN . '/klarna/helpers/klarna_ajax.php';
     if (!class_exists('VmModel')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'vmmodel.php';
     }
     $model = VmModel::getModel('paymentmethod');
     $payment = $model->getPayment();
     if (!class_exists('vmParameters')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'parameterparser.php';
     }
     $parameters = new vmParameters($payment, $payment->payment_element, 'plugin', 'vmpayment');
     $method = $parameters->getParamByName('data');
     $country = JRequest::getWord('country');
     $country = KlarnaHandler::convertToThreeLetterCode($country);
     if (!class_exists('klarna_virtuemart')) {
         require JPATH_VMKLARNAPLUGIN . '/klarna/helpers/klarna_virtuemart.php';
     }
     $settings = KlarnaHandler::getCountryData($method, $country);
     $klarna = new Klarna_virtuemart();
     $klarna->config($settings['eid'], $settings['secret'], $settings['country'], $settings['language'], $settings['currency'], KlarnaHandler::getKlarnaMode($method), VMKLARNA_PC_TYPE, KlarnaHandler::getKlarna_pc_type(), true);
     $SelfCall = new KlarnaAjax($klarna, (int) $settings['eid'], JPATH_VMKLARNAPLUGIN, Juri::base());
     $action = JRequest::getWord('action');
     $jlang = JFactory::getLanguage();
     $currentLang = substr($jlang->getDefault(), 0, 2);
     $newIso = JRequest::getWord('newIso');
     if ($currentLang != $newIso) {
         $iso = array("sv" => "sv-SE", "da" => "da-DK", "en" => "en-GB", "de" => "de-DE", "nl" => "nl-NL", "nb" => "nb-NO", "fi" => "fi-FI");
         if (array_key_exists($newIso, $iso)) {
             $jlang->load('plg_vmpayment_klarna', JPATH_ADMINISTRATOR, $iso[$newIso], true);
         }
     }
     echo $SelfCall->{$action}();
     jexit();
 }
示例#2
0
 /**
  * @param $method
  * @param $country_code
  * @param $cart
  * @return array|bool|null
  */
 function checkCountryCondition($method, $country_code, $cart)
 {
     if (!class_exists('CurrencyDisplay')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'currencydisplay.php';
     }
     $active_country = "klarna_active_" . strtolower($country_code);
     if (!isset($method->{$active_country}) or !$method->{$active_country}) {
         return FALSE;
     }
     if (empty($country_code)) {
         $msg = vmText::_('VMPAYMENT_KLARNA_GET_SWEDISH_ADDRESS');
         $country_code = "swe";
         vmWarn($msg);
         //return false;
     }
     /*
     if (strtolower ($country_code) == 'nld') {
     	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 FALSE;
     	}
     }
     */
     // Get the country settings
     if (!class_exists('KlarnaHandler')) {
         require JPATH_VMKLARNAPLUGIN . DS . 'klarna' . DS . 'helpers' . DS . 'klarnahandler.php';
     }
     $cData = KlarnaHandler::getCountryData($method, $country_code);
     if ($cData['eid'] == '' || $cData['eid'] == 0) {
         return FALSE;
     }
     return $cData;
 }