コード例 #1
0
ファイル: fondy.php プロジェクト: cloudipsp/virtuemart
   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;
       }
       include_once dirname(__FILE__) . DS . "/Fondy.cls.php";
       if (!class_exists('VirtueMartModelCurrency')) {
           require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'currency.php';
       }
       JFactory::getLanguage()->load($filename = 'com_virtuemart', JPATH_ADMINISTRATOR);
       $vendorId = 0;
       $html = "";
       if (!class_exists('VirtueMartModelOrders')) {
           require JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'orders.php';
       }
       $this->getPaymentCurrency($method);
       if ($method->FONDY_SYSTEM_CURRENCY == 1) {
           $currencyModel = new VirtueMartModelCurrency();
           $currencyObj = $currencyModel->getCurrency($order['details']['BT']->order_currency);
           $currency = $currencyObj->currency_code_3;
       } else {
           switch ($method->FONDY_COUNTRY) {
               case "RU":
                   $currency = "RUB";
                   break;
               case "EN":
                   $currency = "USD";
                   break;
               default:
                   $currency = "UAH";
                   break;
           }
       }
       list($lang, ) = explode('-', JFactory::getLanguage()->getTag());
       $paymentMethodID = $order['details']['BT']->virtuemart_paymentmethod_id;
       $responseUrl = JROUTE::_(JURI::root() . 'index.php?option=com_virtuemart&view=pluginresponse&task=pluginnotification&tmpl=component&pm=' . $paymentMethodID);
       $callbackUrl = JROUTE::_(JURI::root() . 'index.php?option=com_virtuemart&view=pluginresponse&task=pluginnotification&tmpl=component&pm=' . $paymentMethodID);
       $user =& $cart->BT;
       $formFields = array('order_id' => $cart->order_number . Fondy::ORDER_SEPARATOR . time(), 'merchant_id' => $method->FONDY_MERCHANT, 'order_desc' => $cart->order_number, 'amount' => Fondy::getAmount($order), 'currency' => $currency, 'server_callback_url' => $callbackUrl, 'response_url' => $responseUrl, 'lang' => strtoupper($lang), 'sender_email' => $user['email']);
       $formFields['signature'] = Fondy::getSignature($formFields, $method->FONDY_SECRET_KEY);
       $fondyArgsArray = array();
       foreach ($formFields as $key => $value) {
           $fondyArgsArray[] = "<input type='hidden' name='{$key}' value='{$value}'/>";
       }
       $html = '	<form action="' . Fondy::URL . '" method="post" id="fondy_payment_form">
 				' . implode('', $fondyArgsArray) . '</form>' . "<div><img src='https://fondy.eu/img/loader.gif' width='50px' style='margin:20px 20px;'></div>" . "<script> setTimeout(function() {\n                 document.getElementById('fondy_payment_form').submit();\n             }, 100);\n            </script>";
       // 	2 = don't delete the cart, don't send email and don't redirect
       return $this->processConfirmedOrderPaymentResponse(2, $cart, $order, $html, '');
   }
コード例 #2
0
ファイル: clasf_feed.php プロジェクト: alesconti/FF_2015
            $origcurrency = $v['value'];
        }
    }
    $origcurrency = $origcurrency != "" ? $origcurrency : "EUR";
    $RATES[$origcurrency] = 1;
}
// ALCON permette la definizione di feed in lingue differenti
$p_lang = @$_GET['lang'] != "" ? @$_GET['lang'] : "it-IT";
$lang =& JFactory::getLanguage();
$lang->setLanguage($p_lang);
$lang->load();
$tagging_params = @$_GET['tagging_params'] != "" ? urldecode($_GET['tagging_params']) : "utm_source=tradetracker-" . substr($p_lang, 0, 2) . "&utm_medium=pxp";
$cat = new VirtuemartModelCategory();
$product = new VirtueMartModelProduct();
$image = new VirtueMartModelMedia();
$currency = new VirtueMartModelCurrency();
// Pagination and limit settings
$pagination = "off";
if (isset($_GET['pg']) && @$_GET['pg'] > 0) {
    $_step = $limit > 0 ? $limit : 1;
    $_start = ($_GET['pg'] - 1) * $_step;
    $_start = $_start >= 0 ? $_start : 0;
    $_end = $_start + $_step - 1;
    $pagination = "on";
}
if ($limit > 0 && $pagination == "on") {
    $product->_noLimit = true;
    $nbrReturnProducts = false;
} elseif ($limit > 0) {
    print $limit . " " . $nbrReturnProducts;
    $product->_noLimit = false;
コード例 #3
0
ファイル: payzen.php プロジェクト: xenten/swift-kanban
	/**
	 * Prepare data and redirect to PayZen payment platform
	 *
	 * @param string $order_number
	 * @param object $orderData
	 * @param string $return_context the session id
	 * @param string $html the form to display
	 * @param bool   $new_status false if it should not be changed, otherwise new staus
	 * @return NULL
	 */
	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;
		}

		$this->_debug = $method->debug; // enable debug
		$session = JFactory::getSession ();
		$return_context = $session->getId ();

		$this->logInfo ('plgVmOnConfirmedOrderGetPaymentForm -- order number: ' . $order['details']['BT']->order_number, 'message');

		if (!class_exists ('VadsApi')) {
			require(JPATH_VMPAYMENTPLUGIN . DS . 'payzen' . DS . 'payzen_api.php');
		}

		$api = new VadsApi('UTF-8');

		// set config parameters
		$paramNames = array(
			'platform_url', 'key_test', 'key_prod', 'capture_delay', 'ctx_mode', 'site_id',
			'validation_mode', 'redirect_enabled', 'redirect_success_timeout', 'redirect_success_message',
			'redirect_error_timeout', 'redirect_error_message', 'return_mode'
		);
		foreach ($paramNames as $name) {
			$api->set ($name, $method->$name);
		}

		// Set urls
		$url_return = JROUTE::_ (JURI::root () . 'index.php?option=com_virtuemart&view=pluginresponse&task=pluginresponsereceived');
		$uri = JURI::getInstance ($url_return);
		//$uri->setVar('pelement', $this->payment_element);
		$uri->setVar ('pm', $order['details']['BT']->virtuemart_paymentmethod_id);
		$uri->setVar ('Itemid', JRequest::getInt ('Itemid'));
		$api->set ('url_return', $uri->toString ());

		$url_success = JROUTE::_ (JURI::root () . 'index.php?option=com_virtuemart&view=pluginresponse&task=pluginresponsereceived');
		$uri = JURI::getInstance ($url_success);
		//$uri->setVar('pelement', $this->payment_element);
		$uri->setVar ('Itemid', JRequest::getInt ('Itemid'));
		$uri->setVar ('pm', $order['details']['BT']->virtuemart_paymentmethod_id);
		$api->set ('url_success', $uri->toString ());

		$url_cancel = JROUTE::_ (JURI::root () . 'index.php?option=com_virtuemart&view=pluginresponse&task=pluginUserPaymentCancel');
		$uri = JURI::getInstance ($url_cancel);
		$uri->setVar ('on', $order['details']['BT']->order_number);
		$uri->setVar ('pm', $order['details']['BT']->virtuemart_paymentmethod_id);
		$uri->setVar ('Itemid', JRequest::getInt ('Itemid'));
		$api->set ('url_cancel', $uri->toString ());

		// Set the language code
		$lang = JFactory::getLanguage ();
		$lang->load ('plg_vmpayment_' . $this->_name, JPATH_ADMINISTRATOR);

		$tag = substr ($lang->get ('tag'), 0, 2);
		$language = in_array ($tag, $api->getSupportedLanguages ()) ? $tag : ($method->language ? $method->language : 'fr');
		$api->set ('language', $language);

		// Set currency
		if (!class_exists ('VirtueMartModelCurrency')) {
			require(JPATH_VM_ADMINISTRATOR . DS . 'models' . DS . 'currency.php');
		}
		$currencyModel = new VirtueMartModelCurrency();
		$currencyObj = $currencyModel->getCurrency ($order['details']['BT']->order_currency);

		$currency = $api->findCurrencyByNumCode ($currencyObj->currency_numeric_code);
		if ($currency == NULL) {
			$this->logInfo ('plgVmOnConfirmedOrderGetPaymentForm -- Could not find currency numeric code for currency : ' . $currencyObj->currency_numeric_code, 'error');
			vmInfo (JText::_ ('VMPAYMENT_' . $this->_name . '_CURRENCY_NOT_SUPPORTED'));
			return NULL;
		}
		$api->set ('currency', $currency->num);

		// payment_cards may be one value or array
		$cards = $method->payment_cards;
		$cards = !is_array ($cards) ? $cards : (in_array ("", $cards) ? "" : implode (";", $cards));
		$api->set ('payment_cards', $cards);

		// available_languages may be one value or array
		$available_languages = $method->available_languages;
		$available_languages = !is_array ($available_languages) ? $available_languages : (in_array ("", $available_languages) ? "" : implode (";", $available_languages));
		$api->set ('available_languages', $available_languages);

		$api->set ('contrib', 'VirtueMart2.0.0_1.2');

		// Set customer info
		// $usr = JFactory::getUser();
		$usrBT = $order['details']['BT'];
		$usrST = ((isset($order['details']['ST'])) ? $order['details']['ST'] : $order['details']['BT']);

		$api->set ('cust_email', $usrBT->email);
		// $api->set('cust_id', '');
		$api->set ('cust_title', @$usrBT->title);
		$api->set ('cust_first_name', $usrBT->first_name);
		$api->set ('cust_last_name', $usrBT->last_name);
		$api->set ('cust_address', $usrBT->address_1 . ' ' . $usrBT->address_2);
		$api->set ('cust_zip', $usrBT->zip);
		$api->set ('cust_city', $usrBT->city);
		$api->set ('cust_state', @ShopFunctions::getStateByID ($usrBT->virtuemart_state_id));
		$api->set ('cust_country', @ShopFunctions::getCountryByID ($usrBT->virtuemart_country_id, 'country_2_code'));
		$api->set ('cust_phone', $usrBT->phone_1);
		$api->set ('cust_cell_phone', $usrBT->phone_2);

		$api->set ('ship_to_first_name', $usrST->first_name);
		$api->set ('ship_to_last_name', $usrST->last_name);
		$api->set ('ship_to_city', $usrST->city);
		$api->set ('ship_to_street', $usrST->address_1);
		$api->set ('ship_to_street2', $usrST->address_2);
		$api->set ('ship_to_state', @ShopFunctions::getStateByID ($usrST->virtuemart_state_id));
		$api->set ('ship_to_country', @ShopFunctions::getCountryByID ($usrST->virtuemart_country_id, 'country_2_code'));
		$api->set ('ship_to_phone_num', $usrST->phone_1);
		$api->set ('ship_to_zip', $usrST->zip);

		// Set order_id
		$api->set ('order_id', $order['details']['BT']->order_number);

		// Set the amount to pay
		$api->set ('amount', round ($order['details']['BT']->order_total * 100));

		// Prepare data that should be stored in the database
		$dbValues['order_number'] = $order['details']['BT']->order_number;
		$dbValues['payment_name'] = $this->renderPluginName ($method, $order);
		$dbValues['virtuemart_paymentmethod_id'] = $cart->virtuemart_paymentmethod_id;
		$dbValues[$this->_name . '_custom'] = $return_context;
		$this->storePSPluginInternalData ($dbValues);

		$this->logInfo ('plgVmOnConfirmedOrderGetPaymentForm -- payment data saved to table ' . $this->_tablename, 'message');

		// echo the redirect form
		$form = '<html><head><meta http-equiv="content-type" content="text/html; charset=utf-8" /><title>Redirection</title></head><body><div style="margin: auto; text-align: center;">';
		$form .= '<p>' . JText::_ ('VMPAYMENT_' . $this->_name . '_PLEASE_WAIT') . '</p>';
		$form .= '<p>' . JText::_ ('VMPAYMENT_' . $this->_name . '_CLICK_BUTTON_IF_NOT_REDIRECTED') . '</p>';
		$form .= '<form action="' . $api->platformUrl . '" method="POST" name="vm_' . $this->_name . '_form" >';
		$form .= '<input type="image" name="submit" src="' . JURI::base (TRUE) . '/images/stories/virtuemart/payment/' . $this->_name . '.jpg" alt="' . JText::_ ('VMPAYMENT_' . $this->_name . '_BTN_ALT') . '" title="' . JText::_ ('VMPAYMENT_PAYZEN_BTN_ALT') . '"/>';
		$form .= $api->getRequestFieldsHtml ();
		$form .= '</form></div>';
		$form .= '<script type="text/javascript">document.forms[0].submit();</script></body></html>';

		$this->logInfo ('plgVmOnConfirmedOrderGetPaymentForm -- user redirected to ' . $this->_name, 'message');

		echo $form;

		$cart->_confirmDone = FALSE;
		$cart->_dataValidated = FALSE;
		$cart->setCartIntoSession ();
		die(); // not save order, not send mail, do redirect
	}