function save(&$order) { $new = false; $config =& hikashop_config(); if (empty($order->order_id)) { if (!is_object($order)) { $order = new stdClass(); } $order->order_created = time(); if (empty($order->order_type)) { $order->order_type = 'sale'; } $order->order_ip = hikashop_getIP(); $order->old = new stdClass(); if (empty($order->order_status)) { $order->order_status = $config->get('order_created_status', 'pending'); } if (empty($order->order_currency_id)) { $order->order_currency_id = hikashop_getCurrency(); } if (defined('MULTISITES_ID')) { $order->order_site_id = MULTISITES_ID; } $new = true; } else { if (empty($order->old)) { $order->old = $this->get($order->order_id); } } $order->order_modified = time(); JPluginHelper::importPlugin('hikashop'); JPluginHelper::importPlugin('hikashoppayment'); JPluginHelper::importPlugin('hikashopshipping'); $dispatcher = JDispatcher::getInstance(); $order_type = ''; if (!empty($order->old->order_type)) { $order_type = $order->old->order_type; } if (!empty($order->order_type)) { $order_type = $order->order_type; } $recalculate = false; if (!empty($order->product)) { $do = true; $dispatcher->trigger('onBeforeOrderProductsUpdate', array(&$order, &$do)); if (!$do) { return false; } $productClass = hikashop_get('class.order_product'); if (is_array($order->product)) { foreach ($order->product as $product) { $productClass->update($product); } } else { $productClass->update($order->product); } $recalculate = true; } if (!$new && (isset($order->order_shipping_price) || isset($order->order_payment_price) || isset($order->order_discount_price))) { if (isset($order->order_shipping_tax_namekey) || isset($order->order_discount_tax_namekey) || isset($order->order_payment_tax_namekey)) { if (!empty($order->old->order_tax_info)) { $order->order_tax_info = $order->old->order_tax_info; foreach ($order->order_tax_info as $k => $tax) { if (isset($order->order_shipping_tax_namekey) && $tax->tax_namekey == $order->order_shipping_tax_namekey) { $order->order_tax_info[$k]->tax_amount_for_shipping = @$order->order_shipping_tax; unset($order->order_shipping_tax_namekey); } elseif (isset($order->order_tax_info[$k]->tax_amount_for_shipping)) { unset($order->order_tax_info[$k]->tax_amount_for_shipping); } if (isset($order->order_payment_tax_namekey) && $tax->tax_namekey == $order->order_payment_tax_namekey) { $order->order_tax_info[$k]->tax_amount_for_payment = @$order->order_payment_tax; unset($order->order_payment_tax_namekey); } elseif (isset($order->order_tax_info[$k]->tax_amount_for_payment)) { unset($order->order_tax_info[$k]->tax_amount_for_payment); } if (isset($order->order_discount_tax_namekey) && $tax->tax_namekey == $order->order_discount_tax_namekey) { $order->order_tax_info[$k]->tax_amount_for_coupon = @$order->order_discount_tax; unset($order->order_discount_tax_namekey); } elseif (isset($order->order_tax_info[$k]->tax_amount_for_coupon)) { unset($order->order_tax_info[$k]->tax_amount_for_coupon); } } } if (isset($order->order_shipping_tax_namekey)) { $order->order_tax_info[$order->order_shipping_tax_namekey] = new stdClass(); $order->order_tax_info[$order->order_shipping_tax_namekey]->tax_namekey = $order->order_shipping_tax_namekey; $order->order_tax_info[$order->order_shipping_tax_namekey]->tax_amount_for_shipping = @$order->order_shipping_tax; unset($order->order_shipping_tax_namekey); } if (isset($order->order_payment_tax_namekey)) { $order->order_tax_info[$order->order_payment_tax_namekey] = new stdClass(); $order->order_tax_info[$order->order_payment_tax_namekey]->tax_namekey = $order->order_payment_tax_namekey; $order->order_tax_info[$order->order_payment_tax_namekey]->tax_amount_for_payment = @$order->order_payment_tax; unset($order->order_payment_tax_namekey); } if (isset($order->order_discount_tax_namekey)) { $order->order_tax_info[$order->order_discount_tax_namekey] = new stdClass(); $order->order_tax_info[$order->order_discount_tax_namekey]->tax_namekey = $order->order_discount_tax_namekey; $order->order_tax_info[$order->order_discount_tax_namekey]->tax_amount_for_coupon = @$order->order_discount_tax; unset($order->order_discount_tax_namekey); } } $recalculate = true; } if ($recalculate) { $this->recalculateFullPrice($order); } $do = true; if ($new) { $dispatcher->trigger('onBeforeOrderCreate', array(&$order, &$do)); } else { $dispatcher->trigger('onBeforeOrderUpdate', array(&$order, &$do)); } if ($do) { if (isset($order->value)) { unset($order->value); } if (isset($order->order_current_lgid)) { unset($order->order_current_lgid); } if (isset($order->order_current_locale)) { unset($order->order_current_locale); } if (isset($order->mail_status)) { unset($order->mail_status); } if (isset($order->order_tax_info) && !is_string($order->order_tax_info)) { $order->order_tax_info = serialize($order->order_tax_info); } if (isset($order->order_currency_info) && !is_string($order->order_currency_info)) { $order->order_currency_info = serialize($order->order_currency_info); } if (isset($order->order_shipping_params) && !is_string($order->order_shipping_params)) { $order->order_shipping_params = serialize($order->order_shipping_params); } if (isset($order->order_payment_params) && !is_string($order->order_payment_params)) { $order->order_payment_params = serialize($order->order_payment_params); } if ($config->get('update_stock_after_confirm') && isset($order->order_status) && isset($order->old->order_status) && $order_type == 'sale') { $invoice_statuses = $config->get('invoice_order_statuses', 'confirmed,shipped'); if (empty($invoice_statuses)) { $invoice_statuses = 'confirmed,shipped'; } $invoice_order_statuses = explode(',', $invoice_statuses); if ($order->old->order_status == 'created' && in_array($order->order_status, $invoice_order_statuses)) { $this->loadProducts($order); if (!empty($order->products)) { $productClass = hikashop_get('class.order_product'); foreach ($order->products as $product) { $product->change = 'minus'; $productClass->update($product); unset($product->change); } } } elseif (in_array($order->old->order_status, $invoice_order_statuses) && $order->order_status == 'created') { $this->loadProducts($order); if (!empty($order->products)) { $productClass = hikashop_get('class.order_product'); foreach ($order->products as $product) { $product->change = 'plus'; $productClass->update($product); unset($product->change); } } } } if (isset($order->order_status) && $order_type == 'sale') { $this->capturePayment($order, 0); } if (!empty($order->order_status) && empty($order->order_invoice_id) && empty($order->old->order_invoice_id) && $order_type == 'sale') { $valid_statuses = explode(',', $config->get('invoice_order_statuses', 'confirmed,shipped')); if (empty($valid_statuses)) { $valid_statuses = array('confirmed', 'shipped'); } $excludeFreeOrders = $config->get('invoice_exclude_free_orders', 0); if (isset($order->order_full_price)) { $total = $order->order_full_price; } elseif (isset($order->old->order_full_price)) { $total = $order->old->order_full_price; } else { $total = 0; } //new order for example if (in_array($order->order_status, $valid_statuses) && ($total > 0 || !$excludeFreeOrders)) { $query = 'SELECT MAX(a.order_invoice_id)+1 FROM ' . hikashop_table('order') . ' AS a WHERE a.order_type = \'sale\''; $resetFrequency = $config->get('invoice_reset_frequency', ''); if (!empty($resetFrequency)) { $y = (int) date('Y'); $m = 1; $d = 1; if ($resetFrequency == 'month') { $m = (int) date('m'); } if (strpos($resetFrequency, '/') !== false) { list($d, $m) = explode('/', $resetFrequency, 2); if ($d == '*') { $d = (int) date('d'); } else { $d = (int) $d; } if ($m == '*') { $m = (int) date('m'); } else { $m = (int) $m; } if ($d <= 0) { $d = 1; } if ($m <= 0) { $m = 1; } } $query .= ' AND a.order_invoice_created >= ' . mktime(0, 0, 0, $m, $d, $y); } $this->database->setQuery($query); $order->order_invoice_id = $this->database->loadResult(); if (empty($order->order_invoice_id)) { $order->order_invoice_id = 1; } $order->order_invoice_number = hikashop_encode($order, 'invoice'); $order->order_invoice_created = time(); } } if (empty($order->old)) { unset($order->old); } $order->order_id = parent::save($order); if (isset($order->order_tax_info) && is_string($order->order_tax_info)) { $order->order_tax_info = unserialize($order->order_tax_info); } if (isset($order->order_payment_params) && is_string($order->order_payment_params)) { $order->order_payment_params = unserialize($order->order_payment_params); } if (isset($order->order_shipping_params) && is_string($order->order_shipping_params)) { $order->order_shipping_params = unserialize($order->order_shipping_params); } if (!empty($order->order_id)) { $productClass = hikashop_get('class.order_product'); if ($new && empty($order->order_number)) { $order->order_number = hikashop_encode($order); $updateOrder = new stdClass(); $updateOrder->order_id = $order->order_id; $updateOrder->order_number = $order->order_number; $config =& hikashop_config(); $valid_statuses = explode(',', $config->get('invoice_order_statuses', 'confirmed,shipped')); if (empty($valid_statuses)) { $valid_statuses = array('confirmed', 'shipped'); } $created_status = $config->get('order_created_status', 'created'); if (in_array($created_status, $valid_statuses)) { $order->order_invoice_id = $order->order_id; $order->order_invoice_number = $order->order_number; $order->order_invoice_created = time(); $updateOrder->order_invoice_id = $order->order_invoice_id; $updateOrder->order_invoice_number = $order->order_invoice_number; } parent::save($updateOrder); } if (!empty($order->cart->products)) { foreach ($order->cart->products as $k => $p) { $order->cart->products[$k]->order_id = $order->order_id; } if ($config->get('update_stock_after_confirm') && $order->order_status == 'created') { foreach ($order->cart->products as $k => $product) { $order->cart->products[$k]->no_update_qty = true; } } $productClass->save($order->cart->products); if ($config->get('update_stock_after_confirm') && $order->order_status == 'created') { foreach ($order->cart->products as $k => $product) { unset($order->cart->products[$k]->no_update_qty); } } if (!empty($order->order_discount_code) && $order_type == 'sale') { $query = 'UPDATE ' . hikashop_table('discount') . ' SET discount_used_times=discount_used_times+1 WHERE discount_code=' . $this->database->Quote($order->order_discount_code) . ' AND discount_type=\'coupon\' LIMIT 1'; $this->database->setQuery($query); $this->database->query(); } if (!empty($order->cart->additional)) { foreach ($order->cart->additional as $k => $p) { $order->cart->additional[$k]->product_id = 0; $order->cart->additional[$k]->order_product_quantity = 0; if (!empty($p->name)) { $order->cart->additional[$k]->order_product_name = $p->name; } $order->cart->additional[$k]->order_product_code = 'order additional'; if (!empty($p->value)) { $order->cart->additional[$k]->order_product_options = $p->value; } if (!empty($p->price_value)) { $order->cart->additional[$k]->order_product_price = $p->price_value; } $order->cart->additional[$k]->order_id = $order->order_id; } $productClass->save($order->cart->additional); } } elseif (!empty($order->order_status) && !empty($order->old)) { $update = $config->get('update_stock_after_confirm'); $config =& hikashop_config(); $cancelled_order_status = explode(',', $config->get('cancelled_order_status')); $invoice_order_statuses = explode(',', $config->get('invoice_order_statuses', 'confirmed,shipped')); if (empty($invoice_order_statuses)) { $invoice_order_statuses = array('confirmed', 'shipped'); } if (!empty($order->order_status) && in_array($order->order_status, $cancelled_order_status) && (empty($order->old->order_status) || !in_array($order->old->order_status, $cancelled_order_status))) { if ($order_type == 'sale' && (in_array($order->order_status, $cancelled_order_status) && (in_array($order->old->order_status, $invoice_order_statuses) || !$update && $order->old->order_status == 'created'))) { $productClass->cancelProductReservation($order->order_id); } if (!isset($order->order_discount_code)) { $code = @$order->old->order_discount_code; } else { $code = $order->order_discount_code; } if (!empty($code) && $order_type == 'sale') { $query = 'UPDATE ' . hikashop_table('discount') . ' SET discount_used_times=discount_used_times-1 WHERE discount_code=' . $this->database->Quote($code) . ' AND discount_type=\'coupon\' LIMIT 1'; $this->database->setQuery($query); $this->database->query(); } } if (!empty($order->order_status) && !in_array($order->order_status, $cancelled_order_status) && !empty($order->old->order_status) && in_array($order->old->order_status, $cancelled_order_status)) { if ($order_type == 'sale' && (in_array($order->old->order_status, $cancelled_order_status) && (in_array($order->order_status, $invoice_order_statuses) || !$update && $order->order_status == 'created'))) { $productClass->resetProductReservation($order->order_id); } if (!isset($order->order_discount_code)) { $code = @$order->old->order_discount_code; } else { $code = $order->order_discount_code; } if (!empty($code) && $order_type == 'sale') { $query = 'UPDATE ' . hikashop_table('discount') . ' SET discount_used_times = discount_used_times + 1 WHERE discount_code=' . $this->database->Quote($code) . ' AND discount_type=\'coupon\' LIMIT 1'; $this->database->setQuery($query); $this->database->query(); } } } if ($new) { $send_email = $this->sendEmailAfterOrderCreation; $dispatcher->trigger('onAfterOrderCreate', array(&$order, &$send_email)); if ($send_email) { $this->loadOrderNotification($order, 'order_creation_notification'); $mail = hikashop_get('class.mail'); if (!empty($order->mail->dst_email)) { $mail->sendMail($order->mail); } $this->mail_success =& $mail->mail_success; $config =& hikashop_config(); $emails = $config->get('order_creation_notification_email'); if (!empty($emails)) { $mail = hikashop_get('class.mail'); if (!empty($order->customer)) { $user_email = $order->customer->user_email; $user_name = $order->customer->name; } else { $order->customer = new stdClass(); } $order->customer->user_email = explode(',', $emails); $order->customer->name = ' '; $this->loadOrderNotification($order, 'order_admin_notification'); $order->mail->subject = trim($order->mail->subject); if (empty($order->mail->subject)) { $order->mail->subject = JText::sprintf('NEW_ORDER_SUBJECT', $order->order_number, HIKASHOP_LIVE); } if (!empty($user_email)) { $mail->mailer->addReplyTo(array($user_email, $user_name)); } if (!empty($order->mail->dst_email)) { $mail->sendMail($order->mail); } if (!empty($user_email)) { $order->customer->user_email = $user_email; $order->customer->name = $user_name; } } } } else { $send_email = @$order->history->history_notified; $dispatcher->trigger('onAfterOrderUpdate', array(&$order, &$send_email)); if ($send_email) { if (empty($order->mail) && isset($order->order_status)) { $this->loadOrderNotification($order, 'order_status_notification'); } else { $order->mail->data =& $order; $order->mail->mail_name = 'order_status_notification'; } if (!empty($order->mail)) { $mail = hikashop_get('class.mail'); if (!empty($order->mail->dst_email)) { $mail->sendMail($order->mail); } $this->mail_success =& $mail->mail_success; } } } } return $order->order_id; } return false; }
function onPaymentNotification(&$statuses) { $vars = array(); $data = array(); $filter = JFilterInput::getInstance(); foreach ($_POST as $key => $value) { $key = $filter->clean($key); if (preg_match("#^[0-9a-z_-]{1,30}\$#i", $key) && !preg_match("#^cmd\$#i", $key)) { $value = JRequest::getString($key); $vars[$key] = $value; $data[] = $key . '=' . urlencode($value); } } $data = implode('&', $data) . '&cmd=_notify-validate'; $order_id = (int) @$vars['cartId']; $dbOrder = $this->getOrder($order_id); if (empty($dbOrder)) { echo "Could not load any order for your notification " . @$vars['cartId']; return false; } $this->loadPaymentParams($dbOrder); if (empty($this->payment_params)) { return false; } if ($this->payment_params->debug) { echo print_r($vars, true) . "\n\n\n"; echo print_r($dbOrder, true) . "\n\n\n"; } $this->loadOrderData($dbOrder); if (@$vars['instId'] != $this->payment_params->instid) { return false; } $url = HIKASHOP_LIVE . 'administrator/index.php?option=com_hikashop&ctrl=order&task=edit&order_id=' . $order_id; $order_text = "\r\n" . JText::sprintf('NOTIFICATION_OF_ORDER_ON_WEBSITE', hikashop_encode($dbOrder), HIKASHOP_LIVE); $order_text .= "\r\n" . str_replace('<br/>', "\r\n", JText::sprintf('ACCESS_ORDER_WITH_LINK', $url)); $hostError = -1; $ip = hikashop_getIP(); if (!empty($element->payment_params->hostname)) { // \.outbound\.wp3\.rbsworldpay\.com $hostname = gethostbyaddr($ip); if (preg_match('#' . $this->payment_params->hostname . '#i', $hostname)) { $hostError = 0; } else { $hostError = 1; } } if ($hostError < 0 && !empty($this->payment_params->ips)) { $ips = str_replace(array('.', '*', ','), array('\\.', '[0-9]+', '|'), $this->payment_params->ips); if (!empty($ips)) { if (preg_match('#(' . implode('|', $ips) . ')#', $ip)) { $hostError = 0; } else { $hostError = 1; } } } if ($hostError > 0) { $email = new stdClass(); $email->subject = JText::sprintf('NOTIFICATION_REFUSED_FOR_THE_ORDER', 'Worldpay Business Gateway') . ' ' . JText::sprintf('IP_NOT_VALID', hikashop_encode($dbOrder)); $body = str_replace('<br/>', "\r\n", JText::sprintf('NOTIFICATION_REFUSED_FROM_IP', 'Worldpay Business Gateway', $ip, 'See Hostname / IPs defined in configuration')) . "\r\n\r\n" . JText::sprintf('CHECK_DOCUMENTATION', HIKASHOP_HELPURL . 'payment-rbsworldpay-error#ip') . $order_text; $email->body = $body; $this->modifyOrder($order_id, $this->payment_params->invalid_status, false, $email); JError::raiseError(403, JText::_('Access Forbidden')); return false; } switch ($vars['transStatus']) { case 'Y': break; default: $email = new stdClass(); $email->subject = JText::sprintf('PAYMENT_NOTIFICATION_FOR_ORDER', 'Worldpay Business Gateway', $vars['transStatus'], $dbOrder->order_number); $body = str_replace('<br/>', "\r\n", JText::sprintf('PAYMENT_NOTIFICATION_STATUS', 'Worldpay Business Gateway', $vars['payment_status'])) . ' ' . JText::_('STATUS_NOT_CHANGED') . "\r\n\r\n" . JText::sprintf('CHECK_DOCUMENTATION', HIKASHOP_HELPURL . 'payment-rbsworldpay-error#status') . $order_text; $email->body = $body; $this->modifyOrder($order_id, $this->payment_params->invalid_status, false, $email); if ($this->payment_params->debug) { echo 'payment ' . $vars['transStatus'] . "\n\n\n"; echo '[OK]'; } $dbg = ob_get_clean(); $return_url = HIKASHOP_LIVE . 'index.php?option=com_hikashop&ctrl=order&task=cancel_order&order_id=' . $order_id . $this->url_itemid; echo '<meta http-equiv="refresh" content="5;url=' . $return_url . '" /> <style> .pageHeading { font-family: Verdana, Arial, sans-serif; font-size: 20px; font-weight: bold; color: #9a9a9a; } .main { font-family: Verdana, Arial, sans-serif; font-size: 11px; line-height: 1.5; } </style> <p class="pageHeading">' . JText::sprintf('TRANSACTION_PROCESSING_ERROR', $vars['transStatus']) . '</p> <form action="' . $return_url . '" method="post"> <div align="center"> <input name="submit" type="submit" class="btn" value="' . JText::_('GO_BACK_TO_SHOP') . '" /> </div> </form> <p> </p> <WPDISPLAY ITEM=banner>'; ob_start(); if ($this->payment_params->debug) { echo $dbg; } return false; } $history = new stdClass(); $email = new stdClass(); $history->notified = 0; $history->amount = @$vars['amount'] . @$vars['currency']; $history->data = ''; $price_check = round($dbOrder->order_full_price, (int) $this->currency->currency_locale['int_frac_digits']); if ($price_check != @$vars['amount'] || $this->currency->currency_code != @$vars['currency']) { $email->subject = JText::sprintf('NOTIFICATION_REFUSED_FOR_THE_ORDER', 'Worldpay Business Gateway') . JText::_('INVALID_AMOUNT'); $body = str_replace('<br/>', "\r\n", JText::sprintf('AMOUNT_RECEIVED_DIFFERENT_FROM_ORDER', 'Worldpay Business Gateway', $history->amount, $price_check . $this->currency->currency_code)) . "\r\n\r\n" . JText::sprintf('CHECK_DOCUMENTATION', HIKASHOP_HELPURL . 'payment-rbsworldpay-error#amount') . $order_text; $email->body = $body; $this->modifyOrder($order_id, $this->payment_params->invalid_status, $history, $email); return false; } switch ($vars['transStatus']) { case 'Y': $payment_status = 'Authenticated'; $order_status = $this->payment_params->verified_status; $history->notified = 1; break; default: $payment_status = 'Unknown'; $order_status = $this->payment_params->invalid_status; $order_text = JText::sprintf('CHECK_DOCUMENTATION', HIKASHOP_HELPURL . 'payment-rbsworldpay-error#pending') . "\r\n\r\n" . $order_text; } $mail_status = $statuses[$order->order_status]; $email->subject = JText::sprintf('PAYMENT_NOTIFICATION_FOR_ORDER', 'Worldpay Business Gateway', $payment_status, $dbOrder->order_number); $body = str_replace('<br/>', "\r\n", JText::sprintf('PAYMENT_NOTIFICATION_STATUS', 'Worldpay Business Gateway', $order_status)) . ' ' . JText::sprintf('ORDER_STATUS_CHANGED', $mail_status) . "\r\n\r\n" . $order_text; $email->body = $body; $this->modifyOrder($order_id, $order_status, $history, $email); $return_url = HIKASHOP_LIVE . 'index.php?option=com_hikashop&ctrl=checkout&task=after_end&order_id=' . $order->order_id . $this->url_itemid; if ($this->payment_params->debug) { echo '[OK]'; } $dbg = ob_get_clean(); echo '<meta http-equiv="refresh" content="5;url=' . $return_url . '" /> <style> .pageHeading { font-family: Verdana, Arial, sans-serif; font-size: 20px; font-weight: bold; color: #9a9a9a; } .main { font-family: Verdana, Arial, sans-serif; font-size: 11px; line-height: 1.5; } </style> <p class="pageHeading">' . JText::_('THANK_YOU_FOR_PURCHASE') . '</p> <form action="' . $return_url . '" method="post"> <div align="center"> <input name="submit" type="submit" class="btn" value="' . JText::_('GO_BACK_TO_SHOP') . '" /> </div> </form> <p> </p> <WPDISPLAY ITEM=banner>'; ob_start(); if ($element->payment_params->debug) { echo $dbg; } return true; }
function onBeforeOrderCreate(&$order, &$do) { if (parent::onBeforeOrderCreate($order, $do) === true) { return true; } if (!function_exists('curl_init')) { $this->app->enqueueMessage('The Payment Express payment plugin needs the CURL library installed but it seems that it is not available on your server. Please contact your web hosting to set it up.', 'error'); return false; } $this->ccLoad(); ob_start(); $dbg = ''; $amount = number_format($order->cart->full_total->prices[0]->price_value_with_tax, 2, '.', ''); $vars = '<Txn>'; $vars .= '<PostUsername>' . $this->payment_params->username . '</PostUsername>'; $vars .= '<PostPassword>' . $this->payment_params->password . '</PostPassword>'; $vars .= '<Amount>' . $amount . '</Amount>'; $vars .= '<InputCurrency>' . $this->currency->currency_code . '</InputCurrency>'; if (!empty($this->cc_CCV)) { $vars .= '<Cvc2>' . $this->cc_CCV . '</Cvc2>'; } if (!empty($this->cc_owner)) { $vars .= '<CardHolderName>' . $this->cc_owner . '</CardHolderName>'; } $vars .= '<CardNumber>' . $this->cc_number . '</CardNumber>'; $vars .= '<DateExpiry>' . $this->cc_month . $this->cc_year . '</DateExpiry>'; $vars .= '<TxnType>Purchase</TxnType>'; if (empty($order->order_number) && !empty($order->order_id)) { $order->order_number = hikashop_encode($order); } if (!empty($order->order_number)) { $vars .= '<MerchantReference>' . $order->order_number . '</MerchantReference>'; } $vars .= '</Txn>'; $domain = 'https://sec.paymentexpress.com/pxpost.aspx'; $session = curl_init($domain); curl_setopt($session, CURLOPT_SSL_VERIFYPEER, 0); curl_setopt($session, CURLOPT_VERBOSE, 1); curl_setopt($session, CURLOPT_SSLVERSION, defined('CURL_SSLVERSION_TLSv1') ? CURL_SSLVERSION_TLSv1 : 1); curl_setopt($session, CURLOPT_POST, 1); curl_setopt($session, CURLOPT_POSTFIELDS, $vars); curl_setopt($session, CURLOPT_RETURNTRANSFER, 1); $ret = curl_exec($session); $error = curl_errno($session); $err_msg = curl_error($session); curl_close($session); if (!empty($ret)) { if ($this->payment_params->debug) { echo print_r($ret, true) . "\n\n\n"; } $error_msg = ''; if (preg_match('#<Success>([0-9])</Success>#', $ret, $res) !== false && $res[1]) { $approvalCode = ''; if (preg_match('#<AuthCode>([0-9]+)</AuthCode>#', $ret, $res) !== false) { $approvalCode = $res[1]; } $transactionId = ''; if (preg_match('#<TransactionId>([0-9]+)</TransactionId>#', $ret, $res) !== false) { $transactionId = $res[1]; } $do = true; $dbg .= ob_get_clean(); if (!empty($dbg)) { $dbg .= "\r\n"; } ob_start(); $history = new stdClass(); $email = new stdClass(); $history->notified = 0; $history->amount = $amount . $this->currency->currency_code; $history->data = $dbg . 'Authorization Code: ' . $approvalCode . "\r\n" . 'Transaction ID: ' . $transactionId; $order_status = $this->payment_params->verified_status; $url = HIKASHOP_LIVE . 'administrator/index.php?option=com_hikashop&ctrl=order&task=listing'; $order_text = "\r\n" . JText::sprintf('NOTIFICATION_OF_ORDER_ON_WEBSITE', '', HIKASHOP_LIVE); $order_text .= "\r\n" . str_replace('<br/>', "\r\n", JText::sprintf('ACCESS_ORDER_WITH_LINK', $url)); $email->subject = JText::sprintf('PAYMENT_NOTIFICATION', 'Payment express', 'Accepted'); $email->body = str_replace('<br/>', "\r\n", JText::sprintf('PAYMENT_NOTIFICATION_STATUS', 'Payment express', 'Accepted')) . ' ' . JText::sprintf('ORDER_STATUS_CHANGED', $order_status) . "\r\n\r\n" . $order_text; $this->modifyorder($order, $order_status, $history, $email); } else { if (preg_match('#<ReCo>([0-9]+)</ReCo>#', $ret, $res)) { $error = $res[1] . ' '; } if (preg_match('#<ResponseText>(.*)</ResponseText>#', $ret, $res)) { $error_msg = $res[1] . ' '; } if (preg_match('#<HelpText>(.*)</HelpText>#', $ret, $res)) { $error_msg .= $res[1]; } $responseMsg = $error . $error_msg; if (!empty($responseMsg)) { $this->app->enqueueMessage('Error : ' . $responseMsg); } else { $this->app->enqueueMessage('Error'); } $do = false; } } else { $this->app->enqueueMessage('There was an error during the connection with the Payment Express gateway'); if ($this->payment_params->debug) { echo 'Curl Err [' . $error . '] : ' . $err_msg . "\n\n\n"; } $do = false; } $this->writeToLog($dbg); if (!$do) { return true; } $this->ccClear(); return true; }
function updateSQL() { if (!$this->update) { return true; } if (version_compare($this->fromVersion, '1.0.2', '<')) { $query = 'UPDATE `#__hikashop_user` AS a LEFT JOIN `#__hikashop_user` AS b ON a.user_email=b.user_email SET a.user_email=CONCAT(\'old_\',a.user_email) WHERE a.user_id>b.user_id'; $this->db->setQuery($query); try { $this->db->query(); } catch (Exception $e) { } $this->addColumns("user", "UNIQUE (`user_email`)"); } if (version_compare($this->fromVersion, '1.1.2', '<')) { $this->databaseHelper->addColumns("product", "`product_max_per_order` INT UNSIGNED DEFAULT 0"); } if (version_compare($this->fromVersion, '1.3.4', '<')) { $this->databaseHelper->addColumns("discount", "`discount_auto_load` TINYINT UNSIGNED DEFAULT 0"); } if (version_compare($this->fromVersion, '1.3.3', '>') && version_compare($this->fromVersion, '1.3.6', '<')) { $this->db->setQuery("DELETE FROM `#__modules` WHERE module='HikaShop Content Module' OR module='HikaShop Cart Module' OR module='HikaShop Currency Switcher Module'"); try { $this->db->query(); } catch (Exception $e) { } } if (version_compare($this->fromVersion, '1.4.1', '<')) { $rand = rand(0, 999999999); $this->db->setQuery("UPDATE #__hikashop_config SET `config_value` = 'media/com_hikashop/upload',`config_default` = 'media/com_hikashop/upload' WHERE `config_namekey` = 'uploadfolder' AND `config_value` LIKE 'components/com_hikashop/upload%' "); try { $this->db->query(); } catch (Exception $e) { } $this->db->setQuery("UPDATE #__hikashop_config SET `config_value` = 'media/com_hikashop/upload/safe',`config_default` = 'media/com_hikashop/upload/safe' WHERE `config_namekey` = 'uploadsecurefolder' AND `config_value` LIKE 'components/com_hikashop/upload/safe%' "); try { $this->db->query(); } catch (Exception $e) { } $this->db->setQuery("UPDATE #__hikashop_config SET `config_value` = 'media/com_hikashop/upload/safe/logs/report_" . $rand . ".log',`config_default` = 'media/com_hikashop/upload/safe/logs/report_" . $rand . ".log' WHERE `config_namekey` IN ('cron_savepath','payment_log_file') "); try { $this->db->query(); } catch (Exception $e) { } $updateClass = hikashop_get('helper.update'); $removeFiles = array(HIKASHOP_FRONT . 'css' . DS . 'backend_default.css', HIKASHOP_FRONT . 'css' . DS . 'frontend_default.css', HIKASHOP_FRONT . 'mail' . DS . 'cron_report.html.php', HIKASHOP_FRONT . 'mail' . DS . 'order_admin_notification.text.php', HIKASHOP_FRONT . 'mail' . DS . 'order_creation_notification.text.php', HIKASHOP_FRONT . 'mail' . DS . 'order_creation_notification.html.php', HIKASHOP_FRONT . 'mail' . DS . 'order_notification.text.php', HIKASHOP_FRONT . 'mail' . DS . 'order_notification.html.php', HIKASHOP_FRONT . 'mail' . DS . 'order_status_notification.text.php', HIKASHOP_FRONT . 'mail' . DS . 'order_status_notification.html.php', HIKASHOP_FRONT . 'mail' . DS . 'user_account.text.php', HIKASHOP_FRONT . 'mail' . DS . 'user_account.html.php', HIKASHOP_FRONT . 'mail' . DS . 'user_account_admin_notification.html.php', HIKASHOP_FRONT . 'mail' . DS . 'user_account_admin_notification.html.php'); foreach ($removeFiles as $oneFile) { if (is_file($oneFile)) { JFile::delete($oneFile); } } $fromFolders = array(); $toFolders = array(); $fromFolders[] = HIKASHOP_FRONT . 'css'; $toFolders[] = HIKASHOP_MEDIA . 'css'; $fromFolders[] = HIKASHOP_FRONT . 'mail'; $toFolders[] = HIKASHOP_MEDIA . 'mail'; $fromFolders[] = HIKASHOP_FRONT . 'upload'; $toFolders[] = HIKASHOP_MEDIA . 'upload'; foreach ($fromFolders as $i => $oneFolder) { if (!is_dir($oneFolder)) { continue; } if (is_dir($toFolders[$i]) || !@rename($oneFolder, $toFolders[$i])) { $updateClass->copyFolder($oneFolder, $toFolders[$i]); } } $deleteFolders = array(HIKASHOP_FRONT . 'css', HIKASHOP_FRONT . 'images', HIKASHOP_FRONT . 'js'); foreach ($deleteFolders as $oneFolder) { if (!is_dir($oneFolder)) { continue; } JFolder::delete($oneFolder); } } if (version_compare($this->fromVersion, '1.4.2', '<')) { $this->databaseHelper->addColumns("discount", "`discount_access` VARCHAR( 255 ) NOT NULL DEFAULT 'all'"); $this->databaseHelper->addColumns("category", "`category_access` VARCHAR( 255 ) NOT NULL DEFAULT 'all'"); $this->databaseHelper->addColumns("product", "`product_access` VARCHAR( 255 ) NOT NULL DEFAULT 'all'"); $this->databaseHelper->addColumns("price", "`price_access` VARCHAR( 255 ) NOT NULL DEFAULT 'all'"); $this->databaseHelper->addColumns("zone", "`zone_currency_id` INT UNSIGNED DEFAULT 0"); if (version_compare(JVERSION, '1.6.0', '<')) { $query = 'UPDATE `#__plugins` SET `published`=0 WHERE `element`=\'geolocation\' AND `folder`=\'hikashop\''; } else { $query = 'UPDATE `#__extensions` SET `enabled`=0 WHERE `element`=\'geolocation\' AND `folder`=\'hikashop\''; } $this->db->setQuery($query); try { $this->db->query(); } catch (Exception $e) { } } if (version_compare($this->fromVersion, '1.4.5', '<')) { $this->databaseHelper->addColumns("product", array("`product_group_after_purchase` VARCHAR( 255 ) NOT NULL DEFAULT ''", "`product_contact` SMALLINT UNSIGNED DEFAULT 0")); } if (version_compare($this->fromVersion, '1.4.6', '<')) { $this->db->setQuery('ALTER TABLE `#__hikashop_product_related` DROP PRIMARY KEY , ADD PRIMARY KEY ( `product_id` , `product_related_id` , `product_related_type` )'); try { $this->db->query(); } catch (Exception $e) { } $this->databaseHelper->addColumns("product", "`product_min_per_order` INT UNSIGNED DEFAULT 0"); } if (version_compare($this->fromVersion, '1.4.7', '<')) { $this->databaseHelper->addColumns("payment", "`payment_access` VARCHAR( 255 ) NOT NULL DEFAULT 'all'"); $this->databaseHelper->addColumns("shipping", "`shipping_access` VARCHAR( 255 ) NOT NULL DEFAULT 'all'"); } if (version_compare($this->fromVersion, '1.4.8', '<')) { $this->databaseHelper->addColumns("history", "`history_user_id` INT UNSIGNED DEFAULT 0"); $this->databaseHelper->addColumns("discount", "`discount_tax_id` INT UNSIGNED DEFAULT 0"); $this->databaseHelper->addColumns("order", array("`order_discount_tax` decimal(12,5) NOT NULL DEFAULT '0.00000'", "`order_shipping_tax` decimal(12,5) NOT NULL DEFAULT '0.00000'")); } if (version_compare($this->fromVersion, '1.4.9', '<')) { $this->databaseHelper->addColumns("order", "`order_number` VARCHAR( 255 ) NOT NULL DEFAULT ''"); $this->db->setQuery("SELECT order_id,order_created FROM " . hikashop_table('order') . ' WHERE order_number=\'\''); $orders = $this->db->loadObjectList(); if (!empty($orders)) { foreach ($orders as $k => $order) { $orders[$k]->order_number = hikashop_encode($order); } $i = 0; $this->db->setQuery("CREATE TABLE IF NOT EXISTS `#__hikashop_order_number` (`order_id` int(10) unsigned NOT NULL DEFAULT '0',`order_number` VARCHAR( 255 ) NOT NULL DEFAULT '') ENGINE=MyISAM ;"); try { $this->db->query(); } catch (Exception $e) { } $inserts = array(); foreach ($orders as $k => $order) { $i++; $inserts[] = '(' . $order->order_id . ',' . $this->db->Quote($order->order_number) . ')'; if ($i >= 500) { $i = 0; $this->db->setQuery('INSERT IGNORE INTO `#__hikashop_order_number` (order_id,order_number) VALUES ' . implode(',', $inserts)); try { $this->db->query(); } catch (Exception $e) { } $inserts = array(); } } $this->db->setQuery('INSERT IGNORE INTO `#__hikashop_order_number` (order_id,order_number) VALUES ' . implode(',', $inserts)); try { $this->db->query(); } catch (Exception $e) { } $this->db->setQuery('UPDATE `#__hikashop_order` AS a , `#__hikashop_order_number` AS b SET a.order_number=b.order_number WHERE a.order_id=b.order_id AND a.order_number=\'\''); try { $this->db->query(); } catch (Exception $e) { } $this->db->setQuery('DROP TABLE IF EXISTS `#__hikashop_order_number`'); try { $this->db->query(); } catch (Exception $e) { } } } if (version_compare($this->fromVersion, '1.5.0', '<')) { $this->databaseHelper->addColumns("field", "`field_access` VARCHAR( 255 ) NOT NULL DEFAULT 'all'"); $this->databaseHelper->addColumns("product", "`product_min_per_order` INT UNSIGNED DEFAULT 0"); if (version_compare(JVERSION, '1.6.0', '<')) { $query = 'UPDATE `#__plugins` SET `published`=0 WHERE `element`=\'hikashop\' AND `folder`=\'user\''; } else { $query = 'UPDATE `#__extensions` SET `enabled`=0 WHERE `element`=\'hikashop\' AND `folder`=\'user\''; } $this->db->setQuery($query); try { $this->db->query(); } catch (Exception $e) { } $this->databaseHelper->addColumns("discount", array("`discount_quota_per_user` INT UNSIGNED DEFAULT 0", "`discount_minimum_products` INT UNSIGNED DEFAULT 0")); } if (version_compare($this->fromVersion, '1.5.2', '<')) { $this->databaseHelper->addColumns("category", "`category_keywords` VARCHAR(255) NOT NULL"); $this->databaseHelper->addColumns("category", "`category_meta_description` varchar(155) NOT NULL DEFAULT ''"); $this->databaseHelper->addColumns("product_related", "`product_related_ordering` INT UNSIGNED DEFAULT 0"); $this->databaseHelper->addColumns("product", "`product_last_seen_date` INT UNSIGNED DEFAULT 0"); $this->databaseHelper->addColumns("file", "`file_free_download` tinyint(3) unsigned NOT NULL DEFAULT '0'"); $manufacturer = new stdClass(); $manufacturer->category_type = 'manufacturer'; $manufacturer->category_name = 'manufacturer'; $class = hikashop_get('class.category'); $class->save($manufacturer); } if (version_compare($this->fromVersion, '1.5.3', '<')) { $this->db->setQuery("\nCREATE TABLE IF NOT EXISTS `#__hikashop_limit` (\n\t`limit_id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n\t`limit_product_id` int(11) NOT NULL DEFAULT '0',\n\t`limit_category_id` int(11) NOT NULL DEFAULT '0',\n\t`limit_per_product` tinyint(4) NOT NULL DEFAULT '0',\n\t`limit_periodicity` varchar(255) NOT NULL DEFAULT '',\n\t`limit_type` varchar(255) NOT NULL DEFAULT '',\n\t`limit_value` int(10) NOT NULL DEFAULT '0',\n\t`limit_unit` varchar(255) DEFAULT NULL,\n\t`limit_currency_id` int(11) NOT NULL DEFAULT '0',\n\t`limit_access` varchar(255) NOT NULL DEFAULT '',\n\t`limit_status` varchar(255) NOT NULL DEFAULT '',\n\t`limit_published` tinyint(4) NOT NULL DEFAULT '0',\n\t`limit_created` int(10) DEFAULT NULL,\n\t`limit_modified` int(10) DEFAULT NULL,\n\t`limit_start` int(10) DEFAULT NULL,\n\t`limit_end` int(10) DEFAULT NULL,\n\tPRIMARY KEY (`limit_id`)\n) ENGINE=MyISAM ;"); try { $this->db->query(); } catch (Exception $e) { } $this->databaseHelper->addColumns("zone", "INDEX ( `zone_code_3` )"); $this->databaseHelper->addColumns("product", "`product_sales` INT UNSIGNED DEFAULT 0"); $this->databaseHelper->addColumns("field", array("`field_with_sub_categories` TINYINT( 1 ) NOT NULL DEFAULT 0", "`field_categories` VARCHAR( 255 ) NOT NULL DEFAULT 'all'")); $this->databaseHelper->addColumns("payment", "`payment_shipping_methods` TEXT NOT NULL DEFAULT ''"); $this->databaseHelper->addColumns("cart_product", "`cart_product_option_parent_id` INT UNSIGNED DEFAULT 0"); $this->databaseHelper->addColumns("order_product", "`order_product_option_parent_id` INT UNSIGNED DEFAULT 0"); $this->databaseHelper->addColumns("taxation", "`taxation_access` VARCHAR( 255 ) NOT NULL DEFAULT 'all'"); $class = hikashop_get('class.category'); $tax = new stdClass(); $tax->category_type = 'tax'; $tax->category_parent_id = 'tax'; $class->getMainElement($tax->category_parent_id); $tax->category_name = 'Default tax category'; $tax->category_namekey = 'default_tax'; $tax->category_depth = 2; $class->save($tax); } if (version_compare($this->fromVersion, '1.5.4', '<')) { $this->db->setQuery("\nCREATE TABLE IF NOT EXISTS `#__hikashop_filter` (\n\t`filter_id` smallint(5) unsigned NOT NULL AUTO_INCREMENT,\n\t`filter_name` varchar(250) NOT NULL,\n\t`filter_namekey` varchar(50) NOT NULL,\n\t`filter_published` tinyint(3) unsigned NOT NULL DEFAULT '1',\n\t`filter_type` varchar(50) DEFAULT NULL,\n\t`filter_category_id` int(10) unsigned NOT NULL,\n\t`filter_ordering` smallint(5) unsigned DEFAULT '99',\n\t`filter_options` text,\n\t`filter_data` text NOT NULL,\n\t`filter_access` varchar(250) NOT NULL DEFAULT 'all',\n\t`filter_direct_application` tinyint(3) NOT NULL DEFAULT '0',\n\t`filter_value` text NOT NULL,\n\t`filter_category_childs` tinyint(3) unsigned NOT NULL,\n\t`filter_height` int(50) unsigned NOT NULL,\n\t`filter_deletable` tinyint(3) unsigned NOT NULL,\n\t`filter_dynamic` tinyint(3) unsigned NOT NULL,\n\tPRIMARY KEY (`filter_id`)\n) ENGINE=MyISAM ;"); try { $this->db->query(); } catch (Exception $e) { } $this->databaseHelper->addColumns("payment", "`payment_currency` VARCHAR( 255 ) NOT NULL"); } if (version_compare($this->fromVersion, '1.5.5', '<')) { $this->db->setQuery("\nCREATE TABLE IF NOT EXISTS `#__hikashop_waitlist` (\n\t`waitlist_id` int(11) NOT NULL AUTO_INCREMENT,\n\t`product_id` int(11) NOT NULL,\n\t`date` int NOT NULL,\n\t`email` varchar(255) NOT NULL,\n\t`name` varchar(255) DEFAULT NULL,\n\t`product_item_id` int(11) NOT NULL,\n\tPRIMARY KEY (`waitlist_id`)\n) ENGINE=MyISAM ;"); try { $this->db->query(); } catch (Exception $e) { } $this->databaseHelper->addColumns("product", "`product_waitlist` SMALLINT( 5 ) UNSIGNED NOT NULL DEFAULT '0'"); $this->databaseHelper->addColumns("discount", "`discount_coupon_nodoubling` TINYINT NULL;"); $this->databaseHelper->addColumns("discount", "`discount_coupon_product_only` TINYINT NULL;"); } if (version_compare($this->fromVersion, '1.5.6', '<')) { $this->databaseHelper->addColumns("taxation", "`taxation_cumulative` TINYINT NULL;"); $this->databaseHelper->addColumns("order", "`order_tax_info` text NOT NULL"); $this->databaseHelper->addColumns("order_product", "`order_product_tax_info` text NOT NULL"); $this->databaseHelper->addColumns("category", "`category_layout` varchar(255) NOT NULL DEFAULT ''"); $this->databaseHelper->addColumns("product", "`product_layout` varchar(255) NOT NULL DEFAULT ''"); } if (version_compare($this->fromVersion, '1.5.7', '<')) { $this->databaseHelper->addColumns("characteristic", "`characteristic_alias` varchar(255) NOT NULL DEFAULT ''"); $this->databaseHelper->addColumns("product", array("`product_average_score` FLOAT NOT NULL", "`product_total_vote` INT NOT NULL DEFAULT '0'")); $this->databaseHelper->addColumns("address", "`address_default` TINYINT NOT NULL DEFAULT '0'"); $this->databaseHelper->addColumns("file", array("`file_ordering` INT UNSIGNED NOT NULL DEFAULT 0", "`file_limit` INT NOT NULL DEFAULT 0")); $this->db->setQuery("\nCREATE TABLE IF NOT EXISTS `#__hikashop_vote_user` (\n\t`vote_user_id` int(11) NOT NULL,\n\t`vote_user_user_id` varchar(26) NOT NULL,\n\t`vote_user_useful` tinyint(4) NOT NULL\n) ENGINE=MyISAM ;"); try { $this->db->query(); } catch (Exception $e) { } $this->db->setQuery("\nCREATE TABLE IF NOT EXISTS `#__hikashop_vote` (\n\t`vote_id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n\t`vote_ref_id` int(11) NOT NULL,\n\t`vote_type` varchar(15) NOT NULL,\n\t`vote_user_id` varchar(26) NOT NULL,\n\t`vote_rating` float NOT NULL,\n\t`vote_comment` varchar(255) NOT NULL,\n\t`vote_useful` int(11) NOT NULL,\n\t`vote_pseudo` varchar(25) NOT NULL,\n\t`vote_ip` varchar(15) NOT NULL,\n\t`vote_email` varchar(80) NOT NULL,\n\t`vote_date` int(10) unsigned NOT NULL,\n\t`vote_published` tinyint(4) NOT NULL DEFAULT '1',\n\tPRIMARY KEY (`vote_id`)\n) ENGINE=MyISAM"); try { $this->db->query(); } catch (Exception $e) { } } if (version_compare($this->fromVersion, '1.5.8', '<')) { $this->db->setQuery("ALTER TABLE `#__hikashop_vote` CHANGE `vote_comment` `vote_comment` TEXT NOT NULL;"); try { $this->db->query(); } catch (Exception $e) { } $this->databaseHelper->addColumns("order", "`order_payment_price` decimal(17,5) NOT NULL DEFAULT '0.00000'"); $this->databaseHelper->addColumns("payment", "`payment_price` decimal(17,5) NOT NULL DEFAULT '0.00000'"); } if (version_compare($this->fromVersion, '1.5.9', '<')) { $this->db->setQuery("\nCREATE TABLE IF NOT EXISTS `#__hikashop_shipping_price` (\n\t`shipping_price_id` int(11) NOT NULL AUTO_INCREMENT,\n\t`shipping_id` int(11) NOT NULL,\n\t`shipping_price_ref_id` int(11) NOT NULL,\n\t`shipping_price_ref_type` varchar(255) NOT NULL DEFAULT 'product',\n\t`shipping_price_min_quantity` int(11) NOT NULL DEFAULT '0',\n\t`shipping_price_value` decimal(15,7) NOT NULL DEFAULT '0',\n\t`shipping_fee_value` decimal(15,7) NOT NULL DEFAULT '0',\n\tPRIMARY KEY (`shipping_price_id`)\n) ENGINE=MyISAM;"); try { $this->db->query(); } catch (Exception $e) { } $this->db->setQuery("UPDATE #__hikashop_config SET `config_value` = '0',`config_default` = '1' WHERE `config_namekey`='variant_increase_perf';"); try { $this->db->query(); } catch (Exception $e) { } $this->databaseHelper->addColumns("product", "`product_page_title` varchar(255) NOT NULL DEFAULT ''"); $this->databaseHelper->addColumns("category", "`category_page_title` varchar(255) NOT NULL DEFAULT ''"); $this->databaseHelper->addColumns("characteristic", "`characteristic_ordering` INT( 12 ) UNSIGNED NOT NULL DEFAULT '0' AFTER `characteristic_alias`"); $this->db->setQuery("\nCREATE TABLE IF NOT EXISTS `#__hikashop_badge` (\n\t`badge_id` int(11) unsigned NOT NULL AUTO_INCREMENT,\n\t`badge_name` varchar(255) NOT NULL DEFAULT '',\n\t`badge_image` varchar(255) NOT NULL DEFAULT '',\n\t`badge_start` int(10) unsigned NOT NULL DEFAULT '0',\n\t`badge_end` int(10) unsigned NOT NULL DEFAULT '0',\n\t`badge_category_id` int(10) unsigned NOT NULL DEFAULT '0',\n\t`badge_category_childs` tinyint(4) NOT NULL DEFAULT '0',\n\t`badge_discount_id` int(10) unsigned NOT NULL DEFAULT '0',\n\t`badge_ordering` int(10) unsigned NOT NULL DEFAULT '0',\n\t`badge_size` float(12,2) unsigned NOT NULL,\n\t`badge_position` varchar(255) NOT NULL DEFAULT 'bottomleft',\n\t`badge_vertical_distance` int(10) NOT NULL DEFAULT '0',\n\t`badge_horizontal_distance` int(10) NOT NULL DEFAULT '0',\n\t`badge_margin` int(10) NOT NULL DEFAULT '0',\n\t`badge_published` tinyint(4) NOT NULL DEFAULT '0',\n\tPRIMARY KEY (`badge_id`)\n) ENGINE=MyISAM;"); try { $this->db->query(); } catch (Exception $e) { } $this->databaseHelper->addColumns("cart", array("`cart_type` varchar(25) NOT NULL DEFAULT 'cart'", "`cart_name` varchar(50) NOT NULL", "`cart_share` varchar(255) NOT NULL DEFAULT 'nobody'", "`cart_current` INT NOT NULL DEFAULT '0'")); $this->databaseHelper->addColumns("cart_product", "`cart_product_wishlist_id` INT NOT NULL DEFAULT '0'"); $this->databaseHelper->addColumns("order_product", "`order_product_wishlist_id` INT NOT NULL DEFAULT '0'"); $this->databaseHelper->addColumns("widget", array("`widget_published` tinyint(4) NOT NULL DEFAULT 1", "`widget_ordering` int(11) NOT NULL DEFAULT 0", "`widget_access` varchar(250) NOT NULL DEFAULT 'all'")); $this->db->setQuery("ALTER TABLE `#__hikashop_field` CHANGE `field_value` `field_value` LONGTEXT CHARACTER SET utf8 COLLATE utf8_general_ci NOT NULL"); try { $this->db->query(); } catch (Exception $e) { } } if (version_compare($this->fromVersion, '1.6.0', '<')) { $this->databaseHelper->addColumns("address", "`address_street2` TEXT NOT NULL"); } if (version_compare($this->fromVersion, '2.0.0', '<')) { $this->databaseHelper->addColumns("order", array("`order_invoice_number` VARCHAR( 255 ) NOT NULL DEFAULT ''", "`order_invoice_id` INT NOT NULL DEFAULT '0'")); $this->db->setQuery("UPDATE `#__hikashop_order` SET `order_invoice_number`=`order_number`;"); try { $this->db->query(); } catch (Exception $e) { } $this->db->setQuery("UPDATE `#__hikashop_order` SET `order_invoice_id`=`order_id`;"); try { $this->db->query(); } catch (Exception $e) { } $this->databaseHelper->addColumns("download", "`file_pos` int(10) NOT NULL DEFAULT '1'"); $this->db->setQuery("ALTER TABLE `#__hikashop_download` DROP PRIMARY KEY , ADD PRIMARY KEY ( `file_id` , `order_id` , `file_pos` );"); try { $this->db->query(); } catch (Exception $e) { } $this->databaseHelper->addColumns("product_category`", "`product_parent_id` INT NOT NULL DEFAULT '0'"); $file = HIKASHOP_BACK . 'admin.hikashop.php'; if (file_exists($file)) { JFile::delete($file); } } if (version_compare($this->fromVersion, '2.0.0', '=')) { $this->databaseHelper->addColumns("product_category", "`product_parent_id` INT NOT NULL DEFAULT '0'"); } if (version_compare($this->fromVersion, '2.1.0', '<')) { $this->databaseHelper->addColumns("product", "`product_alias` VARCHAR( 255 ) NOT NULL DEFAULT ''"); $this->databaseHelper->addColumns("category", "`category_alias` VARCHAR( 255 ) NOT NULL DEFAULT ''"); if ($this->level == 'starter') { $this->db->setQuery("DELETE FROM `#__hikashop_widget` ;"); try { $this->db->query(); } catch (Exception $e) { } } $this->databaseHelper->addColumns("order", "`order_invoice_created` INT(10) UNSIGNED NOT NULL DEFAULT '0'"); $this->db->setQuery("UPDATE #__hikashop_order SET `order_invoice_created` = `order_created` WHERE `order_invoice_created`=0 AND `order_invoice_id`>0;"); try { $this->db->query(); } catch (Exception $e) { } } if (version_compare($this->fromVersion, '2.1.1', '<')) { $this->databaseHelper->addColumns("product", "`product_price_percentage` decimal(15,7) NOT NULL DEFAULT '0'"); $this->databaseHelper->addColumns("discount", "`discount_affiliate` INT(10) NOT NULL DEFAULT '0'"); $this->databaseHelper->addColumns("badge", "`badge_keep_size` INT(10) NOT NULL DEFAULT '0'"); } if (version_compare($this->fromVersion, '2.1.2', '<')) { $this->databaseHelper->addColumns("product", array("`product_canonical` VARCHAR( 255 ) NOT NULL DEFAULT ''", "`product_msrp` decimal(15,7) NULL DEFAULT '0'")); $this->databaseHelper->addColumns("badge", "`badge_quantity` VARCHAR( 255 ) NULL DEFAULT ''"); $this->databaseHelper->addColumns("category", array("`category_canonical` VARCHAR( 255 ) NOT NULL DEFAULT ''", "`category_site_id` VARCHAR( 255 ) NULL DEFAULT ''")); } if (version_compare($this->fromVersion, '2.2.0', '<')) { $this->databaseHelper->addColumns("payment", array("`payment_ordering` int(10) unsigned NOT NULL DEFAULT '0'", "`payment_published` tinyint(4) NOT NULL DEFAULT '1'")); $this->db->setQuery("ALTER TABLE `#__hikashop_payment` DROP INDEX payment_type"); try { $this->db->query(); } catch (Exception $e) { } $this->databaseHelper->addColumns("order", array("`order_shipping_params` text NOT NULL DEFAULT ''", "`order_payment_params` text NOT NULL DEFAULT ''")); $this->databaseHelper->addColumns("order_product", array("`order_product_shipping_id` varchar(255) NOT NULL DEFAULT ''", "`order_product_shipping_method` varchar(255) NOT NULL DEFAULT ''", "`order_product_shipping_price` decimal(17,5) NOT NULL DEFAULT '0.00000'", "`order_product_shipping_tax` decimal(17,5) NOT NULL DEFAULT '0.00000'", "`order_product_shipping_params` varchar(255) NOT NULL DEFAULT ''")); $this->db->setQuery("\nCREATE TABLE IF NOT EXISTS `#__hikashop_massaction` (\n\t`massaction_id` int(10) unsigned NOT NULL AUTO_INCREMENT,\n\t`massaction_name` varchar(255) NOT NULL DEFAULT '',\n\t`massaction_description` text NOT NULL,\n\t`massaction_table` varchar(255) NOT NULL DEFAULT 'product',\n\t`massaction_published` tinyint(4) NOT NULL DEFAULT '1',\n\t`massaction_lasttime` int(10) unsigned NOT NULL DEFAULT '0',\n\t`massaction_triggers` text NOT NULL,\n\t`massaction_filters` text NOT NULL,\n\t`massaction_actions` text NOT NULL,\n\t`massaction_report` text NOT NULL,\n\tPRIMARY KEY (`massaction_id`),\n\tKEY `massaction_table` (`massaction_table`)\n) ENGINE=MyISAM;"); try { $this->db->query(); } catch (Exception $e) { } } if (version_compare($this->fromVersion, '2.2.1', '<')) { $this->db->setQuery("\nCREATE TABLE IF NOT EXISTS `#__hikashop_plugin` (\n\t`plugin_id` INT(10) NOT NULL AUTO_INCREMENT,\n\t`plugin_type` VARCHAR(255) NOT NULL,\n\t`plugin_published` INT(4) NOT NULL DEFAULT 0,\n\t`plugin_name` VARCHAR(255) NOT NULL,\n\t`plugin_ordering` INT(10) NOT NULL DEFAULT 0,\n\t`plugin_description` TEXT NOT NULL DEFAULT '',\n\t`plugin_params` TEXT NOT NULL DEFAULT '',\n\t`plugin_access` VARCHAR(255) NOT NULL DEFAULT 'all',\n\tPRIMARY KEY (`plugin_id`)\n) ENGINE=MyISAM"); try { $this->db->query(); } catch (Exception $e) { } $this->databaseHelper->addColumns("field", "`field_display` text NOT NULL DEFAULT ''"); $this->databaseHelper->addColumns("badge", "`badge_url` VARCHAR( 255 ) NULL DEFAULT ''"); } if (version_compare($this->fromVersion, '2.2.2', '<')) { $this->databaseHelper->addColumns("taxation", "`taxation_post_code` VARCHAR( 255 ) NULL DEFAULT ''"); $this->databaseHelper->addColumns("product", "`product_display_quantity_field` SMALLINT DEFAULT 0"); jimport('joomla.filesystem.file'); jimport('joomla.filesystem.folder'); $lng_override_folder = JLanguage::getLanguagePath(JPATH_ROOT) . DS . 'overrides'; if (JFolder::exists($lng_override_folder)) { $lngFiles = JFolder::files($lng_override_folder); if (!empty($lngFiles)) { foreach ($lngFiles as $lngfile) { $content = JFile::read($lng_override_folder . DS . $lngfile); if (!empty($content) && strpos($content, 'PLEASE_ACCEPT_TERMS_BEFORE_FINISHING_ORDER="') !== false) { $content = preg_replace('#PLEASE_ACCEPT_TERMS_BEFORE_FINISHING_ORDER="(.*)"#', 'PLEASE_ACCEPT_TERMS_BEFORE_FINISHING_ORDER="\\1"' . "\r\n" . 'PLEASE_ACCEPT_TERMS="\\1"', $content); JFile::write($lng_override_folder . DS . $lngfile, $content); unset($content); } } unset($lngFiles); } } } if (version_compare($this->fromVersion, '2.2.3', '<')) { $this->databaseHelper->addColumns("cart", "`cart_params` text NOT NULL DEFAULT ''"); } if (version_compare($this->fromVersion, '2.3.0', '<')) { $this->databaseHelper->addColumns("taxation", array("`taxation_date_start` int(10) unsigned NOT NULL DEFAULT '0'", "`taxation_date_end` int(10) unsigned NOT NULL DEFAULT '0'")); $this->db->setQuery("\n\t\t\tCREATE TABLE IF NOT EXISTS `#__hikashop_warehouse` (\n\t\t\t\t`warehouse_id` INT(10) NOT NULL AUTO_INCREMENT,\n\t\t\t\t`warehouse_name` VARCHAR(255) NOT NULL DEFAULT '',\n\t\t\t\t`warehouse_published` tinyint(4) NOT NULL DEFAULT '1',\n\t\t\t\t`warehouse_description` TEXT NOT NULL,\n\t\t\t\t`warehouse_ordering` INT(10) NOT NULL DEFAULT 0,\n\t\t\t\t`warehouse_created` int(10) DEFAULT NULL,\n\t\t\t\t`warehouse_modified` int(10) DEFAULT NULL,\n\t\t\t\tPRIMARY KEY (`warehouse_id`)\n\t\t\t) ENGINE=MyISAM"); try { $this->db->query(); } catch (Exception $e) { } $this->databaseHelper->addColumns("product", "`product_warehouse_id` int(10) unsigned NOT NULL DEFAULT '0'"); if (file_exists(HIKASHOP_MEDIA . 'css' . DS . 'frontend_old.css')) { $this->db->setQuery("UPDATE #__hikashop_config SET `config_value` = 'old',`config_default` = 'old' WHERE `config_namekey` = 'css_frontend' AND `config_value` = 'default' "); try { $this->db->query(); } catch (Exception $e) { } } } if (version_compare($this->fromVersion, '2.3.1', '<')) { $this->databaseHelper->addColumns("product", "`product_quantity_layout` varchar(255) NOT NULL DEFAULT ''"); $this->databaseHelper->addColumns("category", "`category_quantity_layout` varchar(255) NOT NULL DEFAULT ''"); } if (version_compare($this->fromVersion, '2.3.2', '<')) { $this->databaseHelper->addColumns("order", "`order_site_id` varchar(255) NOT NULL DEFAULT ''"); $this->databaseHelper->addColumns("price", "`price_site_id` varchar(255) NOT NULL DEFAULT ''"); $this->databaseHelper->addColumns("characteristic", array("`characteristic_display_type` varchar(255) NOT NULL DEFAULT ''", "`characteristic_params` TEXT NOT NULL DEFAULT ''")); } if (version_compare($this->fromVersion, '2.3.4', '<')) { $this->databaseHelper->addColumns("taxation", array("`taxation_internal_code` varchar(15) NOT NULL DEFAULT ''", "`taxation_note` TEXT NOT NULL", "`taxation_site_id` varchar(255) NOT NULL DEFAULT ''")); $this->databaseHelper->addColumns("shipping", "`shipping_currency` varchar(255) NOT NULL DEFAULT ''"); } if (version_compare($this->fromVersion, '2.4.0', '<')) { $this->db->setQuery("ALTER TABLE `#__hikashop_discount` CHANGE `discount_product_id` `discount_product_id` VARCHAR(255) NOT NULL DEFAULT '';"); try { $this->db->query(); } catch (Exception $e) { } $this->db->setQuery("ALTER TABLE `#__hikashop_discount` CHANGE `discount_category_id` `discount_category_id` VARCHAR(255) NOT NULL DEFAULT '';"); try { $this->db->query(); } catch (Exception $e) { } $this->db->setQuery("ALTER TABLE `#__hikashop_discount` CHANGE `discount_zone_id` `discount_zone_id` VARCHAR(255) NOT NULL DEFAULT '';"); try { $this->db->query(); } catch (Exception $e) { } $this->db->setQuery("ALTER TABLE `#__hikashop_badge` CHANGE `badge_discount_id` `badge_discount_id` VARCHAR(255) NOT NULL DEFAULT '';"); try { $this->db->query(); } catch (Exception $e) { } $this->db->setQuery("ALTER TABLE `#__hikashop_badge` CHANGE `badge_category_id` `badge_category_id` VARCHAR(255) NOT NULL DEFAULT '';"); try { $this->db->query(); } catch (Exception $e) { } $this->databaseHelper->addColumns("field", "`field_products` varchar(255) NOT NULL DEFAULT ''"); } if (version_compare($this->fromVersion, '2.5.0', '<')) { $this->databaseHelper->addColumns("order", "`order_currency_info` text NOT NULL DEFAULT ''"); $this->databaseHelper->addColumns("taxation", "`taxation_ordering` int(10) unsigned NOT NULL DEFAULT '0'"); $this->databaseHelper->addColumns("characteristic", "`characteristic_display_method` varchar(255) NOT NULL DEFAULT ''"); } if (version_compare($this->fromVersion, '2.6.0', '<')) { $this->db->setQuery("ALTER TABLE `#__hikashop_filter` CHANGE `filter_category_id` `filter_category_id` VARCHAR(255) NOT NULL DEFAULT '';"); try { $this->db->query(); } catch (Exception $e) { } $this->databaseHelper->addColumns("discount", "`discount_site_id` VARCHAR(255) NULL DEFAULT '';"); $this->databaseHelper->addColumns("order", array("`order_payment_tax` decimal(12,5) NOT NULL DEFAULT '0.00000'")); } if (version_compare($this->fromVersion, '2.6.1', '<')) { $this->databaseHelper->addColumns("badge", "`badge_access` varchar(255) NOT NULL DEFAULT 'all';"); } }
function onAfterRoute() { $app = JFactory::getApplication(); if ($app->isAdmin()) { return true; } if (@$_REQUEST['option'] == 'com_gcalendar') { return true; } $key_name = $this->params->get('partner_key_name', 'partner_id'); $partner_id = JRequest::getCmd($key_name, 0); if (empty($partner_id)) { return true; } static $done = false; if ($done) { return true; } $done = true; if (!(include_once rtrim(JPATH_ADMINISTRATOR, DS) . DS . 'components' . DS . 'com_hikashop' . DS . 'helpers' . DS . 'helper.php')) { return true; } $partner_id = hikashop_decode($partner_id, 'partner'); $userClass = hikashop_get('class.user'); $user = $userClass->get($partner_id); if (empty($user->user_partner_activated)) { return true; } $config = hikashop_config(); $cookie = true; if ($config->get('no_affiliation_if_cart_present')) { $cart_id = $app->getUserState(HIKASHOP_COMPONENT . '.cart_id', 0, 'int'); if ($cart_id) { $cookie = false; } } if ($cookie) { setcookie('hikashop_affiliate', hikashop_encode($partner_id, 'partner'), time() + $config->get('click_validity_period', 2592000), '/'); } $ip = hikashop_getIP(); $clickClass = hikashop_get('class.click'); $latest = $clickClass->getLatest($partner_id, $ip, $config->get('click_min_delay', 86400)); if (empty($user->user_params->user_custom_fee)) { $user->user_params->partner_click_fee = $config->get('partner_click_fee', 0); $user->user_params->partner_fee_currency = $config->get('partner_currency', 1); } else { $user->user_params->partner_click_fee = $user->user_params->user_partner_click_fee; } if (!$config->get('allow_currency_selection', 0) || empty($user->user_currency_id)) { $user->user_currency_id = $config->get('partner_currency', 1); } if (bccomp($user->user_params->partner_click_fee, 0, 5) && $user->user_currency_id != $user->user_params->partner_fee_currency) { $user->user_params->partner_click_fee = $this->_convert($user->user_params->partner_click_fee, $user->user_params->partner_fee_currency, $user->user_currency_id); } if (!empty($latest)) { $user->user_params->partner_click_fee = 0; } $click = new stdClass(); $click->click_partner_id = $partner_id; $click->click_ip = $ip; $click->click_partner_price = $user->user_params->partner_click_fee; $click->click_partner_currency_id = $user->user_currency_id; $clickClass->save($click); return true; }
function onPaymentNotification(&$statuses) { $pluginsClass = hikashop_get('class.plugins'); $elements = $pluginsClass->getMethods('payment', 'bf_rbsglobalgateway'); if (empty($elements)) { return false; } $element = reset($elements); if (!$element->payment_params->notification) { return false; } $vars = array(); $data = array(); $filter = JFilterInput::getInstance(); foreach ($_REQUEST as $key => $value) { $key = $filter->clean($key); if (preg_match("#^[0-9a-z_-]{1,30}\$#i", $key) && !preg_match("#^cmd\$#i", $key)) { switch ($key) { case 'option': case 'ctrl': case 'task': case 'notif_payment': case 'tmpl': case 'lang': case 'status': case 'orderKey': case 'paymentStatus': case 'paymentAmount': case 'paymentCurrency': case 'orderAmount': case 'orderCurrency': case 'mac': case 'jlbz': case 'view': $value = JRequest::getString($key); $vars[$key] = $value; $data[] = $key . '=' . urlencode($value); break; } } } if (empty($vars['orderKey'])) { rbsglobalgateway_helper::raiseError($element->payment_params->showVars, 'Missing Order Key'); return false; } $orderKey = explode('^', @$vars['orderKey']); if ($orderKey[0] != @$element->payment_params->adminCode) { rbsglobalgateway_helper::raiseError($element->payment_params->showVars, 'Invalid admin code: ' . $orderKey[0]); } if (@$orderKey[1] != @$element->payment_params->merchantCode) { rbsglobalgateway_helper::raiseError($element->payment_params->showVars, 'Invalid merchant code: ' . $orderKey[1]); } $orderCode = @$orderKey[2]; if (empty($orderCode)) { rbsglobalgateway_helper::raiseError($element->payment_params->showVars, 'Missing Order Code'); return false; } if (empty($vars['paymentCurrency'])) { $vars['paymentCurrency'] = @$vars['orderCurrency']; if (empty($vars['paymentCurrency'])) { rbsglobalgateway_helper::raiseError($element->payment_params->showVars, 'Missing Payment Currency'); return false; } } if (empty($vars['paymentAmount'])) { $vars['paymentAmount'] = @$vars['orderAmount']; if (empty($vars['paymentAmount'])) { rbsglobalgateway_helper::raiseError($element->payment_params->showVars, 'Missing Payment Amount'); return false; } } if (!empty($element->payment_params->macSecret)) { $mac = rbsglobalgateway_helper::calculateMAC(@$vars['orderKey'], @$vars['paymentAmount'], @$vars['paymentCurrency'], @$vars['paymentStatus'], $element->payment_params->macSecret); if ($mac != @$vars['mac']) { rbsglobalgateway_helper::raiseError($element->payment_params->showVars, 'Invalid MAC'); } } if (empty($vars['paymentStatus'])) { $vars['paymentStatus'] = 'CANCELLED'; } if ($element->payment_params->debug) { echo print_r($vars, true) . "\n\n\n"; } $data = implode('&', $data) . '&cmd=_notify-validate'; $db = JFactory::getDBO(); $query = 'SELECT order_id FROM ' . hikashop_table('order') . ' WHERE order_number = ' . $db->Quote($orderCode) . ' LIMIT 1'; $db->setQuery($query); $order_id = $db->loadResult(); $orderClass = hikashop_get('class.order'); $dbOrder = $orderClass->get((int) $order_id); if (empty($dbOrder)) { rbsglobalgateway_helper::raiseError($method->payment_params->showVars, 'Could not load order : ' . $orderCode); return false; } $order = new stdClass(); $order->order_id = $dbOrder->order_id; $order->old_status->order_status = $dbOrder->order_status; $url = HIKASHOP_LIVE . 'administrator/index.php?option=com_hikashop&ctrl=order&task=edit&order_id=' . $order->order_id; $order_text = "\r\n" . JText::sprintf('NOTIFICATION_OF_ORDER_ON_WEBSITE', hikashop_encode($dbOrder), HIKASHOP_LIVE); $order_text .= "\r\n" . str_replace('<br/>', "\r\n", JText::sprintf('ACCESS_ORDER_WITH_LINK', $url)); if ($element->payment_params->debug) { echo print_r($dbOrder, true) . "\n\n\n"; } $mailer = JFactory::getMailer(); $config =& hikashop_config(); $sender = array($config->get('from_email'), $config->get('from_name')); $mailer->setSender($sender); $mailer->addRecipient(explode(',', $config->get('payment_notification_email'))); $currencyClass = hikashop_get('class.currency'); $currencies = null; $currencies = $currencyClass->getCurrencies($dbOrder->order_currency_id, $currencies); $currency = $currencies[$dbOrder->order_currency_id]; $fracDigits = (int) $currency->currency_locale['int_frac_digits']; $paymentAmount = (int) @$vars['paymentAmount'] / pow(10, $fracDigits); $order->history->history_reason = JText::sprintf('AUTOMATIC_PAYMENT_NOTIFICATION'); $order->history->history_notified = 0; $order->history->history_amount = $paymentAmount . @$vars['paymentCurrency']; $order->history->history_payment_id = $element->payment_id; $order->history->history_payment_method = $element->payment_type; $order->history->history_data = ob_get_clean(); $order->history->history_type = 'payment'; if (@$vars['paymentStatus'] != 'CANCELLED') { $price_check = round($dbOrder->order_full_price, $fracDigits); if ($price_check != $paymentAmount || $currency->currency_code != @$vars['paymentCurrency']) { $order->order_status = $element->payment_params->invalid_status; $orderClass->save($order); $mailer->setSubject(JText::sprintf('NOTIFICATION_REFUSED_FOR_THE_ORDER', 'Worldpay Global Gateway') . JText::_('INVALID_AMOUNT')); $body = str_replace('<br/>', "\r\n", JText::sprintf('AMOUNT_RECEIVED_DIFFERENT_FROM_ORDER', 'Worldpay Global Gateway', $order->history->history_amount, $price_check . $currency->currency_code)) . "\r\n\r\n" . $order_text; $mailer->setBody($body); $mailer->Send(); return false; } } switch ($vars['paymentStatus']) { case 'AUTHORISED': $payment_status = 'Authenticated'; $order_status = $element->payment_params->verified_status; $message = $element->payment_params->verifiedMessage; $url = $element->payment_params->verifiedURL; $order->history->history_notified = 1; break; case 'PENDING': $payment_status = 'Pending'; $order_status = $element->payment_params->pending_status; $message = $element->payment_params->pendingMessage; $url = $element->payment_params->pendingURL; break; case 'REFUSED': $payment_status = 'Refused'; $order_status = $element->payment_params->invalid_status; $message = $element->payment_params->invalidMessage; $url = $element->payment_params->invalidURL; break; case 'CANCELLED': $payment_status = 'Cancelled'; $order_status = $element->payment_params->cancelled_status; $message = $element->payment_params->cancelledMessage; $url = $element->payment_params->cancelledURL; break; default: $payment_status = 'Unknown'; $order_status = $element->payment_params->invalid_status; $message = $element->payment_params->invalidMessage; $url = $element->payment_params->invalidURL; break; } if (!empty($element->payment_params->responseRefField)) { $responseRefField = $element->payment_params->responseRefField; $response = rbsglobalgateway_helper::getOrderPaymentResponse($element->payment_params, $dbOrder->order_number); if (!empty($response)) { $order->{$responseRefField} = $response; } } if (!empty($order_status)) { $order->order_status = $order_status; } $order->mail_status = $statuses[$order->order_status]; $mailer->setSubject(JText::sprintf('PAYMENT_NOTIFICATION_FOR_ORDER', 'Worldpay Global Gateway', $payment_status, $dbOrder->order_number)); $body = str_replace('<br/>', "\r\n", JText::sprintf('PAYMENT_NOTIFICATION_STATUS', 'Worldpay Global Gateway', $vars['paymentStatus'])) . ' ' . JText::sprintf('ORDER_STATUS_CHANGED', $order->mail_status) . "\r\n\r\n" . $order_text; $mailer->setBody($body); $mailer->Send(); $orderClass->save($order); $dbg = null; if ($element->payment_params->debug) { $dbg = ob_get_clean(); } $app = JFactory::getApplication(); if (!empty($message)) { $app->set('_messageQueue', ''); JError::raiseNotice(100, $message); } if (!empty($url)) { if (empty($element->payment_params->showVars)) { $app->redirect($url); } else { echo '<a href="' . $url . '">Click here to continue...</a>'; echo '<pre>'; print_r($vars); echo '</pre>'; if (!empty($dbg)) { echo '<hr/><pre>' . $dbg . '</pre>'; } exit(0); } } if (!empty($dbg)) { ob_start(); echo $dbg; } return true; }