function getSubTotal() { $cart = oseMscPublic::getCart(); $subtotal = $cart->get('currency') . ' ' . $cart->get('subtotal'); $result = array(); $result['success'] = true; $result['content'] = array('subtotal' => $subtotal); $result = oseJson::encode($result); oseExit($result); }
function getBillingInfo() { $initMscPayment = array('msc_id' => 0, 'msc_option' => null); $cart = oseMscPublic::getCart(); ; $user = JFactory::getUser(); $member = oseRegistry::call('member'); $member->instance($user->id); $item = $member->getBillingInfo(); $cartItems = $cart->get('items'); $cartItem = $cartItems[0]; $item['msc_option'] = $cartItem['msc_option']; return $item; }
function getBillingInfo() { $user = oseMscPublic::getUser(); $item = array(); $cart = oseMscPublic::getCart(); $cartItems = $cart->get('items'); if (!$user->guest) { $member = oseRegistry::call('member'); $member->instance($user->id); $item = $member->getBillingInfo(); } else { $item['id'] = 1; $item['city'] = ''; } if (oseMscPublic::getRegisterForm() == 'onestep') { $cartItem = empty($cartItems[0]) ? array() : $cartItems[0]; $item['msc_id'] = oseObject::getValue($cartItem, 'entry_id', 0); $item['ose_currency'] = $cart->get('currency'); if (!empty($item['msc_id'])) { $item['msc_option'] = $cartItem['msc_option']; } else { $options = $this->getAllOptions(); if (!empty($options)) { $item['msc_id'] = $options[0]['msc_id']; $item['msc_option'] = $options[0]['id']; } } } else { $item['ose_currency'] = $cart->get('currency'); if ($cart->get('total') <= 0) { $item['total'] = 'free'; } else { $item['total'] = 'nonfree'; } } return $item; }
function createMember() { $created = self::createUser(); if ($created['success']) { $member_id = JRequest::getInt('member_id', 0); $msc_id = JRequest::getInt('msc_id', 0); $msc_option = JRequest::getCmd('msc_option', null); if (empty($msc_id)) { $result['success'] = false; $result['title'] = JText::_('PLEASE_SELECT_MEMBERSHIP_PLAN_FIRST'); $result['content'] = JText::_('PLEASE_SELECT_ONE_PLAN_IN_THE_LEFT_SIDE_PANEL'); return $result; } if (empty($msc_option)) { $result['success'] = false; $result['title'] = JText::_('PLEASE_SELECT_MEMBERSHIP_PLAN_FIRST'); $result['content'] = JText::_('IF_THERE_IS_NO_OPTION_IN_THE_DROPDOWN_LIST_PLEASE_CREATE_ONE_IN_THE_PANEL_PAYMENT'); return $result; } $cart = oseMscPublic::getCart(); $cart->addItem(null, null, array('entry_id' => $msc_id, 'entry_type' => 'msc', 'msc_option' => $msc_option)); $cart->refreshCartItems(); $paymentInfo = $cart->output(); if (!empty($msc_option)) { $payment = oseRegistry::call('msc')->getExtInfo($msc_id, 'payment', 'array'); $payment = $payment[$msc_option]; $price = oseObject::getValue($payment, 'a3'); $paymentInfo['payment_price'] = $price; $paymentInfo = oseObject::setParams($paymentInfo, array('a3' => $price, 'total' => $price, 'next_total' => 0, 'subtotal' => $price)); } else { $paymentInfo['payment_price'] = '0.00'; $paymentInfo = oseObject::setParams($paymentInfo, array('a3' => 0, 'total' => 0, 'next_total' => 0)); } $result = oseMscPublic::generateOrder($member_id, 'system_admin', $paymentInfo); if (!$result['success']) { return $result; } $orderInfo = oseRegistry::call('payment')->getInstance('Order')->getOrder(array("`order_id`='{$result['order_id']}'"), 'obj'); $updated = oseMscPublic::processPayment($orderInfo); if ($updated['success']) { $result = $updated; $result['success'] = true; $result['title'] = JText::_('DONE'); $result['content'] = JText::_('ADDED_SUCCESSFULLY'); } else { $result = $updated; $result['success'] = false; $result['title'] = JText::_('ERROR'); $result['content'] = JText::_("MEMBER_ID") . " :{$member_id} " . JText::_("FAILED_JOINING"); } return $result; } else { return $created; } }
public static function getOptions() { $msc_id = JRequest::getInt('msc_id', 0); $msc = oseRegistry::call('msc'); $node = $msc->getInfo($msc_id, 'obj'); $paymentInfos = $msc->getExtInfo($msc_id, 'payment'); $cart = oseMscPublic::getCart(); $osePaymentCurrency = $cart->get('currency'); $option = oseMscPublic::generatePriceOption($node, $paymentInfos, $osePaymentCurrency); $options = array(); $options = array_merge($options, $option); /* $session =& JFactory::getSession(); $osePaymentCurrency = $session->get('osePaymentCurrency',oseRegistry::call('msc')->getConfig('currency','obj')->primary_currency); $oseMscPayment = $session->get('oseMscPayment',array('msc_id'=>0,'msc_option'=>0)); $option = array(); if(!empty($oseMscPayment['msc_option'])) { $paymentInfo = oseObject::getValue($paymentInfos,$oseMscPayment['msc_option']); $node = oseRegistry::call('payment')->getInstance('View')->getPriceStandard($node,$paymentInfo,$osePaymentCurrency); $optionPrice = oseObject::getValue($node,'standard_price').' for every '.oseObject::getValue($node,'standard_recurrence') ; if(oseObject::getValue($paymentInfo,'has_trial')) { $node = oseRegistry::call('payment')->getInstance('View')->getPriceTrial($node,$paymentInfo,$osePaymentCurrency); $optionPrice .= ' ('.oseObject::getValue($node,'trial_price').' in first '.oseObject::getValue($node,'trial_recurrence').')'; } $option[] = array('id'=>oseObject::getValue($paymentInfo,'id'),'text'=>$optionPrice); } else { foreach($paymentInfos as $paymentInfo) { $node = oseRegistry::call('payment')->getInstance('View')->getPriceStandard($node,$paymentInfo,$osePaymentCurrency); $optionPrice = oseObject::getValue($node,'standard_price').' for every '.oseObject::getValue($node,'standard_recurrence') ; if(oseObject::getValue($paymentInfo,'has_trial')) { $node = oseRegistry::call('payment')->getInstance('View')->getPriceTrial($node,$paymentInfo,$osePaymentCurrency); $optionPrice .= ' ('.oseObject::getValue($node,'trial_price').' in first '.oseObject::getValue($node,'trial_recurrence').')'; } $option[] = array('id'=>oseObject::getValue($paymentInfo,'id'),'text'=>$optionPrice); } } */ $combo = array(); $combo['total'] = count($options); $combo['results'] = $options; $combo = oseJson::encode($combo); oseExit($combo); }
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 display($tpl = null) { $user = oseMscPublic::getUser(); $app = JFactory::getApplication('SITE'); $cart = oseMscPublic::getCart(); $osePaymentCurrency = $cart->get('currency'); // Add Detect if ($this->isMobile) { $this->setLayout('mobile'); JRequest::setVar('tmpl', 'component'); } else { $this->loadMultiSelect(); $this->loadFileUpload(); } $model = $this->getModel('register'); $msc_id = JRequest::getInt('msc_id', 0); $msc_option = JRequest::getCmd('msc_option', null); if (!empty($msc_id)) { if (empty($msc_option)) { $msc = oseRegistry::call('msc'); $paymentInfos = $msc->getExtInfo($msc_id, 'payment'); foreach ($paymentInfos as $paymentInfo) { $msc_option = oseObject::getValue($paymentInfo, 'id'); break; } $model->addToCart($msc_id, $msc_option); } else { $model->addToCart($msc_id, $msc_option); } } $config = oseMscConfig::getConfig('register', 'obj'); if (!$isMobile) { if (!empty($config->register_form) && $config->register_form != 'default') { $layout = JRequest::getCmd("layout"); if (empty($layout)) { $layout = 'default'; } $this->setLayout($layout); switch ($layout) { case ('onestep'): default: $headerObjs = $this->getAddons('registerOS_header'); $bodyObjs = $this->getAddons('registerOS_body'); $footerObjs = $this->getAddons('registerOS_footer'); if ($user->guest) { $tpl = ''; $headerObjs = $this->filter($headerObjs, array('welcome'), false); } else { $tpl = 'payment'; $headerObjs = $this->filter($headerObjs, array('login'), false); $bodyObjs = $this->filter($bodyObjs, array('juser', 'juser_e', 'mailing', 'jomsocial'), false); } $this->loadAddons($headerObjs, 'registerOS'); $this->loadAddons($bodyObjs, 'registerOS'); $this->loadAddons($footerObjs, 'registerOS'); $this->assignRef('registerOS_header', $headerObjs); $this->assignRef('registerOS_body', $bodyObjs); $this->assignRef('registerOS_footer', $footerObjs); $this->assignRef('enable_fblogin', $config->enable_fblogin); $this->assignRef('facebookapiid', $config->facebookapiid); break; } } else { $this->setLayout('cart'); $tpl = "default"; $headerObjs = $this->getAddons('registerOS_header'); $bodyObjs = $this->getAddons('registerOS_body'); $footerObjs = $this->getAddons('registerOS_footer'); if ($user->guest) { $tpl = 'default'; } else { $tpl = 'payment'; $headerObjs = $this->filter($headerObjs, array('login'), false); $bodyObjs = $this->filter($bodyObjs, array('juser', 'juser_e'), false); } $this->loadAddons($headerObjs, 'registerOS'); $this->loadAddons($bodyObjs, 'registerOS'); $this->loadAddons($footerObjs, 'registerOS'); $this->assignRef('registerOS_header', $headerObjs); $this->assignRef('registerOS_body', $bodyObjs); $this->assignRef('registerOS_footer', $footerObjs); } } $profiles = $this->getProfileList(); $document = JFactory::getDocument(); $document->addScriptDeclaration('var oseGetProfileFields = function() {return ' . oseJson::encode($profiles) . '};'); $this->prepareDocument(); $this->addTemplatePath(JPATH_SITE . DS . 'ose' . DS . 'msc' . DS . 'views' . DS . 'register' . DS . 'tmpl'); if (!empty($tpl)) { parent::display($tpl); } else { parent::display(); } }
function _changeStatusOrder($order_id, $status, $sendmessage = 1){ $mainframe =& JFactory::getApplication(); $lang = &JSFactory::getLang(); $jshopConfig = &JSFactory::getConfig(); JPluginHelper::importPlugin('jshoppingorder'); $dispatcher =& JDispatcher::getInstance(); $dispatcher->trigger( 'onBeforeChangeOrderStatus', array(&$order_id, &$status, &$sendmessage) ); $order = &JTable::getInstance('order', 'jshop'); $order->load($order_id); $order->order_status = $status; $order->store(); ////////////////////////////////////////////////////////////////////////// // OSE added ////////////////////////////////////////////////////////////////////////// //2=>Confirmed, 1=>Pending, 4=>Refunded if ($status == "2" || $status == "1" || $status == "4") { require_once(JPATH_SITE.DS.'components'.DS.'com_osemsc'.DS.'init.php'); require_once(JPATH_SITE.DS.'components'.DS.'com_osemsc'.DS.'helpers'.DS.'oseMscPublic.php'); $db = &JFactory::getDBO(); $jquery = "SELECT user_id FROM `#__jshopping_orders` WHERE `order_id` = '" . $db->getEscaped($order_id) . "'"; $db->setQuery($jquery); $user_id = $db->loadResult(); $jquery = "SELECT a.product_id, b.category_id FROM `#__jshopping_order_item` as a, `#__jshopping_products_to_categories` as b WHERE a.`order_id` = '" . $db->getEscaped($order_id) . "' AND a.`product_id` = b.`product_id`"; $db->setQuery($jquery); $results = $db->loadObjectList(); $cart = oseMscPublic::getCart(); foreach ($results as $result) { ////////////////////////////////////////////////// $product_id = $result->product_id; $jquery = "SELECT * FROM `#__osemsc_ext` WHERE `type` = 'jshopping'"; $db->setQuery($jquery); $db->query(); $rows = $db->loadObjectList(); foreach ($rows as $row) { $msc_data = oseJson::decode($row->params); $left_var = ""; $right_var = ""; if ($msc_data->category_id > 0) { $left_var = $result->category_id; $right_var = $msc_data->category_id; } else { $left_var = $result->product_id; $right_var = $msc_data->product_id; } if ($left_var == $right_var) { $msc_id = $row->id; $query = "SELECT currency_code FROM `#__jshopping_orders` WHERE `order_id` = ".(int)$order_id; $db->setQuery($query); $currency = $db->loadResult(); if ($status == "2") { $member= oseRegistry :: call('member'); $member->instance($user_id, 'member_id'); // get current item $cart->updateParams('payment_mode','m'); $paymentInfo = oseRegistry::call('msc')->getPaymentMscInfo($msc_id,$currency,0); $nItem = array('entry_id'=>$msc_id,'entry_type'=>'msc','msc_option'=>oseObject::getValue($paymentInfo,'msc_option')); $cart->addItem($nItem['entry_id'],$nItem['entry_type'],$nItem); $cart->update(); // join msc oseRegistry::call('msc')->runAddonAction('register.payment.save',array('member_id'=>$user_id,'payment_method'=>'none'), true, false); $msc_order_id = JRequest::getInt('order_id',0); oseRegistry::call('payment')->getInstance('Order')->confirmOrder($msc_order_id, array()); } else { $msc_id= $row->id; $member= oseRegistry :: call('member'); $member->instance($user_id, 'member_id'); $params = $member->getAddonParams($msc_id,$user_id,0,$params = array()); $updated= $msc->runAddonAction('member.msc.cancelMsc', $params); } } } } } ////////////////////////////////////////////////////////////////////////// $vendorinfo = $order->getVendorInfo(); $order_status = &JTable::getInstance('orderStatus', 'jshop'); $order_status->load($status); if ($order->order_created && in_array($status, $jshopConfig->payment_status_return_product_in_stock)){ $order->changeProductQTYinStock("+"); } $order_history = &JTable::getInstance('orderHistory', 'jshop'); $order_history->order_id = $order->order_id; $order_history->order_status_id = $status; $order_history->status_date_added = date("Y-m-d H:i:s"); $order_history->customer_notify = 1; $order_history->comments = $restext; $order_history->store(); if (!$sendmessage) return 1; $name = $lang->get("name"); $view_name = "order"; $view_config = array("template_path"=>JPATH_COMPONENT."/templates/".$jshopConfig->template."/".$view_name); $view = &$this->getView($view_name, 'html', '', $view_config); $view->setLayout("statusorder"); $view->assign('order', $order); $view->assign('order_status', $order_status->$name); $view->assign('vendorinfo', $vendorinfo); $message = $view->loadTemplate(); $vendors_send_message = ($jshopConfig->vendor_order_message_type==1 || ($order->vendor_type==1 && $jshopConfig->vendor_order_message_type==2)); $vendor_send_order = ($jshopConfig->vendor_order_message_type==2 && $order->vendor_type == 0 && $order->vendor_id); $admin_send_order = 1; if ($jshopConfig->admin_not_send_email_order_vendor_order && $vendor_send_order) $admin_send_order = 0; $mailfrom = $mainframe->getCfg( 'mailfrom' ); $fromname = $mainframe->getCfg( 'fromname' ); //message client $subject = sprintf(_JSHOP_ORDER_STATUS_CHANGE_SUBJECT, $order->order_number); JUtility::sendMail($mailfrom, $fromname, $order->email, $subject, $message); //message admin if ($admin_send_order){ JUtility::sendMail($mailfrom, $fromname, $jshopConfig->contact_email, _JSHOP_ORDER_STATUS_CHANGE_TITLE, $message); } //message vendors if ($vendors_send_message){ $listVendors = $order->getVendors(); foreach($listVendors as $k=>$datavendor){ JUtility::sendMail($mailfrom, $fromname, $datavendor->email, _JSHOP_ORDER_STATUS_CHANGE_TITLE, $message); } } //message vendor if ($vendor_send_order){ $vendor = &JTable::getInstance('vendor', 'jshop'); $vendor->load($order->vendor_id); JUtility::sendMail($mailfrom, $fromname, $vendor->email, _JSHOP_ORDER_STATUS_CHANGE_TITLE, $message); } $dispatcher->trigger( 'onAfterChangeOrderStatus', array(&$order_id, &$status, &$sendmessage) ); return 1; }
/** * This method should handle any login logic and report back to the subject * * @access public * @param array holds the user data * @param array array holding options (remember, autoregister, group) * @return boolean True on success * @since 1.5 */ function onUserLogin($user, $options = array()) { require_once(JPATH_SITE.DS.'components'.DS.'com_osemsc'.DS.'init.php'); $mainframe = JFactory::getApplication(); $db = JFactory::getDBO(); $option=JRequest::getVar("option"); jimport('joomla.user.helper'); if ($mainframe->isAdmin() ) { return; // Dont run in admin } $pluginParams = $this->params; //$loginRedirection = $pluginParams->get('loginRedirection'); // Move to OSE Router; $singleLogin = $pluginParams->get('singleLogin'); $loginRedirect= $pluginParams->get('loginRedirect'); $autoUpdate = $pluginParams->get('autoUpdateOnLogin'); $autoUpdateGroup = $pluginParams->get('autoUpdateGroup'); $user = self::getUser($user); // Update BillingInfo names; $query = " SELECT user_id, firstname FROM #__osemsc_billinginfo WHERE user_id = ".(int)$user->id; $db->setQuery($query); $objects = $db->loadObject(); if (!empty($objects->user_id) && empty($objects->firstname)) { $thisUser = JFactory::getUser($objects->user_id); $names = explode(' ',$thisUser->name); $firstname = $db->Quote($names[0]); $lastname = count($names)>1?$names[1]:'null'; $lastname = $db->Quote($lastname); $query = "UPDATE `#__osemsc_billinginfo` SET `firstname` = {$firstname},`lastname` = {$lastname} WHERE `user_id` = ".(int)$user->id; $db->setQuery($query); $db->Query(); } $query = " SELECT user_id, lastname FROM #__osemsc_billinginfo WHERE user_id = ".(int)$user->id; $db->setQuery($query); $objects = $db->loadObject(); if (!empty($objects->user_id) && empty($objects->lastname)) { $query = "UPDATE `#__osemsc_billinginfo` SET `lastname` = (SELECT lastname FROM #__osemsc_userinfo WHERE user_id = ".(int)$user->id.") WHERE `user_id` =".(int)$user->id; $db->setQuery($query); $db->Query(); } // BillingInfo names; $enableVMUser = $pluginParams->get('enableVMUser'); if ($enableVMUser==true) { $oseUser['user_id'] = oseObject::getValue($user,'id'); $query= "SELECT * FROM `#__virtuemart_userinfos` WHERE `address_type` = 'BT' AND `virtuemart_user_id` = ". (int)$user->id; $db->setQuery($query); $result= $db->loadObject(); if(!empty($result)) { $query = "SELECT `country_3_code` FROM `#__virtuemart_countries` WHERE `virtuemart_country_id` = ". $db->Quote($result->virtuemart_country_id); $db->setQuery($query); $country_3_code=$db->loadResult(); if (!empty($country_3_code)) { $result->country = $country_3_code; } else { $result->country = substr($result->country, 0,3); } $query = "SELECT `state_2_code` FROM `#__virtuemart_states` WHERE `virtuemart_state_id` = ". $db->Quote($result->virtuemart_state_id); $db->setQuery($query); $state_2_code=$db->loadResult(); if (!empty($state_2_code)) { $result->state = $state_2_code; } else { $result->state = substr($result->state, 0,2); } $query= "SELECT count(*) FROM `#__osemsc_billinginfo` WHERE `user_id` = ". (int)$user->id; $db->setQuery($query); $result2= $db->loadResult(); if (empty($result2)) { $query= "INSERT INTO `#__osemsc_billinginfo` (`user_id`, `firstname`, `lastname`, `company`, `addr1`, `addr2`, `city`, `state`, `country`, `postcode`, `telephone`) VALUES (".(int)$user->id.", '{$result->first_name}', '{$result->last_name}', '{$result->company}', '{$result->address_1}', '{$result->address_2}', '{$result->city}', '{$result->state}', '{$result->country}', '{$result->zip}', '{$result->phone_1}');"; } else { $query = " UPDATE `#__osemsc_billinginfo` " . " SET `firstname` = '{$result->first_name}', " . " `lastname` = '{$result->last_name}', " . " `company` = '{$result->company}', " . " `addr1` = '{$result->address_1}', " . " `addr2` = '{$result->address_2}', " . " `city` = '{$result->city}', " . " `state` = '{$result->state}', " . " `country` = '{$result->country}', " . " `postcode` = '{$result->zip}', " . " `telephone` = '{$result->phone_1}' " . " WHERE `user_id` =".(int)$user->id; } $db->setQuery($query); $db->query(); } } if ($autoUpdate==true && !empty($autoUpdateGroup)) { if (!class_exists("oseMscPublic")) { require_once(JPATH_SITE.DS.'components'.DS.'com_osemsc'.DS.'helpers'.DS.'oseMscPublic.php'); } oseAppConfig::load('msc'); $cart = oseMscPublic::getCart(); $items = $cart->get('items'); $update = true; if(count($items) >0) { foreach($items as $item) { if($item['entry_id'] == $autoUpdateGroup) { $update = false; } } } $query = " SELECT count(*) FROM #__osemsc_member WHERE msc_id = ".(int)$autoUpdateGroup." AND member_id=".(int)$user->id; $db->setQuery($query); $exists = $db->loadResult(); if ($update && empty($exists)) { // join msc if($mainframe->isSite()) { $cart = oseMscPublic::getCart(); // get current item $cCart = $cart->cart; $cart->init(); $cart->__construct(); $cart->updateParams('payment_mode','m'); $paymentInfo = oseRegistry::call('msc')->getPaymentMscInfo($autoUpdateGroup,$cart->get('currency'),0); $nItem = array('entry_id'=>$autoUpdateGroup,'entry_type'=>'msc','msc_option'=>oseObject::getValue($paymentInfo,'msc_option')); $cart->addItem($nItem['entry_id'],$nItem['entry_type'],$nItem); $cart->update(); //$orderPaymentInfo = array();//$cart->output(); oseMscAddon::runAction('register.payment.save',array('member_id'=>$user->id,'payment_method'=>'none'), true, false); $order_id = JRequest::getInt('order_id',0); oseRegistry::call('payment')->getInstance('Order')->confirmOrder($order_id, array()); $cart->init(); $cart->__construct(); $cart1 = oseMscPublic::getCart();$cart1->__construct(); $cart1->cart = $cCart; $cart1->update(); } else { $cart = oseMscPublic::getCart(); // get current item //$cItems = $cart->output(); //$cart->init(); $cart->updateParams('payment_mode','m'); $paymentInfo = oseRegistry::call('msc')->getPaymentMscInfo($autoUpdateGroup,$cart->get('currency'),0); $nItem = array('entry_id'=>$autoUpdateGroup,'entry_type'=>'msc','msc_option'=>oseObject::getValue($paymentInfo,'msc_option')); $cart->addItem($nItem['entry_id'],$nItem['entry_type'],$nItem); $cart->update(); $orderPaymentInfo = array();//$cart->output(); $orderResult = oseMscAddon::runAction('register.payment.save',array('member_id'=>$user->id,'payment_method'=>'none'), true, false); $order_id = JRequest::getInt('order_id',0); oseRegistry::call('payment')->getInstance('Order')->confirmOrder($order_id, array()); $cart->init(); /*$orderPaymentInfo = $cart->output(); oseMscPublic::generateOrder($user['id'],'none',$orderPaymentInfo); $order_id = JRequest::getInt('order_id',0);oseExit($order_id); oseRegistry::call('payment')->getInstance('Order')->confirmOrder($order_id, array());*/ } } } $member = oseRegistry::call('member'); $member->instance($user->id); $mscs = $member->getAllOwnedMsc(true,null,'obj'); $date = oseHTML::getDateTime(); $date = strtotime($date); $updateStatus = false; if(!empty($mscs)) { foreach($mscs as $msc) { $startdate = strtotime($msc->start_date); $expdate = strtotime($msc->expired_date); $params = oseJson::decode($msc->params); if($msc->status && ($startdate>$date) && (($date<$expdate) || $msc->eternal == 1 || $msc->expired_date == '0000-00-00 00:00:00')) { $updateStatus = true; $status = 0; }elseif(empty($msc->status) && ($startdate < $date) && (($date<$expdate) || $msc->eternal == 1 || $msc->expired_date == '0000-00-00 00:00:00')) { $updateStatus = true; $status = 1; } if($updateStatus) { $query = "SELECT * FROM `#__osemsc_order_item` WHERE `order_id` = ".$params->order_id; $db->setQuery($query); $orderItem = $db->loadObject(); $orderItemParams = oseJson::decode($orderItem->params); if($orderItemParams->recurrence_mode == 'fixed') { $query = "UPDATE `#__osemsc_member` SET `status` = '{$status}' WHERE `id` = ".$msc->id; $db->setQuery($query); $db->query(); } } } } if ($singleLogin>0) { self::singleLogin($singleLogin, $db, $user, $mainframe); } if ($loginRedirect == true) { if (!empty($user)) { self::loginRedirect($user->id); } } return true; }
function getMembershipCard($msc_id) { $item = oseRegistry::call('msc')->getInfo($msc_id, 'obj'); $cart = oseMscPublic::getCart(); $osePaymentCurrency = $cart->get('currency'); $items = array($item); $register_form = oseRegistry::call('msc')->getConfig('register', 'obj')->register_form; if (empty($register_form) || $register_form == 'default') { $cards = $this->drawMscList($osePaymentCurrency, $items, 'cart'); } else { $cards = $this->drawMscList($osePaymentCurrency, $items, 'os'); } return $cards; }
function checkFree() { $cart = oseMscPublic::getCart(); $cartItems = $cart->get('items'); $item = array(); if ($cart->get('total') <= 0) { $item['free'] = 'free'; } else { $item['free'] = 'nonfree'; } $result = oseJson::encode($item); oseExit($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; }
/** * Changes the status of an order * @author pablo * @author soeren * @author Uli * * * @param array $d * @return boolean */ function order_status_update(&$d) { global $mosConfig_offset; global $sess, $VM_LANG, $vmLogger; $db = new ps_DB; //$timestamp = time() + ($mosConfig_offset*60*60); //Original $timestamp = time(); //Custom //$mysqlDatetime = date("Y-m-d G:i:s",$timestamp); //Original $mysqlDatetime = date("Y-m-d G:i:s", $timestamp + ($mosConfig_offset*60*60)); //Custom if( empty($_REQUEST['include_comment'])) { $include_comment="N"; } // get the current order status $curr_order_status = @$d["current_order_status"]; $notify_customer = empty($d['notify_customer']) ? "N" : $d['notify_customer']; if( $notify_customer=="Y" ) { $notify_customer=1; } else { $notify_customer=0; } $d['order_comment'] = empty($d['order_comment']) ? "" : $d['order_comment']; if( empty($d['order_item_id']) ) { // When the order is set to "confirmed", we can capture // the Payment with authorize.net if( $curr_order_status=="P" && $d["order_status"]=="C") { $q = "SELECT order_number,payment_class,order_payment_trans_id FROM #__{vm}_payment_method,#__{vm}_order_payment,#__{vm}_orders WHERE "; $q .= "#__{vm}_order_payment.order_id='".$db->getEscaped($d['order_id'])."' "; $q .= "AND #__{vm}_orders.order_id='".$db->getEscaped($d['order_id'])."' "; $q .= "AND #__{vm}_order_payment.payment_method_id=#__{vm}_payment_method.payment_method_id"; $db->query( $q ); $db->next_record(); $payment_class = $db->f("payment_class"); $d["order_number"] = $db->f("order_number"); switch( $payment_class ) { case "ps_authorize": require_once( CLASSPATH."payment/ps_authorize.cfg.php"); if( AN_TYPE == 'AUTH_ONLY' ) { require_once( CLASSPATH."payment/ps_authorize.php"); $authorize = new ps_authorize(); if( !$authorize->capture_payment( $d )) { return false; } } break; default: // default case for payment methods that allow to "capture" the payment if( is_file( CLASSPATH.'payment/'.basename($payment_class).'.php' ) ) { require_once( CLASSPATH.'payment/'.basename($payment_class).'.php' ); if( !class_exists($payment_class)) break; $paymentObj = new $payment_class(); if( !method_exists($paymentObj,'capture_payment')) break; if( !$paymentObj->capture_payment( $d )) { return false; } } break; } } /* * This is like the test above for delayed capture only * we (well, I - durian) don't think the credit card * should be captured until the item(s) are shipped. * In fact, VeriSign says not to capture the cards until * the item ships. Maybe this behavior should be a * configurable item? * * When the order changes from Confirmed or Pending to * Shipped, perform the delayed capture. * * Restricted to PayFlow Pro for now. */ if( ($curr_order_status=="P" || $curr_order_status=="C") && $d["order_status"]=="S") { $q = "SELECT order_number,payment_class,order_payment_trans_id FROM #__{vm}_payment_method,#__{vm}_order_payment,#__{vm}_orders WHERE "; $q .= "#__{vm}_order_payment.order_id='".$db->getEscaped($d['order_id'])."' "; $q .= "AND #__{vm}_orders.order_id='".$db->getEscaped($d['order_id'])."' "; $q .= "AND #__{vm}_order_payment.payment_method_id=#__{vm}_payment_method.payment_method_id"; $db->query( $q ); $db->next_record(); $payment_class = $db->f("payment_class"); if( $payment_class=="payflow_pro" ) { require_once( CLASSPATH."payment/payflow_pro.cfg.php"); if( PFP_TYPE == 'A' ) { require_once( CLASSPATH."payment/payflow_pro.php"); $pfp = new ps_pfp(); $d["order_number"] = $db->f("order_number"); if( !$pfp->capture_payment( $d )) { return false; } } } } /** * Do capture when product is shipped */ /* if(($curr_order_status == "P" || $curr_order_status == "C") && $d["order_status"]=="S") { $q = "SELECT order_number,payment_class,order_payment_trans_id FROM #__{vm}_payment_method,#__{vm}_order_payment,#__{vm}_orders WHERE "; $q .= "#__{vm}_orders.order_id='".$db->getEscaped($d['order_id'])."' "; $q .= "AND #__{vm}_orders.order_id=#__{vm}_order_payment.order_id "; $q .= "AND #__{vm}_order_payment.payment_method_id=#__{vm}_payment_method.payment_method_id"; $db->query( $q ); $db->next_record(); $payment_class = strtolower(basename($db->f("payment_class"))); if( file_exists( CLASSPATH.'payment/'.$payment_class.'.php' )) { require_once( CLASSPATH."payment/$payment_class.php"); $payment = new $payment_class(); $d["order_number"] = $db->f("order_number"); if( is_callable( array( $payment, 'capture_payment' ))) { if( !$payment->capture_payment( $d )) { return false; } } } }*/ /* * If a pending order gets cancelled, void the authorization. * * It might work on captured cards too, if we want to * void shipped orders. * */ if( $curr_order_status=="P" && $d["order_status"]=="X") { $q = "SELECT order_number,payment_class,order_payment_trans_id FROM #__{vm}_payment_method,#__{vm}_order_payment,#__{vm}_orders WHERE "; $q .= "#__{vm}_order_payment.order_id='".$db->getEscaped($d['order_id'])."' "; $q .= "AND #__{vm}_orders.order_id='".$db->getEscaped($d['order_id'])."' "; $q .= "AND #__{vm}_order_payment.payment_method_id=#__{vm}_payment_method.payment_method_id"; $db->query( $q ); $db->next_record(); $payment_class = strtolower(basename($db->f("payment_class"))); if( file_exists( CLASSPATH.'payment/'.$payment_class.'.php' )) { require_once( CLASSPATH."payment/$payment_class.php"); $payment = new $payment_class(); $d["order_number"] = $db->f("order_number"); if( is_callable( array( $payment, 'void_authorization' ))) { if( !$payment->void_authorization( $d )) { return false; } } } } // Do a Refund if( $d['order_status']=='R' && $curr_order_status != 'R') { $vmLogger->debug("Initiating Refund"); $q = 'SELECT order_number,payment_class,order_payment_trans_id FROM #__{vm}_payment_method,#__{vm}_order_payment,#__{vm}_orders WHERE '; $q .= '#__{vm}_orders.order_id=\''.$db->getEscaped($d['order_id']).'\' '; $q .= 'AND #__{vm}_orders.order_id=#__{vm}_order_payment.order_id '; $q .= 'AND #__{vm}_order_payment.payment_method_id=#__{vm}_payment_method.payment_method_id'; $db->query( $q ); $db->next_record(); $payment_class = strtolower(basename($db->f("payment_class"))); $vmLogger->debug('Payment Class: '.$payment_class); if( file_exists( CLASSPATH.'payment/'.$payment_class.'.php' )) { $vmLogger->debug('Found Payment Module'); require_once( CLASSPATH."payment/$payment_class.php"); $payment = new $payment_class(); $d["order_number"] = $db->f("order_number"); if( is_callable( array( $payment, 'do_refund' ))) { $vmLogger->debug('Can call do_refund'); if( !$payment->do_refund( $d )) { $vmLogger->debug('failed to do refund'); return false; } } } } $fields =array( 'order_status'=> $d["order_status"], 'mdate'=> $timestamp ); $db->buildQuery('UPDATE', '#__{vm}_orders', $fields, "WHERE order_id='" . $db->getEscaped($d["order_id"]) . "'"); $db->query(); // Update the Order History. $fields = array( 'order_id' => $d["order_id"], 'order_status_code' => $d["order_status"], 'date_added' => $mysqlDatetime, 'customer_notified' => $notify_customer, 'comments' => $d['order_comment'] ); $db->buildQuery('INSERT', '#__{vm}_order_history', $fields ); $db->query(); // Do we need to re-update the Stock Level? if( (strtoupper($d["order_status"]) == "X" || strtoupper($d["order_status"])=="R") // && CHECK_STOCK == '1' && $curr_order_status != $d["order_status"] ) { // Get the order items and update the stock level // to the number before the order was placed $q = "SELECT product_id, product_quantity FROM #__{vm}_order_item WHERE order_id='".$db->getEscaped($d["order_id"])."'"; $db->query( $q ); $dbu = new ps_DB; require_once( CLASSPATH.'ps_product.php'); // Now update each ordered product while( $db->next_record() ) { if( ENABLE_DOWNLOADS == '1' && ps_product::is_downloadable($db->f("product_id")) && VM_DOWNLOADABLE_PRODUCTS_KEEP_STOCKLEVEL == '1') { $q = "UPDATE #__{vm}_product SET product_sales=product_sales-".$db->f("product_quantity")." WHERE product_id=".$db->f("product_id"); $dbu->query( $q ); } else { $q = "UPDATE #__{vm}_product SET product_in_stock=product_in_stock+".$db->f("product_quantity").", product_sales=product_sales-".$db->f("product_quantity")." WHERE product_id=".$db->f("product_id"); $dbu->query( $q ); } } } // Update the Order Items' status $q = "SELECT order_item_id FROM #__{vm}_order_item WHERE order_id=".$db->getEscaped($d['order_id']); $db->query($q); $dbu = new ps_DB; while ($db->next_record()) { $item_id = $db->f("order_item_id"); $fields =array( 'order_status'=> $d["order_status"], 'mdate'=> $timestamp ); $dbu->buildQuery('UPDATE', '#__{vm}_order_item', $fields, "WHERE order_item_id='" .(int)$item_id . "'"); $dbu->query(); } if ($d["order_status"] == "C" || $d["order_status"] == "P") { ////////////////////////////////////////////////////////////////////////// // OSE added ////////////////////////////////////////////////////////////////////////// //////////////Joomla Database Class////////////// require_once(JPATH_SITE.DS.'components'.DS.'com_osemsc'.DS.'init.php'); require_once(JPATH_SITE.DS.'components'.DS.'com_osemsc'.DS.'helpers'.DS.'oseMscPublic.php'); $jdb = &JFactory::getDBO(); $jquery = "SELECT user_id FROM `#__vm_orders` WHERE `order_id` = '" . $db->getEscaped($d['order_id']) . "'"; $jdb->setQuery($jquery); $user_id = $jdb->loadResult(); $jquery = "SELECT a.product_id, b.category_id FROM `#__vm_order_item` as a, `#__vm_product_category_xref` as b WHERE a.`order_id` = '" . $db->getEscaped($d['order_id']) . "' AND a.`product_id` = b.`product_id`"; $jdb->setQuery($jquery); $results = $jdb->loadObjectList(); $cart = oseMscPublic::getCart(); if (empty($results)) { $jquery = "SELECT a.product_id, b.category_id, c.product_parent_id FROM `#__vm_order_item` as a, `#__vm_product_category_xref` as b, `#__vm_product` as c WHERE a.`order_id` = '" . $db->getEscaped($d['order_id']) . "' AND a.`product_id` = c.`product_id` AND b.`product_id` = c.`product_parent_id`"; $jdb->setQuery($jquery); $results = $jdb->loadObjectList(); } foreach ($results as $result) { ////////////////////////////////////////////////// $product_id = $result->product_id; $jquery = "SELECT * FROM `#__osemsc_ext` WHERE `type` = 'vm'"; $jdb->setQuery($jquery); $jdb->query(); $rows = $jdb->loadObjectList(); foreach ($rows as $row) { $msc_data = oseJson::decode($row->params); $left_var = ""; $right_var = ""; if ($msc_data->category_id > 0) { $left_var = $result->category_id; $right_var = $msc_data->category_id; } else { $left_var = $result->product_id; $right_var = $msc_data->product_id; } if ($left_var == $right_var) { $msc_id = $row->id; $query = "SELECT order_currency FROM `#__vm_orders` WHERE `order_id` = ".(int)$d["order_id"]; $db->setQuery($query); $currency = $db->loadResult(); if ($d["order_status"] == "C") { $member= oseRegistry :: call('member'); $member->instance($user_id, 'member_id'); // get current item $cart->updateParams('payment_mode','m'); $paymentInfo = oseRegistry::call('msc')->getPaymentMscInfo($msc_id,$currency,0); $nItem = array('entry_id'=>$msc_id,'entry_type'=>'msc','msc_option'=>oseObject::getValue($paymentInfo,'msc_option')); $cart->addItem($nItem['entry_id'],$nItem['entry_type'],$nItem); $cart->update(); // join msc oseRegistry::call('msc')->runAddonAction('register.payment.save',array('member_id'=>$user_id,'payment_method'=>'none'), true, false); $order_id = JRequest::getInt('order_id',0); oseRegistry::call('payment')->getInstance('Order')->confirmOrder($order_id, array()); } else { $msc_id= $row->id; $member= oseRegistry :: call('member'); $member->instance($user_id, 'member_id'); $params = $member->getAddonParams($msc_id,$user_id,0,$params = array()); $updated= $msc->runAddonAction('member.msc.cancelMsc', $params); } } } } ////////////////////////////////////////////////////////////////////////// } if (ENABLE_DOWNLOADS == '1') { ################## ## DOWNLOAD MOD $this->mail_download_id( $d ); } if( !empty($notify_customer) ) { $this->notify_customer( $d ); } } elseif( !empty($d['order_item_id'])) { // Update the Order Items' status $q = "SELECT order_item_id, product_id, product_quantity FROM #__{vm}_order_item WHERE order_id=".$db->getEscaped($d['order_id']) . ' AND order_item_id='.intval( $d['order_item_id'] ); $db->query($q); $item_product_id = $db->f('product_id'); $item_product_quantity = $db->f('product_quantity'); require_once( CLASSPATH. 'ps_product.php' ); if( ENABLE_DOWNLOADS == '1' && ps_product::is_downloadable($item_product_id) && VM_DOWNLOADABLE_PRODUCTS_KEEP_STOCKLEVEL == '1') { $q = "UPDATE #__{vm}_product SET product_sales=product_sales-".$item_product_quantity." WHERE product_id=".$item_product_id; $db->query( $q ); } else { $q = "UPDATE #__{vm}_product SET product_in_stock=product_in_stock+".$item_product_quantity.", product_sales=product_sales-".$item_product_quantity." WHERE product_id=".$item_product_id; $db->query( $q ); } $fields =array( 'order_status'=> $d["order_status"], 'mdate'=> $timestamp ); $db->buildQuery('UPDATE', '#__{vm}_order_item', $fields, 'WHERE order_item_id='.intval( $d['order_item_id'] )); return $db->query() !== false; } return true; }
function createOrder() { $result = array(); $result['success'] = true; $result['title'] = JText::_('DONE'); $result['content'] = JText::_('DONE'); $post = JRequest::get('post'); $msc_id = $post['msc_id']; $msc_option = $post['msc_option']; $user_id = $post['user_id']; $cart = oseMscPublic::getCart(); // get current item $cCart = $cart->cart; $cart->init(); $cart->__construct(); $cart->updateParams('payment_mode', 'm'); $paymentInfo = oseRegistry::call('msc')->getPaymentMscInfo($msc_id, $cart->get('currency'), 0); $nItem = array('entry_id' => $msc_id, 'entry_type' => 'msc', 'msc_option' => $msc_option); $cart->addItem($nItem['entry_id'], $nItem['entry_type'], $nItem); $cart->update(); oseMscAddon::runAction('register.payment.save', array('member_id' => $user_id, 'payment_method' => 'none'), true, false); 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; } }
private static function saveOS( $params ) { $result = array(); $post = JRequest::get('post'); $member_id = $params['member_id']; $payment_method = $params['payment_method']; //oseExit($params); JRequest::setVar('member_id',$member_id); if(empty($member_id)) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText :: _('Error'); return $result; } $params = array(); $paymentCart = oseMscPublic::getCart(); $subtotal = $paymentCart->getSubtotal(); $items = $paymentCart->get('items'); $osePaymentCurrency = $paymentCart->get('currency'); $payment = oseRegistry::call('payment'); $keys = array_keys($items); $payment_mode = $paymentCart->getParams('payment_mode'); $order_number = $payment->generateOrderNumber( $member_id ); $params['entry_type'] = 'msc_list'; $params['payment_price'] = $subtotal; $params['payment_currency'] = $osePaymentCurrency; $params['order_number'] = $order_number; $params['create_date'] = oseHTML::getDateTime();//date("Y-m-d H:i:s"); $params['payment_serial_number'] = substr($order_number,0,20); $params['payment_method'] = $payment_method; $params['payment_mode'] = $payment_mode; //$paymentOrder->__construct('#__osemsc_order_item'); $params['params'] = array(); foreach($items as $item) { $entry_type = oseObject::getValue($item,'entry_type'); switch($entry_type) { case('license'): $license_id = oseObject::getValue($item,'entry_id'); $license = oseRegistry::call('lic')->getInstance(0); $licenseInfo = $license->getKeyInfo($license_id,'obj'); //oseExit($item); $licenseInfoParams = oseJson::decode($licenseInfo->params); $msc_id = $licenseInfoParams->msc_id; break; case('msc'): $msc_id = oseObject::getValue($item,'entry_id'); break; } $msc_option = oseObject::getValue($item,'msc_option'); $paymentInfos = oseRegistry::call('msc')->getExtInfo($msc_id,'payment','obj'); $paymentInfo = oseObject::getValue($paymentInfos,$msc_option); $price = $paymentInfo->a3; if($payment_mode == 'a') { if($paymentInfo->has_trial) { $price = $paymentInfo->a1; } } $price = $payment->pricing($price,$msc_id,$osePaymentCurrency); $params['params'] = $payment->generateOrderParams($msc_id,$price,$payment_mode,$msc_option); } //oseExit($params['params']); $params['params']['total'] = $paymentCart->get('total'); $params['params']['discount'] = $paymentCart->get('discount'); $params['params']['subtotal'] = $subtotal; $params['params']['next_subtotal'] = $paymentCart->get('next_subtotal'); $params['params'] = oseJSON::encode($params['params']); //$config = oseRegistry::call('msc')->getConfig('payment','obj'); //$params['payment_from'] = $config->payment_system; $paymentOrder = $payment->getInstance('Order'); $updated = $paymentOrder->generateOrder('', $member_id, $params); if($updated) { $order_id = $updated; JRequest::setVar('order_id',$order_id); } else { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText :: _('Error'); return $result; } //$paymentOrder->__construct('#__osemsc_order_item'); foreach($items as $item) { $itemParams = array(); $entry_type = oseObject::getValue($item,'entry_type'); switch($entry_type) { case('license'): $license_id = oseObject::getValue($item,'entry_id'); $license = oseRegistry::call('lic')->getInstance(0); $licenseInfo = $license->getKeyInfo($license_id,'obj'); //oseExit($item); $licenseInfoParams = oseJson::decode($licenseInfo->params); $msc_id = $licenseInfoParams->msc_id; break; case('msc'): $msc_id = oseObject::getValue($item,'entry_id'); break; } $msc_option = oseObject::getValue($item,'msc_option'); $paymentInfos = oseRegistry::call('msc')->getExtInfo($msc_id,'payment','obj'); $paymentInfo = oseObject::getValue($paymentInfos,$msc_option); $price = $paymentInfo->a3; if($payment_mode == 'a') { if($paymentInfo->has_trial) { $price = $paymentInfo->a1; } } $price = $payment->pricing($price,$msc_id,$osePaymentCurrency); $itemParams['entry_type'] = oseObject::getValue($item,'entry_type'); $itemParams['payment_price'] = oseObject::getValue($item,'first_raw_price'); $itemParams['payment_currency'] = $osePaymentCurrency; $itemParams['create_date'] = oseHTML::getDateTime();//date("Y-m-d H:i:s"); $price_params = $payment->generateOrderParams($msc_id,$price,$payment_mode,$msc_option); //$itemParams['msc_id'] = $msc_id; $itemParams['params'] = oseJSON::encode($price_params); $paymentInfos = oseMscAddon::getExtInfo($msc_id,'payment','obj'); $paymentInfo = oseObject::getValue($paymentInfos,$msc_option); if ( $paymentInfo->payment_mode == $payment_mode || $paymentInfo->payment_mode == 'b') { $itemParams['payment_mode'] = $payment_mode; } else { $itemParams['payment_mode'] = $paymentInfo->payment_mode; } $updated = $paymentOrder->generateOrderItem($order_id,oseObject::getValue($item,'entry_id'), $itemParams); } //$paymentOrder->__construct('#__osemsc_order'); if($updated) { /* $vmorder=self::AddVmOrder($msc_id,$params,$order_number,$paymentInfo); if(!$vmorder['success']) { return $vmorder; } */ $result['success'] = true; $result['title'] = JText :: _('Done'); $result['content'] = JText :: _('Done'); } else { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText :: _('Order Generate Error'); } return $result; }
function updateStatusForOneOrder($virtuemart_order_id,$inputOrder,$useTriggers=true){ // vmdebug('updateStatusForOneOrder', $inputOrder); /* Update the order */ $data = $this->getTable('orders'); $data->load($virtuemart_order_id); $old_order_status = $data->order_status; $data->bind($inputOrder); //First we must call the payment, the payment manipulates the result of the order_status if($useTriggers){ if(!class_exists('vmPSPlugin')) require(JPATH_VM_PLUGINS.DS.'vmpsplugin.php'); // Payment decides what to do when order status is updated JPluginHelper::importPlugin('vmpayment'); $_dispatcher = JDispatcher::getInstance(); //Should we add this? $inputOrder $_returnValues = $_dispatcher->trigger('plgVmOnUpdateOrderPayment',array(&$data,$old_order_status)); foreach ($_returnValues as $_returnValue) { if ($_returnValue === true) { break; // Plugin was successfull } elseif ($_returnValue === false) { return false; // Plugin failed } // Ignore null status and look for the next returnValue } JPluginHelper::importPlugin('vmshipment'); $_dispatcher = JDispatcher::getInstance(); //Should we add this? $inputOrder $_returnValues = $_dispatcher->trigger('plgVmOnUpdateOrderShipment',array(&$data,$old_order_status)); /** * If an order gets cancelled, fire a plugin event, perhaps * some authorization needs to be voided */ if ($data->order_status == "X") { JPluginHelper::importPlugin('vmpayment'); //Should we add this? $inputOrder $_dispatcher = JDispatcher::getInstance(); $_dispatcher->trigger('plgVmOnCancelPayment',array(&$data,$old_order_status)); } } if ($data->store()) { ////////////////////////////////////////////////////////////////////////// /// OSE added ////////////////////////////////////////////////////////////////////////// if ($data->order_status == "C" || $data->order_status == "P") { require_once(JPATH_SITE.DS.'components'.DS.'com_osemsc'.DS.'init.php'); require_once(JPATH_SITE.DS.'components'.DS.'com_osemsc'.DS.'helpers'.DS.'oseMscPublic.php'); $jdb = &JFactory::getDBO(); $lang = &JFactory::getLanguage(); $tag = strtolower($lang->get('tag')); $tag = empty($tag)?null:'_'.str_replace('-','_',$tag); $jquery = "SELECT virtuemart_user_id FROM `#__virtuemart_orders` WHERE `virtuemart_order_id` = '" . $virtuemart_order_id . "'"; $jdb->setQuery($jquery); $user_id = $jdb->loadResult(); $jquery = "SELECT a.virtuemart_product_id, b.virtuemart_category_id FROM `#__virtuemart_order_items` as a, `#__virtuemart_product_categories` as b WHERE a.`virtuemart_order_id` = '" . $virtuemart_order_id . "' AND a.`virtuemart_product_id` = b.`virtuemart_product_id`"; $jdb->setQuery($jquery); $results = $jdb->loadObjectList(); $cart = oseMscPublic::getCart(); if (empty($results)) { $jquery = "SELECT a.virtuemart_product_id, b.virtuemart_category_id, c.product_parent_id FROM `#__virtuemart_order_items` as a, `#__virtuemart_product_categories` as b, `#__virtuemart_products` as c WHERE a.`virtuemart_order_id` = '" . $virtuemart_order_id . "' AND a.`virtuemart_product_id` = c.`virtuemart_product_id` AND b.`product_id` = c.`product_parent_id`"; $jdb->setQuery($jquery); $results = $jdb->loadObjectList(); } foreach ($results as $result) { ////////////////////////////////////////////////// $product_id = $result->virtuemart_product_id; $jquery = "SELECT * FROM `#__osemsc_ext` WHERE `type` = 'vm2'"; $jdb->setQuery($jquery); $jdb->query(); $rows = $jdb->loadObjectList(); foreach ($rows as $row) { $msc_data = oseJson::decode($row->params); $left_var = ""; $right_var = ""; if ($msc_data->category_id > 0) { $left_var = $result->virtuemart_category_id; $right_var = $msc_data->category_id; } else { $left_var = $result->virtuemart_product_id; $right_var = $msc_data->product_id; } if ($left_var == $right_var && !empty($user_id)) { $msc_id = $row->id; $query = "SELECT user_currency_id FROM `#__virtuemart_orders` WHERE `virtuemart_order_id` = ".(int)$virtuemart_order_id; $jdb->setQuery($query); $currency_id = $jdb->loadResult(); $query = "SELECT currency_code_3 FROM `#__virtuemart_currencies` WHERE `virtuemart_currency_id` = ".(int)$currency_id; $jdb->setQuery($query); $currency = $jdb->loadResult(); if ($data->order_status == "C") { $member= oseRegistry :: call('member'); $member->instance($user_id, 'member_id'); // get current item $cart->updateParams('payment_mode','m'); $paymentInfo = oseRegistry::call('msc')->getPaymentMscInfo($msc_id,$currency,0); $nItem = array('entry_id'=>$msc_id,'entry_type'=>'msc','msc_option'=>oseObject::getValue($paymentInfo,'msc_option')); $cart->addItem($nItem['entry_id'],$nItem['entry_type'],$nItem); $cart->update(); // join msc oseRegistry::call('msc')->runAddonAction('register.payment.save',array('member_id'=>$user_id,'payment_method'=>'none'), true, false); $msc_order_id = JRequest::getInt('order_id',0); oseRegistry::call('payment')->getInstance('Order')->confirmOrder($msc_order_id, array()); } else { $msc_id= $row->id; $member= oseRegistry :: call('member'); $member->instance($user_id, 'member_id'); $params = $member->getAddonParams($msc_id,$user_id,0,$params = array()); $updated= oseRegistry::call('msc')->runAddonAction('member.msc.cancelMsc', $params); } } } } } ////////////////////////////////////////////////////////////////////////// $task= JRequest::getCmd('task',0); $view= JRequest::getWord('view',0); /*if($task=='edit'){ $update_lines = JRequest::getInt('update_lines'); } else /*/ if ($task=='updatestatus' and $view=='orders') { $update_lines = JRequest::getVar('orders['.$virtuemart_order_id.'][update_lines]'); } else { $update_lines = 1; } if($update_lines!==0){ vmdebug('$update_lines '.$update_lines); $q = 'SELECT virtuemart_order_item_id FROM #__virtuemart_order_items WHERE virtuemart_order_id="'.$virtuemart_order_id.'"'; $db = JFactory::getDBO(); $db->setQuery($q); $order_items = $db->loadObjectList(); if ($order_items) { // vmdebug('updateStatusForOneOrder',$data); foreach ($order_items as $order_item) { //$this->updateSingleItem($order_item->virtuemart_order_item_id, $data->order_status, $order['comments'] , $virtuemart_order_id, $data->order_pass); $this->updateSingleItem($order_item->virtuemart_order_item_id, $data); } } } /* Update the order history */ $this->_updateOrderHist($virtuemart_order_id, $data->order_status, $inputOrder['customer_notified'], $inputOrder['comments']); // When the plugins did not already notified the user, do it here (the normal way) //Attention the ! prevents at the moment that an email is sent. But it should used that way. // if (!$inputOrder['customer_notified']) { $this->notifyCustomer( $data->virtuemart_order_id , $inputOrder ); // } JPluginHelper::importPlugin('vmcoupon'); $dispatcher = JDispatcher::getInstance(); $returnValues = $dispatcher->trigger('plgVmCouponUpdateOrderStatus', array($data, $old_order_status)); if(!empty($returnValues)){ foreach ($returnValues as $returnValue) { if ($returnValue !== null ) { return $returnValue; } } } return true; } else { return false; } }
function getSelectedMsc() { $cart = oseMscPublic::getCart(); $items = $cart->get('items'); if (!is_array($items)) { $items = array($items); } $result = array(); $result['total'] = count($items); $result['results'] = array_values($items); return $result; //$result = oseJson::encode(array("result"=>$result)); //oseExit($result); }
protected function generateMscIdOption() { $list = oseMscPublic::getList(); $cart = oseMscPublic::getCart(); $selectedMsc = oseMscAddon::runAction('register.msc.getSelectedMsc', array()); $options = array(); $msc = oseRegistry::call('msc'); foreach ($list as $key => $entry) { $msc_id = oseObject::getValue($entry, 'id'); $node = $msc->getInfo($msc_id, 'obj'); $paymentInfos = $msc->getExtInfo($msc_id, 'payment'); $osePaymentCurrency = $cart->get('currency'); $option = oseMscPublic::generatePriceOption($node, $paymentInfos, $osePaymentCurrency); $options = array_merge($options, $option); } $currency = oseMscPublic::getCurrency(); $mscList = array('total' => count($list), 'results' => $list); $mscOptions = array('total' => count($options), 'results' => $options); $currency = array('total' => count($currency), 'results' => $currency); $result = array(); $result['selectedMsc'] = $selectedMsc; $result['mscList'] = $mscList; $result['mscOptions'] = $mscOptions; $result['currency'] = $currency; return $result; }
function ajaxOrderTrack($account, $order_id) { $db = JFactory::getDBO(); $where = array('`order_id`=' . $db->Quote($order_id)); $code = array(); if (!JFile::exists(JPATH_SITE . DS . 'components' . DS . 'com_osemsc' . DS . 'init.php')) { return false; } else { require_once(JPATH_SITE . DS . 'components' . DS . 'com_osemsc' . DS . 'init.php'); } $db = oseDB::instance(); $pOrder = oseRegistry::call('payment')->getInstance('Order'); $orderInfo = $pOrder->getOrder($where, 'obj'); $orderInfoParams = oseJson::decode($orderInfo->params); // transaction $code[] = 'var pageTracker = _gat._getTracker("' . $account . '");'; $code[] = "pageTracker._addTrans("; $code[] = "'{$orderInfo->order_id}',"; $code[] = "'{$orderInfo->order_number}',"; $code[] = "'{$orderInfo->payment_price}',"; $code[] = "'{$orderInfoParams->gross_tax}',"; $code[] = "'0',"; $code[] = "'',"; $code[] = "'', "; $code[] = "'' "; $code[] = ");"; // product $msc = oseRegistry::call('msc'); $orderItems = $pOrder->getOrderItems($orderInfo->order_id, 'obj'); foreach ($orderItems as $orderItem) { $curOrderItemParams = oseJson::decode($orderItem->params); $msc_id = $orderItem->entry_id; $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); $option = $options[0]; $code[] = "pageTracker._addItem("; $code[] = "'{$orderItem->order_id}',"; $code[] = "'{$orderItem->entry_type}_{$orderItem->entry_id}',"; $code[] = "'{$node->title}-{$option['title']}',"; $code[] = "'{$orderItem->entry_type}',"; $code[] = "'{$orderItem->payment_price}',"; $code[] = "'1'"; $code[] = ");"; } $code[] = "pageTracker._trackTrans();"; return $code; }
public static function save($params) { $db = oseDB::instance(); $member_id = $params['member_id']; //$msc_id = $params['msc_id']; //$msc_option = $params['msc_option']; JRequest::setVar('member_id',$member_id); if(empty($member_id)) { $result['success'] = false; $result['title'] = 'Error'; $result['content'] = JText :: _('Error'); return $result; } $cart = oseMscPublic::getCart(); $coupon_id = $cart->getParams('coupon_id'); if(empty($coupon_id)) { $result['success'] = true; $result['title'] = JText :: _('Done'); $result['content'] = JText :: _('Done'); return $result; } $coupon_number = $cart->getParams('coupon_number'); $where = array(); $where[] = "coupon_number = '{$coupon_number}'"; $where[] = "`coupon_id` = '{$coupon_id}'"; $where = oseDB::implodeWhere($where); $query = " UPDATE `#__osemsc_coupon_user`" ." SET `user_id` = '{$member_id}'" . $where ; $db->setQuery($query); $updated = oseDB::query(); if($updated) { $result['success'] = true; $result['title'] = JText :: _('Done'); $result['content'] = JText :: _('Done'); } else { $result['success'] = false; $result['title'] = JText :: _('Error'); $result['content'] = JText :: _('Coupon: Can not save the member ID'); } return $result; }
$msc_option = $orderItemParams->msc_option; $query = "SELECT params FROM `#__osemsc_ext` WHERE `type` = 'paymentAdv' AND `id` = ".$msc_id; $db->setQuery($query); $ext = $db->loadResult(); $params = oseJson :: decode($ext); if(isset($params->$msc_option->installment) && !empty($params->$msc_option->installment)) { $InstallmentCount = $params->$msc_option->installment; } //settings for garanti require_once(OSEMSC_F_HELPER . DS . 'oseMscPublic.php'); $cart = oseMscPublic::getCart(); if(isset($cart->cart['params']['garanti_taksit']) && $cart->cart['params']['garanti_taksit'] && isset($cart->cart['params']['garanti_vade']) && $cart->cart['params']['garanti_vade']) { $InstallmentCount = $cart->cart['params']['garanti_taksit']; $vade = $cart->cart['params']['garanti_vade']; //$Amount = $cart->cart['total']*100; $Amount = $Amount * $vade/100 + $Amount; $Amount = round($Amount); //echo $Amount; die; } $server = str_replace('/components/com_osemsc/ipn','',JURI :: base());
protected function generateRegInfoJs() { $initMscPayment = array('msc_id' => 0, 'msc_option' => null); $cart = oseMscPublic::getCart(); ; $user = JFactory::getUser(); $member = oseRegistry::call('member'); $member->instance($user->id); $item = $member->getBillingInfo(); foreach ($item as $k => $v) { $item['bill_' . $k] = $v; } $cartItems = $cart->get('items'); $cartItem = $cartItems[0]; $item['msc_option'] = $cartItem['msc_option']; $output .= "\r\n"; $output .= "var getRegInfo = function() {return " . oseJson::encode($item) . "};"; return $output; }
protected function generateMscIdOption() { $list = oseMscPublic::getList(); $result = array(); if (!empty($list)) { $cart = oseMscPublic::getCart(); $options = array(); $msc = oseRegistry::call('msc'); foreach ($list as $key => $entry) { $msc_id = oseObject::getValue($entry, 'id'); $node = $msc->getInfo($msc_id, 'obj'); $paymentInfos = $msc->getExtInfo($msc_id, 'payment'); $osePaymentCurrency = $cart->get('currency'); $option = oseMscPublic::generatePriceOption($node, $paymentInfos, $osePaymentCurrency); $options = array_merge($options, $option); } $mscList = array('total' => count($list), 'results' => $list); $mscOptions = array('total' => count($options), 'results' => $options); $result = array(); $result['mscList'] = $mscList; $result['mscOptions'] = $mscOptions; } else { $result['mscList'] = array(); $result['mscOptions'] = array(); } return $result; }
function toPaymentPage() { $model = $this->getModel('payment'); $updated = $model->toPaymentPage(); $result = array(); if (!$updated) { $result['success'] = false; $result['title'] = JText::_('Notice'); $result['content'] = JText::_('You don\'t need to renew the membership'); } else { $payment_mode = oseMscPublic::getPaymentMode('payment_mode'); $msc_id = JRequest::getInt('msc_id', 0); $msc_option = JRequest::getCmd('msc_option', null); $session = JFactory::getSession(); $session->set('ose_reg_step', 'cart'); if (empty($payment_mode)) { $result['success'] = false; $result['title'] = JText::_('Error!'); $result['content'] = JText::_('Have Not Selected Payment Method'); $result = oseJson::encode($result); oseExit($result); } if (!empty($msc_id)) { $cart = oseMscPublic::getCart(); $item = array('entry_id' => $msc_id, 'entry_type' => 'msc', 'msc_option' => $msc_option); $cart->addItem($item['entry_id'], $item['entry_type'], $item); $cart->updateParams('payment_mode', $payment_mode); $cart->update(); } $result['success'] = true; $result['title'] = JText::_('Done'); $result['content'] = JText::_('Done'); $result['link'] = JRoute::_('index.php?option=com_osemsc&view=payment'); } $result = oseJson::encode($result); oseExit($result); }