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, ''); }
if ($current_id == $prod_id) { continue; } else { $current_id = $prod_id; } $cat->setId($categoryId); $categoryDetails = $cat->getCategory(); $parents = $categoryDetails->parents; $CATEGORIES_ARR = array(); while (count($parents) > 0) { $CATEGORIES_ARR[] = array_shift($parents)->category_name; } $categoryName = join(" - ", $CATEGORIES_ARR); // Currency $currency->setId($productItem->product_currency); $prod_currency = $currency->getCurrency(); // if (($on_stock_only == "on" && $productItem->product_in_stock > 0) || ((VmConfig::get('check_stock') && $productItem->product_in_stock > 0) || (VmConfig::get('show_out_of_stock_products') && $productItem->product_in_stock = 0) || !VmConfig::get('check_stock'))) { $shippingPrice = null; // ALCON $category_name = $categoryName; $prod_manufacturer = $show_manufacturer == "on" ? $productItem->mf_name : ""; $prod_model = $productItem->intnotes; $prod_name = $prod_manufacturer . ' ' . $productItem->product_name; $prod_desc = $prod_name; //var_dump($productItem); $prod_url = $base_path . str_replace('/it/', '/' . substr($p_lang, 0, 2) . '/', $productItem->link); // var_dump($productItem); // Add GA Tagging parameters to url if ($add_tagging == "on") { $and_param = preg_match("/\\?/", $prod_url) ? "&" : "?"; $prod_url = $prod_url . $and_param . $tagging_params;
/** * 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 }