public function getOrderDetails() { $orderModel = VmModel::getModel('orders'); $orderDetails = 0; // If the user is not logged in, we will check the order number and order pass if ($orderPass = JRequest::getString('order_pass', false) and $orderNumber = JRequest::getString('order_number', false)) { $orderId = $orderModel->getOrderIdByOrderPass($orderNumber, $orderPass); if (empty($orderId)) { vmDebug('Invalid order_number/password ' . JText::_('COM_VIRTUEMART_RESTRICTED_ACCESS')); return 0; } $orderDetails = $orderModel->getOrder($orderId); } if ($orderDetails == 0) { $_currentUser = JFactory::getUser(); $cuid = $_currentUser->get('id'); // If the user is logged in, we will check if the order belongs to him $virtuemart_order_id = JRequest::getInt('virtuemart_order_id', 0); if (!$virtuemart_order_id) { $virtuemart_order_id = VirtueMartModelOrders::getOrderIdByOrderNumber(JRequest::getString('order_number')); } $orderDetails = $orderModel->getOrder($virtuemart_order_id); JLoader::register('Permissions', JPATH_VM_ADMINISTRATOR . '/helpers/permissions.php'); if (!Permissions::getInstance()->check("admin")) { if (!empty($orderDetails['details']['BT']->virtuemart_user_id)) { if ($orderDetails['details']['BT']->virtuemart_user_id != $cuid) { echo 'view ' . JText::_('COM_VIRTUEMART_RESTRICTED_ACCESS'); return; } } } } return $orderDetails; }
/** * @param $product * @return bool */ private function showPP($product) { if (!isset($this->klarna_virtuemart) || !$this->klarna_virtuemart instanceof Klarna_virtuemart) { return FALSE; } if (!VMKLARNA_SHOW_PRODUCTPRICE) { return FALSE; } // the price is in the vendor currency // convert price in NLD currency= euro $price = KlarnaHandler::convertPrice($product->prices['salesPrice'], $product->product_currency, 'EUR'); if (strtolower($this->cData['country_code']) == 'nl' && $price > 250) { vmDebug('showPP', 'dont show price for NL', $this->cData['country_code'], $price); return FALSE; } if ($price <= $this->cData['min_amount'] and !empty($this->cData['min_amount'])) { return FALSE; } return TRUE; }
function plgVmConfirmedOrder($cart, $order) { if (!($method = $this->getVmPluginMethod($order['details']['BT']->virtuemart_paymentmethod_id))) { return NULL; // Another method was selected, do nothing } if (!$this->selectedThisElement($method->payment_element)) { return FALSE; } $session = JFactory::getSession(); $return_context = $session->getId(); $this->_debug = $method->HEIDELPAY_DEBUG; if (!class_exists('VirtueMartModelOrders')) { require VMPATH_ADMIN . DS . 'models' . DS . 'orders.php'; } if (!class_exists('VirtueMartModelCurrency')) { require VMPATH_ADMIN . DS . 'models' . DS . 'currency.php'; } $address = isset($order['details']['BT']) ? $order['details']['BT'] : $order['details']['ST']; if (!class_exists('TableVendors')) { require VMPATH_ADMIN . DS . 'table' . DS . 'vendors.php'; } $vendorModel = VmModel::getModel('Vendor'); $vendorModel->setId(1); $vendor = $vendorModel->getVendor(); $vendorModel->addImages($vendor, 1); $this->getPaymentCurrency($method); $currency_code_3 = shopFunctions::getCurrencyByID($method->payment_currency, 'currency_code_3'); $paymentCurrency = CurrencyDisplay::getInstance($method->payment_currency); $totalInPaymentCurrency = round($paymentCurrency->convertCurrencyTo($method->payment_currency, $order['details']['BT']->order_total, FALSE), 2); $cd = CurrencyDisplay::getInstance($cart->pricesCurrency); // prepare the post var values: $languageTag = $this->getLang(); $params = array(); /* * Default configuration for hco */ $params['FRONTEND.MODE'] = "DEFAULT"; $params['FRONTEND.ENABLED'] = "true"; $params['FRONTEND.POPUP'] = "false"; $params['FRONTEND.REDIRECT_TIME'] = "0"; $params['REQUEST.VERSION'] = "1.0"; $params['FRONTEND.NEXTTARGET'] = "top.location.href"; $params['PRESENTATION.AMOUNT'] = $totalInPaymentCurrency; $params['PRESENTATION.CURRENCY'] = $currency_code_3; $params['FRONTEND.LANGUAGE'] = $languageTag; $params['CRITERION.LANG'] = $params['FRONTEND.LANGUAGE']; $params['IDENTIFICATION.TRANSACTIONID'] = $order['details']['BT']->order_number; /* * Set payment methode to PA for online transfer, invoice and prepayment */ $PaymentTypePA = array('OT', 'PP', 'IV'); if (in_array(substr($method->HEIDELPAY_PAYMENT_TYPE, 0, 2), $PaymentTypePA)) { $method->HEIDELPAY_PAYMENT_METHOD = "PA"; } else { $method->HEIDELPAY_PAYMENT_METHOD = $method->HEIDELPAY_PAYMENT_METHOD; } $params['PAYMENT.CODE'] = substr($method->HEIDELPAY_PAYMENT_TYPE, 0, 2) . "." . $method->HEIDELPAY_PAYMENT_METHOD; $params['TRANSACTION.CHANNEL'] = $method->HEIDELPAY_CHANNEL_ID; /* * Special case for paypal without hco iframe */ if ($method->HEIDELPAY_PAYMENT_TYPE == "VAPAYPAL") { $params['PAYMENT.CODE'] = "VA.DB"; $params['ACCOUNT.BRAND'] = "PAYPAL"; $params['FRONTEND.PM.DEFAULT_DISABLE_ALL'] = "true"; $params['FRONTEND.PM.0.ENABLED'] = "true"; $params['FRONTEND.PM.0.METHOD'] = "VA"; $params['FRONTEND.PM.0.SUBTYPES'] = "PAYPAL"; } /* * Special case for MangirKart without hco iframe */ if ($method->HEIDELPAY_PAYMENT_TYPE == "PCMANGIR") { $params['PAYMENT.CODE'] = "PC.PA"; $params['ACCOUNT.BRAND'] = "MANGIRKART"; } /* * case for GiroPay */ if ($method->HEIDELPAY_PAYMENT_TYPE == "OTGIR") { $params['FRONTEND.SEPA'] = 'YES'; $params['FRONTEND.SEPASWITCH'] = 'NO'; } /* * Special case for BarPay without hco iframe */ if ($method->HEIDELPAY_PAYMENT_TYPE == "PPBARPAY") { $params['PAYMENT.CODE'] = "PP.PA"; $params['ACCOUNT.BRAND'] = "BARPAY"; } /* * Special case for BillSAFE */ if ($method->HEIDELPAY_PAYMENT_TYPE == "IVBILLSAFE") { $toCheck = array('last_name', 'first_name', 'middle_name', 'phone_1', 'phone_2', 'fax', 'address_1', 'address_2', 'city', 'virtuemart_state_id', 'virtuemart_country_id', 'zip'); $bsError = false; foreach ($toCheck as $val) { if (isset($order['details']['ST']->{$val})) { if ($order['details']['ST']->{$val} != $order['details']['BT']->{$val}) { $bsError = true; $errorVal = $val; break; } } } if ($bsError) { $msg = vmText::_('VMPAYMENT_HEIDELPAY_TECHNICAL_ERROR') . "<br />" . vmText::_('VMPAYMENT_HEIDELPAY_BILLSAFE_ERROR') . "<br />"; $app = JFactory::getApplication(); $app->redirect('index.php?option=com_virtuemart&view=cart', $msg); } $params['PAYMENT.CODE'] = "IV.PA"; $params['ACCOUNT.BRAND'] = "BILLSAFE"; $params = array_merge($params, $this->getBasketDetails()); } /* * User account information */ $params['ACCOUNT.HOLDER'] = $address->first_name . " " . $address->last_name; $params['NAME.GIVEN'] = $address->first_name; $params['NAME.FAMILY'] = $address->last_name; if (!empty($address->company)) { $params['NAME.COMPANY'] = $address->company; } $params['ADDRESS.STREET'] = $address->address_1; isset($address->address_2) ? $params['ADDRESS.STREET'] .= " " . $address->address_2 : ''; $params['ADDRESS.ZIP'] = $address->zip; $params['ADDRESS.CITY'] = $address->city; $params['ADDRESS.COUNTRY'] = ShopFunctions::getCountryByID($address->virtuemart_country_id, 'country_2_code'); $params['CONTACT.EMAIL'] = $order['details']['BT']->email; $params['CONTACT.IP'] = $_SERVER['REMOTE_ADDR']; /* * Add debug informations for merchiant support */ $params['SHOP.TYPE'] = 'VirtueMart ' . VmConfig::getInstalledVersion(); $params['SHOPMODULE.VERSION'] = $this->version; $params['CRITERION.PAYMENT_NAME'] = vmText::_('VMPAYMENT_HEIDELPAY_' . $method->HEIDELPAY_PAYMENT_TYPE); $params['CRITERION.PAYMENT_NAME'] = strip_tags($params['CRITERION.PAYMENT_NAME']); /* * Create hash to secure the response */ $params['CRITERION.SECRET'] = $this->createSecretHash($order['details']['BT']->order_number, $method->HEIDELPAY_SECRET); /* * Set transaction mode */ if ($method->HEIDELPAY_TRANSACTION_MODE == 2) { $params['TRANSACTION.MODE'] = "LIVE"; } elseif ($method->HEIDELPAY_TRANSACTION_MODE == 0) { $params['TRANSACTION.MODE'] = "INTEGRATOR_TEST"; } else { $params['TRANSACTION.MODE'] = "CONNECTOR_TEST"; } /* * Add response and css path */ $params['FRONTEND.RESPONSE_URL'] = JROUTE::_(JURI::root(), $xhtml = true, $ssl = 0) . 'plugins/vmpayment/heidelpay/heidelpay/heidelpay_response.php?option=com_virtuemart&view=pluginresponse&task=pluginresponsereceived&on=' . urlencode($order['details']['BT']->order_number) . '&pm=' . $order['details']['BT']->virtuemart_paymentmethod_id; $cssFile = "heidelpay_default.css"; if (!empty($method->HEIDELPAY_STYLE)) { $cssFile = $method->HEIDELPAY_STYLE; } $params['FRONTEND.CSS_PATH'] = JROUTE::_(JURI::root(), $xhtml = true, $ssl = 0) . 'plugins/vmpayment/heidelpay/heidelpay/' . $cssFile; $requestUrl = $method->HEIDELPAY_PAYMENT_URL; $params['SECURITY.SENDER'] = $method->HEIDELPAY_SECURITY_SENDER; $params['USER.LOGIN'] = $method->HEIDELPAY_USER_LOGIN; $params['USER.PWD'] = $method->HEIDELPAY_USER_PW; if (substr($method->HEIDELPAY_PAYMENT_TYPE, 0, 2) == 'DD') { $sepaform = array(); $sepaform = $this->switchDirectDebitFrom($method->HEIDELPAY_SEPA_FORM); $params = array_merge($sepaform, $params); } /* * send request to payment server */ $response = $this->doRequest($requestUrl, $params, $method->HEIDELPAY_DEBUG); if ($params['TRANSACTION.MODE'] != "LIVE") { vmInfo('VMPAYMENT_HEIDELPAY_PAYMENT_TESTMODE'); } /* * On success show iframe or show error information for your customer */ $returnValue = 0; if ($response['PROCESSING_RESULT'] == "ACK" || $response['POST_VALIDATION'] == "ACK") { $returnValue = 2; $html = $this->renderByLayout('displaypayment', array('response' => $response['FRONTEND_REDIRECT_URL'])); } else { $html = vmText::_('VMPAYMENT_HEIDELPAY_TECHNICAL_ERROR') . " <br /> - " . addslashes($response['PROCESSING_RETURN']) . "<br />" . vmText::_('VMPAYMENT_HEIDELPAY_CONTACT_SHOPOWNER'); } /* * Show debug information */ if ($method->HEIDELPAY_DEBUG == 1) { vmDebug('HEIDELPAY plgVmConfirmedOrder', $params); } return $this->processConfirmedOrderPaymentResponse($returnValue, $cart, $order, $html, '', ''); }
/** * @return bool|null */ function plgVmOnUserPaymentCancel() { $order_number = vRequest::getString('on', ''); $virtuemart_paymentmethod_id = vRequest::getInt('pm', ''); if (empty($order_number) or empty($virtuemart_paymentmethod_id) or !$this->selectedThisByMethodId($virtuemart_paymentmethod_id)) { vmdebug('plgVmOnUserPaymentCancel', $order_number, $virtuemart_paymentmethod_id); return NULL; } if (!class_exists('VirtueMartModelOrders')) { require VMPATH_ADMIN . DS . 'models' . DS . 'orders.php'; } if (!($virtuemart_order_id = VirtueMartModelOrders::getOrderIdByOrderNumber($order_number))) { return NULL; } if (!($paymentTable = $this->getDataByOrderId($virtuemart_order_id))) { return NULL; } vmdebug('plgVmOnUserPaymentCancel', 'VMPAYMENT_SOFORT_PAYMENT_CANCELLED'); VmInfo(vmText::_('VMPAYMENT_SOFORT_PAYMENT_CANCELLED')); $session = JFactory::getSession(); $return_context = $session->getId(); if (strcmp($paymentTable->sofort_custom, $return_context) === 0) { vmDebug('handlePaymentUserCancel'); $this->handlePaymentUserCancel($virtuemart_order_id); } else { vmDebug('Return context', $paymentTable->sofort_custom, $return_context); } return TRUE; }
if (!class_exists($_class)) { require $basePath . DS . 'controllers' . DS . $_controller . '.php'; } } else { // try plugins JPluginHelper::importPlugin('vmextended'); $dispatcher = JDispatcher::getInstance(); $rets = $dispatcher->trigger($trigger, array($_controller)); foreach ($rets as $ret) { if ($ret) { return true; } } } if (class_exists($_class)) { $controller = new $_class(); $controller->execute($task); //vmTime($_class.' Finished task '.$task,'Start'); vmRam('End'); vmRamPeak('Peak'); /* Redirect if set by the controller */ $controller->redirect(); } else { vmDebug('VirtueMart controller not found: ' . $_class); if (tsmConfig::get('handle_404', 1)) { $mainframe = Jfactory::getApplication(); $mainframe->redirect(JRoute::_('index.php?option=com_virtuemart&view=tsmart', FALSE)); } else { JError::raise(E_ERROR, '404', 'Not found'); } }
/** * @static * @param $price * @param string $toCurrency * @return float */ static function convertPrice($price, $fromCurrency, $toCurrency = '', $cartPricesCurrency = '') { if (!(is_int($toCurrency) or is_numeric($toCurrency)) && !empty($toCurrency)) { $toCurrency = ShopFunctions::getCurrencyIDByName($toCurrency); } if ($fromCurrency == $toCurrency) { return $price; } // product prices or total in cart is always in vendor currency $priceInNewCurrency = vmPSPlugin::getAmountInCurrency($price, $toCurrency); // set back the currency display if (empty($cartPricesCurrency)) { $cartPricesCurrency = $fromCurrency; } $cd = CurrencyDisplay::getInstance($cartPricesCurrency); vmDebug('convertPrice', $price, $toCurrency, $fromCurrency, $cartPricesCurrency, $priceInNewCurrency); return $priceInNewCurrency['value']; }
/** * @return bool|null */ function plgVmOnUserPaymentCancel() { $order_number = vRequest::getString('on', ''); // cancel / abort link must be insterted in the SOFORT BE // must be http://mysite.com/index.php?option=com_virtuemart&view=pluginresponse&task=pluginUserPaymentCancel&on=-REASON1- $virtuemart_paymentmethod_id = vRequest::getInt('pm', ''); if (empty($order_number) or empty($virtuemart_paymentmethod_id) or !$this->selectedThisByMethodId($virtuemart_paymentmethod_id)) { return NULL; } $error_codes = vRequest::getString('error_codes', ''); if (!empty($error_codes)) { $errors = explode(",", $error_codes); foreach ($errors as $error) { // TODO $lang = JFactory::getLanguage(); $lang_key = 'VMPAYMENT_SOFORT_IDEAL_ERROR_CODES_' . $error; if ($lang->hasKey($lang_key)) { vmInfo(vmText::_($lang_key)); } else { vmInfo(vmText::sprintf('VMPAYMENT_SOFORT_IDEAL_ERROR_CODES_UNKNOWN_CODE', $error)); } } //return false; } if (!class_exists('VirtueMartModelOrders')) { require VMPATH_ADMIN . DS . 'models' . DS . 'orders.php'; } if (!($virtuemart_order_id = VirtueMartModelOrders::getOrderIdByOrderNumber($order_number))) { return NULL; } if (!($paymentTable = $this->getDataByOrderId($virtuemart_order_id))) { return NULL; } if (!($method = $this->getVmPluginMethod($paymentTable->virtuemart_paymentmethod_id))) { return NULL; // Another method was selected, do nothing } if (!$this->selectedThisElement($method->payment_element)) { //vmdebug('IDEAL plgVmOnPaymentResponseReceived NOT selectedThisElement' ); return NULL; } vmdebug(__CLASS__ . '::' . __FUNCTION__, 'VMPAYMENT_SOFORT_PAYMENT_CANCELLED', $error_codes); if (empty($error_codes)) { VmInfo(vmText::_('VMPAYMENT_SOFORT_PAYMENT_CANCELLED')); $comment = ''; } else { $comment = vmText::_($lang_key); } $session = JFactory::getSession(); $return_context = $session->getId(); vmDebug('handlePaymentUserCancel', $virtuemart_order_id, $paymentTable->sofort_custom, $return_context); if (strcmp($paymentTable->sofort_custom, $return_context) === 0) { vmDebug('handlePaymentUserCancel', $virtuemart_order_id); $this->handlePaymentUserCancel($virtuemart_order_id, $method->status_canceled, $comment); } else { vmDebug('Return context', $paymentTable->sofort_custom, $return_context); } return TRUE; }
/** * This event is fired after the payment method has been selected. It can be used to store * additional payment info in the cart. * * @author Valérie isaksen * * @param VirtueMartCart $cart: the actual cart * @return null if the payment was not selected, true if the data is valid, error message if the data is not vlaid * */ public function plgVmOnSelectCheckPayment (VirtueMartCart $cart, &$msg) { if (!$this->selectedThisByMethodId ($cart->virtuemart_paymentmethod_id)) { return NULL; // Another method was selected, do nothing } if (!($method = $this->getVmPluginMethod ($cart->virtuemart_paymentmethod_id))) { return NULL; // Another method was selected, do nothing } if (!class_exists ('KlarnaAddr')) { require (JPATH_VMKLARNAPLUGIN . DS . 'klarna' . DS . 'api' . DS . 'klarnaaddr.php'); } $session = JFactory::getSession (); $sessionKlarna = new stdClass(); //$post = JRequest::get('post'); $errors = array(); $klarnaData_paymentmethod = JRequest::getVar ('klarna_paymentmethod', ''); if ($klarnaData_paymentmethod == 'klarna_invoice') { $sessionKlarna->klarna_option = 'invoice'; } elseif ($klarnaData_paymentmethod == 'klarna_partPayment') { $sessionKlarna->klarna_option = 'part'; } elseif ($klarnaData_paymentmethod == 'klarna_speccamp') { $sessionKlarna->klarna_option = 'spec'; } else { return NULL; } // Store payment_method_id so we can activate the // right payment in case something goes wrong. $sessionKlarna->virtuemart_payment_method_id = $cart->virtuemart_paymentmethod_id; $sessionKlarna->klarna_paymentmethod = $klarnaData_paymentmethod; $country3 = NULL; $countryId = 0; $this->_getCountryCode ($cart, $country3, $countryId, 'country_3_code'); // $country2= strtolower($country2); if (empty($country3)) { $country3 = "SWE"; $countryId = ShopFunctions::getCountryIDByName ($country3); } $cData = KlarnaHandler::countryData ($method, strtoupper ($country3)); $klarnaData = KlarnaHandler::getDataFromEditPayment (); if ($msg = KlarnaHandler::checkDataFromEditPayment ($klarnaData, $cData['country_code_3'])) { //vmInfo($msg); // meanwhile the red baloon works $session->set ('Klarna', serialize ($sessionKlarna), 'vm'); return FALSE; } $klarnaData['country'] = $cData['country_code']; $klarnaData['country3'] = $cData['country_code_3']; //$country = $cData['country_code']; //KlarnaHandler::convertCountry($method, $country2); //$lang = $cData['language_code']; //KlarnaHandler::getLanguageForCountry($method, $country); // Get the correct data //Removes spaces, tabs, and other delimiters. // If it is a swedish customer we use the information from getAddress if (strtolower ($cData['country_code']) == "se") { $swedish_addresses = KlarnaHandler::getAddresses ($klarnaData['socialNumber'], $cData, $method); if (empty($swedish_addresses)) { $msg = JText::_ ('VMPAYMENT_KLARNA_ERROR_TITLE_2'); $msg .= JText::_ ('VMPAYMENT_KLARNA_NO_GETADDRESS'); $session->set ('Klarna', serialize ($sessionKlarna), 'vm'); return FALSE; } //This example only works for GA_GIVEN. foreach ($swedish_addresses as $address) { if ($address->isCompany) { $klarnaData['company_name'] = $address->getCompanyName (); $klarnaData['first_name'] = "-"; $klarnaData['last_name'] = "-"; } else { $klarnaData['first_name'] = $address->getFirstName (); $klarnaData['last_name'] = $address->getLastName (); } $klarnaData['street'] = $address->getStreet (); $klarnaData['zip'] = $address->getZipCode (); $klarnaData['city'] = $address->getCity (); $klarnaData['country'] = $address->getCountryCode (); $countryId = $klarnaData['virtuemart_country_id'] = shopFunctions::getCountryIDByName ($klarnaData['country']); } foreach ($klarnaData as $key => $value) { $klarnaData[$key] = mb_convert_encoding ($klarnaData[$key], 'UTF-8', 'ISO-8859-1'); } } $address_type = NULL; $st = $this->getCartAddress ($cart, $address_type, TRUE); vmDebug ('getCartAddress', $st); if ($address_type == 'BT') { $prefix = ''; } else { $prefix = 'shipto_'; } // Update the Shipping Address to what is specified in the register. $update_data = array( $prefix . 'address_type_name' => 'Klarna', $prefix . 'company' => $klarnaData['company_name'], $prefix . 'title' => $klarnaData['title'], $prefix . 'first_name' => $klarnaData['first_name'], $prefix . 'middle_name' => $st['middle_name'], $prefix . 'last_name' => $klarnaData['last_name'], $prefix . 'address_1' => $klarnaData['street'], $prefix . 'address_2' => $klarnaData['house_ext'], $prefix . 'house_no' => $klarnaData['house_no'], $prefix . 'zip' => html_entity_decode ($klarnaData['zip']), $prefix . 'city' => $klarnaData['city'], $prefix . 'virtuemart_country_id' => $countryId, //$klarnaData['virtuemart_country_id'], $prefix . 'state' => '', $prefix . 'phone_1' => $klarnaData['phone'], $prefix . 'phone_2' => $st['phone_2'], $prefix . 'fax' => $st['fax'], //$prefix . 'birthday' => empty($klarnaData['birthday']) ? $st['birthday'] : $klarnaData['birthday'], //$prefix . 'socialNumber' => empty($klarnaData['pno']) ? $klarnaData['socialNumber'] : $klarnaData['pno'], 'address_type' => $address_type ); if ($address_type == 'BT') { $update_data ['email'] = $klarnaData['email']; } if (!empty($st)) { $update_data = array_merge ($st, $update_data); } // save address in cart if different // if (false) { $cart->saveAddressInCart ($update_data, $update_data['address_type'], TRUE); //vmdebug('plgVmOnSelectCheckPayment $cart',$cart); //vmInfo(JText::_('VMPAYMENT_KLARNA_ADDRESS_UPDATED_NOTICE')); // } //} // Store the Klarna data in a session variable so // we can retrevie it later when we need it //$klarnaData['pclass'] = ($klarnaData_paymentmethod == 'klarna_invoice' ? -1 : intval(JRequest::getVar($kIndex . "paymentPlan"))); $klarnaData['pclass'] = ($klarnaData_paymentmethod == 'klarna_invoice' ? -1 : intval (JRequest::getVar ("part_klarna_paymentPlan"))); $sessionKlarna->KLARNA_DATA = $klarnaData; // 2 letters small //$settings = KlarnaHandler::getCountryData($method, $cart_country2); try { $address = new KlarnaAddr( $klarnaData['email'], $klarnaData['phone'], "", //mobile $klarnaData['first_name'], $klarnaData['last_name'], '', $klarnaData['street'], $klarnaData['zip'], $klarnaData['city'], $klarnaData['country'], // $settings['country'], $klarnaData['house_no'], $klarnaData['house_ext'] ); } catch (Exception $e) { VmInfo ($e->getMessage ()); return FALSE; //KlarnaHandler::redirectPaymentMethod('message', $e->getMessage()); } if (isset($errors) && count ($errors) > 0) { $msg = JText::_ ('VMPAYMENT_KLARNA_ERROR_TITLE_1'); foreach ($errors as $error) { $msg .= "<li> -" . $error . "</li>"; } $msg .= JText::_ ('VMPAYMENT_KLARNA_ERROR_TITLE_2'); unset($errors); VmError ($msg); return FALSE; //KlarnaHandler::redirectPaymentMethod('error', $msg); } $session->set ('Klarna', serialize ($sessionKlarna), 'vm'); return TRUE; }
/** * This is a proxy function to return an order safely, we may set the getOrder function to private * Maybe the right place would be the controller, cause there are JRequests in it. But for a fast solution, * still better than to have it 3-4 times in the view.html.php of the views. * @author Max Milbers * * @return array */ public function getMyOrderDetails($orderID = 0, $orderNumber = false, $orderPass = false) { $_currentUser = JFactory::getUser(); $cuid = $_currentUser->get('id'); $orderDetails = false; // If the user is not logged in, we will check the order number and order pass if (empty($cuid)) { $sess = JFactory::getSession(); $orderNumber = vRequest::getString('order_number', $orderNumber); $tries = $sess->get('getOrderDetails.' . $orderNumber, 0); if ($tries > 5) { vmDebug('Too many tries, Invalid order_number/password ' . vmText::_('COM_VIRTUEMART_RESTRICTED_ACCESS')); return false; } // If the user is not logged in, we will check the order number and order pass if ($orderPass = vRequest::getString('order_pass', $orderPass)) { $orderId = $this->getOrderIdByOrderPass($orderNumber, $orderPass); if (empty($orderId)) { echo vmText::_('COM_VIRTUEMART_RESTRICTED_ACCESS'); vmdebug('getMyOrderDetails COM_VIRTUEMART_RESTRICTED_ACCESS', $orderNumber, $orderPass, $tries); $tries++; $sess->set('getOrderDetails.' . $orderNumber, $tries); return false; } $orderDetails = $this->getOrder($orderId); } } else { // If the user is logged in, we will check if the order belongs to him $virtuemart_order_id = vRequest::getInt('virtuemart_order_id', $orderID); if (!$virtuemart_order_id) { $virtuemart_order_id = VirtueMartModelOrders::getOrderIdByOrderNumber(vRequest::getString('order_number')); } $orderDetails = $this->getOrder($virtuemart_order_id); $user = JFactory::getUser(); if (!vmAccess::manager('orders')) { if (!isset($orderDetails['details']['BT']->virtuemart_user_id)) { $orderDetails['details']['BT']->virtuemart_user_id = 0; } if ($orderDetails['details']['BT']->virtuemart_user_id != $cuid) { echo vmText::_('COM_VIRTUEMART_RESTRICTED_ACCESS'); return false; } } } return $orderDetails; }
/** * plgVmOnSelfCallBE ... Called to execute some plugin action in the backend (e.g. set/reset dl counter, show statistics etc.) */ function plgVmOnSelfCallBE($type, $name, &$output) { if ($name != $this->_name || $type != 'vmshopper') { return false; } vmDebug('plgVmOnSelfCallBE'); $user = JFactory::getUser(); $authorized = ($user->authorise('core.admin', 'com_virtuemart') or $user->authorise('core.manage', 'com_virtuemart') or $user->authorise('vm.orders', 'com_virtuemart')); $json = array(); $json['authorized'] = $authorized; if (!$authorized) { return FALSE; } $action = vRequest::getCmd('action'); $counter = vRequest::getString('counter'); $nrtype = vRequest::getInt('nrtype'); $json['action'] = $action; $json['success'] = 0; // default: unsuccessfull switch ($action) { case "deleteCounter": $json['success'] = $this->_deleteCounter($nrtype, $counter); break; case "addCounter": $value = vRequest::getInt('value', 0); if ($this->_counterExists($nrtype, $counter)) { $json['error'] = JText::sprintf('PLG_ORDERNUMBER_COUNTERLIST_EXISTS', $counter); $json['success'] = false; } else { $json['success'] = $this->_addCounter($nrtype, $counter, $value); // Return the table row for the new counter in the JSON: $pluginpath = '/plugins/vmshopper/ordernumber/ordernumber/'; $displayfmt = $counter == "" ? JText::_('PLG_ORDERNUMBER_COUNTERLIST_GLOBAL') : $counter; $html = array(); $html[] = "<tr class='counter_row counter_type_{$nrtype}'>"; $html[] = " <td class='counter_format'>" . (string) $displayfmt . "</td>"; $html[] = " <td class='counter_value'>" . (string) $value . "</td>"; $html[] = " <td class='counter_buttons'><img src='" . JURI::root(true) . $pluginpath . "assets/images/icon-16-edit.png' class='vmordernumber-counter-editbtn vmordernumber-btn' onClick='ajaxEditCounter(this, {$nrtype}, " . json_encode($counter) . ", {$value})' /><img src='" . JURI::root(true) . $pluginpath . "assets/images/icon-16-delete.png' class='vmordernumber-counter-deletebtn vmordernumber-btn' onClick='ajaxDeleteCounter(this, {$nrtype}, " . json_encode($counter) . ", {$value})' /></td>"; $html[] = "</tr>"; $json['newrow'] = implode("\n", $html); } break; case "setCounter": $value = vRequest::getInt('value'); $json['success'] = $this->_setCounter($nrtype, $counter, $value); break; } // Also return all messages (in HTML format!): // Since we are in a JSON document, we have to temporarily switch the type to HTML // to make sure the html renderer is actually used $document = JFactory::getDocument(); $previoustype = $document->getType(); $document->setType('html'); $msgrenderer = $document->loadRenderer('message'); $json['messages'] = $msgrenderer->render('Message'); $document->setType($previoustype); // WORKAROUND for broken (i.e. duplicate) content-disposition headers in Joomla 2.x: // We request everything in raw and here send the headers for JSON and return // the raw output in json format $document = JFactory::getDocument(); $document->setMimeEncoding('application/json'); JResponse::setHeader('Content-Disposition', 'attachment;filename="ordernumber.json"'); $output = json_encode($json); }
public function getOrderDetails() { $orderModel = VmModel::getModel('orders'); $orderDetails = 0; // If the user is not logged in, we will check the order number and order pass if ($orderPass = vRequest::getString('order_pass', false) and $orderNumber = vRequest::getString('order_number', false)) { $orderId = $orderModel->getOrderIdByOrderPass($orderNumber, $orderPass); if (empty($orderId)) { vmDebug('Invalid order_number/password ' . vmText::_('COM_VIRTUEMART_RESTRICTED_ACCESS')); return 0; } $orderDetails = $orderModel->getOrder($orderId); } if ($orderDetails == 0) { $_currentUser = JFactory::getUser(); $cuid = $_currentUser->get('id'); // If the user is logged in, we will check if the order belongs to him $virtuemart_order_id = vRequest::getInt('virtuemart_order_id', 0); if (!$virtuemart_order_id) { $virtuemart_order_id = VirtueMartModelOrders::getOrderIdByOrderNumber(vRequest::getString('order_number')); } $orderDetails = $orderModel->getOrder($virtuemart_order_id); $user = JFactory::getUser(); if ($user->authorise('core.admin', 'com_virtuemart') or $user->authorise('core.manage', 'com_virtuemart')) { if (!empty($orderDetails['details']['BT']->virtuemart_user_id)) { if ($orderDetails['details']['BT']->virtuemart_user_id != $cuid) { echo 'view ' . vmText::_('COM_VIRTUEMART_RESTRICTED_ACCESS'); return; } } } } return $orderDetails; }
/** * @static * @param $price * @param string $toCurrency * @return float */ static function convertPrice($price, $cartPricesCurrency, $toCurrency = '') { if (!(is_int($toCurrency) or is_numeric($toCurrency)) && !empty($toCurrency)) { $toCurrency = ShopFunctions::getCurrencyIDByName($toCurrency); } if ($cartPricesCurrency == $toCurrency) { return $price; } $currencyToConvert = CurrencyDisplay::getInstance($toCurrency); // product prices or total in cart is always in vendor currency $priceInNewCurrency = round($currencyToConvert->convertCurrencyTo($toCurrency, $price, FALSE), 2); // set back the currency display $cd = CurrencyDisplay::getInstance($cartPricesCurrency); vmDebug('convertPrice', $price, $cartPricesCurrency, $toCurrency, $priceInNewCurrency); return $priceInNewCurrency; }