public static function add($params) { $result = array(); $result['success'] = true; if(empty($params)) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Error Register_Order.PAP'); return $result; } //unset($params['allow_work']); if(!empty($_COOKIE['oseAffiliate'])) { $orderParams = oseJson::decode($params['params']); $oseAffiliate = oseJSON::decode($_COOKIE['oseAffiliate']); $orderParams->oseaffiliateID = $oseAffiliate->oafid; $orderParams->osebannerID = $oseAffiliate->obid; $orderParams->first_ip = oseMscPublic::getIP(); //$orderParams->first_ip = oseMscPublic::getIP(); $params['params'] = oseJson::encode($orderParams); return $params; } else { return $params; } }
public static function save($params) { $result = array(); $result['success'] = true; if (empty($params['allow_work'])) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Error Join.Order.1'); return $result; } unset($params['allow_work']); if ($params['join_from'] != 'payment') { $result['success'] = true; $result['title'] = JText::_('Done'); $result['content'] = JText::_('Done Join.Order'); return $result; } $db = oseDB::instance(); $msc_id = $params['msc_id']; $member_id = $params['member_id']; $order_id = $params['order_id']; $order_item_id = $params['order_item_id']; $where = array(); $where[] = "order_id = {$order_id}"; $payment = oseRegistry::call('payment'); $curOrder = $payment->getOrder($where, 'obj'); $member = oseRegistry::call('member'); $member->instance($member_id); $memParams = $member->getMemberInfo($msc_id, 'obj')->memParams; if (empty($memParams)) { $memParams = new stdClass(); } else { $memParams = oseJSON::decode($memParams); } $memParams->order_id = $order_id; $memParams->payment_mode = $curOrder->payment_mode; $memParams->order_item_id = $order_item_id; // Order problem for system add $memParams = oseJSON::encode($memParams); $query = " UPDATE `#__osemsc_member`" . " SET `params` = " . $db->Quote($memParams) . " WHERE msc_id = {$msc_id} AND member_id = {$member_id}"; $memConfig = oseMscConfig::getConfig('register', 'obj'); $db->setQuery($query); if (!oseDB::query()) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Error Join.Order.2'); } // User activation function; $params = JComponentHelper::getParams('com_users'); $useractivation = $params->get('useractivation'); if (oseObject::getValue($memConfig, 'disabled_non_paid', false) == true) { if ($useractivation == 0) { $query = " UPDATE `#__users` SET `block` = 0 where `id` = " . $member_id; $db->setQuery($query); $db->query(); } } return $result; }
public static function save($params) { $result = array(); $result['success'] = true; //oseExit($params); if (empty($params['allow_work'])) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Error Join.Idev'); return $result; } unset($params['allow_work']); if ($params['join_from'] != 'payment') { $result['success'] = true; $result['title'] = JText::_('Done'); $result['content'] = JText::_('Done Join.Order'); return $result; } $oseMscConfig = oseRegistry::call('msc')->getConfig('thirdparty', 'obj'); if (empty($oseMscConfig->idev_enable)) { return $result; } if (empty($oseMscConfig->idev_url)) { return $result; } $db = oseDB::instance(); //$post = JRequest::get('post'); $msc_id = $params['msc_id']; $member_id = $params['member_id']; $order_id = $params['order_id']; $order_item_id = $params['order_item_id']; $where = array(); $where[] = "order_id = {$order_id}"; $payment = oseRegistry::call('payment'); $curOrder = $payment->getOrder($where, 'obj'); $curOrderParams = oseJson::decode($curOrder->params); $member = oseRegistry::call('member'); $member->instance($member_id); $userInfo = $member->getUserInfo('obj'); $memParams = $member->getMemberInfo($msc_id, 'obj')->memParams; $memParams = oseJSON::decode($memParams); $memParams->first_ip = $curOrderParams->first_ip; try { $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $oseMscConfig->idev_url . "/sale.php?profile=72198&idev_saleamt={$curOrder->payment_price}&idev_ordernum={$order_id}&ip_address={$memParams->first_ip}"); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_exec($ch); curl_close($ch); return $result; } catch (Exception $e) { return $result; } }
function getDefMsgtoNonmembers($content_type, $content_id, $com_type = null) { $db = oseDB::instance(); $controllingMSC = self::getControllingMsc($content_type, $content_id, $com_type); if (!empty($controllingMSC)) { $controllingMSC = $controllingMSC[0]; $query = " SELECT `params` FROM `#__osemsc_ext` WHERE `type` = 'msc' AND `id` = " . (int) $controllingMSC->id; $db->setQuery($query); $result = $db->loadResult(); $result = oseJSON::decode($result); return oseObject::getValue($result, 'restrict'); } else { return false; } }
public static function save($params) { $result = array(); $result['success'] = true; //oseExit($params); if (empty($params['allow_work'])) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Error Join.Order.1'); return $result; } unset($params['allow_work']); if ($params['join_from'] != 'payment') { $result['success'] = true; $result['title'] = JText::_('Done'); $result['content'] = JText::_('Done Join.Order'); return $result; } $db = oseDB::instance(); //$post = JRequest::get('post'); $msc_id = $params['msc_id']; $member_id = $params['member_id']; $order_id = $params['order_id']; $where = array(); $where[] = "order_id = {$order_id}"; $payment = oseRegistry::call('payment'); $curOrder = $payment->getOrder($where, 'obj'); $member = oseRegistry::call('member'); $member->instance($member_id); $memParams = $member->getMemberInfo($msc_id, 'obj')->memParams; $memParams = oseJSON::decode($memParams); $memParams->order_id = $order_id; $memParams->payment_mode = $curOrder->payment_mode; // Order problem for system add $memParams = oseJSON::encode($memParams); $query = " UPDATE `#__osemsc_member`" . " SET params = " . $db->Quote($memParams) . " WHERE msc_id = {$msc_id} AND member_id = {$member_id}"; $db->setQuery($query); //oseExit($db->_sql); if (!oseDB::query()) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Error Join.Order.2'); } return $result; }
public function getModMemlist() { $search = JRequest::getString('search', null); $start = JRequest::getInt('start', 0); $limit = JRequest::getInt('limit', 20); if (JOOMLA16 || JOOMLA17) { $module = JModuleHelper::getModule('osememlist'); $params = oseJSON::decode($module->params); $msc_id = $params->msc; $status = $params->status; } else { $module = JModuleHelper::getModule('osememlist'); $params = new JParameter($module->params); $msc_id = $params->get('msc'); $status = $params->get('status'); } $db = oseDB::instance(); $where = array(); $where[] = ' m.msc_id = ' . $msc_id; if (isset($status) && $status != 'all') { $where[] = ' m.status = ' . $status; } if (!empty($search)) { $searchQuery = $db->Quote('%' . $search . '%'); $where[] = "m.username LIKE {$searchQuery} OR m.name LIKE {$searchQuery} OR m.email LIKE {$searchQuery}"; } $where = oseDB::implodeWhere($where); $query = " SELECT COUNT(*) " . " FROM `#__osemsc_member_view` AS m " . " INNER JOIN `#__osemsc_billinginfo` AS b ON m.member_id = b.user_id" . $where; $db->setQuery($query); $total = $db->loadResult(); $query = " SELECT * " . " FROM `#__osemsc_member_view` AS m " . " INNER JOIN `#__osemsc_billinginfo` AS b ON m.member_id = b.user_id" . $where; $db->setQuery($query, $start, $limit); $items = oseDB::loadList(); $result = array(); $result['total'] = $total; $result['results'] = $items; return $result; }
function getCurrencyList() { $db = oseDB::instance(); $query = " SELECT * FROM `#__osemsc_configuration` WHERE `key` = 'primary_currency'"; $db->setQuery($query); $objs = oseDB::loadList('obj'); $currency = array(); $currency[0]['title'] = $objs[0]->value; $currency[0]['value'] = $objs[0]->value; $others = oseJSON::decode($objs[0]->default); $i = 1; if (!empty($others)) { foreach ($others as $key => $value) { $currency[$i]['title'] = $key; $currency[$i]['value'] = $key; $i++; } } $result = array(); $result['results'] = $currency; $result['total'] = count($result['results']); $result = oseJson::encode($result); oseExit($result); }
function getOptions() { $db = oseDB::instance(); $msc_id = JRequest::getInt('msc_id', 0); $date = JRequest::getVar('date', 0); $query = "SELECT title FROM `#__osemsc_acl` WHERE `id` = " . (int) $msc_id; $db->setQuery($query); $title = $db->loadResult(); $msc = oseRegistry::call('msc'); $opts = $msc->runAddonAction('panel.payment.getOptions'); $options = $opts['results']; $items = array(); $item = array(); foreach ($options as $option) { $item['option_id'] = $option['id']; $item['option_name'] = $option['optionname']; $item['msc'] = $title; $query = " SELECT * FROM `#__osemsc_member` AS mem" . " WHERE `msc_id` = '{$msc_id}' AND DATE(`start_date`) = '{$date}' AND `status` = 1"; $db->setQuery($query); $mems = $db->loadObjectList(); $newMem = 0; foreach ($mems as $mem) { $params = oseJSON::decode($mem->params); $query = "SELECT params FROM `#__osemsc_order_item` WHERE `order_item_id` = '{$params->order_item_id}'"; $db->setQuery($query); $order_params = oseJSON::decode($db->loadResult()); if ($order_params->msc_option == $item['option_id']) { $newMem++; } } $item['newmem'] = $newMem; $query = " SELECT * FROM `#__osemsc_member` AS mem" . " WHERE `msc_id` = '{$msc_id}' AND DATE(`expired_date`) = '{$date}' AND `status` = 0"; $db->setQuery($query); $mems = $db->loadObjectList(); $expMem = 0; foreach ($mems as $mem) { $params = oseJSON::decode($mem->params); $query = "SELECT params FROM `#__osemsc_order_item` WHERE `order_item_id` = '{$params->order_item_id}'"; $db->setQuery($query); $order_params = oseJSON::decode($db->loadResult()); if ($order_params->msc_option == $item['option_id']) { $expMem++; } } $item['expmem'] = $expMem; $ratio = round($item['expmem'] / $item['newmem'] * 100, 2); $item['ratio'] = $ratio . '%'; $query = " SELECT ord.payment_price, ord.payment_currency, ooi.params, ord.params as order_params FROM `#__osemsc_order` AS ord" . " INNER JOIN `#__osemsc_order_item` AS ooi" . " ON ord.`order_id` = ooi.`order_id`" . " WHERE ord.`order_status` = 'confirmed' AND ooi.`entry_id` = '{$msc_id}' AND DATE(ord.`create_date`) = '{$date}'"; $db->setQuery($query); $objs = $db->loadObjectList(); $arr = array(); $arr2 = array(); foreach ($objs as $obj) { $params = oseJSON::decode($obj->params); if ($params->msc_option == $item['option_id']) { $arr[$obj->payment_currency] += $obj->payment_price; $orderParams = oseJSON::decode($obj->order_params); $arr2[$obj->payment_currency] += $orderParams->gross_tax; } } $profit = null; foreach ($arr as $key => $value) { if (empty($value)) { continue; } else { $profit .= $value . ' ' . $key . ' ,'; } } $profit = trim($profit, ","); $item['profits'] = $profit; $tax = null; foreach ($arr2 as $key => $value) { if (empty($value)) { continue; } else { $tax .= $value . ' ' . $key . ' ,'; } } $tax = trim($tax, ","); $item['tax'] = $tax; $items[] = $item; } //print_r($items);exit; $result = array(); $result['total'] = count($items); $result['results'] = $items; return $result; }
function login($username, $password) { $app = JFactory::getApplication(); // Populate the data array: $data = array(); $data['return'] = base64_decode(JRequest::getVar('return', '', 'POST', 'BASE64')); // Set the return URL if empty. if (empty($data['return'])) { $data['return'] = 'index.php?option=com_users&view=profile'; } // Get the log in options. $options = array(); $options['remember'] = JRequest::getBool('remember', false); $options['return'] = $data['return']; // Get the log in credentials. $credentials = array(); $credentials['username'] = $username; $credentials['password'] = $password; // Perform the log in. $error = $app->login($credentials, $options); if (JOOMLA16 || JOOMLA17) { $plugin = JPluginHelper::getPlugin('user', 'oseuser'); if (!empty($plugin)) { $pluginParams = oseJSON::decode($plugin->params); $loginRedirect = $pluginParams->loginRedirect; $redmenuid = $pluginParams->redmenuid; $sefroutemethod = $pluginParams->sefroutemethod; } else { $loginRedirect = false; } } else { $plugin = JPluginHelper::getPlugin('user', 'oseuser'); if (!empty($plugin)) { $pluginParams = new JParameter($plugin->params); $loginRedirect = $pluginParams->get('loginRedirect'); $redmenuid = $pluginParams->get('redmenuid'); $sefroutemethod = $pluginParams->get('sefroutemethod'); } else { $loginRedirect = false; } } $user = JFactory::getUser(); $db = JFactory::getDBO(); $query = " SELECT a.menuid" . " FROM `#__menu` as m" . " LEFT JOIN `#__osemsc_acl` as a ON a.menuid = m.id" . " LEFT JOIN `#__osemsc_member` as b ON b.msc_id = a.id" . " WHERE b.member_id={$user->id} AND b.status = 1 ORDER BY a.menuid DESC LIMIT 1"; $db->setQuery($query); $menu = $db->loadObject(); if (!empty($menu)) { $redmenuid = $menu->menuid; } if ($loginRedirect && !empty($redmenuid)) { $db = JFactory::getDBO(); $query = "SELECT * FROM `#__menu` WHERE `id` = " . (int) $redmenuid; $db->setQuery($query); $menu = $db->loadObject(); switch ($sefroutemethod) { default: case 0: $return = ($menu->link == 'index.php?Itemid=') ? 'index.php' : $menu->link . "&Itemid=" . $menu->id; break; case 1: $return = ($menu->link == 'index.php?Itemid=') ? JRoute::_(JURI::root() . 'index.php') : JRoute::_($menu->link . "&Itemid=" . $menu->id); break; case 2: $return = JRoute::_($menu->alias); break; } } else { $session = JFactory::getSession(); $return = $session->get('oseReturnUrl', base64_encode(JURI::root() . 'index.php?option=com_osemsc&view=login')); $return = base64_decode($return); } $result = array(); // Check if the log in succeeded. $user_id = intval(JUserHelper::getUserId($username)); $user = JFactory::getUser($user_id); if ($user->get('block')) { $result['success'] = false; $result['title'] = JText::_('Error'); $result['content'] = JText::_('LOGIN_DENIED_YOUR_ACCOUNT_HAS_EITHER_BEEN_BLOCKED_OR_YOU_HAVE_NOT_ACTIVATED_IT_YET'); $result['returnUrl'] = $return; return $result; } if ($error) { if (!JError::isError($error)) { $result['success'] = true; $result['returnUrl'] = $return; return $result; } else { $errors = JError::getErrors(); $result['success'] = false; $result['title'] = JText::_('Error'); $result['content'] = JText::_('PLEASE_MAKE_SURE_YOUR_ACCOUNT_AND_PASSWORD_IS_CORRECT');//implode("<br />",JError::getErrors());//'Make sure your account and password is correct';//Error ::getError(); $result['returnUrl'] = $return; return $result; } } else { $result['success'] = false; $result['title'] = JText::_('Error'); $result['content'] = JText::_('PLEASE_MAKE_SURE_YOUR_ACCOUNT_AND_PASSWORD_IS_CORRECT');//implode("<br />",JError::getErrors());//'Make sure your account and password is correct';//Error ::getError(); $result['returnUrl'] = $return; return $result; } }
private static function activateInAutomaticMode($msc_id,$member_id,$orderInfo,$ext) { $db = oseDB::instance(); $result = array(); $result['success'] = true; $orderParams = oseJSON::decode($orderInfo->params); $start_date = oseHTML::getDateTime(); $start_date = $db->Quote($start_date); $recurrence_num = $orderParams->p3; $recurrence_unit = $orderParams->t3; $expired_date = " DATE_ADD({$start_date},INTERVAL {$recurrence_num} {$recurrence_unit}) "; $query = " UPDATE `#__osemsc_member` " ." SET expired_date = {$expired_date}" ." WHERE member_id = {$member_id} AND msc_id = {$msc_id} " ; $db->setQuery($query); //oseExit($db->_sql); if(!oseDB::query()) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_(' Fail Updated Member\'s Recurrence '); return $result; } $query = " SELECT expired_date FROM `#__osemsc_member` " ." WHERE member_id = {$member_id} AND msc_id = {$msc_id} " ; $db->setQuery($query); $end_date = $db->loadResult(); $end_date = $db->Quote($end_date); $expired_date = " DATE_ADD({$end_date},INTERVAL 1 DAY) "; if(oseObject::getValue($orderParams,'recurrence_times',0) > 1) { } else { $query = " UPDATE `#__osemsc_member` " ." SET expired_date = {$expired_date}" ." WHERE member_id = {$member_id} AND msc_id = {$msc_id} " ; $db->setQuery($query); //oseExit($db->_sql); if(!oseDB::query()) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_(' Fail Updated Member\'s Recurrence '); return $result; } } return $result; }
public static function save($params) { if(!class_exists('oseMscPublic')) { require_once(OSEMSC_F_HELPER.DS.'oseMscPublic.php'); } $result = array(); $result['success'] = true; //oseExit($params); if(empty($params['allow_work'])) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Error Join.PAP'); return $result; } unset($params['allow_work']); /* Offline payments should be counted as well; removed from v 6.0.5 if( $params['join_from'] != 'payment') { $result['success'] = true; $result['title'] = JText::_('Done'); $result['content'] = JText::_('Done Join.Order'); return $result; } */ $oseMscConfig = oseRegistry::call('msc')->getConfig('thirdparty','obj'); if(empty($oseMscConfig->pap_enable)) { return $result; } if(empty($oseMscConfig->pap_url)) { return $result; } $db = oseDB::instance(); //$post = JRequest::get('post'); $msc_id = $params['msc_id']; $member_id = $params['member_id']; $order_id = $params['order_id']; $order_item_id = $params['order_item_id']; $where = array(); $where[] = "order_id = {$order_id}"; $payment = oseRegistry::call('payment'); $curOrder = $payment->getOrder($where,'obj'); $curOrderParams = oseJson::decode($curOrder->params); $recurrence_times = ($curOrderParams->has_trial)?$curOrderParams->recurrence_times+1:$curOrderParams->recurrence_times; $member = oseRegistry::call('member'); $member->instance($member_id); $userInfo = $member->getUserInfo('obj'); $memParams = $member->getMemberInfo($msc_id,'obj')->memParams; $memParams = oseJSON::decode($memParams); $memParams->first_ip = oseObject::getValue($curOrderParams,'first_ip');; if(empty($curOrderParams->pap_visitorid)) { return $result; //$memParams->pap_visitorid = 'paypal'; } else { $memParams->pap_visitorid = $curOrderParams->pap_visitorid; //$memParams->pap_visitorid = $_COOKIE['PAPVisitorId']; } $memParams_encode = oseJSON::encode($memParams); $query = " UPDATE `#__osemsc_member`" ." SET params = ".$db->Quote($memParams_encode) ." WHERE msc_id = {$msc_id} AND member_id = {$member_id}" ; $db->setQuery($query); //oseExit($db->_sql); if(!oseDB::query()) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Error Join.Order.2'); return $result; } try { require_once(OSEMSC_B_LIB.DS.'PapApi.class.php'); $saleTracker = new Pap_Api_SaleTracker($oseMscConfig->pap_url.'/scripts/sale.php'); $saleTracker->setAccountId(oseObject::getValue($oseMscConfig,'pap_account_id','default1')); $saleTracker->setVisitorId($memParams->pap_visitorid); $sale1 = $saleTracker->createSale(); $msc = oseRegistry::call('msc'); $where = array(); $where[] = "`order_item_id` = '{$order_item_id}'"; $curOrderItem = $payment->getInstance('Order')->getOrderItem($where,'obj'); $curOrderItemParams = oseJson::decode($curOrderItem->params); $node = $msc->getInfo($msc_id,'obj'); $paymentInfos = $msc->getExtInfo($msc_id,'payment'); foreach($paymentInfos as $key => $paymentInfo) { if($key != $curOrderItemParams->msc_option) { unset($paymentInfos[$key]); } } $cart = oseMscPublic::getCart(); $osePaymentCurrency = $cart->get('currency'); $items = $cart->get('items'); $options = oseMscPublic::generatePriceOption($node,$paymentInfos,$osePaymentCurrency); $sale1->setTotalCost($curOrder->payment_price); $sale1->setOrderID($order_id); $sale1->setProductID("{$node->title}-{$options[0]['title']}"); $sale1->setData1($userInfo->email); $sale1->setData2($userInfo->jname); $sale1->setData3($memParams->first_ip); $sale1->setData4($curOrder->payment_serial_number); $sale1->setData5("{$curOrder->order_id}-{$node->title}-{$options[0]['title']}-#recurrence:{$recurrence_times}"); $saleTracker->register(); //$memParams->pap_affiliate_id = $sale1->getAffiliateId(); //$memParams->pap_campaign_id = $sale1->getCampaignId(); //$memParams->pap_banner_id = $sale1->getBannerId(); // Order problem for system add return $result; } catch (Exception $e) { return $result; } }
function checkJoiningControl($msc_id) { $db = JFactory::getDBO(); $user = JFactory::getUser(); $query = " SELECT `params` FROM `#__osemsc_ext` " . " WHERE `id` = " . (int) $msc_id . " AND `type` = 'msc'"; $db->setQuery($query); $result = $db->loadResult(); $result = oseJSON::decode($result); if (!empty($result->control_joining) && $result->control_joining == true) { if (!empty($result->joined_msc)) { if (!isset($result->control_active)) { $result->control_active = 1; } $query = " SELECT `id` FROM `#__osemsc_member` " . " WHERE `msc_id` = " . (int) $result->joined_msc . " AND `member_id` = " . (int) $user->id . " AND `status` = " . (int) $result->control_active; $db->setQuery($query); $result = $db->loadResult(); return (!empty($result)) ? true : false; } else { return true; } } else { return true; } }
function getDefMsgtoNonmembers($content_type, $content_id, $com_type = null) { $db = oseDB::instance(); $controllingMSC = self::getControllingMsc($content_type, $content_id, $com_type); if (!empty($controllingMSC)) { $controllingMSC = $controllingMSC[0]; $query = " SELECT `params` FROM `#__osemsc_ext` WHERE `type` = 'msc' AND `id` = " . (int) $controllingMSC->id; $db->setQuery($query); $result = $db->loadResult(); $result = oseJSON::decode($result); return !empty($result->restrict) ? $result->restrict : JText::_("This is members only. Please subscribe a membership to continue."); } else { return false; } }
public static function processPayment($payment_method, $orderInfo, $post) { $switch = 1; if ($switch == 2) { // Testing Purpose; please do not delete; //$payment= oseRegistry :: call('payment'); //$gateway = $payment->getGateWay($payment_method); } $order_id = $orderInfo->order_id; $payment = oseRegistry::call('payment'); $config = oseRegistry::call('msc')->getConfig('', 'obj'); //check payment method $db = oseDB::instance(); $query = "SELECT entry_id FROM `#__osemsc_order_item` WHERE `order_id` = " . $order_id; $db->setQuery($query); $msc_id = $db->loadResult(); $query = "SELECT * FROM `#__osemsc_ext` WHERE `id` = '{$msc_id}' AND `type` = 'hidepayment'"; $db->setQuery($query); $data = $db->loadObject(); if (!empty($data->params)) { $data = oseJson::decode($data->params); if (!empty($data->enable) && !empty($data->value)) { $values = explode(",", $data->value); if (in_array($payment_method, $values)) { $result['success'] = false; $result['title'] = JText::_('ERROR'); $result['content'] = $payment_method . ' ' . JText::_('CAN_NOT_USE_ON_THIS_MEMBERSIHP'); $result['reload'] = ($config->error_registration == 'refresh') ? true : false; return $result; } } } $creditInfo = array(); if (isset($post['creditcard_number'])) { $creditInfo['creditcard_type'] = $post['creditcard_type']; $creditInfo['creditcard_name'] = $post['creditcard_name']; $creditInfo['creditcard_owner'] = $creditInfo['creditcard_name']; $creditInfo['creditcard_number'] = $post['creditcard_number']; $creditInfo['creditcard_year'] = $post['creditcard_year']; $creditInfo['creditcard_month'] = $post['creditcard_month']; $creditInfo['creditcard_expirationdate'] = $post['creditcard_year'] . '-' . $post['creditcard_month']; $creditInfo['creditcard_cvv'] = $post['creditcard_cvv']; } switch ($payment_method) { case ('authorize'): if (!$config->enable_authorize) { return false; } $updated = $payment->processCCForm($orderInfo, $creditInfo, 'authorize'); if ($updated['success']) { $updated['success'] = true; $updated['title'] = JText::_('SUCCESSFUL_ACTIVATION'); $updated['content'] = JText::_('MEMBERSHIP_ACTIVATED_CONTINUE'); $updated['payment_method'] = 'authorize'; } $updated['reload'] = ($config->error_registration == 'refresh') ? true : false; return $updated; break; case ('paypal_cc'): $expiration = $post['creditcard_year'] . '-' . $post['creditcard_month']; $creditInfo['creditcard_expirationdate'] = $expiration; $updated = $payment->processCCForm($orderInfo, $creditInfo, 'paypal_cc'); $updated['payment_method'] = 'paypal_cc'; if (JFile::exists(JPATH_SITE . DS . 'modules' . DS . 'mod_ose_gag' . DS . 'helper.php')) { require_once(JPATH_SITE . DS . 'modules' . DS . 'mod_ose_gag' . DS . 'helper.php'); $mod = JModuleHelper::getModule('ose_gag'); if (JOOMLA16) { $modParams = new JRegistry; $modParams->loadJSON($mod->params); } else { $modParams = new JParameter($mod->params); } $db = oseDB::instance(); $where = array('`order_id`=' . $db->Quote($orderInfo->order_id)); $code = osegagHelper::getOrderCode($modParams->get('account'), $where); $code = explode("\r\n", $code); array_shift($code); array_pop($code); if (empty($code)) { $code = false; } else { $code = implode("", $code); } $updated['code'] = $code; } if (class_exists('plgSystemoseMscGoogleAnalytics')) { $config = oseMscConfig::getConfig('thirdparty', 'obj'); $account = $config->gag_account; $code = oseMscPublic::ajaxOrderTrack($account, $order_id); if (empty($code)) { $code = false; } else { $code = implode("", $code); } $updated['code'] = $code; } $updated['reload'] = ($config->error_registration == 'refresh') ? true : false; return $updated; break; case ('paypal'): $html = $payment->getPaypalForm($orderInfo); $result = array(); $result['success'] = true; $result['html'] = $html; $result['payment_method'] = 'paypal'; $result['reload'] = ($config->error_registration == 'refresh') ? true : false; return $result; break; case ('eway'): $expiration = $post['creditcard_year'] . '-' . $post['creditcard_month']; $creditInfo['creditcard_expirationdate'] = $expiration; $updated = $payment->processCCForm($orderInfo, $creditInfo, 'eway'); $config = oseMscConfig::getConfig('thirdparty', 'obj'); $account = oseObject::getValue($config, 'gag_account'); $standard_type = oseObject::getValue($config, 'gag_domain_mode'); $domain = oseObject::getValue($config, 'gag_domain'); $htmlTrack = oseMscPublic::htmlTrack($account, $standard_type, $domain, $order_id); $code = oseMscPublic::ajaxOrderTrack($account, $order_id); if (empty($code)) { $code = false; } else { $code = implode("", $code); } if (!empty($code) && !empty($htmlTrack)) { $updated['code'] = $code; $updated['htmlTrack'] = $htmlTrack; } if ($updated['success']) { $updated['success'] = true; $updated['title'] = JText::_('SUCCESSFUL_ACTIVATION'); $updated['content'] = JText::_('MEMBERSHIP_ACTIVATED_CONTINUE'); $updated['payment_method'] = 'eway'; } $updated['reload'] = ($config->error_registration == 'refresh') ? true : false; return $updated; break; case ('epay'): if ($orderInfo->payment_mode == 'a') { $html = $payment->getInstance('Order')->ePayCreateProfile($orderInfo); if (!$html) { $result['success'] = false; $result['title'] = 'Epay Free Trial Banned'; $result['payment_method'] = 'It does not support free trial subscription yet. If it still has problem, please contact the webmaster!'; $result['reload'] = ($config->error_registration == 'refresh') ? true : false; return $result; } } else { $html = $payment->getInstance('Order')->ePayOneOffPay($orderInfo); } $result = array(); $result['success'] = true; $result['html'] = $html; $result['payment_method'] = 'epay'; return $result; break; case ('pnw'): if ($orderInfo->payment_mode == 'a') { $result['success'] = false; $result['title'] = 'Payment Network Error'; $result['payment_method'] = 'It does not support subscription.'; $result['reload'] = ($config->error_registration == 'refresh') ? true : false; return $result; } else { $html = $payment->getInstance('Order')->PNWOneOffPay($orderInfo); } $result = array(); $result['success'] = true; $result['html'] = $html; $result['payment_method'] = $payment_method; return $result; break; case ('beanstream'): $updated = $payment->processCCForm($orderInfo, $creditInfo, 'beanstream'); $updated['reload'] = ($config->error_registration == 'refresh') ? true : false; $config = oseMscConfig::getConfig('thirdparty', 'obj'); $account = oseObject::getValue($config, 'gag_account'); $standard_type = oseObject::getValue($config, 'gag_domain_mode'); $domain = oseObject::getValue($config, 'gag_domain'); $htmlTrack = oseMscPublic::htmlTrack($account, $standard_type, $domain, $order_id); $code = oseMscPublic::ajaxOrderTrack($account, $order_id); if (empty($code)) { $code = false; } else { $code = implode("", $code); } if (!empty($code) && !empty($htmlTrack)) { $updated['code'] = $code; $updated['htmlTrack'] = $htmlTrack; } return $updated; break; case ('vpcash_cc'): case ('vpcash'): if ($orderInfo->payment_mode == 'a') { $result['success'] = false; $result['title'] = 'VirtualPayCash Error'; $result['payment_method'] = 'It does not support subscription.'; $result['reload'] = ($config->error_registration == 'refresh') ? true : false; } else { $html = $payment->getInstance('Order')->VpcashOneOffPostForm($orderInfo, $payment_method); $result = array(); $result['success'] = true; $result['html'] = $html; $result['payment_mode'] = $orderInfo->payment_mode; $result['payment_method'] = $payment_method; } return $result; break; case ('bbva'): if ($orderInfo->payment_mode == 'a') { $result['success'] = false; $result['title'] = 'BBVA Error'; $result['payment_method'] = 'It does not support subscription.'; $result['reload'] = ($config->error_registration == 'refresh') ? true : false; } else { $html = $payment->getInstance('Order')->BBVAOneOffPostForm($orderInfo); $result = array(); $result['success'] = true; $result['html'] = $html; $result['payment_mode'] = $orderInfo->payment_mode; $result['payment_method'] = $payment_method; } return $result; break; case ('payfast'): if ($orderInfo->payment_mode == 'a') { $result['success'] = false; $result['title'] = 'Payfast Error'; $result['payment_method'] = 'It does not support subscription.'; $result['reload'] = ($config->error_registration == 'refresh') ? true : false; } else { $html = $payment->getInstance('Order')->PayFastOneOffPostForm($orderInfo); $result = array(); $result['success'] = true; $result['html'] = $html; $result['payment_mode'] = $orderInfo->payment_mode; $result['payment_method'] = $payment_method; } return $result; break; case ('gco'): if ($orderInfo->payment_mode == 'a') { $html = $payment->getInstance('Order')->GcoRecurringPostForm($orderInfo); $result = array(); $result['success'] = true; $result['html'] = $html; $result['payment_mode'] = $orderInfo->payment_mode; $result['payment_method'] = $payment_method; } else { $html = $payment->getInstance('Order')->GcoOneOffPostForm($orderInfo); $result = array(); $result['success'] = true; $result['html'] = $html; $result['payment_mode'] = $orderInfo->payment_mode; $result['payment_method'] = $payment_method; } return $result; break; case ('ewaysh'): if ($orderInfo->payment_mode == 'a') { $result['success'] = false; $result['title'] = 'Error'; $result['payment_method'] = 'It does not support subscription.'; $result['reload'] = ($config->error_registration == 'refresh') ? true : false; } else { $html = $payment->getInstance('Order')->eWaySharedHostingPostForm($orderInfo); $result = array(); $result['success'] = true; $result['html'] = $html; $result['payment_mode'] = $orderInfo->payment_mode; $result['payment_method'] = $payment_method; } return $result; break; case ('2co'): $html = $payment->get2COForm($orderInfo); $result = array(); $result['success'] = true; $result['html'] = $html; $result['payment_method'] = $payment_method; return $result; break; case ('poffline'): //send Pay 0fline notification email $member = oseRegistry::call('member'); $email = $member->getInstance('email'); $emailConfig = oseMscConfig::getConfig('email', 'obj'); $emailTempDetail = $email->getDoc($emailConfig->pay_offline_email, 'obj'); if (!empty($emailTempDetail)) { $juser = new JUser($orderInfo->user_id); $variables = $email->getEmailVariablesReceipt($order_id); $emailParams = $email->buildEmailParams($emailTempDetail->type); $emailDetail = $email->transEmail($emailTempDetail, $variables, $emailParams); $email->sendEmail($emailDetail, $juser->get('email')); if ($emailConfig->sendPayOffline2Admin) { $email->sendToAdminGroup($emailDetail, $emailConfig->admin_group); } } $result['payment_method'] = 'poffline'; $user = JFactory::getUser(); $params = JComponentHelper::getParams('com_users'); $useractivation = $params->get('useractivation'); if (($useractivation == 2 || $useractivation == 1) && $user->guest) { $result['title'] = JText::_('SUCCESSFUL_ACTIVATION'); $result['content'] = JText::_('MEMBERSHIP_PAYOFFLINE_CONTINUE'); } if (!empty($config->poffline_art_id)) { $link = JURI::root() . "index.php?option=com_content&view=article&id={$config->poffline_art_id}"; } else { $link = JURI::root() . "index.php"; } $result['success'] = true; $result['returnUrl'] = $link; $result['payment_method'] = $payment_method; return $result; break; case ('cp'): if ($orderInfo->payment_mode == 'a') { $result['success'] = false; $result['title'] = 'Error'; $result['payment_method'] = 'It does not support subscription.'; $result['reload'] = ($config->error_registration == 'refresh') ? true : false; } else { $html = $payment->getInstance('Order')->CPoneOffPostForm($orderInfo, $creditInfo); $result = array(); $result['success'] = true; $result['html'] = $html; $result['payment_mode'] = $orderInfo->payment_mode; $result['payment_method'] = $payment_method; } return $result; break; case ('clickbank'): $html = $payment->getInstance('Order')->getClickBankForm($orderInfo); $result = array(); $result['success'] = true; $result['html'] = $html; $result['payment_method'] = $payment_method; return $result; break; case ('ccavenue'): if ($orderInfo->payment_mode == 'a') { $result['success'] = false; $result['title'] = 'CCAvenue Error'; $result['payment_method'] = 'It does not support subscription.'; $result['reload'] = ($config->error_registration == 'refresh') ? true : false; } else { $html = $payment->getInstance('Order')->CCAvenueOneOffPostForm($orderInfo); $result = array(); $result['success'] = true; $result['html'] = $html; $result['payment_mode'] = $orderInfo->payment_mode; $result['payment_method'] = $payment_method; } return $result; break; case ('usaepay'): if ($orderInfo->payment_mode == 'a') { $update = array(); $updated['success'] = false; $updated['title'] = 'Error'; $updated['content'] = 'It does not support subscription.'; $updated['reload'] = ($config->error_registration == 'refresh') ? true : false; } else { $updated = $payment->getInstance('Order')->processUSAePayForm($orderInfo, $creditInfo); $config = oseMscConfig::getConfig('thirdparty', 'obj'); $account = oseObject::getValue($config, 'gag_account'); $standard_type = oseObject::getValue($config, 'gag_domain_mode'); $domain = oseObject::getValue($config, 'gag_domain'); $htmlTrack = oseMscPublic::htmlTrack($account, $standard_type, $domain, $order_id); $code = oseMscPublic::ajaxOrderTrack($account, $order_id); if (empty($code)) { $code = false; } else { $code = implode("", $code); } if (!empty($code) && !empty($htmlTrack)) { $updated['code'] = $code; $updated['htmlTrack'] = $htmlTrack; } } return $updated; break; case ('icepay'): if ($orderInfo->payment_mode == 'a') { $result = array(); $result['success'] = false; $result['title'] = 'Error'; $result['content'] = 'It does not support subscription.'; $result['reload'] = ($config->error_registration == 'refresh') ? true : false; } else { $html = $payment->getInstance('Order')->ICEPAYOffPostForm($orderInfo); $result = array(); $result['success'] = true; $result['html'] = $html; $result['payment_mode'] = $orderInfo->payment_mode; $result['payment_method'] = $payment_method; } return $result; break; case ('oospay'): if ($orderInfo->payment_mode == 'a') { $result = array(); $result['success'] = false; $result['title'] = 'Error'; $result['content'] = 'It does not support subscription.'; $result['reload'] = ($config->error_registration == 'refresh') ? true : false; } else { $html = $payment->getInstance('Order')->OOSPayOneOffPay($orderInfo); $result = array(); $result['success'] = true; $result['html'] = $html; $result['payment_mode'] = $orderInfo->payment_mode; $result['payment_method'] = $payment_method; } return $result; break; case ('ebs'): if ($orderInfo->payment_mode == 'a') { $result = array(); $result['success'] = false; $result['title'] = 'Error'; $result['content'] = 'It does not support subscription.'; $result['reload'] = ($config->error_registration == 'refresh') ? true : false; } else { $html = $payment->getInstance('Order')->EBSOneOffPay($orderInfo); $result = array(); $result['success'] = true; $result['html'] = $html; $result['payment_mode'] = $orderInfo->payment_mode; $result['payment_method'] = $payment_method; } return $result; break; case ('liqpay'): if ($orderInfo->payment_mode == 'a') { $result['success'] = false; $result['title'] = 'Error'; $result['payment_method'] = 'It does not support subscription.'; $result['reload'] = ($config->error_registration == 'refresh') ? true : false; } else { $html = $payment->getInstance('Order')->LiqPayOneOffPay($orderInfo); $result = array(); $result['success'] = true; $result['html'] = $html; $result['payment_mode'] = $orderInfo->payment_mode; $result['payment_method'] = $payment_method; } return $result; break; case ('virtualmerchant'): if ($orderInfo->payment_mode == 'a') { $update = array(); $updated['success'] = false; $updated['title'] = 'Error'; $updated['content'] = 'It does not support subscription.'; $updated['reload'] = ($config->error_registration == 'refresh') ? true : false; } else { $updated = $payment->getInstance('Order')->VirtualMerchantOneOffPay($orderInfo, $creditInfo); } return $updated; break; case ('realex_remote'): case ('realex_redirect'): if ($orderInfo->payment_mode == 'a') { $update = array(); $updated['success'] = false; $updated['title'] = 'Error'; $updated['content'] = 'It does not support subscription.'; $updated['reload'] = ($config->error_registration == 'refresh') ? true : false; } else { $updated = $payment->getInstance('Order')->RealexOneOffPay($orderInfo, $creditInfo); $config = oseMscConfig::getConfig('thirdparty', 'obj'); $account = oseObject::getValue($config, 'gag_account'); $standard_type = oseObject::getValue($config, 'gag_domain_mode'); $domain = oseObject::getValue($config, 'gag_domain'); $htmlTrack = oseMscPublic::htmlTrack($account, $standard_type, $domain, $order_id); $code = oseMscPublic::ajaxOrderTrack($account, $order_id); if (empty($code)) { $code = false; } else { $code = implode("", $code); } if (!empty($code) && !empty($htmlTrack)) { $updated['code'] = $code; $updated['htmlTrack'] = $htmlTrack; } } return $updated; break; case ('sisow'): $result = array(); if ($orderInfo->payment_mode == 'a') { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = 'It does not support subscription.'; $result['payment_method'] = $payment_method; } else { $result = $payment->getInstance('Order')->SisowPostForm($orderInfo); } return $result; break; case ('pagseguro'): if ($orderInfo->payment_mode == 'a') { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = 'It does not support subscription.'; $result['payment_method'] = $payment_method; } else { $result = $payment->getInstance('Order')->PagSeguroOneOffPay($orderInfo); } return $result; break; case ('paygate'): if ($orderInfo->payment_mode == 'a') { $result['success'] = false; $result['title'] = 'Error'; $result['payment_method'] = 'It does not support subscription.'; $result['reload'] = ($config->error_registration == 'refresh') ? true : false; } else { $html = $payment->getInstance('Order')->PayGateOneOffPay($orderInfo); $result = array(); $result['success'] = true; $result['html'] = $html; $result['payment_mode'] = $orderInfo->payment_mode; $result['payment_method'] = $payment_method; } return $result; break; case ('quickpay'): if ($orderInfo->payment_mode == 'a') { $result['success'] = false; $result['title'] = 'Error'; $result['payment_method'] = 'It does not support subscription.'; $result['reload'] = ($config->error_registration == 'refresh') ? true : false; } else { $html = $payment->getInstance('Order')->QuickpayOneOffPay($orderInfo); $result = array(); $result['success'] = true; $result['html'] = $html; $result['payment_mode'] = $orderInfo->payment_mode; $result['payment_method'] = $payment_method; } return $result; break; case ('sagepay'): if ($orderInfo->payment_mode == 'a') { $result['success'] = false; $result['title'] = 'Error'; $result['payment_method'] = 'It does not support subscription.'; $result['reload'] = ($config->error_registration == 'refresh') ? true : false; } else { $html = $payment->getInstance('Order')->sagepayOneOffPay($orderInfo); $result = array(); $result['success'] = true; $result['html'] = $html; $result['payment_mode'] = $orderInfo->payment_mode; $result['payment_method'] = $payment_method; } return $result; break; case ('alipay'): if ($orderInfo->payment_mode == 'a') { $result['success'] = false; $result['title'] = 'Error'; $result['payment_method'] = 'It does not support subscription.'; $result['reload'] = ($config->error_registration == 'refresh') ? true : false; } else { $html = $payment->getInstance('Order')->AlipayOneOffPay($orderInfo); $result = array(); $result['success'] = true; $result['html'] = $html; $result['payment_mode'] = $orderInfo->payment_mode; $result['payment_method'] = $payment_method; } return $result; break; default: $result = array(); $orderParams = oseJSON::decode($orderInfo->params); if ($orderParams->total == "0.00" && $orderParams->next_total == "0.00") { $result['success'] = true; $result['title'] = JText::_('SUCCESSFUL_ACTIVATION'); $result['content'] = JText::_('MEMBERSHIP_ACTIVATED_CONTINUE'); $result['payment_method'] = 'none'; } else { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('No Payment Method'); $result['payment_method'] = 'none'; $result['reload'] = ($config->error_registration == 'refresh') ? true : false; } return $result; break; } return $result; }
public static function renew($params) { if(!class_exists('oseMscPublic')) { require_once(OSEMSC_F_HELPER.DS.'oseMscPublic.php'); } $result = array(); $result['success'] = true; if(empty($params['allow_work'])) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Error Renew.Order'); return $result; } //unset($params['allow_work']); $oseMscConfig = oseRegistry::call('msc')->getConfig('thirdparty','obj'); if(empty($oseMscConfig->pap_enable)) { return $result; } if(empty($oseMscConfig->pap_url)) { return $result; } $db = oseDB::instance(); //$post = JRequest::get('post'); $msc_id = $params['msc_id']; $member_id = $params['member_id']; $order_id = $params['order_id']; $order_item_id = $params['order_item_id']; $where = array(); $where[] = "order_id = {$order_id}"; $payment = oseRegistry::call('payment'); $curOrder = $payment->getOrder($where,'obj'); $curOrderParams = oseJson::decode($curOrder->params); $recurrence_times = ($curOrderParams->has_trial)?oseObject::getValue($curOrderParams,'recurrence_times',0)+1:oseObject::getValue($curOrderParams,'recurrence_times',0); $member = oseRegistry::call('member'); $member->instance($member_id); $userInfo = $member->getUserInfo('obj'); $memParams = $member->getMemberInfo($msc_id,'obj')->memParams; $memParams = oseJSON::decode($memParams); $usePAPUserId = false; require_once(OSEMSC_B_LIB.DS.'PapApi.class.php'); if(!oseObject::GetValue($memParams,'pap_visitorid',oseObject::getValue($curOrderParams,'pap_visitorid',false))) { if(oseObject::GetValue($memParams,'pap_userid',false)) { $usePAPUserId = true; } else { // check whether has table in old version 4.4 $tableList = $db->getTableList(); if(in_array($db->replacePrefix('#__osemsc_affiliate_tracking'),$tableList)) { $session = new Gpf_Api_Session($oseMscConfig->pap_url.'/scripts/server.php'); if(!$session->login(oseObject::getValue($oseMscConfig,'pap_username'), oseObject::getValue($oseMscConfig,'pap_password'))) { $result['success'] = false; $result['title'] = JText::_('Error'); $result['content'] = $session->getMessage(); return $result; } $request = new Pap_Api_TransactionsGrid($session); // set filter //$request->addFilter('dateinserted', Gpf_Data_Filter::DATERANGE_IS, Gpf_Data_Filter::RANGE_THIS_YEAR); $request->addFilter('orderid', Gpf_Data_Filter::EQUALS, $order_id); $request->setLimit(0, 30); $request->setSorting('orderid', false); $request->sendNow(); $grid = $request->getGrid(); $recordset = $grid->getRecordset(); if($grid->getTotalCount() > 0) { $usePAPUserId = true; foreach($recordset as $rec) { $memParams->pap_userid = $rec->get('userid'); break; } } else { return $result; } } else { return $result; } } } else { $memParams->pap_visitorid = oseObject::GetValue($memParams,'pap_visitorid',oseObject::getValue($curOrderParams,'pap_visitorid')); } //oseObject::GetValue($memParams,'pap_visitorid',oseObject::getValue($curOrderParams,'pap_visitorid',false)); $memParams->first_ip = oseObject::getValue($memParams,'first_ip',oseObject::getValue($curOrderParams,'first_ip',oseMscPublic::getIP())); $memParams->pap_url = OSEMSC_B_LIB; $memParams_encode = oseJSON::encode($memParams); $query = " UPDATE `#__osemsc_member`" ." SET `params` = ".$db->Quote($memParams_encode) ." WHERE `msc_id` = '{$msc_id}' AND `member_id` = '{$member_id}'" ; $db->setQuery($query); if(!oseDB::query()) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Error Join.Order.2'); return $result; } try { $msc = oseRegistry::call('msc'); $where = array(); $where[] = "`order_item_id` = '{$order_item_id}'"; $curOrderItem = $payment->getInstance('Order')->getOrderItem($where,'obj'); $curOrderItemParams = oseJson::decode($curOrderItem->params); $node = $msc->getInfo($msc_id,'obj'); $paymentInfos = $msc->getExtInfo($msc_id,'payment'); foreach($paymentInfos as $key => $paymentInfo) { if($key != $curOrderItemParams->msc_option) { unset($paymentInfos[$key]); } } $cart = oseMscPublic::getCart(); $osePaymentCurrency = $cart->get('currency'); $options = oseMscPublic::generatePriceOption($node,$paymentInfos,$osePaymentCurrency); $saleTracker = new Pap_Api_SaleTracker($oseMscConfig->pap_url.'/scripts/sale.php'); $saleTracker->setAccountId(oseObject::getValue($oseMscConfig,'pap_account_id','default1')); $sale1 = $saleTracker->createSale(); if($usePAPUserId) { $sale1->setAffiliateID($memParams->pap_userid); } else { $saleTracker->setVisitorId($memParams->pap_visitorid); } $sale1->setTotalCost($curOrder->payment_price); $sale1->setOrderID($order_id); $sale1->setProductID("{$node->title}-{$options[0]['title']}"); $sale1->setData1($userInfo->email); $sale1->setData2($userInfo->jname); $sale1->setData3($memParams->first_ip); $sale1->setData4($curOrder->payment_serial_number); $sale1->setData5("{$curOrder->order_id}-{$node->title}-{$options[0]['title']}-#recurrence:{$recurrence_times}"); $saleTracker->register(); return $result; } catch (Exception $e) { return $result; } }
function checkZooItem($item,$isTaskCategory = false) { $db= JFactory :: getDBO(); $user= JFactory :: getUser(); $mainframe= JFactory :: getApplication(); $item->controlled =false; // Load Plugin Parameters; $plugin = JPluginHelper::getPlugin('content','osecontent'); $pluginParams = oseJSON::decode($plugin->params); $runPlugin= array(); $runPlugin['frontpage']= $pluginParams->run_frontpage; $runPlugin['catlayout']= $pluginParams->run_catlayout; $runPlugin['seclayout']= $pluginParams->run_seclayout; $dontcontinue = self::runPluginCheck($runPlugin, $item, $mainframe, $user); if ($dontcontinue==true) { return $item; } // Replace Content $controlMethod= empty($controlMethod)?$pluginParams->controlMethod:$controlMethod; $allow_uncat= $pluginParams->allow_uncat; $allow_intro= $pluginParams->allow_intro; // Redirection; $redmenuid= $pluginParams->redmenuid; $redmessage= $pluginParams->redmessage; // load OSE Core functions; require_once(JPATH_SITE.DS.'components'.DS.'com_osemsc'.DS.'init.php'); $oseContent = oseRegistry :: call('content'); $allowtoRead= true; $resCatIDs= $oseContent->getRestrictedContent('zoo', 'category'); $relatedCats = $item->getRelatedCategoryIds(true); $resArtIDs= $oseContent->getRestrictedContent('zoo', 'article'); $DefMsgtoNonmembers= stripslashes($oseContent->getDefMsgtoNonmembers ('category', $item->getPrimaryCategoryId(true),'zoo')); $DefMsgtoNonmembers = empty($DefMsgtoNonmembers)?"Members Only":$DefMsgtoNonmembers; if(count(array_intersect($relatedCats,$resCatIDs)) > 0 || in_array($item->id,$resArtIDs)) { $allowtoRead = false; if($isTaskCategory) { if(!$allow_intro) { $item = null; } } else { // task = item //$item->direction = $DefMsgtoNonmembers; $item->getParams()->set('config.enable_comments', 0); $item->getParams()->set('metadata.title', 0); if(!$allow_intro) { //$item = null; } $item->getType()->__unset('elements'); echo '<div class="yoo-zoo " id="yoo-zoo"><div class="item">' . '<div class="pos-header">' . '<h1 class="pos-title"> '.$item->name.' </h1>' ; echo '</div>' . '<div>'.$DefMsgtoNonmembers.'</div>'; echo '</div></div>'; $item->name = null; } } else { } if($allowtoRead == false) { $item->controlled = true; if($controlMethod == 'redirect') { $result['controlMethod'] = 'redirect'; self :: redirect($redmenuid, $redmessage); } else { $result['controlMethod'] = 'replace'; $result['DefMsgtoNonmembers'] = $DefMsgtoNonmembers; $result['allow_intro'] = $allow_intro; } } $result ['allowtoRead'] = $allowtoRead; return $item; }
private static function joinInAutomaticMode($msc_id, $member_id, $orderInfo) { $db = oseDB::instance(); $result = array(); $result['success'] = true; $orderParams = oseJSON::decode($orderInfo->params); $start_date = oseHTML::getDateTime(); $start_date = $db->Quote($start_date); if ($orderParams->has_trial) { $recurrence_num = $orderParams->p1 + 1; $recurrence_unit = $orderParams->t1; } else { $recurrence_num = $orderParams->p3 + 1; $recurrence_unit = $orderParams->t3; } $expired_date = " DATE_ADD({$start_date},INTERVAL {$recurrence_num} {$recurrence_unit}) "; $query = " UPDATE `#__osemsc_member` " . " SET start_date = {$start_date} , expired_date = {$expired_date}" . " WHERE member_id = {$member_id} AND msc_id = {$msc_id} "; $db->setQuery($query); if (!oseDB::query()) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_(' Fail Updated Member\'s Recurrence '); return $result; } return $result; }
function generateOrder($msc_id, $msc_option = null) { $vals = array(); $params = array(); $subtotal = 0.0; $order_number = $this->generateOrderNumber($this->user_id); $params['entry_type'] = 'msc_list'; $params['payment_price'] = 0.0; $params['payment_currency'] = 'USD'; $params['order_number'] = $order_number; $params['create_date'] = oseHTML2::getDateTime(); //date("Y-m-d H:i:s"); $params['payment_serial_number'] = substr($order_number, 0, 20); $params['payment_method'] = 'free'; $params['payment_mode'] = 'm'; $entry_type = 'msc'; $db = oseDB::instance(); $query = "SELECT * FROM `#__osemsc_ext`" . " WHERE `type` = 'payment' AND `id` = '{$msc_id}'"; $db->setQuery($query); $planPayment = oseDB::loadItem('obj'); $options = oseJSON::decode($planPayment->params, true); $paymentInfo = oseGetValue($options, $lc->entry_option, array()); $price = 0.0; $pVals = array(); $pVals['recurrence_mode'] = 'period'; $pVals['a3'] = $price; $pVals['p3'] = oseGetValue($paymentInfo, 'p3'); $pVals['t3'] = oseGetValue($paymentInfo, 't3'); $pVals['msc_option'] = $msc_option; $pVals['recurrence_mode'] = 'fixed'; $pVals['start_date'] = oseHtml2::getDateTime(); $pVals['expired_date'] = oseGetValue($this, 'expired_date', oseHtml2::getDateTime()); $pVals['isLicensee'] = 1; // set licensee true $this->set('isLicensee', true); $pVals['eternal'] = oseGetValue($paymentInfo, 'eternal'); $params['params'] = $pVals; $params['params']['total'] = $price; $params['params']['discount'] = $price; $params['params']['subtotal'] = $price; $params['params']['next_subtotal'] = $price; $params['params'] = oseJSON::encode($params['params']); $updated = oseDB::insert('#__osemsc_order', $params); if ($updated) { $order_id = $updated; $this->order_id = $order_id; } else { $result['success'] = false; $result['title'] = $result['status'] = 'Error'; $result['content'] = $result['result'] = JText::_('Error'); return $result; } $itemParams = array(); $itemParams['entry_type'] = $entry_type; $itemParams['payment_price'] = $price; $itemParams['payment_currency'] = 'USD'; $itemParams['create_date'] = oseHTML2::getDateTime(); //date("Y-m-d H:i:s"); $itemParams['payment_mode'] = 'm'; $itemParams['params'] = oseJSON::encode($pVals); $updated = oseDB::insert('#__osemsc_order_item', $itemParams); if ($updated) { $this->order_item_id = $updated; $result['success'] = true; $result['title'] = $result['status'] = JText::_('Done'); $result['content'] = $result['result'] = JText::_('Done'); } else { $result['success'] = false; $result['title'] = $result['status'] = 'Error'; $result['content'] = $result['result'] = JText::_('Order Generate Error'); } return $result; }
function getOseProfile() { $user = JFactory::getUser(); $member_id = $user->id; $db = oseDB::instance(); $msc_id = JRequest::getInt('msc_id'); if(empty($msc_id)) { $cart= oseMscPublic :: getCart(); $items= $cart->get('items'); $item= $items[0]; $msc_id = oseMscPublic :: getEntryMscId($item); } $where = array(); if(!empty($msc_id)) { $query = "SELECT params FROM `#__osemsc_ext` WHERE `type` = 'profilecontrol' AND `id` = ".$msc_id; $db->setQuery($query); $paymentParams = $db->loadResult(); $paymentParams = oseJSON::decode($paymentParams); if(!empty($paymentParams->enable)) { $pids = $paymentParams->value; $where[] = " `id` IN (".$pids.")"; } } $where[] = " `published` = '1'"; $where= oseDB :: implodeWhere($where); $query = "SELECT * FROM `#__osemsc_fields` ".$where." ORDER BY `ordering`"; $db->setQuery($query); $items = $db->loadObjectList(); foreach($items as $item) { if($item->type == 'radio') { $params=explode(',',$item->params); foreach($params as $param) { $option = array(); $option['boxLabel'] = $param; $option['inputValue'] = $param; $options[] = $option; } $item->params = $options; unset($options); } if(!empty($item->params)) { $params=explode(',',$item->params); foreach($params as $param) { $option = array(); $option['name'] = $param; $options[] = $option; } $item->data = $options; unset($options); } if(!empty($member_id)) { $query = "SELECT value FROM `#__osemsc_fields_values` WHERE `field_id` = '{$item->id}' AND `member_id` = '{$member_id}'"; $db->setQuery($query); $item->value = $db->loadResult(); }else{ $item->value = null; } } $result = array(); $result['total'] = count($items); $result['results'] = $items; return $result; }
public static function getProfile($params = array()) { $member_id = JRequest::getInt('member_id', 0); $db = oseDB::instance(); $member = oseRegistry::call('member'); $member->instance($member_id); $mscs = $member->getAllOwnedMsc(true, 1, 'obj'); if (!empty($mscs)) { foreach ($mscs as $msc) { $Mem_mscs[] = $msc->msc_id; } } else { $Mem_mscs = array(); } $pids = array(); if (!empty($Mem_mscs)) { foreach ($Mem_mscs as $msc_id) { $query = "SELECT params FROM `#__osemsc_ext` WHERE `type` = 'profilecontrol' AND `id` = " . $msc_id; $db->setQuery($query); $paymentParams = $db->loadResult(); $paymentParams = oseJSON::decode($paymentParams); if (!empty($paymentParams->enable)) { $values = explode(",", $paymentParams->value); $pids = array_merge($pids, $values); } } } $where = array(); if (!empty($pids)) { $pids = array_unique($pids); $pids = implode(",", $pids); $where[] = " `id` IN (" . $pids . ")"; } $where[] = " `published` = '1'"; $where = oseDB::implodeWhere($where); $query = "SELECT * FROM `#__osemsc_fields` " . $where . " ORDER BY `ordering`"; $db->setQuery($query); $items = oseDB::loadList('obj'); foreach ($items as $item) { if ($item->type == 'radio') { $params = explode(',', $item->params); foreach ($params as $param) { $option = array(); $option['boxLabel'] = $param; $option['inputValue'] = $param; $option['autoWidth'] = true; $options[] = $option; } $item->params = $options; unset($options); } $query = "SELECT value FROM `#__osemsc_fields_values` WHERE `field_id` = '{$item->id}' AND `member_id` = '{$member_id}'"; $db->setQuery($query); $item->value = $db->loadResult(); } if (empty($items)) { $result['total'] = 0; $result['results'] = ''; } else { $result['total'] = count($items); $result['results'] = $items; } return $result; }
function oseGetAppTitle($app, $id, $entry_option = null) { $db = oseDB::instance(); switch ($app) { case 'contract': $query = " SELECT * FROM `#__ose_contract_plan`" . " WHERE `id` = '{$id}'"; break; case 'msc': $query = " SELECT * FROM `#__osemsc_acl`" . " WHERE `id` = '{$id}'"; break; } $db->setQuery($query); $appItem = oseDB::loadItem('obj'); if (oseGetValue($appItem, 'parent_id', 0) > 1) { $title = oseGetAppTitle($app, $appItem->parent_id) . '-' . $appItem->title; return $title; } elseif ($app == 'msc' && oseGetVersion('com_osemsc') < 6 && !empty($entry_option)) { $query = "SELECT * FROM `#__osemsc_ext`" . " WHERE `type` = 'payment' AND `id` = '{$id}'"; $db->setQuery($query); $planPayment = oseDB::loadItem('obj'); $options = oseJSON::decode($planPayment->params, true); $option = oseGetValue($options, $entry_option, array()); $title = $appItem->title . '-' . oseGetValue($option, 'optionname', ''); return $title; } else { return $appItem->title; } }
public static function renew($params) { $result = array(); $result['success'] = true; if(empty($params['allow_work'])) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText::_('Error Renew.Order'); return $result; } //unset($params['allow_work']); $oseMscConfig = oseRegistry::call('msc')->getConfig('thirdparty','obj'); if(empty($oseMscConfig->idev_enable)) { return $result; } if(empty($oseMscConfig->idev_url)) { return $result; } $db = oseDB::instance(); //$post = JRequest::get('post'); $msc_id = $params['msc_id']; $member_id = $params['member_id']; $order_id = $params['order_id']; $order_item_id = $params['order_item_id']; $where = array(); $where[] = "order_id = {$order_id}"; $payment = oseRegistry::call('payment'); $curOrder = $payment->getOrder($where,'obj'); $curOrderParams = oseJson::decode($curOrder->params); $member = oseRegistry::call('member'); $member->instance($member_id); $userInfo = $member->getUserInfo('obj'); $memParams = $member->getMemberInfo($msc_id,'obj')->memParams; $memParams = oseJSON::decode($memParams); if(empty($curOrderParams->first_ip)) { return $result; } $coupon_user_id = $curOrderParams->coupon_user_id; $query = "SELECT coupon_id FROM `#__osemsc_coupon_user`"; $db->setQuery($query); $coupon_id = $db->loadResult(); $query = "SELECT code FROM `#__osemsc_coupon`"; $db->setQuery($query); $coupon = $db->loadResult(); $code = null; if(!empty($coupon)) { $code = "&coupon_code=".$coupon; } try { require_once(OSEMSC_B_LIB.DS.'PapApi.class.php'); $ch = curl_init(); curl_setopt($ch, CURLOPT_URL,$oseMscConfig->idev_url."/sale.php?profile=72198&idev_saleamt={$curOrder->payment_price}&idev_ordernum={$order_id}&ip_address={$curOrderParams->first_ip}".$code); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_exec($ch); curl_close($ch); return $result; } catch (Exception $e) { return $result; } }
function exportCsvAll() { $db = oseDB::instance(); $out = null; $array = array(); $array['member_id'] = JText::_('Member ID'); $array['firstname'] = JText::_('First Name'); $array['lastname'] = JText::_('Last Name'); $array['company'] = JText::_('Company'); $array['address1'] = JText::_('Address1'); $array['address2'] = JText::_('Address2'); $array['city'] = JText::_('City'); $array['state'] = JText::_('State'); $array['country'] = JText::_('County'); $array['postcode'] = JText::_('Zip'); $array['telephone'] = JText::_('Phone'); $array['username'] = JText::_('User Name'); $array['email'] = JText::_('e-mail'); $array['msc'] = JText::_('Membership Plan'); $array['start_date'] = JText::_('Start Date'); $array['end_date'] = JText::_('End Date'); $array['create_date'] = JText::_('Purchase Date'); $array['subtotal'] = JText::_('Subtotal'); $array['tax'] = JText::_('Tax'); $array['total'] = JText::_('Total'); $array['payment_method'] = JText::_('Payment Method'); //Additional Info $query = " SELECT * FROM `#__osemsc_fields` WHERE `published` = '1' ORDER BY `ordering`"; $db->setQuery($query); $fields = $db->loadObjectList(); foreach ($fields as $field) { $array['field' . $field->id] = JText::_(ucwords($field->name)); } $out .= implode(',', $array); $out .= "\n"; $msc_id = JRequest::getInt('msc_id', 0); $where = array(); if (!empty($msc_id)) { $where[] = 'mem.`msc_id` = ' . $msc_id; } $where = count($where) ? ' WHERE (' . implode(') AND (', $where) . ')' : ''; $query = " SELECT * FROM `#__osemsc_member_view` as mem" . " INNER JOIN `#__osemsc_billinginfo` as bil" . " ON mem.`member_id` = bil.`user_id`" . $where; $db->setQuery($query); $objs = $db->loadObjectList(); //$time = oseHTML::getDateTime(); $time = date("Y-m-d"); $filename = "member-all-" . $time . ".csv"; $csv_terminated = "\n"; $csv_separator = ","; $csv_enclosed = '"'; $csv_escaped = "\\"; foreach ($objs as $key => $obj) { $array = array(); $array['member_id'] = $obj->member_id; $array['firstname'] = $obj->firstname; $array['lastname'] = $obj->lastname; $array['company'] = $obj->company; $array['address1'] = $obj->addr1; $array['address2'] = $obj->addr2; $array['city'] = $obj->city; $array['state'] = self::getStateName($obj->state); $array['country'] = self::getCountryName($obj->country); $array['postcode'] = $obj->postcode; $array['telephone'] = $obj->telephone; $array['username'] = $obj->username; $array['email'] = $obj->email; $array['msc'] = $obj->msc_name; $array['start_date'] = date("Y-m-d", strtotime($obj->start_date)); if ($obj->expired_date == '0000-00-00 00:00:00') { $array['end_date'] = '0000-00-00'; } else { $array['end_date'] = date("Y-m-d", strtotime($obj->expired_date)); } $memParams = oseJSON::decode($obj->memParams); $order_id = $memParams->order_id; $query = "SELECT * FROM `#__osemsc_order` WHERE `order_id` = '{$order_id}'"; $db->setQuery($query); $orderInfo = $db->loadObject(); $orderParams = empty($orderInfo->params) ? null : oseJSON::decode($orderInfo->params); $array['create_date'] = empty($orderInfo->create_date) ? null : date("Y-m-d", strtotime($orderInfo->create_date)); $array['subtotal'] = empty($orderParams->subtotal) ? 0 : $orderParams->subtotal . ' ' . $orderInfo->payment_currency; $array['tax'] = empty($orderParams->gross_tax) ? 0 : $orderParams->gross_tax . ' ' . $orderInfo->payment_currency; $array['total'] = empty($orderParams->total) ? 0 : $orderParams->total . ' ' . $orderInfo->payment_currency; $payment_method = empty($orderInfo->payment_method) ? null : $orderInfo->payment_method; $array['payment_method'] = self::transPaymentMethod($payment_method); //Additional Info foreach ($fields as $field) { $query = "SELECT value FROM `#__osemsc_fields_values` WHERE `field_id` = " . $field->id . " AND `member_id` = " . $obj->member_id; $db->setQuery($query); $value = $db->loadResult(); $array['field' . $field->id] = empty($value) ? null : $value; } foreach ($array as $akey => $arr) { $array[$akey] = str_replace(',', ';', $array[$akey]); $array[$akey] = str_replace('\\n', ' ', $array[$akey]); } $out .= implode(',', $array); $out .= "\n"; } header("Cache-Control: must-revalidate, post-check=0, pre-check=0"); header("Content-Length: " . strlen($out)); // Output to browser with appropriate mime type, you choose ;) header("Content-type: text/csv"); header("Content-Disposition: attachment; filename={$filename}"); oseExit($out); }