Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- /**
- *
- * @ This file is created by deZender.Net
- * @ deZender (PHP5 Decoder for ionCube Loader)
- *
- * @ Version : 2.0.0.3
- * @ Author : DeZender
- * @ Release on : 06.05.2013
- * @ Official site : http://DeZender.Net
- *
- */
- if (!(defined("_JEXEC")))
- {
- exit("Restricted access");
- }
- if (!class_exists("vmPSPlugin"))
- {
- require JPATH_VM_PLUGINS . DS . "vmpsplugin.php";
- }
- class plgVmPaymentHellaspay extends vmPSPlugin {
- public static $_this = false;
- private $_vivinstalments = "";
- private $_vivinstalmentsamount = "";
- private $instalmentoptions = "";
- private $instalmentcharge = "";
- private $split_instal_hellaspay = "";
- private $merchant_ref = "";
- private $hellaspay_amount = "";
- private $hellaspay_lang = "";
- private $hellaspay_period = "";
- private $hellaspay_period_note = "";
- private $tm_private_key = "QzIwMTJfVC5DLiB2YW4gZGVyIFZlZXJfd2ViaXQuYno=";
- public function __construct(&$subject, $config) {
- parent::__construct($subject, $config);
- $this->_loggable = true;
- $this->tableFields = array_keys($this->getTableSQLFields());
- $this->_tablepkey = "id";
- $this->_tableId = "id";
- $varsToPush = array("hellaspay_merchant_id" => array("", "char"), "hellaspay_merchant_pass" => array("", "char"), "hellaspay_source" => array("", "char"), "hellaspay_instalments" => array("", "char"), "hellaspay_instalments_charge" => array("", "char"), "hellaspay_production" => array("", "int"), "payment_currency" => array("", "int"), "payment_logos" => array("", "char"), "debug" => array(0, "int"), "status_pending" => array("", "char"), "status_success" => array("", "char"), "status_canceled" => array("", "char"), "language" => array("", "char"), "countries" => array("", "char"), "min_amount" => array("", "int"), "max_amount" => array("", "int"), "cost_per_transaction" => array("", "int"), "cost_percent_total" => array("", "int"), "tax_id" => array(0, "int"));
- $this->setConfigParameterable($this->_configTableFieldName, $varsToPush);
- return;
- }
- public function getVmPluginDropTableSQL() {
- $db = JFactory::getdbo();
- $config = JFactory::getconfig();
- $table = $config->getValue("config.dbprefix") . "virtuemart_payment_plg_hellaspay";
- $db->setQuery("DROP TABLE " . $table);
- return $db->query();
- }
- public function getVmPluginCreateTableSQL() {
- $this->getVmPluginDropTableSQL();
- return $this->createTableSQL("Payment HellasPay Table");
- }
- public function getTableSQLFields() {
- $SQLfields = array("id" => " INT(11) unsigned NOT NULL AUTO_INCREMENT ", "virtuemart_order_id" => " int(1) UNSIGNED DEFAULT NULL", "order_number" => " char(32) DEFAULT NULL", "virtuemart_paymentmethod_id" => " mediumint(1) UNSIGNED DEFAULT NULL", "payment_name" => "varchar(5000)", "payment_order_total" => "decimal(15,5) NOT NULL DEFAULT '0.00000' ", "payment_currency" => "char(3) ", "cost_per_transaction" => " decimal(10,2) DEFAULT NULL ", "cost_percent_total" => " decimal(10,2) DEFAULT NULL ", "tax_id" => " smallint(1) DEFAULT NULL", "hellaspay_custom" => " varchar(255) ", "hellaspay_OrderCode" => " varchar(255) ", "hellaspay_ErrorCode" => " varchar(255) ", "hellaspay_ErrorText" => " varchar(255) ", "hellaspay_ref" => " varchar(255) ", "hellaspay_order_state" => " char(1) DEFAULT NULL", "hellaspay_instalments" => " varchar(5) DEFAULT NULL", "hellaspayresponse_raw" => " varchar(512) DEFAULT NULL");
- return $SQLfields;
- }
- public function plgVmConfirmedOrder($cart, $order) {
- if (!($this->_currentMethod = $this->getVmPluginMethod($order["details"]["BT"]->virtuemart_paymentmethod_id)))
- {
- return NULL;
- }
- if (!$this->selectedThisElement($this->_currentMethod->payment_element))
- {
- return FALSE;
- }
- $session = JFactory::getsession();
- $return_context = $session->getId();
- if (!class_exists("VirtueMartModelOrders"))
- {
- require VMPATH_ADMIN . DS . "models" . DS . "orders.php";
- }
- if (!class_exists("VirtueMartModelCurrency"))
- {
- require VMPATH_ADMIN . DS . "models" . DS . "currency.php";
- }
- $new_status = "";
- $usrBT = $order["details"]["BT"];
- $address = isset($order["details"]["ST"]) ? ($order["details"]["ST"]) : ($order["details"]["BT"]);
- if (!class_exists("TableVendors"))
- {
- require VMPATH_ADMIN . DS . "table" . DS . "vendors.php";
- }
- $vendorModel = VmModel::getmodel("Vendor");
- $vendorModel->setId(1);
- $vendor = $vendorModel->getVendor();
- $vendorModel->addImages($vendor, 1);
- $this->getPaymentCurrency($this->_currentMethod);
- $q = "SELECT `currency_code_3` FROM `#__virtuemart_currencies` WHERE `virtuemart_currency_id`=\"" . $this->_currentMethod->payment_currency . "\" ";
- $db = &JFactory::getdbo();
- $db->setQuery($q);
- $currency_code_3 = $db->loadResult();
- $paymentCurrency = CurrencyDisplay::getinstance($this->_currentMethod->payment_currency);
- $totalInPaymentCurrency = round($paymentCurrency->convertCurrencyTo($this->_currentMethod->payment_currency, $order["details"]["BT"]->order_total, false), 2);
- $cd = CurrencyDisplay::getinstance($cart->pricesCurrency);
- $merchant_id = $this->_getMerchantId($this->_currentMethod);
- if (empty($merchant_id))
- {
- vmInfo(vmText::_("VMPAYMENT_HELLASPAY_MERCHANT_ID_NOT_SET"));
- return false;
- }
- $merchant_pass = $this->_getMerchantPass($this->_currentMethod);
- if (empty($merchant_pass))
- {
- vmInfo(vmText::_("VMPAYMENT_HELLASPAY_MERCHANT_PASS_NOT_SET"));
- return false;
- }
- $merchant_ref = "REF" . substr(md5(uniqid(rand(), true)), 0, 9);
- $TmSecureKey = "d2ViaXQuYnovbGljZW5zZS50eHQ=";
- $hellaspay_amount = number_format($totalInPaymentCurrency, 2, ".", "") * 100;
- $lang = JFactory::getlanguage();
- $this->lang_tag = $lang->getTag();
- if (strtolower($this->lang_tag) == "el-gr")
- {
- $hellaspay_lang = "el-GR";
- }
- else
- {
- $hellaspay_lang = "en-US";
- }
- $this->_getHellaspayIntoSession();
- if (1 < $this->_vivinstalments)
- {
- $hellaspay_period = $this->_vivinstalments;
- $hellaspay_period_note = "- Instalments: " . $this->_vivinstalments;
- }
- else
- {
- $hellaspay_period = "0";
- $hellaspay_period_note = "";
- }
- if (0 < $hellaspay_period)
- {
- $Installments = (int)$hellaspay_period;
- }
- else
- {
- $Installments = "1";
- }
- $postargs = "Amount=" . urlencode($hellaspay_amount) . "&RequestLang=" . urlencode($hellaspay_lang) . "&Email=" . urlencode($order["details"]["BT"]->email) . "&MaxInstallments=" . urlencode($Installments) . "&MerchantTrns=" . urlencode($order["details"]["BT"]->order_number) . "&SourceCode=" . urlencode($this->_currentMethod->hellaspay_source) . "&PaymentTimeOut=300";
- if ($this->_currentMethod->hellaspay_production == "1")
- {
- $curl = curl_init("http://demo.vivapayments.com/api/orders");
- }
- else
- {
- $curl = curl_init("https://www.vivapayments.com/api/orders");
- }
- curl_setopt($curl, CURLOPT_POST, true);
- curl_setopt($curl, CURLOPT_POSTFIELDS, $postargs);
- curl_setopt($curl, CURLOPT_HEADER, false);
- curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
- curl_setopt($curl, CURLOPT_USERPWD, $this->_currentMethod->hellaspay_merchant_id . ":" . $this->_currentMethod->hellaspay_merchant_pass);
- $curlversion = curl_version();
- if (!preg_match("/NSS/", $curlversion["ssl_version"]))
- {
- curl_setopt($curl, CURLOPT_SSL_CIPHER_LIST, "TLSv1");
- }
- if ($this->_currentMethod->hellaspay_production != "1");
- if (!($response = curl_exec($curl)))
- {
- die(curl_error($curl));
- }
- curl_close($curl);
- try
- {
- $resultObj = json_decode($response);
- }
- catch (Exception $e)
- {
- throw new Exception("Result is not a json object (" . $e->getMessage() . ")");
- }
- if ($resultObj->ErrorCode == 0)
- {
- $OrderCode = $resultObj->OrderCode;
- $ErrorCode = $resultObj->ErrorCode;
- $ErrorText = $resultObj->ErrorText;
- }
- else
- {
- throw new Exception("Unable to create order code (" . $resultObj->ErrorText . ")");
- }
- $dbValues["order_number"] = $order["details"]["BT"]->order_number;
- $dbValues["payment_name"] = parent::renderpluginname($this->_currentMethod);
- $dbValues["virtuemart_paymentmethod_id"] = $cart->virtuemart_paymentmethod_id;
- $dbValues["hellaspay_custom"] = $return_context;
- $dbValues["hellaspay_instalments"] = $Installments;
- $dbValues["hellaspay_OrderCode"] = '' . $OrderCode;
- $dbValues["hellaspay_ErrorCode"] = '' . $ErrorCode;
- $dbValues["hellaspay_ErrorText"] = '' . $ErrorText;
- $dbValues["cost_per_transaction"] = $this->_currentMethod->cost_per_transaction;
- $dbValues["cost_percent_total"] = $this->_currentMethod->cost_percent_total;
- $dbValues["payment_currency"] = "978";
- $dbValues["payment_order_total"] = $totalInPaymentCurrency;
- $dbValues["tax_id"] = $this->_currentMethod->tax_id;
- $this->storePSPluginInternalData($dbValues);
- $post_variables = array("Ref" => $OrderCode);
- if ($this->_currentMethod->hellaspay_production == "1")
- {
- $url = "http://demo.vivapayments.com/web/newtransaction.aspx";
- }
- else
- {
- $url = "https://www.vivapayments.com/web/newtransaction.aspx";
- }
- $html = "<html><head><title>Redirection</title></head><body><div style=\"margin: auto; text-align: center;\">";
- $html .= "<form action=\"" . $url . "\" method=\"get\" name=\"vm_hellaspay_form\" >";
- $html .= "<input type=\"submit\" value=\"" . vmText::_("VMPAYMENT_HELLASPAY_REDIRECT_MESSAGE") . "\" />";
- foreach ($post_variables as $name => $value)
- {
- $html .= "<input type=\"hidden\" name=\"" . $name . "\" value=\"" . htmlspecialchars($value) . "\" />";
- continue;
- }
- $html .= "</form></div>";
- $html .= " <script type=\"text/javascript\">";
- $html .= " document.vm_hellaspay_form.submit();";
- $html .= " </script></body></html>";
- return $this->processConfirmedOrderPaymentResponse(2, $cart, $order, $html, $dbValues["payment_name"], $new_status);
- }
- public function plgVmgetPaymentCurrency($virtuemart_paymentmethod_id, &$paymentCurrencyId) {
- if (!($this->_currentMethod = $this->getVmPluginMethod($virtuemart_paymentmethod_id)))
- {
- return NULL;
- }
- if (!$this->selectedThisElement($this->_currentMethod->payment_element))
- {
- return FALSE;
- }
- $this->getPaymentCurrency($this->_currentMethod);
- $paymentCurrencyId = $this->_currentMethod->payment_currency;
- return;
- }
- public function _getHtmlPaymentResponse($msg, $is_success = true, $order_id = null, $order_nr = null, $amount = null, $txid = null, $period = null, $date = null, $paymethodid = null) {
- if (!$is_success)
- {
- ..........................................................................
- ..............................
- ........
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement