Exemple #1
0
 function editshop()
 {
     $user = JFactory::getUser();
     //the virtuemart_user_id var gets overriden in the edit function, when not set. So we must set it here
     vRequest::setVar('virtuemart_user_id', (int) $user->id);
     $this->edit();
 }
 /**
  * Install sample data into the database
  *
  * @author RickG
  */
 function checkForLatestVersion()
 {
     $model = $this->getModel('updatesMigration');
     vRequest::setVar('latestverison', $model->getLatestVersion());
     vRequest::setVar('view', 'updatesMigration');
     parent::display();
 }
 function __construct()
 {
     parent::__construct();
     if (VmConfig::get('shop_is_offline') == '1') {
         vRequest::setVar('layout', 'off_line');
     } else {
         vRequest::setVar('layout', 'default');
     }
 }
 /**
  * Generic edit task
  */
 function edit_review()
 {
     vRequest::setVar('controller', $this->_cname);
     vRequest::setVar('view', $this->_cname);
     vRequest::setVar('layout', 'edit_review');
     if (empty($view)) {
         $document = JFactory::getDocument();
         $viewType = $document->getType();
         $view = $this->getView($this->_cname, $viewType);
     }
     parent::display();
 }
Exemple #5
0
	/**
	 * Write the order header record
	 *
	 * @author Oscar van Eijk
	 * @param object $_cart The cart data
	 * @param object $_usr User object
	 * @param array $_prices Price data
	 * @return integer The new ordernumber
	 */
	private function _createOrder($_cart, $_usr)
	{
		//		TODO We need tablefields for the new values:
		//		Shipment:
		//		$_prices['shipmentValue']		w/out tax
		//		$_prices['shipmentTax']			Tax
		//		$_prices['salesPriceShipment']	Total
		//
		//		Payment:
		//		$_prices['paymentValue']		w/out tax
		//		$_prices['paymentTax']			Tax
		//		$_prices['paymentDiscount']		Discount
		//		$_prices['salesPricePayment']	Total

		$_orderData = new stdClass();

		$_orderData->virtuemart_order_id = null;
		$_orderData->virtuemart_user_id = $_usr->get('id');
		$_orderData->virtuemart_vendor_id = $_cart->vendorId;
		$_orderData->customer_number = $_cart->customer_number;
		$_prices = $_cart->cartPrices;
		//Note as long we do not have an extra table only storing addresses, the virtuemart_userinfo_id is not needed.
		//The virtuemart_userinfo_id is just the id of a stored address and is only necessary in the user maintance view or for choosing addresses.
		//the saved order should be an snapshot with plain data written in it.
		//		$_orderData->virtuemart_userinfo_id = 'TODO'; // $_cart['BT']['virtuemart_userinfo_id']; // TODO; Add it in the cart... but where is this used? Obsolete?
		$_orderData->order_total = $_prices['billTotal'];
		$_orderData->order_salesPrice = $_prices['salesPrice'];
		$_orderData->order_billTaxAmount = $_prices['billTaxAmount'];
		$_orderData->order_billDiscountAmount = $_prices['billDiscountAmount'];
		$_orderData->order_discountAmount = $_prices['discountAmount'];
		$_orderData->order_subtotal = $_prices['priceWithoutTax'];
		$_orderData->order_tax = $_prices['taxAmount'];
		$_orderData->order_shipment = $_prices['shipmentValue'];
		$_orderData->order_shipment_tax = $_prices['shipmentTax'];
		$_orderData->order_payment = $_prices['paymentValue'];
		$_orderData->order_payment_tax = $_prices['paymentTax'];

		if (!empty($_cart->cartData['VatTax'])) {
			$taxes = array();
			foreach($_cart->cartData['VatTax'] as $k=>$VatTax) {
				$taxes[$k]['virtuemart_calc_id'] = $k;
				$taxes[$k]['calc_name'] = $VatTax['calc_name'];
				$taxes[$k]['calc_value'] = $VatTax['calc_value'];
				$taxes[$k]['result'] = $VatTax['result'];
			}
			$_orderData->order_billTax = json_encode($taxes);
		}

		if (!empty($_cart->couponCode)) {
			$_orderData->coupon_code = $_cart->couponCode;
			$_orderData->coupon_discount = $_prices['salesPriceCoupon'];
		}
		$_orderData->order_discount = $_prices['discountAmount'];  // discount order_items


		$_orderData->order_status = 'P';
		$_orderData->order_currency = $this->getVendorCurrencyId($_orderData->virtuemart_vendor_id);
		if (!class_exists('CurrencyDisplay')) {
			require(VMPATH_ADMIN . '/helpers/currencydisplay.php');
		}
		if (isset($_cart->pricesCurrency)) {
			$_orderData->user_currency_id = $_cart->paymentCurrency ;//$this->getCurrencyIsoCode($_cart->pricesCurrency);
			$currency = CurrencyDisplay::getInstance($_orderData->user_currency_id);
			if($_orderData->user_currency_id != $_orderData->order_currency){
				$_orderData->user_currency_rate =   $currency->convertCurrencyTo($_orderData->user_currency_id ,1.0,false);
			} else {
				$_orderData->user_currency_rate=1.0;
			}
		}

		$_orderData->virtuemart_paymentmethod_id = $_cart->virtuemart_paymentmethod_id;
		$_orderData->virtuemart_shipmentmethod_id = $_cart->virtuemart_shipmentmethod_id;

		//Some payment plugins need a new order_number for any try
		$_orderData->order_number = '';
		$_orderData->order_pass = '';

		$_orderData->order_language = $_cart->order_language;
		$_orderData->ip_address = $_SERVER['REMOTE_ADDR'];

		$maskIP = VmConfig::get('maskIP','last');
		if($maskIP=='last'){
			$rpos = strrpos($_orderData->ip_address,'.');
			$_orderData->ip_address = substr($_orderData->ip_address,0,($rpos+1)).'xx';
		}

		if($_cart->_inConfirm){
			$order = false;
			$db = JFactory::getDbo();
			$q = 'SELECT * FROM `#__virtuemart_orders` ';
			if(!empty($_cart->virtuemart_order_id)){
				$db->setQuery($q . ' WHERE `order_number`= "'.$_cart->virtuemart_order_id.'" AND `order_status` = "P" ');
				$order = $db->loadAssoc();
				if(!$order){
					vmdebug('This should not happen, there is a cart with order_number, but not order stored '.$_cart->virtuemart_order_id);
				}
			}

			if(VmConfig::get('reuseorders',true) and !$order){
				$jnow = JFactory::getDate();
				$jnow->sub(new DateInterval('PT1H'));
				$minushour = $jnow->toSQL();
				$q .= ' WHERE `customer_number`= "'.$_orderData->customer_number.'" ';
				$q .= '	AND `order_status` = "P"
				AND `created_on` > "'.$minushour.'" ';
				$db->setQuery($q);
				$order = $db->loadAssoc();
			}

			if($order){
				if(!empty($order['virtuemart_order_id'])){
					$_orderData->virtuemart_order_id = $order['virtuemart_order_id'];
				}

				//Dirty hack
				$this->removeOrderItems($order['virtuemart_order_id']);
			}
		}

		JPluginHelper::importPlugin('vmshopper');
		$dispatcher = JDispatcher::getInstance();
		$plg_datas = $dispatcher->trigger('plgVmOnUserOrder',array(&$_orderData));
		foreach($plg_datas as $plg_data){
			// 				$data = array_merge($plg_data,$data);
		}
		if(empty($_orderData->order_number)){
			$_orderData->order_number = $this->generateOrderNumber($_usr->get('id'),4,$_orderData->virtuemart_vendor_id);
		}
		if(empty($_orderData->order_pass)){
			$_orderData->order_pass = '******'.substr( md5((string)time().rand(1,1000).$_orderData->order_number ), 0, 5);
		}

		$orderTable =  $this->getTable('orders');
		$orderTable -> bindChecknStore($_orderData);

		$db = JFactory::getDBO();

		if (!empty($_cart->couponCode)) {
			//set the virtuemart_order_id in the Request for 3rd party coupon components (by Seyi and Max)
			vRequest::setVar ( 'virtuemart_order_id', $orderTable->virtuemart_order_id );
			// If a gift coupon was used, remove it now
			CouponHelper::setInUseCoupon($_cart->couponCode, true);
		}
		// the order number is saved into the session to make sure that the correct cart is emptied with the payment notification
		$_cart->order_number = $orderTable->order_number;
		$_cart->virtuemart_order_id = $orderTable->virtuemart_order_id;
		$_cart->setCartIntoSession ();

		return $orderTable->virtuemart_order_id;
	}
Exemple #6
0
 public function portMedia()
 {
     $ok = true;
     vRequest::setVar('synchronise', true);
     //Prevents search field from interfering with syncronization
     vRequest::setVar('searchMedia', '');
     //$imageExtensions = array('jpg','jpeg','gif','png');
     if (!class_exists('VirtueMartModelMedia')) {
         require VMPATH_ADMIN . DS . 'models' . DS . 'media.php';
     }
     $this->mediaModel = VmModel::getModel('Media');
     //First lets read which files are already stored
     $this->storedMedias = $this->mediaModel->getFiles(false, true);
     //check for entries without file
     foreach ($this->storedMedias as $media) {
         if ($media->file_is_forSale != 1) {
             $media_path = VMPATH_ROOT . DS . str_replace('/', DS, $media->file_url);
         } else {
             $media_path = $media->file_url;
         }
         if (!file_exists($media_path)) {
             vmInfo('File for ' . $media_path . ' is missing');
             //The idea is here to test if the media with missing data is used somewhere and to display it
             //When it not used, the entry should be deleted then.
             /*				$q = 'SELECT * FROM `#__virtuemart_category_medias` as cm,
             				`#__virtuemart_product_medias` as pm,
             				`#__virtuemart_manufacturer_medias` as mm,
             				`#__virtuemart_vendor_medias` as vm
             				WHERE cm.`virtuemart_media_id` = "'.$media->virtuemart_media_id.'"
             				OR pm.`virtuemart_media_id` = "'.$media->virtuemart_media_id.'"
             				OR mm.`virtuemart_media_id` = "'.$media->virtuemart_media_id.'"
             				OR vm.`virtuemart_media_id` = "'.$media->virtuemart_media_id.'" ';
             
             				$this->_db->setQuery($q);
             				$res = $this->_db->loadColumn();
             				vmdebug('so',$res);
             				if(count($res)>0){
             				vmInfo('File for '.$media->file_url.' is missing, but used ');
             				}
             				*/
         }
     }
     $countTotal = 0;
     //We do it per type
     $url = VmConfig::get('media_product_path');
     $type = 'product';
     $count = $this->_portMediaByType($url, $type);
     $countTotal += $count;
     $this->_app->enqueueMessage(vmText::sprintf('COM_VIRTUEMART_UPDATE_PORT_MEDIA_RESULT', $count, $type, $url));
     if (microtime(true) - $this->starttime >= $this->maxScriptTime) {
         return $msg = vmText::sprintf('COM_VIRTUEMART_UPDATE_PORT_MEDIA_RESULT_NOT_FINISH', $countTotal);
     }
     $url = VmConfig::get('media_category_path');
     $type = 'category';
     $count = $this->_portMediaByType($url, $type);
     $countTotal += $count;
     $this->_app->enqueueMessage(vmText::sprintf('COM_VIRTUEMART_UPDATE_PORT_MEDIA_RESULT', $count, $type, $url));
     if (microtime(true) - $this->starttime >= $this->maxScriptTime) {
         return $msg = vmText::sprintf('COM_VIRTUEMART_UPDATE_PORT_MEDIA_RESULT_NOT_FINISH', $countTotal);
     }
     $url = VmConfig::get('media_manufacturer_path');
     $type = 'manufacturer';
     $count = $this->_portMediaByType($url, $type);
     $countTotal += $count;
     $this->_app->enqueueMessage(vmText::sprintf('COM_VIRTUEMART_UPDATE_PORT_MEDIA_RESULT', $count, $type, $url));
     if (microtime(true) - $this->starttime >= $this->maxScriptTime) {
         return $msg = vmText::sprintf('COM_VIRTUEMART_UPDATE_PORT_MEDIA_RESULT_NOT_FINISH', $countTotal);
     }
     $url = VmConfig::get('media_vendor_path');
     $type = 'vendor';
     $count = $this->_portMediaByType($url, $type);
     $countTotal += $count;
     $this->_app->enqueueMessage(vmText::sprintf('COM_VIRTUEMART_UPDATE_PORT_MEDIA_RESULT', $count, $type, $url));
     $url = VmConfig::get('forSale_path');
     $type = 'forSale';
     $count = $this->_portMediaByType($url, $type);
     $countTotal += $count;
     $this->_app->enqueueMessage(vmText::sprintf('COM_VIRTUEMART_UPDATE_PORT_MEDIA_RESULT', $count, $type, $url));
     return $msg = vmText::sprintf('COM_VIRTUEMART_UPDATE_PORT_MEDIA_RESULT_FINISH', $countTotal);
 }
Exemple #7
0
 /**
  * @param $cart
  * @param $order
  * @return bool
  */
 function confirmedOrder($cart, $order)
 {
     if (!class_exists('VirtueMartModelOrders')) {
         require VMPATH_ADMIN . DS . 'models' . DS . 'orders.php';
     }
     if (!class_exists('VirtueMartModelCurrency')) {
         require VMPATH_ADMIN . DS . 'models' . DS . 'currency.php';
     }
     $this->plugin->getPaymentCurrency($this->_method);
     $q = 'SELECT `currency_numeric_code` FROM `#__virtuemart_currencies` WHERE `virtuemart_currency_id`="' . $this->_method->payment_currency . '" ';
     $db = JFactory::getDBO();
     $db->setQuery($q);
     $currency_numeric_code = $db->loadResult();
     $totalInPaymentCurrency = vmPSPlugin::getAmountInCurrency($order['details']['BT']->order_total, $this->_method->payment_currency);
     $orderTotalVendorCurrency = $order['details']['BT']->order_total;
     $pbxOrderTotalInPaymentCurrency = $this->getPbxAmount($totalInPaymentCurrency['value']);
     $email_currency = $this->plugin->getEmailCurrency($this->_method);
     // If the file is not there anylonger, just create it
     //$this->plugin->createRootFile($this->_method->virtuemart_paymentmethod_id);
     if (!$this->getPayboxServerUrl()) {
         $this->redirectToCart();
         return false;
     }
     if (!($payboxReturnUrls = $this->getPayboxReturnUrls())) {
         $this->redirectToCart();
         return false;
     }
     $post_variables = array("PBX_SITE" => $this->_method->site_id, "PBX_RANG" => $this->_method->rang, "PBX_IDENTIFIANT" => $this->_method->identifiant, "PBX_TOTAL" => $this->getPbxTotal($pbxOrderTotalInPaymentCurrency), "PBX_DEVISE" => $currency_numeric_code, "PBX_CMD" => $order['details']['BT']->order_number, "PBX_PORTEUR" => $order['details']['BT']->email, "PBX_RETOUR" => $this->getReturn(), "PBX_HASH" => $this->getHashAlgo(), "PBX_TIME" => $this->getTime(), "PBX_LANGUE" => $this->getLangue(), "PBX_EFFECTUE" => $payboxReturnUrls['url_effectue'], "PBX_ANNULE" => $payboxReturnUrls['url_annule'], "PBX_REFUSE" => $payboxReturnUrls['url_refuse'], "PBX_ERREUR" => $payboxReturnUrls['url_erreur'], "PBX_REPONDRE_A" => $payboxReturnUrls['url_notification'], "PBX_RUF1" => 'POST');
     if ($this->_method->debit_type == 'authorization_only') {
         $post_variables["PBX_DIFF"] = str_pad($this->_method->diff, 2, '0', STR_PAD_LEFT);
     }
     // min_amount_3dsecure is in vendor currency
     if (!$this->isActivate3ds($orderTotalVendorCurrency)) {
         $post_variables["PBX_3DS"] = 'N';
     }
     jimport('joomla.environment.browser');
     $browser = JBrowser::getInstance();
     if ($browser->isMobile()) {
         $post_variables["PBX_SOURCE"] = 'XHTML';
     }
     $subscribe = array();
     $recurring = array();
     $post_variables["PBX_CMD"] = $order['details']['BT']->order_number;
     if ($this->_method->integration == "recurring" and $orderTotalVendorCurrency > $this->_method->recurring_min_amount) {
         $recurring = $this->getRecurringPayments($pbxOrderTotalInPaymentCurrency);
         // PBX_TOTAL will be replaced in the array_merge.
         $post_variables = array_merge($post_variables, $recurring);
     } else {
         if ($this->_method->integration == "subscribe") {
             $subscribe_data = $this->getSubscribePayments($cart, $this->getPbxAmount($orderTotalVendorCurrency));
             if ($subscribe_data) {
                 // PBX_TOTAL is the order total in this case
                 $post_variables["PBX_TOTAL"] = $subscribe_data["PBX_TOTAL"];
                 $post_variables["PBX_CMD"] .= $subscribe_data['PBX_CMD'];
             }
         }
     }
     $post_variables["PBX_HMAC"] = $this->getHmac($post_variables, $this->_method->key);
     // Prepare data that should be stored in the database
     $dbValues['order_number'] = $order['details']['BT']->order_number;
     $dbValues['virtuemart_order_id'] = $order['details']['BT']->virtuemart_order_id;
     $dbValues['payment_name'] = $this->plugin->renderPluginName($this->_method);
     $dbValues['virtuemart_paymentmethod_id'] = $cart->virtuemart_paymentmethod_id;
     $dbValues['paybox_custom'] = $this->getContext();
     $dbValues['cost_per_transaction'] = $this->_method->cost_per_transaction;
     $dbValues['cost_percent_total'] = $this->_method->cost_percent_total;
     $dbValues['payment_currency'] = $this->_method->payment_currency;
     $dbValues['email_currency'] = $email_currency;
     $dbValues['payment_order_total'] = $post_variables["PBX_TOTAL"];
     if (!empty($recurring)) {
         $dbValues['recurring'] = json_encode($recurring);
         $dbValues['recurring_number'] = $this->_method->recurring_number;
         $dbValues['recurring_periodicity'] = $this->_method->recurring_periodicity;
     } else {
         $dbValues['recurring'] = NULL;
     }
     if (!empty($subscribe)) {
         $dbValues['subscribe'] = json_encode($subscribe);
         //$dbValues['recurring_number'] = $this->_method->recurring_number;
         //$dbValues['recurring_periodicity'] = $this->_method->recurring_periodicity;
     } else {
         $dbValues['subscribe'] = NULL;
     }
     $dbValues['tax_id'] = $this->_method->tax_id;
     $this->plugin->storePSPluginInternalData($dbValues);
     $html = $this->getConfirmedHtml($post_variables, $this);
     // 	2 = don't delete the cart, don't send email and don't redirect
     $cart->_confirmDone = FALSE;
     $cart->_dataValidated = FALSE;
     $cart->setCartIntoSession();
     vRequest::setVar('display_title', false);
     vRequest::setVar('html', $html);
     return;
 }
 function plgVmConfirmedOrder($cart, $order, $payment_method = '')
 {
     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->logInfo('plgVmConfirmedOrder order number: ' . $order['details']['BT']->order_number, 'message');
     if (!class_exists('VirtueMartModelOrders')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php';
     }
     if (!class_exists('VirtueMartModelCurrency')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'currency.php';
     }
     $usrBT = $order['details']['BT'];
     $address = isset($order['details']['ST']) ? $order['details']['ST'] : $order['details']['BT'];
     if (!class_exists('TableVendors')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'tables' . DS . 'vendors.php';
     }
     $vendorModel = VmModel::getModel('Vendor');
     $vendorModel->setId(1);
     $vendor = $vendorModel->getVendor();
     $vendorModel->addImages($vendor, 1);
     $this->getPaymentCurrency($method);
     $q = 'SELECT `currency_code_3` FROM `#__virtuemart_currencies` WHERE `virtuemart_currency_id`="' . $method->payment_currency . '" ';
     $db = JFactory::getDBO();
     $db->setQuery($q);
     $currency_code_3 = $db->loadResult();
     $totalInPaymentCurrency = vmPSPlugin::getAmountInCurrency($order['details']['BT']->order_total, $method->payment_currency);
     $cartCurrency = CurrencyDisplay::getInstance($cart->pricesCurrency);
     if ($totalInPaymentCurrency['value'] <= 0) {
         vmInfo(vmText::_('VMPAYMENT_MONEYBOOKERS_PAYMENT_AMOUNT_INCORRECT'));
         return FALSE;
     }
     $merchant_email = $method->pay_to_email;
     if (empty($merchant_email)) {
         vmInfo(vmText::_('VMPAYMENT_MONEYBOOKERS_MERCHANT_EMAIL_NOT_SET'));
         return FALSE;
     }
     $lang = JFactory::getLanguage();
     $tag = substr($lang->get('tag'), 0, 2);
     $post_variables = array('pay_to_email' => $merchant_email, 'pay_from_email' => $address->email, 'payment_methods' => $payment_method, 'recipient_description' => $vendorModel->getVendorName(), 'transaction_id' => $order['details']['BT']->order_number, 'return_url' => JURI::root() . 'index.php?option=com_virtuemart&view=pluginresponse&task=pluginresponsereceived&on=' . $order['details']['BT']->order_number . '&pm=' . $order['details']['BT']->virtuemart_paymentmethod_id . '&Itemid=' . vRequest::getInt('Itemid') . '&lang=' . vRequest::getCmd('lang', ''), 'cancel_url' => JURI::root() . 'index.php?option=com_virtuemart&view=pluginresponse&task=pluginUserPaymentCancel&on=' . $order['details']['BT']->order_number . '&pm=' . $order['details']['BT']->virtuemart_paymentmethod_id . '&Itemid=' . vRequest::getInt('Itemid') . '&lang=' . vRequest::getCmd('lang', ''), 'status_url' => JURI::root() . 'index.php?option=com_virtuemart&view=pluginresponse&task=pluginnotification&tmpl=component&lang=' . vRequest::getCmd('lang', ''), 'platform' => '21477272', 'hide_login' => $method->hide_login, 'prepare_only' => 1, 'logo_url' => $method->logourl, 'language' => strtoupper($tag), "firstname" => $address->first_name, "lastname" => $address->last_name, "address" => $address->address_1, "address2" => isset($address->address_2) ? $address->address_2 : '', "phone_number" => $address->phone_1, "postal_code" => $address->zip, "city" => $address->city, "state" => isset($address->virtuemart_state_id) ? ShopFunctions::getStateByID($address->virtuemart_state_id, 'state_2_code') : '', "country" => ShopFunctions::getCountryByID($address->virtuemart_country_id, 'country_3_code'), 'amount' => $totalInPaymentCurrency['value'], 'currency' => $currency_code_3, 'detail1_description' => vmText::_('VMPAYMENT_MONEYBOOKERS_ORDER_NUMBER') . ': ', 'detail1_text' => $order['details']['BT']->order_number);
     // Prepare data that should be stored in the database
     $dbValues['user_session'] = $return_context;
     $dbValues['order_number'] = $order['details']['BT']->order_number;
     $dbValues['payment_name'] = $this->renderPluginName($method, $order);
     $dbValues['virtuemart_paymentmethod_id'] = $cart->virtuemart_paymentmethod_id;
     $dbValues['cost_per_transaction'] = $method->cost_per_transaction;
     $dbValues['cost_percent_total'] = $method->cost_percent_total;
     $dbValues['payment_currency'] = $method->payment_currency;
     $dbValues['payment_order_total'] = $totalInPaymentCurrency['value'];
     $dbValues['tax_id'] = $method->tax_id;
     $this->storePSPluginInternalData($dbValues);
     $content = http_build_query($post_variables);
     $url = $this->_getMoneybookersURL($method);
     $header = "POST /app/payment.pl HTTP/1.1\r\n";
     $header .= "Host: {$url}\r\n";
     $header .= "Content-Type: application/x-www-form-urlencoded\r\n";
     $header .= "Content-Length: " . strlen($content) . "\r\n\r\n";
     $fps = fsockopen('ssl://' . $url, 443, $errno, $errstr, 10);
     // timeout applies only to connecting not for I/O
     $sid = '';
     if (!$fps || !stream_set_blocking($fps, 0)) {
         $this->sendEmailToVendorAndAdmins("Error with Moneybookers: ", vmText::sprintf('VMPAYMENT_MONEYBOOKERS_ERROR_POSTING_IPN', $errstr, $errno));
         $this->logInfo('Process IPN ' . vmText::sprintf('VMPAYMENT_MONEYBOOKERS_ERROR_POSTING_IPN', $errstr, $errno), 'message');
         vmInfo(vmText::_('VMPAYMENT_MONEYBOOKERS_DISPLAY_GWERROR'));
         return NULL;
     } else {
         fwrite($fps, $header);
         fwrite($fps, $content);
         stream_set_timeout($fps, 10);
         $read = array($fps);
         $write = $except = NULL;
         $msg = $rbuff = '';
         if (stream_select($read, $write, $except, 10)) {
             $rbuff = fread($fps, 2048);
             $msg .= $rbuff;
         }
         $response = $this->_parse_response($msg);
         if (!count($response)) {
             $this->logInfo('Process IPN (empty or bad response) ' . $msg, 'message');
             vmInfo(vmText::_('VMPAYMENT_MONEYBOOKERS_DISPLAY_GWERROR'));
             return NULL;
         }
         $sid = $response[0];
         $this->logInfo($response[0], 'message');
     }
     fclose($fps);
     $height = $method->hide_login ? 720 : 500;
     $html = '<html><head><title></title><script type="text/javascript">
             jQuery(document).ready(function () {
                 jQuery(\'#main h3\').css("display", "none");
             });
             </script></head><body>';
     $html .= '<iframe src="https://' . $this->_getMoneybookersURL($method) . '/app/payment.pl?sid=' . $sid . '" scrolling="yes" style="x-overflow: none;"
             frameborder="0" height="' . (string) $height . 'px" width="650px"></iframe>';
     $cart->_confirmDone = FALSE;
     $cart->_dataValidated = FALSE;
     $cart->setCartIntoSession();
     vRequest::setVar('html', $html);
 }
 public function processConfirmedOrderPaymentResponse($returnValue, $cart, $order, $html, $payment_name, $new_status = '')
 {
     if ($returnValue == 1) {
         //We delete the old stuff
         // send the email only if payment has been accepted
         // update status
         $modelOrder = VmModel::getModel('orders');
         $order['order_status'] = $new_status;
         $order['customer_notified'] = 1;
         $order['comments'] = '';
         $modelOrder->updateStatusForOneOrder($order['details']['BT']->virtuemart_order_id, $order, TRUE);
         $order['paymentName'] = $payment_name;
         //if(!class_exists('shopFunctionsF')) require(VMPATH_SITE.DS.'helpers'.DS.'shopfunctionsf.php');
         //shopFunctionsF::sentOrderConfirmedEmail($order);
         //We delete the old stuff
         $cart->emptyCart();
         vRequest::setVar('html', $html);
         // payment echos form, but cart should not be emptied, data is valid
     } elseif ($returnValue == 2) {
         $cart->_confirmDone = false;
         $cart->_dataValidated = false;
         $cart->_inConfirm = false;
         $cart->setCartIntoSession(false, true);
         vRequest::setVar('html', $html);
     } elseif ($returnValue == 0) {
         // error while processing the payment
         $mainframe = JFactory::getApplication();
         $mainframe->enqueueMessage($html);
         $mainframe->redirect(JRoute::_('index.php?option=com_virtuemart&view=cart', FALSE), vmText::_('COM_VIRTUEMART_CART_ORDERDONE_DATA_NOT_VALID'));
     }
 }
Exemple #10
0
 function display($tpl = null)
 {
     // Get the task
     $task = vRequest::getCmd('task', $this->getLayout());
     $this->assignRef('task', $task);
     // Load helpers
     if (!class_exists('CurrencyDisplay')) {
         require VMPATH_ADMIN . DS . 'helpers' . DS . 'currencydisplay.php';
     }
     if (!class_exists('VmHTML')) {
         require VMPATH_ADMIN . DS . 'helpers' . DS . 'html.php';
     }
     if (!class_exists('VmImage')) {
         require VMPATH_ADMIN . DS . 'helpers' . DS . 'image.php';
     }
     $model = tmsModel::getModel();
     // Handle any publish/unpublish
     switch ($task) {
         case 'add':
         case 'edit':
             //this was in the controller for the edit tasks, we need this for the access by FE
             //$this->addTemplatePath(JPATH_COMPONENT_ADMINISTRATOR.DS.'views'.DS.'product'.DS.'tmpl');
             tsmConfig::loadJLang('com_tsmart_orders', TRUE);
             tsmConfig::loadJLang('com_tsmart_shoppers', TRUE);
             $model_country = tmsModel::getModel('country');
             $this->countries = $model_country->getItemList();
             $tsmart_product_id = vRequest::getInt('tsmart_product_id');
             if (is_array($tsmart_product_id) && count($tsmart_product_id) > 0) {
                 $tsmart_product_id = (int) $tsmart_product_id[0];
             } else {
                 $tsmart_product_id = (int) $tsmart_product_id;
             }
             $product = $model->getItem($tsmart_product_id);
             require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmserviceclass.php';
             $product->tsmart_service_class_ids = tsmserviceclass::get_list_service_class_ids_by_tour_id($tsmart_product_id);
             require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmgroupsize.php';
             $product->tsmart_group_size_ids = tsmGroupSize::get_list_group_size_ids_by_tour_id($tsmart_product_id);
             //$user = JFactory::getUser();
             $superVendor = vmAccess::isSuperVendor();
             if ($superVendor != 1 and $superVendor != $product->tsmart_vendor_id) {
                 vmdebug('Product view.html.php ' . $superVendor, $product->tsmart_vendor_id);
                 JFactory::getApplication()->redirect('index.php?option=com_tsmart&view=tsmart', tsmText::_('com_tsmart_ALERTNOTAUTHOR'), 'error');
             }
             if (!empty($product->product_parent_id)) {
                 $product_parent = $model->getProductSingle($product->product_parent_id, false);
             }
             require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmserviceclass.php';
             $this->tour_service_class = tsmserviceclass::get_list_tour_service_class();
             $customfields = tmsModel::getModel('Customfields');
             $product->allIds[] = $product->tsmart_product_id;
             if (!empty($product->product_parent_id)) {
                 $product->allIds[] = $product->product_parent_id;
             }
             $product->customfields = $customfields->getCustomEmbeddedProductCustomFields($product->allIds);
             // Get the category tree
             if (isset($product->categories)) {
                 $this->category_tree = ShopFunctions::categoryListTree($product->categories);
             } else {
                 $this->category_tree = ShopFunctions::categoryListTree();
             }
             //Fallback for categories inherited by parent to correctly calculate the prices
             if (empty($product->categories) and !empty($product_parent->categories)) {
                 $product->categories = $product_parent->categories;
             }
             //Get the shoppergoup list - Cleanshooter Custom Shopper Visibility
             if (!isset($product->shoppergroups)) {
                 $product->shoppergroups = 0;
             }
             $this->shoppergroupList = ShopFunctions::renderShopperGroupList($product->shoppergroups);
             // Load the product price
             if (!class_exists('calculationHelper')) {
                 require VMPATH_ADMIN . DS . 'helpers' . DS . 'calculationh.php';
             }
             //Do we need the children? If there is a C customfield, we dont want them
             $isCustomVariant = false;
             foreach ($product->customfields as $custom) {
                 if ($custom->field_type == 'C' and $custom->tsmart_product_id == $tsmart_product_id) {
                     $isCustomVariant = true;
                     break;
                 }
             }
             if (!class_exists('tsmartModelConfig')) {
                 require VMPATH_ADMIN . '/models/config.php';
             }
             $productLayouts = tsmartModelConfig::getLayoutList('productdetails');
             $this->productLayouts = $productLayouts;
             // Load Images
             $model->addImages($product);
             if (!class_exists('VmTemplate')) {
                 require VMPATH_SITE . DS . 'helpers' . DS . 'vmtemplate.php';
             }
             $vmtemplate = VmTemplate::loadVmTemplateStyle();
             $this->imagePath = shopFunctions::getAvailabilityIconUrl($vmtemplate);
             // Load the vendors
             $vendor_model = tmsModel::getModel('vendor');
             $lists['vendors'] = '';
             if ($this->showVendors()) {
                 $lists['vendors'] = Shopfunctions::renderVendorList($product->tsmart_vendor_id);
             }
             // Load the currencies
             $currency_model = tmsModel::getModel('currency');
             $vendor_model->setId(vmAccess::isSuperVendor());
             $this->vendor = $vendor_model->getVendor();
             $currency = $currency_model->getItemList();
             $this->vendor_currency_symb = $currency->currency_symbol;
             $lists['manufacturers'] = shopFunctions::renderManufacturerList($product->tsmart_manufacturer_id, true);
             if (!empty($product->product_weight_uom)) {
                 $product_weight_uom = $product->product_weight_uom;
             } else {
                 if (!empty($product_parent)) {
                     $product_weight_uom = $product_parent->product_weight_uom;
                 } else {
                     $product_weight_uom = tsmConfig::get('weight_unit_default');
                 }
             }
             if (!empty($product->product_lwh_uom)) {
                 $product_lwh_uom = $product->product_lwh_uom;
             } else {
                 if (!empty($product_parent)) {
                     $product_lwh_uom = $product_parent->product_lwh_uom;
                 } else {
                     $product_lwh_uom = tsmConfig::get('lwh_unit_default');
                 }
             }
             if (!empty($product->product_unit)) {
                 $product_unit = $product->product_unit;
             } else {
                 if (!empty($product_parent)) {
                     $product_unit = $product_parent->product_unit;
                 } else {
                     $product_unit = tsmConfig::get('product_unit_default', 'KG');
                 }
             }
             $lists['product_weight_uom'] = ShopFunctions::renderWeightUnitList('product_weight_uom', $product_weight_uom);
             $lists['product_iso_uom'] = ShopFunctions::renderUnitIsoList('product_unit', $product_unit);
             $lists['product_lwh_uom'] = ShopFunctions::renderLWHUnitList('product_lwh_uom', $product_lwh_uom);
             if (empty($product->product_available_date)) {
                 $product->product_available_date = date("Y-m-d");
             }
             $waitinglistmodel = tmsModel::getModel('waitinglist');
             /* Load waiting list */
             if ($product->tsmart_product_id) {
                 //$waitinglist = $this->get('waitingusers', 'waitinglist');
                 $waitinglist = $waitinglistmodel->getWaitingusers($product->tsmart_product_id);
                 $this->assignRef('waitinglist', $waitinglist);
             }
             $orderstatusModel = tmsModel::getModel('orderstatus');
             $lists['OrderStatus'] = $orderstatusModel->renderOSList(array(), 'order_status', TRUE);
             // Add the tsmart_shoppergroup_ids
             $cid = JFactory::getUser()->id;
             $this->activeShoppergroups = shopfunctions::renderGuiList($cid, 'shoppergroups', 'shopper_group_name', 'category', 'vmuser_shoppergroups', 'tsmart_user_id');
             if (!empty($this->activeShoppergroups)) {
                 $shoppergroupModel = tmsModel::getModel('shoppergroup');
                 $this->activeShoppergroups = tsmText::_($shoppergroupModel->getDefault(0)->shopper_group_name);
             }
             // Load protocustom lists
             $customModel = tmsModel::getModel('custom');
             $this->fieldTypes = tsmartModelCustom::getCustomTypes();
             $customsList = $customModel->getCustomsList();
             $attribs = 'style= "width: 300px;"';
             $customlist = JHtml::_('select.genericlist', $customsList, 'customlist', $attribs, 'value', 'text', null, false, true);
             $this->assignRef('customsList', $customlist);
             if ($product->product_parent_id > 0) {
                 // Set up labels
                 $info_label = tsmText::_('com_tsmart_PRODUCT_FORM_ITEM_INFO_LBL');
                 $status_label = tsmText::_('com_tsmart_PRODUCT_FORM_ITEM_STATUS_LBL');
                 $dim_weight_label = tsmText::_('com_tsmart_PRODUCT_FORM_ITEM_DIM_WEIGHT_LBL');
                 $images_label = tsmText::_('com_tsmart_PRODUCT_FORM_ITEM_IMAGES_LBL');
                 $delete_message = tsmText::_('com_tsmart_PRODUCT_FORM_DELETE_ITEM_MSG');
             } else {
                 if ($task == 'add') {
                     $action = tsmText::_('com_tsmart_PRODUCT_FORM_NEW_PRODUCT_LBL');
                 } else {
                     $action = tsmText::_('com_tsmart_PRODUCT_FORM_UPDATE_ITEM_LBL');
                 }
                 $info_label = tsmText::_('com_tsmart_PRODUCT_FORM_PRODUCT_INFO_LBL');
                 $status_label = tsmText::_('com_tsmart_PRODUCT_FORM_PRODUCT_STATUS_LBL');
                 $dim_weight_label = tsmText::_('com_tsmart_PRODUCT_FORM_PRODUCT_DIM_WEIGHT_LBL');
                 $images_label = tsmText::_('com_tsmart_PRODUCT_FORM_PRODUCT_IMAGES_LBL');
                 $delete_message = tsmText::_('com_tsmart_PRODUCT_FORM_DELETE_PRODUCT_MSG');
             }
             //get countries
             require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmcountries.php';
             $countries = tsmcountries::get_countries();
             $this->assignRef('countries', $countries);
             //end get countries
             //get cities
             require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/vmcities.php';
             $cities = tsmcities::get_cities();
             $this->assignRef('cities', $cities);
             //end get cities
             //get tour style
             require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmtourstyle.php';
             $list_tour_style = tsmtourstyle::get_list_tour_style();
             $this->assignRef('list_tour_style', $list_tour_style);
             //end get toursyle
             //get tour section
             require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmtoursection.php';
             $list_tour_section = tsmtoursection::get_list_tour_section();
             $this->assignRef('list_tour_section', $list_tour_section);
             //end get toursyle
             //get tour physicalgrade
             require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmphysicalgrade.php';
             $list_physical_grade = vmphysicalgrade::get_physical_grade();
             $this->assignRef('list_physical_grade', $list_physical_grade);
             //end get physicalgrade
             //get tour_type
             require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmtourtype.php';
             $list_tour_type = tsmtourtype::get_list_tour_type();
             $this->assignRef('list_tour_type', $list_tour_type);
             //end get tour_type
             //get tour_type
             require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmserviceclass.php';
             $list_tour_service_class = tsmserviceclass::get_list_tour_service_class();
             $product->list_tour_service_class_id = tsmserviceclass::get_list_service_class_ids_by_tour_id($product->tsmart_product_id);
             $this->assignRef('list_tour_service_class', $list_tour_service_class);
             //end get tour_type
             //get activities
             require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/vmactivities.php';
             $product->list_activity_id = tsmactivities::get_list_activity_id_by_tour_id($product->tsmart_product_id);
             $activities = tsmactivities::get_activities();
             $this->assignRef('activities', $activities);
             //end get activities
             //get list group size
             require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmgroupsize.php';
             $list_group_size = tsmGroupSize::get_list_group_size();
             $product->list_group_size_id = tsmGroupSize::get_list_group_size_ids_by_tour_id($product->tsmart_product_id);
             $this->assignRef('list_group_size', $list_group_size);
             //end get list group size
             //get list country
             require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmcountries.php';
             $product->list_tsmart_country_id = tsmcountries::get_list_tsmart_country_id_by_tour_id($product->tsmart_product_id);
             //end get list group size
             require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmprice.php';
             $this->list_price_type = vmprice::get_list_price_type();
             require_once JPATH_ROOT . '/administrator/components/com_tsmart/helpers/tsmproduct.php';
             $this->list_tour_method = vmproduct::get_list_tour_method();
             $this->assignRef('product', $product);
             $this->assignRef('product_parent', $product_parent);
             /* Assign label values */
             $this->assignRef('action', $action);
             $this->assignRef('info_label', $info_label);
             $this->assignRef('status_label', $status_label);
             $this->assignRef('dim_weight_label', $dim_weight_label);
             $this->assignRef('images_label', $images_label);
             $this->assignRef('delete_message', $delete_message);
             $this->assignRef('lists', $lists);
             // Toolbar
             if ($product->product_sku) {
                 $sku = ' (' . $product->product_sku . ')';
             } else {
                 $sku = "";
             }
             //if (!empty($product->canonCatLink)) $canonLink = '&tsmart_category_id=' . $product->canonCatLink; else $canonLink = '';
             if (!empty($product->tsmart_product_id)) {
                 if (!class_exists('shopFunctionsF')) {
                     require VMPATH_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php';
                 }
                 $menuItemID = shopFunctionsF::getMenuItemId(JFactory::getLanguage()->getTag());
                 $canonLink = '';
                 if ($product->canonCatId) {
                     $canonLink = '&tsmart_category_id=' . $product->canonCatId;
                 }
                 $text = '<a href="' . juri::root() . 'index.php?option=com_tsmart&view=productdetails&tsmart_product_id=' . $product->tsmart_product_id . $canonLink . '&Itemid=' . $menuItemID . '" target="_blank" >' . $product->product_name . $sku . '<span class="vm2-modallink"></span></a>';
                 if (JFactory::getApplication()->isSite()) {
                     $bar = JToolBar::getInstance('toolbar');
                     $bar->appendButton('Link', 'back', 'com_tsmart_LEAVE_TO_PRODUCT', juri::root() . 'index.php?option=com_tsmart&view=productdetails&tsmart_product_id=' . $product->tsmart_product_id . $canonLink . '&Itemid=' . $menuItemID);
                 }
             } else {
                 $text = $product->product_name . $sku;
             }
             $this->SetViewTitle('PRODUCT', $text);
             $this->addStandardEditViewCommandsNoValidate($product->tsmart_product_id);
             break;
         case 'massxref_cats':
         case 'massxref_cats_exe':
             $this->SetViewTitle('PRODUCT_MASSXREF');
             $showVendors = $this->showVendors();
             $this->assignRef('showVendors', $showVendors);
             $keyWord = '';
             $catmodel = tmsModel::getModel('category');
             $this->assignRef('catmodel', $catmodel);
             $this->addStandardDefaultViewCommandsNoValidate();
             $this->addStandardDefaultViewLists($catmodel, 'category_name');
             $session = JFactory::getSession();
             $reset = $session->get('reset_pag', false, 'vm');
             $limit = '';
             if ($reset) {
                 $limit = 0;
                 $session->set('reset_pag', false, 'vm');
             }
             $this->categories = $catmodel->getCategoryTree(0, 0, false, $this->lists['search'], $limit);
             $catpagination = $catmodel->getPagination();
             $this->assignRef('catpagination', $catpagination);
             $this->setLayout('massxref');
             JToolBarHelper::custom('massxref_cats_exe', 'new', 'new', tsmText::_('com_tsmart_PRODUCT_XREF_CAT_EXE'), false);
             break;
         case 'massxref_sgrps':
         case 'massxref_sgrps_exe':
             $sgrpmodel = tmsModel::getModel('shoppergroup');
             $this->addStandardDefaultViewLists($sgrpmodel);
             $shoppergroups = $sgrpmodel->getShopperGroups(false, true);
             $this->assignRef('shoppergroups', $shoppergroups);
             $sgrppagination = $sgrpmodel->getPagination();
             $this->assignRef('sgrppagination', $sgrppagination);
             $this->setLayout('massxref');
             JToolBarHelper::custom('massxref_sgrps_exe', 'new', 'new', tsmText::_('com_tsmart_PRODUCT_XREF_SGRPS_EXE'), false);
             break;
         default:
             if ($product_parent_id = vRequest::getInt('product_parent_id', false)) {
                 $product_parent = $model->getProductSingle($product_parent_id, false);
                 if ($product_parent) {
                     $title = 'PRODUCT_CHILDREN_LIST';
                     $link_to_parent = JHtml::_('link', JRoute::_('index.php?view=product&task=edit&tsmart_product_id=' . $product_parent->tsmart_product_id . '&option=com_tsmart'), $product_parent->product_name, array('title' => tsmText::_('com_tsmart_EDIT_PARENT') . ' ' . $product_parent->product_name));
                     $msg = tsmText::_('com_tsmart_PRODUCT_OF') . " " . $link_to_parent;
                 } else {
                     $title = 'PRODUCT_CHILDREN_LIST';
                     $msg = 'Parent with product_parent_id ' . $product_parent_id . ' not found';
                 }
             } else {
                 $title = 'PRODUCT';
                 $msg = "";
             }
             $this->SetViewTitle($title, $msg);
             $this->addStandardDefaultViewLists($model, 'created_on');
             if ($cI = vRequest::getInt('tsmart_category_id', false)) {
                 $app = JFactory::getApplication();
                 //$old_state = $app->getUserState('tsmart_category_id');
                 $old_state = $app->getUserState('tsmart_category_id');
                 if (empty($old_state) or $old_state != $cI) {
                     vRequest::setVar('com_tsmart.product.filter_order', 'pc.ordering');
                     $model->filter_order = 'pc.ordering';
                     $old_state = $app->setUserState('tsmart_category_id', $cI);
                 }
             }
             //Get the list of products
             $productlist = $model->getItemList();
             //The pagination must now always set AFTER the model load the listing
             $this->pagination = $model->getPagination();
             //Get the category tree
             $categoryId = $model->tsmart_category_id;
             //OSP switched to filter in model, was vRequest::getInt('tsmart_category_id');
             $category_tree = ShopFunctions::categoryListTree(array($categoryId));
             $this->assignRef('category_tree', $category_tree);
             //load service class
             //Load the product price
             if (!class_exists('calculationHelper')) {
                 require VMPATH_ADMIN . DS . 'helpers' . DS . 'calculationh.php';
             }
             $vendor_model = tmsModel::getModel('vendor');
             $productreviews = tmsModel::getModel('ratings');
             $this->mfTable = $model->getTable('manufacturers');
             $this->catTable = $model->getTable('categories');
             $this->lists['vendors'] = '';
             if ($this->showVendors()) {
                 $this->lists['vendors'] = Shopfunctions::renderVendorList(vmAccess::getVendorId());
             }
             foreach ($productlist as $tsmart_product_id => $product) {
                 $product->mediaitems = count($product->tsmart_media_id);
                 $product->reviews = $productreviews->countReviewsForProduct($product->tsmart_product_id);
                 $vendor_model->setId($product->tsmart_vendor_id);
                 $vendor = $vendor_model->getVendor();
                 $currencyDisplay = CurrencyDisplay::getInstance($vendor->vendor_currency, $vendor->tsmart_vendor_id);
                 if (!empty($product->allPrices[$product->selectedPrice]['product_price']) && !empty($product->allPrices[$product->selectedPrice]['product_currency'])) {
                     $product->product_price_display = $currencyDisplay->priceDisplay($product->allPrices[$product->selectedPrice]['product_price'], (int) $product->allPrices[$product->selectedPrice]['product_currency'], 1, true);
                 } else {
                     if (!empty($product->allPrices) and count($product->allPrices) > 1) {
                         $product->product_price_display = tsmText::_('com_tsmart_MULTIPLE_PRICES');
                     } else {
                         $product->product_price_display = tsmText::_('com_tsmart_NO_PRICE_SET');
                     }
                 }
                 // Write the first 5 categories in the list
                 $product->categoriesList = '';
                 if (!empty($product->categories[0])) {
                     $product->categoriesList = shopfunctions::renderGuiList($product->categories, 'categories', 'category_name', 'category');
                 }
                 // Write the first 5 manufacturers in the list
                 $product->manuList = '';
                 if (!empty($product->tsmart_manufacturer_id[0])) {
                     $product->manuList = shopfunctions::renderGuiList($product->tsmart_manufacturer_id, 'manufacturers', 'mf_name', 'manufacturer');
                 }
             }
             $mf_model = tmsModel::getModel('manufacturer');
             $manufacturers = $mf_model->getManufacturerDropdown();
             $this->assignRef('manufacturers', $manufacturers);
             /* add Search filter in lists*/
             /* Search type */
             $options = array('' => tsmText::_('com_tsmart_LIST_EMPTY_OPTION'), 'parent' => tsmText::_('com_tsmart_PRODUCT_LIST_SEARCH_BY_PARENT_PRODUCT'), 'product' => tsmText::_('com_tsmart_PRODUCT_LIST_SEARCH_BY_DATE_TYPE_PRODUCT'), 'price' => tsmText::_('com_tsmart_PRODUCT_LIST_SEARCH_BY_DATE_TYPE_PRICE'), 'withoutprice' => tsmText::_('com_tsmart_PRODUCT_LIST_SEARCH_BY_DATE_TYPE_WITHOUTPRICE'));
             $this->lists['search_type'] = VmHTML::selectList('search_type', vRequest::getVar('search_type'), $options);
             /* Search order */
             $options = array('bf' => tsmText::_('com_tsmart_PRODUCT_LIST_SEARCH_BY_DATE_BEFORE'), 'af' => tsmText::_('com_tsmart_PRODUCT_LIST_SEARCH_BY_DATE_AFTER'));
             $this->lists['search_order'] = VmHTML::selectList('search_order', vRequest::getVar('search_order'), $options);
             // Toolbar
             /*if (vmAccess::manager('product.edit')) {
                   JToolBarHelper::custom('massxref_cats', 'new', 'new', vmText::_('com_tsmart_PRODUCT_XREF_CAT'), true);
                   JToolBarHelper::custom('massxref_sgrps', 'new', 'new', vmText::_('com_tsmart_PRODUCT_XREF_SGRPS'), true);
               }
               if (vmAccess::manager('product.create')) {
                   JToolBarHelper::custom('createchild', 'new', 'new', vmText::_('com_tsmart_PRODUCT_CHILD'), true);
                   JToolBarHelper::custom('cloneproduct', 'copy', 'copy', vmText::_('com_tsmart_PRODUCT_CLONE'), true);
               }*/
             // JToolBarHelper::custom('addrating', 'default', '', vmText::_('com_tsmart_ADD_RATING'), true);
             $view = vRequest::getCmd('view', vRequest::getCmd('controller', 'tsmart'));
             JToolBarHelper::divider();
             if (vmAccess::manager($view . '.edit.state')) {
                 JToolBarHelper::publishList();
                 JToolBarHelper::unpublishList();
             }
             if (vmAccess::manager($view . '.delete')) {
                 JToolBarHelper::spacer('10');
                 JToolBarHelper::deleteList();
             }
             $this->assignRef('productlist', $productlist);
             $this->assignRef('tsmart_category_id', $categoryId);
             $this->assignRef('model', $model);
             break;
     }
     parent::display($tpl);
 }
Exemple #11
0
 public function plgVmOnPaymentResponseReceived(&$html)
 {
     if (!class_exists('VirtueMartCart')) {
         require JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php';
     }
     if (!class_exists('shopFunctionsF')) {
         require JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php';
     }
     if (!class_exists('VirtueMartModelOrders')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php';
     }
     VmConfig::loadJLang('com_virtuemart_orders', TRUE);
     // the payment itself should send the parameter needed.
     $virtuemart_paymentmethod_id = vRequest::getInt('pm', 0);
     $order_number = vRequest::getString('on', 0);
     if (!($this->_currentMethod = $this->getVmPluginMethod($virtuemart_paymentmethod_id))) {
         return NULL;
         // Another method was selected, do nothing
     }
     if (!$this->selectedThisElement($this->_currentMethod->payment_element)) {
         return NULL;
     }
     if (!($virtuemart_order_id = VirtueMartModelOrders::getOrderIdByOrderNumber($order_number))) {
         return NULL;
     }
     $payments = $this->getDatasByOrderId($virtuemart_order_id);
     VmConfig::loadJLang('com_virtuemart');
     $orderModel = VmModel::getModel('orders');
     $order = $orderModel->getOrder($virtuemart_order_id);
     $realexInterface = $this->_loadRealexInterface();
     $realexInterface->loadCustomerData();
     $realexInterface->setOrder($order);
     $html = $realexInterface->getResponseHTML($payments);
     $this->customerData->clear();
     $cart = VirtueMartCart::getCart();
     $cart->emptyCart();
     vRequest::setVar('display_title', false);
     vRequest::setVar('html', $html);
     return TRUE;
 }
 /**
  * Post-process method (e.g. footer HTML, redirect, etc)
  *
  * @param string Process type (i.e. install, uninstall, update)
  * @param object JInstallerComponent parent
  */
 public function postflight($type, $parent = null)
 {
     $_REQUEST['install'] = 0;
     if ($type != 'uninstall') {
         $this->loadVm();
         //fix joomla BE menu
         $model = VmModel::getModel('updatesmigration');
         // 				VmConfig::loadConfig(true);
         if (!class_exists('VirtueMartModelConfig')) {
             require VMPATH_ADMIN . '/models/config.php';
         }
         $res = VirtueMartModelConfig::checkConfigTableExists();
         if (!empty($res)) {
             vRequest::setVar(JSession::getFormToken(), '1');
             $config = VmModel::getModel('config');
             $config->setDangerousToolsOff();
         }
     }
     return true;
 }
Exemple #13
0
 public function updatecart($html = true)
 {
     $cart = VirtueMartCart::getCart();
     $cart->_fromCart = true;
     $cart->_redirected = false;
     if (vRequest::get('cancel', 0)) {
         $cart->_inConfirm = false;
     }
     if ($cart->getInCheckOut()) {
         vRequest::setVar('checkout', true);
     }
     $cart->saveCartFieldsInCart();
     if ($cart->updateProductCart()) {
         vmInfo('COM_VIRTUEMART_PRODUCT_UPDATED_SUCCESSFULLY');
     }
     $cart->STsameAsBT = vRequest::getInt('STsameAsBT', vRequest::getInt('STsameAsBTjs', 0));
     $cart->selected_shipto = vRequest::getVar('shipto', -1);
     $currentUser = JFactory::getUser();
     if (empty($cart->selected_shipto) or $cart->selected_shipto < 1) {
         $cart->STsameAsBT = 1;
         $cart->selected_shipto = 0;
     } else {
         if ($cart->selected_shipto > 0) {
             $userModel = VmModel::getModel('user');
             $stData = $userModel->getUserAddressList($currentUser->id, 'ST', $cart->selected_shipto);
             if (isset($stData[0]) and is_object($stData[0])) {
                 $stData = get_object_vars($stData[0]);
                 //if($cart->validateUserData('ST', $stData)>0){
                 $cart->ST = $stData;
                 //}
             } else {
                 $cart->selected_shipto = 0;
                 $cart->ST = $cart->BT;
             }
         }
     }
     if (!empty($cart->STsameAsBT) or empty($cart->selected_shipto)) {
         //Guest
         $cart->ST = $cart->BT;
     }
     $cart->prepareCartData();
     $coupon_code = trim(vRequest::getString('coupon_code', ''));
     if (!empty($coupon_code)) {
         $msg = $cart->setCouponCode($coupon_code);
         if ($msg) {
             vmInfo($msg);
         }
     }
     $cart->setShipmentMethod(true, !$html);
     $cart->setPaymentMethod(true, !$html);
     if ($html) {
         $this->display();
     } else {
         $json = new stdClass();
         ob_start();
         $this->display();
         $json->msg = ob_get_clean();
         echo json_encode($json);
         jExit();
     }
 }
 function plgVmOnPaymentResponseReceived(&$html)
 {
     if (!class_exists('VirtueMartCart')) {
         require VMPATH_SITE . DS . 'helpers' . DS . 'cart.php';
     }
     if (!class_exists('shopFunctionsF')) {
         require VMPATH_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php';
     }
     if (!class_exists('VirtueMartModelOrders')) {
         require VMPATH_ADMIN . DS . 'models' . DS . 'orders.php';
     }
     VmConfig::loadJLang('com_virtuemart_orders', TRUE);
     $po = vRequest::getString('po', '');
     if (!$po) {
         return NULL;
     }
     $klikandpayData = $this->getRetourParams($po);
     $virtuemart_paymentmethod_id = $klikandpayData['virtuemart_paymentmethod_id'];
     $order_number = $klikandpayData['order_number'];
     $context = $klikandpayData['context'];
     if (!$this->isValidContext($context)) {
         return NULL;
     }
     if (!($this->_currentMethod = $this->getVmPluginMethod($virtuemart_paymentmethod_id))) {
         return NULL;
         // Another method was selected, do nothing
     }
     if (!$this->selectedThisElement($this->_currentMethod->payment_element)) {
         return NULL;
     }
     if (!($virtuemart_order_id = VirtueMartModelOrders::getOrderIdByOrderNumber($order_number))) {
         return FALSE;
     }
     if (!($payments = $this->getDatasByOrderId($virtuemart_order_id))) {
         $this->debugLog('no payments found', 'getDatasByOrderId', 'debug', false);
         return FALSE;
     }
     $orderModel = VmModel::getModel('orders');
     $order = $orderModel->getOrder($virtuemart_order_id);
     $html = $this->getResponseHTML($order, $payments);
     //$cart = VirtueMartCart::getCart();
     //$cart->emptyCart();
     vRequest::setVar('display_title', false);
     vRequest::setVar('html', $html);
     return TRUE;
 }
Exemple #15
0
 /**
  *
  *
  * @author Valérie Isaksen
  */
 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;
     }
     VmConfig::loadJLang('com_virtuemart', true);
     VmConfig::loadJLang('com_virtuemart_orders', TRUE);
     if (!class_exists('VirtueMartModelOrders')) {
         require VMPATH_ADMIN . DS . 'models' . DS . 'orders.php';
     }
     $this->getPaymentCurrency($method);
     $currency_code_3 = shopFunctions::getCurrencyByID($method->payment_currency, 'currency_code_3');
     $email_currency = $this->getEmailCurrency($method);
     $totalInPaymentCurrency = vmPSPlugin::getAmountInCurrency($order['details']['BT']->order_total, $method->payment_currency);
     $dbValues['payment_name'] = $this->renderPluginName($method) . '<br />' . $method->payment_info;
     $dbValues['order_number'] = $order['details']['BT']->order_number;
     $dbValues['virtuemart_paymentmethod_id'] = $order['details']['BT']->virtuemart_paymentmethod_id;
     $dbValues['cost_per_transaction'] = $method->cost_per_transaction;
     $dbValues['cost_percent_total'] = $method->cost_percent_total;
     $dbValues['payment_currency'] = $currency_code_3;
     $dbValues['email_currency'] = $email_currency;
     $dbValues['payment_order_total'] = $totalInPaymentCurrency['value'];
     $dbValues['tax_id'] = $method->tax_id;
     $this->storePSPluginInternalData($dbValues);
     $payment_info = '';
     if (!empty($method->payment_info)) {
         $lang = JFactory::getLanguage();
         if ($lang->hasKey($method->payment_info)) {
             $payment_info = vmText::_($method->payment_info);
         } else {
             $payment_info = $method->payment_info;
         }
     }
     if (!class_exists('VirtueMartModelCurrency')) {
         require VMPATH_ADMIN . DS . 'models' . DS . 'currency.php';
     }
     $currency = CurrencyDisplay::getInstance('', $order['details']['BT']->virtuemart_vendor_id);
     $html = $this->renderByLayout('post_payment', array('order_number' => $order['details']['BT']->order_number, 'order_pass' => $order['details']['BT']->order_pass, 'payment_name' => $dbValues['payment_name'], 'displayTotalInPaymentCurrency' => $totalInPaymentCurrency['display']));
     $modelOrder = VmModel::getModel('orders');
     $order['order_status'] = $this->getNewStatus($method);
     $order['customer_notified'] = 1;
     $order['comments'] = '';
     $modelOrder->updateStatusForOneOrder($order['details']['BT']->virtuemart_order_id, $order, TRUE);
     //We delete the old stuff
     $cart->emptyCart();
     vRequest::setVar('html', $html);
     return TRUE;
 }
Exemple #16
0
 /**
  * This functions updates the variables of the model which are used in the sortSearchListQuery
  *  with the variables from the Request
  *
  * @author Max Milbers
  */
 function updateRequests()
 {
     $this->keyword = vRequest::getString('keyword', '');
     //vRequest::uword ('keyword', "", ' ,-,+,.,_,#,/');
     if ($this->keyword === '') {
         $this->keyword = vRequest::getString('filter_product', '');
         //vRequest::uword ('filter_product', "", ' ,-,+,.,_,#,/');
         vRequest::setVar('filter_product', $this->keyword);
     } else {
         vRequest::setVar('keyword', $this->keyword);
     }
     $app = JFactory::getApplication();
     $option = 'com_virtuemart';
     $view = 'product';
     $valid_search_fields = VmConfig::get('browse_search_fields');
     if ($app->isSite()) {
         $filter_order = vRequest::getString('orderby', "0");
         if ($filter_order == "0") {
             $filter_order_raw = $this->getLastProductOrdering($this->_selectedOrdering);
             $filter_order = $this->checkFilterOrder($filter_order_raw);
         } else {
             $filter_order = $this->checkFilterOrder($filter_order);
             $this->setLastProductOrdering($filter_order);
         }
         $filter_order_Dir = strtoupper(vRequest::getCmd('dir', VmConfig::get('prd_brws_orderby_dir', 'ASC')));
     } else {
         $filter_order = strtolower($app->getUserStateFromRequest('com_virtuemart.' . $view . '.filter_order', 'filter_order', $this->_selectedOrdering, 'cmd'));
         $filter_order = $this->checkFilterOrder($filter_order);
         $filter_order_Dir = strtoupper($app->getUserStateFromRequest($option . '.' . $view . '.filter_order_Dir', 'filter_order_Dir', '', 'word'));
         $valid_search_fields = array_unique(array_merge($this->valid_BE_search_fields, $valid_search_fields));
     }
     $filter_order_Dir = $this->checkFilterDir($filter_order_Dir);
     $this->filter_order = $filter_order;
     $this->filter_order_Dir = $filter_order_Dir;
     $this->valid_search_fields = $valid_search_fields;
     $this->product_parent_id = vRequest::getInt('product_parent_id', FALSE);
     $this->virtuemart_manufacturer_id = vRequest::getInt('virtuemart_manufacturer_id', FALSE);
     $this->search_type = vRequest::getVar('search_type', '');
     $this->searchcustoms = vRequest::getInt('customfields');
     $this->searchplugin = vRequest::getInt('custom_parent_id', 0);
     //$this->virtuemart_vendor_id = vmAccess::isSuperVendor();
     $this->virtuemart_vendor_id = vmAccess::getVendorId();
 }
Exemple #17
0
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $input = JFactory::getApplication()->input;
     $this->prepareContinueLink();
     if (VmConfig::get('use_as_catalog', 0)) {
         vmInfo('This is a catalogue, you cannot access the cart');
         $app->redirect($this->continue_link);
     }
     $pathway = $app->getPathway();
     $document = JFactory::getDocument();
     $document->setMetaData('robots', 'NOINDEX, NOFOLLOW, NOARCHIVE, NOSNIPPET');
     $this->addTemplatePath(dirname(__FILE__) . DS . 'tmpl' . DS);
     $path = JPATH_BASE . '/templates/' . $app->getTemplate() . '/html/plg_content_onepage_generic/';
     $this->addTemplatePath($path);
     $layoutName = $this->getLayout();
     if (!$layoutName) {
         $layoutName = vRequest::getCmd('layout', 'default');
     }
     $this->assignRef('layoutName', $layoutName);
     $format = vRequest::getCmd('format');
     if (!class_exists('VirtueMartCart')) {
         require VMPATH_SITE . DS . 'helpers' . DS . 'cart.php';
     }
     $cart = VirtueMartCart::getCart();
     $cart->prepareVendor();
     $this->cart = $cart;
     //Why is this here, when we have view.raw.php
     if ($format == 'raw') {
         vRequest::setVar('layout', 'mini_cart');
         $this->setLayout('mini_cart');
         $this->prepareContinueLink();
     }
     if ($layoutName == 'select_shipment') {
         $cart->prepareCartData();
         $this->lSelectShipment();
         $pathway->addItem(vmText::_('COM_VIRTUEMART_CART_OVERVIEW'), JRoute::_('index.php?option=com_virtuemart&view=cart', FALSE));
         $pathway->addItem(vmText::_('COM_VIRTUEMART_CART_SELECTSHIPMENT'));
         $document->setTitle(vmText::_('COM_VIRTUEMART_CART_SELECTSHIPMENT'));
     } else {
         if ($layoutName == 'select_payment') {
             $cart->prepareCartData();
             $this->lSelectPayment();
             $pathway->addItem(vmText::_('COM_VIRTUEMART_CART_OVERVIEW'), JRoute::_('index.php?option=com_virtuemart&view=cart', FALSE));
             $pathway->addItem(vmText::_('COM_VIRTUEMART_CART_SELECTPAYMENT'));
             $document->setTitle(vmText::_('COM_VIRTUEMART_CART_SELECTPAYMENT'));
         } else {
             if ($layoutName == 'order_done') {
                 VmConfig::loadJLang('com_virtuemart_shoppers', true);
                 $this->lOrderDone();
                 $pathway->addItem(vmText::_('COM_VIRTUEMART_CART_THANKYOU'));
                 $document->setTitle(vmText::_('COM_VIRTUEMART_CART_THANKYOU'));
             } else {
                 VmConfig::loadJLang('com_virtuemart_shoppers', true);
                 $this->renderCompleteAddressList();
                 if (!class_exists('VirtueMartModelUserfields')) {
                     require VMPATH_ADMIN . DS . 'models' . DS . 'userfields.php';
                 }
                 $userFieldsModel = VmModel::getModel('userfields');
                 $userFieldsCart = $userFieldsModel->getUserFields('cart', array('captcha' => true, 'delimiters' => true), array('delimiter_userinfo', 'user_is_vendor', 'username', 'password', 'password2', 'agreed', 'address_type'));
                 $this->userFieldsCart = $userFieldsModel->getUserFieldsFilled($userFieldsCart, $cart->cartfields);
                 if (!class_exists('CurrencyDisplay')) {
                     require VMPATH_ADMIN . DS . 'helpers' . DS . 'currencydisplay.php';
                 }
                 $this->currencyDisplay = CurrencyDisplay::getInstance($cart->pricesCurrency);
                 $currency = $this->currencyDisplay;
                 $customfieldsModel = VmModel::getModel('Customfields');
                 $this->assignRef('customfieldsModel', $customfieldsModel);
                 $this->lSelectCoupon();
                 $totalInPaymentCurrency = $this->getTotalInPaymentCurrency();
                 $checkoutAdvertise = $this->getCheckoutAdvertise();
                 if ($cart->getDataValidated()) {
                     if ($cart->_inConfirm) {
                         $pathway->addItem(vmText::_('COM_VIRTUEMART_CANCEL_CONFIRM_MNU'));
                         $document->setTitle(vmText::_('COM_VIRTUEMART_CANCEL_CONFIRM_MNU'));
                         $text = vmText::_('COM_VIRTUEMART_CANCEL_CONFIRM');
                         $this->checkout_task = 'cancel';
                     } else {
                         $pathway->addItem(vmText::_('COM_VIRTUEMART_ORDER_CONFIRM_MNU'));
                         $document->setTitle(vmText::_('COM_VIRTUEMART_ORDER_CONFIRM_MNU'));
                         $text = vmText::_('COM_VIRTUEMART_ORDER_CONFIRM_MNU');
                         $this->checkout_task = 'confirm';
                     }
                 } else {
                     $pathway->addItem(vmText::_('COM_VIRTUEMART_CART_OVERVIEW'));
                     $document->setTitle(vmText::_('COM_VIRTUEMART_CART_OVERVIEW'));
                     $text = vmText::_('COM_VIRTUEMART_CHECKOUT_TITLE');
                     $this->checkout_task = 'checkout';
                 }
                 $this->checkout_link_html = '<button type="submit"  id="checkoutFormSubmit" name="' . $this->checkout_task . '" value="1" class="vm-button-correct" ><span>' . $text . '</span> </button>';
                 if (!class_exists('vmPSPlugin')) {
                     require JPATH_VM_PLUGINS . DS . 'vmpsplugin.php';
                 }
                 JPluginHelper::importPlugin('vmshipment');
                 JPluginHelper::importPlugin('vmpayment');
                 vmdebug('cart view oncheckout_opc ');
                 $this->lSelectShipment();
                 $this->lSelectPayment();
                 if (VmConfig::get('oncheckout_opc', 1)) {
                 } else {
                     $this->checkPaymentMethodsConfigured();
                     $this->checkShipmentMethodsConfigured();
                 }
                 if ($cart->virtuemart_shipmentmethod_id) {
                     $shippingText = vmText::_('COM_VIRTUEMART_CART_CHANGE_SHIPPING');
                 } else {
                     $shippingText = vmText::_('COM_VIRTUEMART_CART_EDIT_SHIPPING');
                 }
                 $this->assignRef('select_shipment_text', $shippingText);
                 if ($cart->virtuemart_paymentmethod_id) {
                     $paymentText = vmText::_('COM_VIRTUEMART_CART_CHANGE_PAYMENT');
                 } else {
                     $paymentText = vmText::_('COM_VIRTUEMART_CART_EDIT_PAYMENT');
                 }
                 $this->assignRef('select_payment_text', $paymentText);
                 $cart->prepareAddressFieldsInCart();
                 $layoutName = $cart->layout;
                 //set order language
                 $lang = JFactory::getLanguage();
                 $order_language = $lang->getTag();
                 $this->assignRef('order_language', $order_language);
             }
         }
     }
     $this->useSSL = VmConfig::get('useSSL', 0);
     $this->useXHTML = false;
     $this->assignRef('totalInPaymentCurrency', $totalInPaymentCurrency);
     $this->assignRef('checkoutAdvertise', $checkoutAdvertise);
     if (!class_exists('VmTemplate')) {
         require VMPATH_SITE . DS . 'helpers' . DS . 'vmtemplate.php';
     }
     VmTemplate::setVmTemplate($this, 0, 0, $layoutName);
     //We never want that the cart is indexed
     $document->setMetaData('robots', 'NOINDEX, NOFOLLOW, NOARCHIVE, NOSNIPPET');
     if ($cart->_inConfirm) {
         vmInfo('COM_VIRTUEMART_IN_CONFIRM');
     }
     if ($cart->layoutPath) {
         $this->addTemplatePath($cart->layoutPath);
     }
     if (isset($_POST["tos"])) {
         $_POST["agreed"] = $_POST["tos"];
     } else {
         $_POST["agreed"] = 0;
     }
     $current = JFactory::getUser();
     $this->allowChangeShopper = false;
     $this->adminID = false;
     if (VmConfig::get('oncheckout_change_shopper')) {
         if ($current->authorise('core.admin', 'com_virtuemart') or $current->authorise('vm.user', 'com_virtuemart')) {
             $this->allowChangeShopper = true;
         } else {
             $this->adminID = JFactory::getSession()->get('vmAdminID', false);
             if ($this->adminID) {
                 if (!class_exists('vmCrypt')) {
                     require VMPATH_ADMIN . DS . 'helpers' . DS . 'vmcrypt.php';
                 }
                 $this->adminID = vmCrypt::decrypt($this->adminID);
                 $adminIdUser = JFactory::getUser($this->adminID);
                 if ($adminIdUser->authorise('core.admin', 'com_virtuemart') or $adminIdUser->authorise('vm.user', 'com_virtuemart')) {
                     $this->allowChangeShopper = true;
                 }
             }
         }
     }
     if ($this->allowChangeShopper) {
         $this->userList = $this->getUserList();
     }
     $task = $input->getString("vmtask");
     if (file_exists(dirname(__FILE__) . "/" . $task . ".php")) {
         require_once dirname(__FILE__) . "/" . $task . ".php";
     }
     if ($task == "completecheckout") {
         require_once dirname(__FILE__) . "/updatecartaddress.php";
         $checkout = $cart->checkoutData(false);
         $app = JFactory::getApplication();
         $messageQueue = $app->getMessageQueue();
         $return_error = "";
         if (count($messageQueue) > 0) {
             foreach ($messageQueue as $message) {
                 $return_error .= $message['message'];
             }
         }
         $returnarray = array();
         if ($checkout) {
             $returnarray["success"] = 1;
         } else {
             $returnarray["success"] = 0;
         }
         $returnarray['message'] = $return_error;
         echo json_encode($returnarray);
         exit;
     }
     if ($task == "ajaxshipment") {
         $this->lSelectShipment();
         echo json_encode($this->shipments_shipment_rates);
         exit;
     }
     if ($task == "ajaxpayment") {
         $this->lSelectPayment();
         echo json_encode($this->paymentplugins_payments);
         exit;
     }
     if ($task == "setsession") {
         $payid = JRequest::getVar("payid", 0);
         if ($payid > 0) {
             $cart->setPaymentMethod(false, false, $payid);
             $cart->setCartIntoSession();
         }
         echo "success";
         exit;
     }
     if ($task == "klarnaupdate") {
         $post = JRequest::get("post");
         $address = array();
         $address['shipto_address_type_name'] = 'ST';
         if (!empty($post['given_name'])) {
             $address['shipto_first_name'] = $post['given_name'];
         }
         if (!empty($post['family_name'])) {
             $address['shipto_last_name'] = $post['family_name'];
         }
         if (!empty($post['street_address'])) {
             $address['shipto_address_1'] = $post['street_address'];
         }
         if (!empty($post['street_address2'])) {
             $address['shipto_address_2'] = $post['street_address2'];
         }
         if (!empty($post['postal_code'])) {
             $address['shipto_zip'] = $post['postal_code'];
         }
         if (!empty($post['city'])) {
             $address['shipto_city'] = $post['city'];
         }
         if (!empty($post['country'])) {
             $address['shipto_virtuemart_country_id'] = ShopFunctions::getCountryIDByName($post['country']);
         } else {
             if (!empty($cart->BT['virtuemart_country_id'])) {
                 $address['shipto_virtuemart_country_id'] = $cart->BT['virtuemart_country_id'];
             }
         }
         if (!empty($post['region'])) {
             $address['shipto_virtuemart_state_id'] = ShopFunctions::getStateIDByName($post['region']);
         }
         if (!empty($post['phone'])) {
             $address['shipto_phone_1'] = $post['phone'];
         }
         $address['tos'] = 1;
         $cart->saveAddressInCart($address, 'ST', true, 'shipto_');
         $cart->setCartIntoSession(false, true);
         $return = array();
         $return['response'] = "success";
         echo json_encode($return);
         exit;
     }
     $cart->setCartIntoSession();
     parent::display($tpl);
 }
Exemple #18
0
	/**
	 * @param $html
	 * @return bool|null
	 */
	function plgVmOnPaymentResponseReceived (&$html) {

		$this->loadVmClass('VirtueMartCart', JPATH_VM_SITE . DS . 'helpers' . DS . 'cart.php');

		if (!class_exists('shopFunctionsF')) {
			require(JPATH_VM_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php');
		}
		$this->loadVmClass('VirtueMartModelOrders', JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php');


		VmConfig::loadJLang('com_virtuemart_orders', TRUE);

		$virtuemart_paymentmethod_id = vRequest::getInt('pm', 0);

		if (!($this->_currentMethod = $this->getVmPluginMethod($virtuemart_paymentmethod_id))) {
			return NULL; // Another method was selected, do nothing
		}
		if (!$this->selectedThisElement($this->_currentMethod->payment_element)) {
			return NULL;
		}

		$html = "We will send you an email confirmation with your order details shortly";
		$html .= "Our order number";
		$html .= "Amazon Reference";
		$html .= "Go tot payments.amazon... to see your payment history and other account information.";
		vRequest::setVar('display_title', false);
		vRequest::setVar('html', $html);
		return true;
	}
Exemple #19
0
 function plgVmOnPaymentResponseReceived(&$html)
 {
     if (!class_exists('VirtueMartCart')) {
         require VMPATH_SITE . DS . 'helpers' . DS . 'cart.php';
     }
     if (!class_exists('shopFunctionsF')) {
         require VMPATH_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php';
     }
     if (!class_exists('VirtueMartModelOrders')) {
         require VMPATH_ADMIN . DS . 'models' . DS . 'orders.php';
     }
     VmConfig::loadJLang('com_virtuemart_orders', TRUE);
     $virtuemart_paymentmethod_id = vRequest::getInt('pm', 0);
     if (!($this->_currentMethod = $this->getVmPluginMethod($virtuemart_paymentmethod_id))) {
         return NULL;
         // Another method was selected, do nothing
     }
     if (!$this->selectedThisElement($this->_currentMethod->payment_element)) {
         return NULL;
     }
     $paybox_data = vRequest::getGet();
     $this->debugLog('"<pre>plgVmOnPaymentResponseReceived :' . var_export($paybox_data, true) . "</pre>", 'debug');
     $payboxInterface = $this->_loadPayboxInterface($this);
     $html = $payboxInterface->paymentResponseReceived($paybox_data);
     vRequest::setVar('display_title', false);
     vRequest::setVar('html', $html);
     return true;
 }
 /**
  * Reimplementation of vmPaymentPlugin::plgVmOnConfirmedOrder()
  *
  * @link http://www.authorize.net/support/AIM_guide.pdf
  * Credit Cards Test Numbers
  * Visa Test Account           4007000000027
  * Amex Test Account           370000000000002
  * Master Card Test Account    6011000000000012
  * Discover Test Account       5424000000000015
  * @author Valerie Isaksen
  */
 function plgVmConfirmedOrder(VirtueMartCart $cart, $order)
 {
     if (!($this->_currentMethod = $this->getVmPluginMethod($order['details']['BT']->virtuemart_paymentmethod_id))) {
         return NULL;
         // Another method was selected, do nothing
     }
     if (!$this->selectedThisElement($this->_currentMethod->payment_element)) {
         return FALSE;
     }
     $this->setInConfirmOrder($cart);
     $usrBT = $order['details']['BT'];
     $usrST = isset($order['details']['ST']) ? $order['details']['ST'] : '';
     $session = JFactory::getSession();
     $return_context = $session->getId();
     $payment_currency_id = shopFunctions::getCurrencyIDByName(self::AUTHORIZE_DEFAULT_PAYMENT_CURRENCY);
     $totalInPaymentCurrency = vmPSPlugin::getAmountInCurrency($order['details']['BT']->order_total, $payment_currency_id);
     $cd = CurrencyDisplay::getInstance($cart->pricesCurrency);
     // Set up data
     $formdata = array();
     $formdata = array_merge($this->_setHeader(), $formdata);
     $formdata = array_merge($this->_setResponseConfiguration(), $formdata);
     $formdata = array_merge($this->_setBillingInformation($usrBT), $formdata);
     if (!empty($usrST)) {
         $formdata = array_merge($this->_setShippingInformation($usrST), $formdata);
     }
     $formdata = array_merge($this->_setTransactionData($order['details']['BT'], $totalInPaymentCurrency['value']), $formdata);
     $formdata = array_merge($this->_setMerchantData(), $formdata);
     // prepare the array to post
     $poststring = '';
     foreach ($formdata as $key => $val) {
         $poststring .= urlencode($key) . "=" . urlencode($val) . "&";
     }
     $poststring = rtrim($poststring, "& ");
     // Prepare data that should be stored in the database
     $dbValues['order_number'] = $order['details']['BT']->order_number;
     $dbValues['virtuemart_order_id'] = $order['details']['BT']->virtuemart_order_id;
     $dbValues['payment_method_id'] = $order['details']['BT']->virtuemart_paymentmethod_id;
     $dbValues['return_context'] = $return_context;
     $dbValues['payment_name'] = parent::renderPluginName($this->_currentMethod);
     $dbValues['cost_per_transaction'] = $this->_currentMethod->cost_per_transaction;
     $dbValues['cost_percent_total'] = $this->_currentMethod->cost_percent_total;
     $dbValues['payment_order_total'] = $totalInPaymentCurrency['value'];
     $dbValues['payment_currency'] = $payment_currency_id;
     $this->debugLog("before store", "plgVmConfirmedOrder", 'debug');
     $this->storePSPluginInternalData($dbValues);
     // send a request
     $response = $this->_sendRequest($poststring);
     $this->debugLog($response, "plgVmConfirmedOrder", 'debug');
     $authnet_values = array();
     // to check the values???
     // evaluate the response
     $html = $this->_handleResponse($response, $authnet_values, $order, $dbValues['payment_name']);
     if ($this->error) {
         $new_status = $this->_currentMethod->payment_declined_status;
         $this->_handlePaymentCancel($order['details']['BT']->virtuemart_order_id, $html);
         return;
         // will not process the order
     } else {
         if ($this->approved) {
             $this->_clearAuthorizeNetSession();
             $new_status = $this->_currentMethod->payment_approved_status;
         } else {
             if ($this->declined) {
                 vRequest::setVar('html', $html);
                 $new_status = $this->_currentMethod->payment_declined_status;
                 $this->_handlePaymentCancel($order['details']['BT']->virtuemart_order_id, $html);
                 return;
             } else {
                 if ($this->held) {
                     $this->_clearAuthorizeNetSession();
                     $new_status = $this->_currentMethod->payment_held_status;
                 }
             }
         }
     }
     $modelOrder = VmModel::getModel('orders');
     $order['order_status'] = $new_status;
     $order['customer_notified'] = 1;
     $order['comments'] = '';
     $modelOrder->updateStatusForOneOrder($order['details']['BT']->virtuemart_order_id, $order, TRUE);
     //We delete the old stuff
     $cart->emptyCart();
     vRequest::setVar('html', $html);
 }
 public function display($tpl = null)
 {
     $show_prices = VmConfig::get('show_prices', 1);
     if ($show_prices == '1') {
         if (!class_exists('calculationHelper')) {
             require VMPATH_ADMIN . DS . 'helpers' . DS . 'calculationh.php';
         }
     }
     $this->assignRef('show_prices', $show_prices);
     if (!class_exists('shopFunctionsF')) {
         require VMPATH_SITE . DS . 'helpers' . DS . 'shopfunctionsf.php';
     }
     $document = JFactory::getDocument();
     $app = JFactory::getApplication();
     $pathway = $app->getPathway();
     if (!class_exists('VmImage')) {
         require VMPATH_ADMIN . DS . 'helpers' . DS . 'image.php';
     }
     // set search and keyword
     if ($keyword = vRequest::getString('keyword', false)) {
         //uword('keyword', false, ' ,-,+,.,_')) {
         $pathway->addItem($keyword);
         //$title .=' ('.$keyword.')';
     }
     //$search = vRequest::uword('keyword', null);
     $this->searchcustom = '';
     $this->searchCustomValues = '';
     //if (!empty($keyword)) {
     $this->getSearchCustom();
     $search = $keyword;
     /*} else {
     			$keyword ='';
     			$search = NULL;
     		}*/
     $this->assignRef('keyword', $keyword);
     $this->assignRef('search', $search);
     $menus = $app->getMenu();
     $menu = $menus->getActive();
     if (!empty($menu->id)) {
         ShopFunctionsF::setLastVisitedItemId($menu->id);
     } else {
         if ($itemId = vRequest::getInt('Itemid', false)) {
             ShopFunctionsF::setLastVisitedItemId($itemId);
         }
     }
     $virtuemart_manufacturer_id = vRequest::getInt('virtuemart_manufacturer_id', -1);
     if ($virtuemart_manufacturer_id === -1 and !empty($menu->query['virtuemart_manufacturer_id'])) {
         $virtuemart_manufacturer_id = $menu->query['virtuemart_manufacturer_id'];
         vRequest::setVar('virtuemart_manufacturer_id', $virtuemart_manufacturer_id);
     }
     $this->categoryId = vRequest::getInt('virtuemart_category_id', -1);
     if ($this->categoryId === -1 and !empty($menu->query['virtuemart_category_id'])) {
         $this->categoryId = $menu->query['virtuemart_category_id'];
         vRequest::setVar('virtuemart_category_id', $this->categoryId);
     } else {
         if ($this->categoryId === -1 and $virtuemart_manufacturer_id === -1) {
             $this->categoryId = ShopFunctionsF::getLastVisitedCategoryId();
         }
     }
     $this->setCanonicalLink($tpl, $document, $this->categoryId, $virtuemart_manufacturer_id);
     if (($this->categoryId === -1 or $this->categoryId === 0) and $virtuemart_manufacturer_id) {
         $this->categoryId = 0;
         $catType = 'manufacturer';
         $this->setCanonicalLink($tpl, $document, $virtuemart_manufacturer_id, $catType);
     }
     $categoryModel = VmModel::getModel('category');
     $productModel = VmModel::getModel('product');
     if ($this->categoryId === -1) {
         $this->categoryId = 0;
     }
     $vendorId = 1;
     $category = $categoryModel->getCategory($this->categoryId);
     if (!isset($menu->query['showproducts'])) {
         $menu->query['showproducts'] = 1;
     }
     $this->showproducts = vRequest::getInt('showproducts', $menu->query['showproducts']);
     if (!empty($category)) {
         $vendorId = $category->virtuemart_vendor_id;
         if ($this->showproducts) {
             //if(empty($category->category_layout) or $category->category_layout != 'categories') {
             // Load the products in the given category
             $ids = $productModel->sortSearchListQuery(TRUE, $this->categoryId);
             $this->perRow = empty($category->products_per_row) ? VmConfig::get('products_per_row', 3) : $category->products_per_row;
             $this->vmPagination = $productModel->getPagination($this->perRow);
             $ratingModel = VmModel::getModel('ratings');
             $this->showRating = $ratingModel->showRating();
             $productModel->withRating = $this->showRating;
             $this->orderByList = $productModel->getOrderByList($this->categoryId);
             $this->products = $productModel->getProducts($ids);
             //$products = $productModel->getProductsInCategory($this->categoryId);
             $imgAmount = VmConfig::get('prodimg_browse', 1);
             $productModel->addImages($this->products, $imgAmount);
             if ($this->products) {
                 $currency = CurrencyDisplay::getInstance();
                 $this->assignRef('currency', $currency);
                 $display_stock = VmConfig::get('display_stock', 1);
                 $showCustoms = VmConfig::get('show_pcustoms', 1);
                 if ($display_stock or $showCustoms) {
                     if (!$showCustoms) {
                         foreach ($this->products as $i => $productItem) {
                             $productItem->stock = $productModel->getStockIndicator($productItem);
                         }
                     } else {
                         shopFunctionsF::sortLoadProductCustomsStockInd($this->products, $productModel);
                     }
                 }
                 // add javascript for price and cart, need even for quantity buttons, so we need it almost anywhere
                 vmJsApi::jPrice();
             }
             // Add feed links
             if ($this->showproducts and $this->products && VmConfig::get('feed_cat_published', 0) == 1) {
                 $link = '&format=feed&limitstart=';
                 $attribs = array('type' => 'application/rss+xml', 'title' => 'RSS 2.0');
                 $document->addHeadLink(JRoute::_($link . '&type=rss', FALSE), 'alternate', 'rel', $attribs);
                 $attribs = array('type' => 'application/atom+xml', 'title' => 'Atom 1.0');
                 $document->addHeadLink(JRoute::_($link . '&type=atom', FALSE), 'alternate', 'rel', $attribs);
             }
             $user = JFactory::getUser();
             $this->showBasePrice = (vmAccess::manager() or vmAccess::isSuperVendor());
         }
         //No redirect here, for category id = 0 means show ALL categories! note by Max Milbers
         if (!empty($this->categoryId) and $this->categoryId !== -1 and (empty($category->slug) or !$category->published)) {
             if (empty($category->slug)) {
                 vmInfo(vmText::_('COM_VIRTUEMART_CAT_NOT_FOUND'));
             } else {
                 if ($category->virtuemart_id !== 0 and !$category->published) {
                     vmInfo('COM_VIRTUEMART_CAT_NOT_PUBL', $category->category_name, $this->categoryId);
                 }
             }
             //Fallback
             $categoryLink = '';
             if ($category->category_parent_id) {
                 $categoryLink = '&view=category&virtuemart_category_id=' . $category->category_parent_id;
             } else {
                 $last_category_id = shopFunctionsF::getLastVisitedCategoryId();
                 if (!$last_category_id or $this->categoryId == $last_category_id) {
                     $last_category_id = vRequest::getInt('virtuemart_category_id', false);
                 }
                 if ($last_category_id and $this->categoryId != $last_category_id) {
                     $categoryLink = '&view=category&virtuemart_category_id=' . $last_category_id;
                 }
             }
             if (VmConfig::get('handle_404', 1)) {
                 $app->redirect(JRoute::_('index.php?option=com_virtuemart' . $categoryLink . '&error=404', FALSE));
             } else {
                 JError::raise(E_ERROR, '404', 'Not found');
             }
             return;
         }
         shopFunctionsF::setLastVisitedCategoryId($this->categoryId);
         shopFunctionsF::setLastVisitedManuId($virtuemart_manufacturer_id);
         // Add the category name to the pathway
         if ($category->parents) {
             foreach ($category->parents as $c) {
                 $pathway->addItem(strip_tags(vmText::_($c->category_name)), JRoute::_('index.php?option=com_virtuemart&view=category&virtuemart_category_id=' . $c->virtuemart_category_id, FALSE));
             }
         }
         $catImgAmount = VmConfig::get('catimg_browse', 1);
         $categoryModel->addImages($category, $catImgAmount);
         if (!isset($menu->query['showcategory'])) {
             $menu->query['showcategory'] = 1;
         }
         $this->showcategory = vRequest::getInt('showcategory', $menu->query['showcategory']);
         //$this->showcategory = vRequest::getInt('showcategory',true);
         if ($this->showcategory) {
             //if($category->category_layout == 'categories' or ($this->categoryId >0 and $virtuemart_manufacturer_id <1)){
             $category->children = $categoryModel->getChildCategoryList($vendorId, $this->categoryId, $categoryModel->getDefaultOrdering(), $categoryModel->_selectedOrderingDir);
             $categoryModel->addImages($category->children, $catImgAmount);
         } else {
             $category->children = false;
         }
         if (VmConfig::get('enable_content_plugin', 0)) {
             shopFunctionsF::triggerContentPlugin($category, 'category', 'category_description');
         }
         $metadesc = '';
         $metakey = '';
         $metarobot = '';
         if (isset($menu->params)) {
             $metadesc = $menu->params->get('menu-meta_description');
             $metakey = $menu->params->get('menu-meta_keywords');
             $metarobot = $menu->params->get('robots');
         }
         if ($category->metadesc) {
             $metadesc = $category->metadesc;
         }
         if ($category->metakey) {
             $metakey = $category->metakey;
         }
         if ($category->metarobot) {
             $metarobot = $category->metarobot;
         }
         $document->setDescription($metadesc);
         $document->setMetaData('keywords', $metakey);
         $document->setMetaData('robots', $metarobot);
         if ($app->getCfg('MetaAuthor') == '1' and !empty($category->metaauthor)) {
             $document->setMetaData('author', $category->metaauthor);
         }
         if (empty($category->category_template)) {
             $category->category_template = VmConfig::get('categorytemplate');
         }
         if (!empty($menu->query['categorylayout'])) {
             //if(!empty($menu->query['categorylayout']) and $menu->query['virtuemart_category_id']==$this->categoryId){
             $category->category_layout = $menu->query['categorylayout'];
         }
         $productsLayout = VmConfig::get('productsublayout', 'products');
         if (empty($productsLayout)) {
             $productsLayout = 'products';
         }
         $this->productsLayout = empty($menu->query['productsublayout']) ? $productsLayout : $menu->query['productsublayout'];
         shopFunctionsF::setVmTemplate($this, $category->category_template, 0, $category->category_layout);
     } else {
         //Backward compatibility
         if (!isset($category)) {
             $category = new stdClass();
             $category->category_name = '';
             $category->category_description = '';
             $category->haschildren = false;
         }
     }
     $this->assignRef('category', $category);
     // Set the titles
     if (!empty($category->customtitle)) {
         $title = strip_tags($category->customtitle);
     } elseif (!empty($category->category_name)) {
         $title = strip_tags($category->category_name);
     } else {
         $title = $this->setTitleByJMenu($app);
     }
     $title = vmText::_($title);
     if (vRequest::getInt('error')) {
         $title .= ' ' . vmText::_('COM_VIRTUEMART_PRODUCT_NOT_FOUND');
     }
     if (!empty($keyword)) {
         $title .= ' (' . strip_tags(htmlspecialchars_decode($keyword)) . ')';
     }
     if ($virtuemart_manufacturer_id > 0 and !empty($this->products[0])) {
         $title .= ' ' . $this->products[0]->mf_name;
     }
     $document->setTitle($title);
     // Override Category name when viewing manufacturers products !IMPORTANT AFTER page title.
     if ($virtuemart_manufacturer_id > 0 and !empty($this->products[0]) and isset($category->category_name)) {
         $category->category_name = $this->products[0]->mf_name;
     }
     if ($app->getCfg('MetaTitle') == '1') {
         $document->setMetaData('title', $title);
     }
     parent::display($tpl);
 }
Exemple #22
0
 /**
  * Display the order item details for editing
  */
 public function editOrderItem()
 {
     vRequest::setVar('layout', 'orders_editorderitem');
     parent::display();
 }
Exemple #23
0
	/**
	 *
	 * @param $cart
	 * @param $order
	 * @return bool|null|void
	 */
	function plgVmConfirmedOrder($cart, $order) {

		if (!($this->_currentMethod = $this->getVmPluginMethod($order['details']['BT']->virtuemart_paymentmethod_id))) {
			return NULL; // Another method was selected, do nothing
		}
		if (!$this->selectedThisElement($this->_currentMethod->payment_element)) {
			return FALSE;
		}

		if (!class_exists('VirtueMartModelOrders')) {
			require(VMPATH_ADMIN . DS . 'models' . DS . 'orders.php');
		}
		if (!class_exists('VirtueMartModelCurrency')) {
			require(VMPATH_ADMIN . DS . 'models' . DS . 'currency.php');
		}
		$html='';
		$this->getPaymentCurrency($this->_currentMethod);
		$email_currency = $this->getEmailCurrency($this->_currentMethod);

		$payment_name = $this->renderPluginName($this->_currentMethod, $order);

		$paypalInterface = $this->_loadPayPalInterface();
		$paypalInterface->debugLog('order number: ' . $order['details']['BT']->order_number, 'plgVmConfirmedOrder', 'message');
		$paypalInterface->setCart($cart);
		$paypalInterface->setOrder($order);
		$paypalInterface->setTotal($order['details']['BT']->order_total);
		$paypalInterface->loadCustomerData();


		// Prepare data that should be stored in the database
		$dbValues['order_number'] = $order['details']['BT']->order_number;
		$dbValues['payment_name'] = $payment_name;
		$dbValues['virtuemart_paymentmethod_id'] = $cart->virtuemart_paymentmethod_id;
		$dbValues['paypal_custom'] = $paypalInterface->getContext();
		$dbValues['cost_per_transaction'] = $this->_currentMethod->cost_per_transaction;
		$dbValues['cost_percent_total'] = $this->_currentMethod->cost_percent_total;
		$dbValues['payment_currency'] = $this->_currentMethod->payment_currency;
		$dbValues['email_currency'] = $email_currency;
		$dbValues['payment_order_total'] = $paypalInterface->getTotal();
		$dbValues['tax_id'] = $this->_currentMethod->tax_id;
		$this->storePSPluginInternalData($dbValues);
		VmConfig::loadJLang('com_virtuemart_orders', TRUE);


		if ($this->_currentMethod->paypalproduct == 'std') {
			$html = $paypalInterface->ManageCheckout();
			// 	2 = don't delete the cart, don't send email and don't redirect
			$cart->_confirmDone = FALSE;
			$cart->_dataValidated = FALSE;
			$cart->setCartIntoSession();
			vRequest::setVar('html', $html);

		} else {
			if ($this->_currentMethod->paypalproduct == 'exp') {
				$success = $paypalInterface->ManageCheckout();
				$response = $paypalInterface->getResponse();

			$payment = $this->_storePaypalInternalData(  $response, $order['details']['BT']->virtuemart_order_id, $cart->virtuemart_paymentmethod_id, $order['details']['BT']->order_number);

				if ($success) {
					$new_status = $paypalInterface->getNewOrderStatus();

					if ($this->_currentMethod->payment_type == '_xclick-subscriptions' || $this->_currentMethod->payment_type == '_xclick-payment-plan') {
						$profilesuccess = $paypalInterface->GetRecurringPaymentsProfileDetails($response['PROFILEID']);
						$response = $paypalInterface->getResponse();
					$this->_storePaypalInternalData(  $response, $order['details']['BT']->virtuemart_order_id, $cart->virtuemart_paymentmethod_id, $order['details']['BT']->order_number);
					}
					$this->customerData->clear();
					$returnValue = 1;
					$html = $this->renderByLayout('expresponse',
						array("method" => $this->_currentMethod,
							"success" => $success,
							"payment_name" => $payment_name,
							"response" => $response,
							"order" => $order));
					return $this->processConfirmedOrderPaymentResponse($returnValue, $cart, $order, $html, $payment_name, $new_status);
				} else {
					$new_status = $this->_currentMethod->status_canceled;
					$returnValue = 2;
					$cart->virtuemart_paymentmethod_id = 0;
					$cart->setCartIntoSession();
					$this->customerData->clear();
					VmInfo('VMPAYMENT_PAYPAL_PAYMENT_NOT_VALID');
					$paypalInterface->debugLog($response, 'plgVmConfirmedOrder, response:', 'error');

					$app = JFactory::getApplication();
					$app->redirect(JRoute::_('index.php?option=com_virtuemart&view=cart&Itemid=' . vRequest::getInt('Itemid'), false));
				}


			} else {
				if ($this->_currentMethod->paypalproduct == 'api') {
					$this->setInConfirmOrder($cart);

					$success = $paypalInterface->ManageCheckout();
					$response = $paypalInterface->getResponse();
			$payment = $this->_storePaypalInternalData(  $response, $order['details']['BT']->virtuemart_order_id, $cart->virtuemart_paymentmethod_id, $order['details']['BT']->order_number);
					if ($success) {
						if ($this->_currentMethod->payment_action == 'Authorization' || $this->_currentMethod->payment_type == '_xclick-payment-plan') {
							$new_status = $this->_currentMethod->status_pending;
						} else {
							$new_status = $this->_currentMethod->status_success;
						}
						if ($this->_currentMethod->payment_type == '_xclick-subscriptions' || $this->_currentMethod->payment_type == '_xclick-payment-plan') {
							$profilesuccess = $paypalInterface->GetRecurringPaymentsProfileDetails($response['PROFILEID']);
							$response = $paypalInterface->getResponse();
					$this->_storePaypalInternalData(  $response, $order['details']['BT']->virtuemart_order_id, $cart->virtuemart_paymentmethod_id, $order['details']['BT']->order_number);
						}
						$this->customerData->clear();
						$returnValue = 1;
					} else {
						$cart->virtuemart_paymentmethod_id = 0;
						$cart->setCartIntoSession();
						$this->redirectToCart();
						return;
					}
//			$this->customerData->clear();
					$html = $this->renderByLayout('apiresponse', array('method' => $this->_currentMethod, 'success' => $success, 'payment_name' => $payment_name, 'responseData' => $response, "order" => $order));
					return $this->processConfirmedOrderPaymentResponse($returnValue, $cart, $order, $html, $payment_name, $new_status);
				} else {
					if ($this->_currentMethod->paypalproduct == 'hosted') {
						$paypalInterface->ManageCheckout();
						if ($this->_currentMethod->template == 'templateD') {
							jimport('joomla.environment.browser');
							$browser = JBrowser::getInstance();


							// this code is only called incase of iframe (templateD), in all other cases redirecttopayapl has been done
							$html = $this->renderByLayout('hostediframe', array("url" => $paypalInterface->response['EMAILLINK'],
								"isMobile" => $browser->isMobile()
							));
						}
						// 	2 = don't delete the cart, don't send email and don't redirect
						$cart->_confirmDone = FALSE;
						$cart->_dataValidated = FALSE;
						$cart->setCartIntoSession();
						vRequest::setVar('html', $html);
					} else {
						vmError('Unknown Paypal mode');
					}
				}
			}
		}
	}
 /**
  * Generic edit task
  *
  * @author Max Milbers
  */
 function edit($layout = 'edit')
 {
     vRequest::setVar('controller', $this->_cname);
     vRequest::setVar('view', $this->_cname);
     vRequest::setVar('layout', $layout);
     $this->addViewPath(VMPATH_ADMIN . DS . 'views');
     $document = JFactory::getDocument();
     $viewType = $document->getType();
     $view = $this->getView($this->_cname, $viewType);
     $view->setLayout($layout);
     $this->display();
 }
Exemple #25
0
            $basePath = VMPATH_ADMIN;
            $trigger = 'onVmAdminController';
            vmJsApi::jQuery(false);
            vmJsApi::loadBECSS();
            $router = $app->getRouter();
            $router->setMode(0);
        } else {
            $session->set('manage', 0, 'vm');
            vRequest::setVar('manage', 0);
            $basePath = VMPATH_SITE;
            $app->redirect('index.php?option=com_virtuemart', tsmText::_('COM_VIRTUEMART_RESTRICTED_ACCESS'));
        }
    } elseif ($_controller) {
        if ($_controller != 'productdetails') {
            $session->set('manage', 0, 'vm');
            vRequest::setVar('manage', '0');
        }
        vmJsApi::jQuery();
        vmJsApi::jSite();
        vmJsApi::cssSite();
        $basePath = VMPATH_SITE;
    }
}
// controller alias
if ($_controller == 'pluginresponse') {
    $_controller = 'vmplg';
}
/* Create the controller name */
$_class = 'VirtuemartController' . ucfirst($_controller);
if (file_exists($basePath . DS . 'controllers' . DS . $_controller . '.php')) {
    if (!class_exists($_class)) {
    /**
     * Installs sample data to the current database.
     *
     * @author Max Milbers, RickG
     * @params $userId User Id to add the userinfo and vendor sample data to
     */
    function installSampleData($userId = null)
    {
        if ($userId == null) {
            $userId = $this->determineStoreOwner();
        }
        $fields['username'] = $this->_user->username;
        $fields['virtuemart_user_id'] = $userId;
        $fields['address_type'] = 'BT';
        // Don't change this company name; it's used in install_sample_data.sql
        $fields['company'] = "Sample Company";
        $fields['title'] = 'Mr';
        $fields['last_name'] = 'John';
        $fields['first_name'] = 'Doe';
        $fields['middle_name'] = '';
        $fields['phone_1'] = '555-555-555';
        $fields['address_1'] = 'PO Box 123';
        $fields['city'] = 'Seattle';
        $fields['zip'] = '98101';
        $fields['virtuemart_state_id'] = '48';
        $fields['virtuemart_country_id'] = '223';
        //Dont change this, atm everything is mapped to mainvendor with id=1
        $fields['user_is_vendor'] = '1';
        $fields['virtuemart_vendor_id'] = '1';
        $fields['vendor_name'] = 'Sample Company';
        //quickndirty hack for vendor_phone
        vRequest::setVar('phone_1', $fields['phone_1']);
        //$fields['vendor_phone'] =  '555-555-1212';
        $fields['vendor_store_name'] = "VirtueMart 3 Sample store";
        $fields['vendor_store_desc'] = '<p>We have the best clothing for up-to-date people. Check it out!</p> <p>We were established in 1869 in a time when getting good clothes was expensive, but the quality was good. Now that only a select few of those authentic clothes survive, we have dedicated this store to bringing the experience alive for collectors and master carrier everywhere.</p> <p>You can easily find products selecting the category you would like to browse above.</p>';
        $fields['virtuemart_media_id'] = 1;
        $fields['vendor_currency'] = '47';
        $fields['vendor_accepted_currencies'] = '52,26,47,144';
        $fields['vendor_terms_of_service'] = '<h5>This is a demo store. Your orders will not proceed. You have not configured any terms of service yet. Click <a href="' . JURI::base(true) . '/index.php?option=com_virtuemart&view=user&task=editshop">here</a> to change this text.</h5>';
        $fields['vendor_url'] = JURI::root();
        $fields['vendor_name'] = 'Sample Company';
        $fields['vendor_legal_info'] = "VAT-ID: XYZ-DEMO<br />Reg.Nr: DEMONUMBER";
        $fields['vendor_letter_css'] = '.vmdoc-header { }
.vmdoc-footer { }
';
        $fields['vendor_letter_header_html'] = '<h1>{vm:vendorname}</h1><p>{vm:vendoraddress}</p>';
        $fields['vendor_letter_header_image'] = '1';
        $fields['vendor_letter_footer_html'] = '{vm:vendorlegalinfo}<br /> Page {vm:pagenum}/{vm:pagecount}';
        if (!class_exists('VirtueMartModelUser')) {
            require VMPATH_ADMIN . DS . 'models' . DS . 'user.php';
        }
        $usermodel = VmModel::getModel('user');
        $usermodel->setId($userId);
        //Save the VM user stuff
        if (!$usermodel->store($fields)) {
            vmError(vmText::_('COM_VIRTUEMART_NOT_ABLE_TO_SAVE_USER_DATA'));
        }
        $filename = VMPATH_ROOT . DS . 'administrator' . DS . 'components' . DS . 'com_virtuemart' . DS . 'install' . DS . 'install_sample_data.sql';
        if (!VmConfig::$vmlang) {
            $params = JComponentHelper::getParams('com_languages');
            $lang = $params->get('site', 'en-GB');
            //use default joomla
            $lang = strtolower(strtr($lang, '-', '_'));
        } else {
            $lang = VmConfig::$vmlang;
        }
        if (!$this->execSQLFile($filename)) {
            vmError(vmText::_('Problems execution of SQL File ' . $filename));
        } else {
            //update jplugin_id from shipment and payment
            $db = JFactory::getDBO();
            $q = 'SELECT `extension_id` FROM #__extensions WHERE element = "weight_countries" AND folder = "vmshipment"';
            $db->setQuery($q);
            $shipment_plg_id = $db->loadResult();
            if (!empty($shipment_plg_id)) {
                $q = 'INSERT INTO `#__virtuemart_shipmentmethods` (`virtuemart_shipmentmethod_id`, `virtuemart_vendor_id`, `shipment_jplugin_id`, `shipment_element`, `shipment_params`, `ordering`, `shared`, `published`, `created_on`, `created_by`, `modified_on`, `modified_by`, `locked_on`, `locked_by`) VALUES
			(1, 1, ' . $shipment_plg_id . ', "weight_countries", \'shipment_logos=""|countries=""|zip_start=""|zip_stop=""|weight_start=""|weight_stop=""|weight_unit="KG"|nbproducts_start=0|nbproducts_stop=0|orderamount_start=""|orderamount_stop=""|cost="0"|package_fee="2.49"|tax_id="0"|free_shipment="500"|\', 0, 0, 1, "0000-00-00 00:00:00", 0,  "0000-00-00 00:00:00", 0,  "0000-00-00 00:00:00", 0)';
                $db->setQuery($q);
                $db->execute();
                $q = 'INSERT INTO `#__virtuemart_shipmentmethods_' . $lang . '` (`virtuemart_shipmentmethod_id`, `shipment_name`, `shipment_desc`, `slug`) VALUES (1, "Self pick-up", "", "Self-pick-up")';
                $db->setQuery($q);
                $db->execute();
                //Create table of the plugin
                if (JVM_VERSION != 1) {
                    $url = '/plugins/vmshipment/weight_countries';
                } else {
                    $url = '/plugins/vmshipment';
                }
                if (!class_exists('plgVmShipmentWeight_countries')) {
                    require VMPATH_ROOT . DS . $url . DS . 'weight_countries.php';
                }
                $this->installPluginTable('plgVmShipmentWeight_countries', '#__virtuemart_shipment_plg_weight_countries', 'Shipment Weight Countries Table');
            }
            $q = 'SELECT `extension_id` FROM #__extensions WHERE element = "standard" AND folder = "vmpayment"';
            $db->setQuery($q);
            $payment_plg_id = $db->loadResult();
            if (!empty($payment_plg_id)) {
                $q = 'INSERT INTO `#__virtuemart_paymentmethods` (`virtuemart_paymentmethod_id`, `virtuemart_vendor_id`, `payment_jplugin_id`,  `payment_element`, `payment_params`, `shared`, `ordering`, `published`, `created_on`, `created_by`, `modified_on`, `modified_by`, `locked_on`, `locked_by`) VALUES
			(1, 1, ' . $payment_plg_id . ',  "standard", \'payment_logos=""|countries=""|payment_currency="0"|status_pending="U"|send_invoice_on_order_null="1"|min_amount=""|max_amount=""|cost_per_transaction="0.10"|cost_percent_total="1.5"|tax_id="0"|payment_info=""|\', 0, 0, 1,  "0000-00-00 00:00:00", 0,  "0000-00-00 00:00:00", 0,  "0000-00-00 00:00:00", 0)';
                $db->setQuery($q);
                $db->execute();
                $q = "INSERT INTO `#__virtuemart_paymentmethods_" . $lang . "` (`virtuemart_paymentmethod_id`, `payment_name`, `payment_desc`, `slug`) VALUES\t(1, 'Cash on delivery', '', 'Cash-on-delivery')";
                $db->setQuery($q);
                $db->execute();
                if (JVM_VERSION != 1) {
                    $url = '/plugins/vmpayment/standard';
                } else {
                    $url = '/plugins/vmpayment';
                }
                if (!class_exists('plgVmPaymentStandard')) {
                    require VMPATH_ROOT . DS . $url . DS . 'standard.php';
                }
                $this->installPluginTable('plgVmPaymentStandard', '#__virtuemart_payment_plg_standard', 'Payment Standard Table');
            }
            vmInfo(vmText::_('COM_VIRTUEMART_SAMPLE_DATA_INSTALLED'));
        }
        return true;
    }
Exemple #27
0
 public function display($tpl = null)
 {
     $app = JFactory::getApplication();
     $this->prepareContinueLink();
     if (VmConfig::get('use_as_catalog', 0)) {
         vmInfo('This is a catalogue, you cannot access the cart');
         $app->redirect($this->continue_link);
     }
     $pathway = $app->getPathway();
     $document = JFactory::getDocument();
     $document->setMetaData('robots', 'NOINDEX, NOFOLLOW, NOARCHIVE, NOSNIPPET');
     $layoutName = $this->getLayout();
     if (!$layoutName) {
         $layoutName = vRequest::getCmd('layout', 'default');
     }
     $this->assignRef('layoutName', $layoutName);
     $format = vRequest::getCmd('format');
     if (!class_exists('VirtueMartCart')) {
         require VMPATH_SITE . DS . 'helpers' . DS . 'cart.php';
     }
     $this->cart = VirtueMartCart::getCart();
     $this->cart->prepareVendor();
     //Why is this here, when we have view.raw.php
     if ($format == 'raw') {
         vRequest::setVar('layout', 'mini_cart');
         $this->setLayout('mini_cart');
         $this->prepareContinueLink();
     }
     if ($layoutName == 'select_shipment') {
         $this->cart->prepareCartData();
         $this->lSelectShipment();
         $pathway->addItem(vmText::_('COM_VIRTUEMART_CART_OVERVIEW'), JRoute::_('index.php?option=com_virtuemart&view=cart', FALSE));
         $pathway->addItem(vmText::_('COM_VIRTUEMART_CART_SELECTSHIPMENT'));
         $document->setTitle(vmText::_('COM_VIRTUEMART_CART_SELECTSHIPMENT'));
     } else {
         if ($layoutName == 'select_payment') {
             $this->cart->prepareCartData();
             $this->lSelectPayment();
             $pathway->addItem(vmText::_('COM_VIRTUEMART_CART_OVERVIEW'), JRoute::_('index.php?option=com_virtuemart&view=cart', FALSE));
             $pathway->addItem(vmText::_('COM_VIRTUEMART_CART_SELECTPAYMENT'));
             $document->setTitle(vmText::_('COM_VIRTUEMART_CART_SELECTPAYMENT'));
         } else {
             if ($layoutName == 'order_done') {
                 VmConfig::loadJLang('com_virtuemart_shoppers', true);
                 $this->lOrderDone();
                 $pathway->addItem(vmText::_('COM_VIRTUEMART_CART_THANKYOU'));
                 $document->setTitle(vmText::_('COM_VIRTUEMART_CART_THANKYOU'));
             } else {
                 VmConfig::loadJLang('com_virtuemart_shoppers', true);
                 $this->renderCompleteAddressList();
                 if (!class_exists('VirtueMartModelUserfields')) {
                     require VMPATH_ADMIN . DS . 'models' . DS . 'userfields.php';
                 }
                 $userFieldsModel = VmModel::getModel('userfields');
                 $userFieldsCart = $userFieldsModel->getUserFields('cart', array('captcha' => true, 'delimiters' => true), array('delimiter_userinfo', 'user_is_vendor', 'username', 'password', 'password2', 'agreed', 'address_type'));
                 $this->userFieldsCart = $userFieldsModel->getUserFieldsFilled($userFieldsCart, $this->cart->cartfields);
                 if (!class_exists('CurrencyDisplay')) {
                     require VMPATH_ADMIN . DS . 'helpers' . DS . 'currencydisplay.php';
                 }
                 $currencyDisplay = CurrencyDisplay::getInstance($this->cart->pricesCurrency);
                 $this->assignRef('currencyDisplay', $currencyDisplay);
                 $customfieldsModel = VmModel::getModel('Customfields');
                 $this->assignRef('customfieldsModel', $customfieldsModel);
                 $this->lSelectCoupon();
                 $totalInPaymentCurrency = $this->getTotalInPaymentCurrency();
                 $checkoutAdvertise = $this->getCheckoutAdvertise();
                 if ($this->cart->getDataValidated()) {
                     if ($this->cart->_inConfirm) {
                         $pathway->addItem(vmText::_('COM_VIRTUEMART_CANCEL_CONFIRM_MNU'));
                         $document->setTitle(vmText::_('COM_VIRTUEMART_CANCEL_CONFIRM_MNU'));
                         $text = vmText::_('COM_VIRTUEMART_CANCEL_CONFIRM');
                         $this->checkout_task = 'cancel';
                     } else {
                         $pathway->addItem(vmText::_('COM_VIRTUEMART_ORDER_CONFIRM_MNU'));
                         $document->setTitle(vmText::_('COM_VIRTUEMART_ORDER_CONFIRM_MNU'));
                         $text = vmText::_('COM_VIRTUEMART_ORDER_CONFIRM_MNU');
                         $this->checkout_task = 'confirm';
                     }
                 } else {
                     $pathway->addItem(vmText::_('COM_VIRTUEMART_CART_OVERVIEW'));
                     $document->setTitle(vmText::_('COM_VIRTUEMART_CART_OVERVIEW'));
                     $text = vmText::_('COM_VIRTUEMART_CHECKOUT_TITLE');
                     $this->checkout_task = 'checkout';
                 }
                 $this->checkout_link_html = '<button type="submit"  id="checkoutFormSubmit" name="' . $this->checkout_task . '" value="1" class="vm-button-correct" ><span>' . $text . '</span> </button>';
                 if (VmConfig::get('oncheckout_opc', 1)) {
                     if (!class_exists('vmPSPlugin')) {
                         require JPATH_VM_PLUGINS . DS . 'vmpsplugin.php';
                     }
                     JPluginHelper::importPlugin('vmshipment');
                     JPluginHelper::importPlugin('vmpayment');
                     $this->lSelectShipment();
                     $this->lSelectPayment();
                 } else {
                     $this->checkPaymentMethodsConfigured();
                     $this->checkShipmentMethodsConfigured();
                 }
                 if ($this->cart->virtuemart_shipmentmethod_id) {
                     $shippingText = vmText::_('COM_VIRTUEMART_CART_CHANGE_SHIPPING');
                 } else {
                     $shippingText = vmText::_('COM_VIRTUEMART_CART_EDIT_SHIPPING');
                 }
                 $this->assignRef('select_shipment_text', $shippingText);
                 if ($this->cart->virtuemart_paymentmethod_id) {
                     $paymentText = vmText::_('COM_VIRTUEMART_CART_CHANGE_PAYMENT');
                 } else {
                     $paymentText = vmText::_('COM_VIRTUEMART_CART_EDIT_PAYMENT');
                 }
                 $this->assignRef('select_payment_text', $paymentText);
                 $this->cart->prepareAddressFieldsInCart();
                 $layoutName = $this->cart->layout;
                 //set order language
                 $lang = JFactory::getLanguage();
                 $order_language = $lang->getTag();
                 $this->assignRef('order_language', $order_language);
             }
         }
     }
     $this->useSSL = VmConfig::get('useSSL', 0);
     $this->useXHTML = false;
     $this->assignRef('totalInPaymentCurrency', $totalInPaymentCurrency);
     $this->assignRef('checkoutAdvertise', $checkoutAdvertise);
     shopFunctionsF::setVmTemplate($this, 0, 0, $layoutName);
     //We never want that the cart is indexed
     $document->setMetaData('robots', 'NOINDEX, NOFOLLOW, NOARCHIVE, NOSNIPPET');
     if ($this->cart->_inConfirm) {
         vmInfo('COM_VIRTUEMART_IN_CONFIRM');
     }
     if ($this->cart->layoutPath) {
         $this->addTemplatePath($this->cart->layoutPath);
     }
     $current = JFactory::getUser();
     $this->allowChangeShopper = false;
     if (VmConfig::get('oncheckout_change_shopper')) {
         if ($current->authorise('core.admin', 'com_virtuemart') or $current->authorise('vm.user', 'com_virtuemart')) {
             $this->allowChangeShopper = true;
         } else {
             $adminID = JFactory::getSession()->get('vmAdminID', false);
             if ($adminID) {
                 $adminIdUser = JFactory::getUser($adminID);
                 if ($adminIdUser->authorise('core.admin', 'com_virtuemart') or $adminIdUser->authorise('vm.user', 'com_virtuemart')) {
                     $this->allowChangeShopper = true;
                 }
             }
         }
     }
     parent::display($tpl);
 }
Exemple #28
0
 private function creditMemo($data)
 {
     $orderModel = VmModel::getModel('orders');
     $orderDetails = $orderModel->getOrder($data->virtuemart_order_id);
     $calc = $this->getOrderCalc($orderDetails);
     if (!$calc) {
         return false;
     }
     if (!is_array($calc['avatax_virtuemart_country_id'])) {
         $calc['avatax_virtuemart_country_id'] = json_decode($calc['avatax_virtuemart_country_id'], true);
     }
     if ($calc['activated'] == 0) {
         avadebug('Avatax creditMemo rule not activated', $calc);
         return false;
     }
     if ($calc['accrual'] and $data->order_status != 'R') {
         avadebug('Avatax creditMemo, type is accrual and not a Refund', $calc);
         return false;
     }
     if (!class_exists('TaxServiceSoap')) {
         require VMAVALARA_CLASS_PATH . DS . 'TaxServiceSoap.class.php';
     }
     if (!class_exists('DocumentType')) {
         require VMAVALARA_CLASS_PATH . DS . 'DocumentType.class.php';
     }
     if (!class_exists('DetailLevel')) {
         require VMAVALARA_CLASS_PATH . DS . 'DetailLevel.class.php';
     }
     if (!class_exists('Line')) {
         require VMAVALARA_CLASS_PATH . DS . 'Line.class.php';
     }
     if (!class_exists('ServiceMode')) {
         require VMAVALARA_CLASS_PATH . DS . 'ServiceMode.class.php';
     }
     if (!class_exists('Line')) {
         require VMAVALARA_CLASS_PATH . DS . 'Line.class.php';
     }
     if (!class_exists('GetTaxResult')) {
         require VMAVALARA_CLASS_PATH . DS . 'GetTaxResult.class.php';
     }
     $this->addresses = $this->fillValidateAvalaraAddress($calc, $orderDetails['details']['BT']);
     if (!$this->addresses) {
         vmdebug('Avatax: on order status update: no valid addresses');
         return false;
     }
     if (is_object($orderDetails['details']['BT'])) {
         self::$vmadd = get_object_vars($orderDetails['details']['BT']);
     } else {
         self::$vmadd = $orderDetails['details']['BT'];
     }
     $toInvoice = VmConfig::get('inv_os', array('C'));
     if (!is_array($toInvoice)) {
         $toInvoice = (array) $toInvoice;
     }
     //Lets find first if the committ was already done, the committ was already done, if one of history orderstatuses
     //have one status for create invoice.
     //vmdebug('my orderDetails ',$orderDetails);
     self::$vmadd['taxOverride'] = null;
     foreach ($orderDetails['history'] as $item) {
         if (in_array($item->order_status_code, $toInvoice)) {
             //the date of the order status used to create the invoice
             self::$vmadd['taxOverride'] = $this->createTaxOverride(substr($item->created_on, 0, 10), $data->order_status, $item->comments);
             //self::$vmadd['paymentDate'] = substr($item->created_on,0,10);
             //Date when order is created
             //self::$vmadd['taxOverride'] = $orderDetails['details']['BT']->created_on;
             break;
         }
     }
     //Accrual Accounting means the committ is done directly after pressing the confirm button in the cart
     //Therefore the date of the committ/invoice is the first order date and we dont need to check the order history
     if (empty(self::$vmadd['taxOverride']) and $calc['accrual']) {
         self::$vmadd['taxOverride'] = $this->createTaxOverride($orderDetails['details']['BT']->created_on, $data->order_status);
     }
     //create the products
     $products = array();
     foreach ($orderDetails['items'] as $k => $item) {
         $product = array();
         $item = (array) $item;
         //vmdebug('my item',$item);
         $product['product_sku'] = $item['order_item_sku'];
         $product['product_name'] = $item['order_item_name'];
         $product['amount'] = $item['product_quantity'];
         //$product['price'] = $item['product_final_price'];
         $product['price'] = $item['product_item_price'];
         $product['discount'] = $item['product_subtotal_discount'];
         $model = VmModel::getModel('product');
         $rProduct = $model->getProduct($item['virtuemart_product_id']);
         $product['categories'] = $rProduct->categories;
         $products[] = $product;
     }
     if (!empty($orderDetails['details']['BT']->virtuemart_shipmentmethod_id)) {
         $shipment = array();
         $shipment['product_sku'] = 'VMShipmentId_' . $orderDetails['details']['BT']->virtuemart_shipmentmethod_id;
         $shipmentModel = VmModel::getModel('Shipmentmethod');
         $shipmentModel->setId($orderDetails['details']['BT']->virtuemart_shipmentmethod_id);
         $shipmentMethod = $shipmentModel->getShipment();
         $shipment['product_name'] = $shipmentMethod->shipment_name;
         $shipment['amount'] = 1;
         $shipment['price'] = $orderDetails['details']['BT']->order_shipment;
         //decimal // TotalAmmount
         $shipment['discount'] = 0.0;
         $products[] = $shipment;
     }
     $products['discountAmount'] = $orderDetails['details']['BT']->order_discountAmount - $orderDetails['details']['BT']->coupon_discount;
     if ($data->order_status == 'R') {
         $sign = -1;
     } else {
         $sign = 1;
     }
     $request = $this->createStandardRequest($calc, $products, $sign);
     $request->setCompanyCode($calc['company_code']);
     // Your Company Code From the Dashboard
     $request->setDocDate(date('Y-m-d'));
     //date
     $request->setCustomerCode($orderDetails['details']['BT']->customer_number);
     //string Required
     if ($orderDetails['details']['BT']->order_number) {
         $request->setPurchaseOrderNo($orderDetails['details']['BT']->order_number);
         //string Optional
     }
     $totalTax = 0.0;
     $invoiceNumber = 'onr_' . $orderDetails['details']['BT']->order_number;
     vRequest::setVar('create_invoice', 1);
     $orderModel->createInvoiceNumber($orderDetails['details']['BT'], $invoiceNumber);
     if (is_array($invoiceNumber)) {
         $invoiceNumber = $invoiceNumber[0];
     }
     if ($calc['committ'] and $invoiceNumber) {
         if ($data->order_status == 'R') {
             $request->setDocType(DocumentType::$ReturnInvoice);
         } else {
             $request->setDocType(DocumentType::$SalesInvoice);
         }
         // Only supported types are SalesInvoice or SalesOrder
         $request->setCommit(true);
         $request->setDocCode($invoiceNumber);
         self::$_taxResult = FALSE;
     }
     vmSetStartTime('avagetTax');
     self::$_taxResult = $this->executeRequest($request);
     vmTime('Avalara executeRequest ', 'avagetTax');
     if (self::$_taxResult) {
         if (isset(self::$_taxResult['totalTax'])) {
             $totalTax = self::$_taxResult['totalTax'];
         }
     }
     return $totalTax;
 }
 /**
  * @param $cart
  * @param $order
  * @return bool|null
  */
 public function plgVmConfirmedOrder($cart, $order)
 {
     if (!($this->_currentMethod = $this->getVmPluginMethod($order['details']['BT']->virtuemart_paymentmethod_id))) {
         return NULL;
         // Another method was selected, do nothing
     }
     if (!$this->selectedThisElement($this->_currentMethod->payment_element)) {
         return FALSE;
     }
     if (!class_exists('VirtueMartModelOrders')) {
         require VMPATH_ADMIN . DS . 'models' . DS . 'orders.php';
     }
     if (!class_exists('VirtueMartModelCurrency')) {
         require VMPATH_ADMIN . DS . 'models' . DS . 'currency.php';
     }
     //$this->setInConfirmOrder($cart);
     $email_currency = $this->getEmailCurrency($this->_currentMethod);
     $payment_name = $this->renderPluginName($this->_currentMethod, 'order');
     $realexInterface = $this->_loadRealexInterface();
     $realexInterface->loadCustomerData();
     $realexInterface->debugLog('order number: ' . $order['details']['BT']->order_number, 'plgVmConfirmedOrder', 'debug');
     $realexInterface->setCart($cart);
     /*
     if (!$realexInterface->validateConfirmedOrder()) {
     	vmInfo('VMPAYMENT_REALEX_HPP_API_PLEASE_SELECT_OPTION');
     	return false;
     }
     */
     $realexInterface->setOrder($order);
     $realexInterface->setPaymentCurrency();
     $realexInterface->setTotalInPaymentCurrency($order['details']['BT']->order_total);
     // Prepare data that should be stored in the database
     $dbValues['order_number'] = $order['details']['BT']->order_number;
     $dbValues['payment_name'] = str_replace(array('\\t', '\\n'), '', $payment_name);
     $dbValues['virtuemart_paymentmethod_id'] = $cart->virtuemart_paymentmethod_id;
     $dbValues['realex_hpp_api_custom'] = $realexInterface->getContext();
     $dbValues['cost_per_transaction'] = $this->_currentMethod->cost_per_transaction;
     $dbValues['cost_percent_total'] = $this->_currentMethod->cost_percent_total;
     $dbValues['payment_currency'] = $realexInterface->getPaymentCurrency();
     $dbValues['email_currency'] = $email_currency;
     $dbValues['payment_order_total'] = $realexInterface->getTotalInPaymentCurrency();
     $dbValues['tax_id'] = $this->_currentMethod->tax_id;
     $this->storePSPluginInternalData($dbValues);
     VmConfig::loadJLang('com_virtuemart_orders', TRUE);
     $selectedCCParams = array();
     if ($this->_currentMethod->integration == 'redirect') {
         if (!$realexInterface->doRealvault($selectedCCParams)) {
             $html = $realexInterface->sendPostRequest();
             vRequest::setVar('html', $html);
             $cart->_confirmDone = FALSE;
             $cart->_dataValidated = FALSE;
             $cart->setCartIntoSession();
         } else {
             if (!JFactory::getUser()->guest and $this->_currentMethod->realvault) {
                 $remoteCCFormParams = $realexInterface->getRemoteCCFormParams();
                 $html = $this->renderByLayout('remote_cc_form', $remoteCCFormParams);
                 vRequest::setVar('html', $html);
                 vRequest::setVar('display_title', false);
                 return;
             }
             $response = $realexInterface->requestReceiptIn($selectedCCParams);
             $request_type = $realexInterface->request_type . '_request';
             $this->_storeRealexInternalData($realexInterface->xml_request, $this->_currentMethod->virtuemart_paymentmethod_id, $order['details']['BT']->virtuemart_order_id, $order['details']['BT']->order_number, $request_type);
             $realexInterface->manageResponseRequestReceiptIn($response);
             $xml_response = simplexml_load_string($response);
             $success = $realexInterface->isResponseSuccess($xml_response);
             if ($success) {
                 $status = $this->_currentMethod->status_success;
                 $amountInCurrency = vmPSPlugin::getAmountInCurrency($order['details']['BT']->order_total, $order['details']['BT']->order_currency);
                 $currencyDisplay = CurrencyDisplay::getInstance($cart->pricesCurrency);
                 $order_history['comments'] = vmText::sprintf('VMPAYMENT_REALEX_HPP_API_PAYMENT_STATUS_CONFIRMED', $amountInCurrency['display'], $order['details']['BT']->order_number);
             } else {
                 $order_history['comments'] = vmText::_('VMPAYMENT_REALEX_HPP_API_PAYMENT_STATUS_CANCELLED');
                 $status = $this->_currentMethod->status_canceled;
             }
             $order_history['customer_notified'] = true;
             $order_history['order_status'] = $status;
             $modelOrder = VmModel::getModel('orders');
             $modelOrder->updateStatusForOneOrder($order['details']['BT']->virtuemart_order_id, $order_history, TRUE);
             $payments = $this->getDatasByOrderId($realexInterface->order['details']['BT']->virtuemart_order_id);
             $params = $realexInterface->getResponseParams($payments);
             $params['payment_name'] = $this->renderPluginName($this->_currentMethod, 'order');
             $html = $this->renderByLayout('response', $params);
             vRequest::setVar('html', $html);
             $this->customerData->clear();
             if ($success) {
                 if (isset($payments[0]->realex_hpp_api_custom)) {
                     $cart->emptyCart();
                 }
             }
         }
     } else {
         $remoteCCFormParams = $realexInterface->getRemoteCCFormParams();
         $html = $this->renderByLayout('remote_cc_form', $remoteCCFormParams);
         vRequest::setVar('html', $html);
         vRequest::setVar('display_title', false);
     }
     return true;
 }
Exemple #30
0
 /**
  *
  *
  * @author Valérie Isaksen
  */
 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;
     }
     VmConfig::loadJLang('com_virtuemart', true);
     if (!class_exists('VirtueMartModelOrders')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php';
     }
     $this->getPaymentCurrency($method);
     $currency_code_3 = shopFunctions::getCurrencyByID($method->payment_currency, 'currency_code_3');
     $email_currency = $this->getEmailCurrency($method);
     $totalInPaymentCurrency = vmPSPlugin::getAmountInCurrency($order['details']['BT']->order_total, $method->payment_currency);
     $dbValues['payment_name'] = $this->renderPluginName($method) . '<br />' . $method->payment_info;
     $dbValues['order_number'] = $order['details']['BT']->order_number;
     $dbValues['virtuemart_paymentmethod_id'] = $order['details']['BT']->virtuemart_paymentmethod_id;
     $dbValues['cost_per_transaction'] = $method->cost_per_transaction;
     $dbValues['cost_percent_total'] = $method->cost_percent_total;
     $dbValues['payment_currency'] = $currency_code_3;
     $dbValues['email_currency'] = $email_currency;
     $dbValues['payment_order_total'] = $totalInPaymentCurrency['value'];
     $dbValues['tax_id'] = $method->tax_id;
     $this->storePSPluginInternalData($dbValues);
     $html = '<table class="vmorder-done">' . "\n";
     $html .= $this->getHtmlRow('STANDARD_PAYMENT_INFO', $dbValues['payment_name'], 'class="vmorder-done-payinfo"');
     if (!empty($payment_info)) {
         $lang = JFactory::getLanguage();
         if ($lang->hasKey($method->payment_info)) {
             $payment_info = vmText::_($method->payment_info);
         } else {
             $payment_info = $method->payment_info;
         }
         $html .= $this->getHtmlRow('STANDARD_PAYMENTINFO', $payment_info, 'class="vmorder-done-payinfo"');
     }
     if (!class_exists('VirtueMartModelCurrency')) {
         require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'currency.php';
     }
     $currency = CurrencyDisplay::getInstance('', $order['details']['BT']->virtuemart_vendor_id);
     $html .= $this->getHtmlRow('STANDARD_ORDER_NUMBER', $order['details']['BT']->order_number, 'class="vmorder-done-nr"');
     $html .= $this->getHtmlRow('STANDARD_AMOUNT', $currency->priceDisplay($order['details']['BT']->order_total), 'class="vmorder-done-amount"');
     if ($method->payment_currency != $order['details']['BT']->order_currency) {
         $html .= $this->getHtmlRow('COM_VIRTUEMART_CART_TOTAL_PAYMENT', $totalInPaymentCurrency['display'], 'class="vmorder-done-amount"');
     }
     //$html .= $this->getHtmlRow('STANDARD_INFO', $method->payment_info);
     //$html .= $this->getHtmlRow('STANDARD_AMOUNT', $totalInPaymentCurrency.' '.$currency_code_3);
     $html .= '</table>' . "\n";
     $modelOrder = VmModel::getModel('orders');
     $order['order_status'] = $this->getNewStatus($method);
     $order['customer_notified'] = 1;
     $order['comments'] = '';
     $modelOrder->updateStatusForOneOrder($order['details']['BT']->virtuemart_order_id, $order, TRUE);
     //We delete the old stuff
     $cart->emptyCart();
     vRequest::setVar('html', $html);
     return TRUE;
 }