/**
  * @param $cData
  */
 public function __construct($cData)
 {
     $this->path = JPATH_VMKLARNAPLUGIN . '/klarna/';
     if (!class_exists('ShopFunctions')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'helpers' . DS . 'shopfunctions.php';
     }
     $this->cData = $cData;
     //$this->currencyId = ShopFunctions::getCurrencyIDByName($this->cData['currency_code']);
     vmdebug('klarna_productPrice', $this->cData);
     try {
         $this->klarna_virtuemart = new Klarna_virtuemart();
         $this->klarna_virtuemart->config($this->cData['eid'], $this->cData['secret'], $this->cData['country'], $this->cData['language'], $this->cData['currency'], $this->cData['mode'], VMKLARNA_PC_TYPE, KlarnaHandler::getKlarna_pc_type(), FALSE);
     } catch (Exception $e) {
         vmDebug('klarna_productPrice', $e->getMessage(), $this->cData);
         unset($this->klarna);
     }
 }
 /**
  * @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) {
         VmError('klarna_payments', $e);
         unset($this->klarna);
     }
 }
Exemple #3
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();
 }
 /**
  * Return pclasses stored in json file.
  */
 public static function getPClasses($type = NULL, $mode, $settings)
 {
     //$settings = self::countryData($method, $country);
     try {
         $klarna = new Klarna_virtuemart();
         $klarna->config($settings['eid'], $settings['secret'], $settings['country'], $settings['language'], $settings['currency'], $mode, VMKLARNA_PC_TYPE, KlarnaHandler::getKlarna_pc_type(), TRUE);
         return $klarna->getPClasses($type);
     } catch (Exception $e) {
     }
 }
 /**
  *
  */
 function cancelReservation($order, $payments)
 {
     $rno = $this->getReservationNumber($payments);
     if (!$rno) {
         return;
         // error already sent
     }
     $this->initKlarnaParams($this->method);
     $klarna = new Klarna_virtuemart();
     $klarna->config($this->merchantid, $this->sharedsecret, $this->country_code_3, NULL, $this->currency_code_3, $this->mode, VMKLARNA_PC_TYPE, KlarnaHandler::getKlarna_pc_type(), $this->ssl);
     $modelOrder = VmModel::getModel('orders');
     try {
         $result = $klarna->cancelReservation($rno);
         $info = vmText::sprintf('VMPAYMENT_KLARNACHECKOUT_RESERVATION_CANCELED', $rno);
         VmInfo($info);
         $history = array();
         $history['customer_notified'] = 1;
         //$history['order_status'] = $this->method->checkout_complete;
         $history['comments'] = $info;
         // $order['details']['BT']->order_number);
         $modelOrder->updateStatusForOneOrder($order->virtuemart_paymentmethod_id, $history, TRUE);
         $dbValues['order_number'] = $payments[0]->order_number;
         $dbValues['payment_name'] = '';
         $dbValues['virtuemart_paymentmethod_id'] = $payments[0]->virtuemart_paymentmethod_id;
         $dbValues['action'] = 'cancelReservation';
         $dbValues['klarna_status'] = 'cancelReservation';
         $dbValues['data'] = $info;
         $this->debugLog($dbValues, 'storePSPluginInternalData cancelReservation', 'debug');
         $values = $this->storePSPluginInternalData($dbValues, $this->_tablepkey);
     } catch (Exception $e) {
         $error = $e->getMessage();
         VmError($e->getMessage(), vmText::sprintf('VMPAYMENT_KLARNACHECKOUT_ERROR_OCCURRED', $this->method->payment_name));
         $this->debugLog($e->getMessage(), 'cancelReservation', 'error');
         return FALSE;
     }
     //$dbValues['data'] = $vm_invoice_name;
     return true;
 }
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');
$data = $parameters->getParamByName('data');
//vmdebug('pclasses',$data);
$eid_array = KlarnaHandler::getEidSecretArray($data);
foreach ($eid_array as $country => $eid_data) {
    try {
        $klarna = new Klarna_virtuemart();
        $klarna->config($eid_data['eid'], $eid_data['secret'], null, null, null, $data->klarna_mode, VMKLARNA_PC_TYPE, KlarnaHandler::getKlarna_pc_type(), $data->klarna_mode == 'klarna_live');
        $klarna->setCountry($country);
        $pclasses = $klarna->getPClasses();
        $total = $total + count($pclasses);
        if (!count($pclasses) == 0) {
            ?>
				<table class="klarna_pclasses">
					<thead class="klarna_pclasses_header">
						<td class="pclass_id"><?php 
            echo JText::_('VMPAYMENT_KLARNA_PCLASS_ID');
            ?>
</td>
						<td class="pclass_description"><?php 
            echo JText::_('VMPAYMENT_KLARNA_PCLASS_DESCRIPTION');
            ?>
</td>
Exemple #7
0
 /**
  *
  */
 function cancelReservation($order, $payments)
 {
     $rno = $this->getReservationNumber($payments);
     if (!$rno) {
         return;
         // error already sent
     }
     $klarna = new Klarna_virtuemart();
     $klarna->config($this->_currentMethod->merchantid, $this->_currentMethod->sharedsecret, $this->country_code_3, NULL, $this->currency_code_3, $this->mode, VMKLARNA_PC_TYPE, KlarnaHandler::getKlarna_pc_type(), $this->ssl);
     $modelOrder = tmsModel::getModel('orders');
     try {
         $result = $klarna->cancelReservation($rno);
         $info = tsmText::sprintf('VMPAYMENT_KLARNACHECKOUT_RESERVATION_CANCELED', $rno);
         VmInfo($info);
         $history = array();
         $history['customer_notified'] = 1;
         //$history['order_status'] = $this->_currentMethod->checkout_complete;
         $history['comments'] = $info;
         // $order['details']['BT']->order_number);
         $modelOrder->updateStatusForOneOrder($order->virtuemart_order_id, $history, TRUE);
     } catch (Exception $e) {
         $error = $e->getMessage();
         $this->KlarnacheckoutError($e->getMessage(), tsmText::sprintf('VMPAYMENT_KLARNACHECKOUT_ERROR_OCCURRED', $this->_currentMethod->payment_name));
         return FALSE;
     }
     //$dbValues['data'] = $vm_invoice_name;
     return $result;
 }