Ejemplo n.º 1
0
	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');
		
		$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);
		
		if(oseObject::GetValue($config, 'oseaffiliate_enabled',true))
		{
			if(empty($curOrderParams->oseaffiliateID) || empty($curOrderParams->osebannerID))
			{
				return true;
			}
			else
			{
				//$memParams->oseaffiliateID = $curOrderParams->oseaffiliateID;
				//$memParams->osebannerID = $curOrderParams->osebannerID;
			}
		
			$file = JPATH_ADMINISTRATOR.DS.'com_ose_affiliates'.DS.'helpers'.DS.'oseaffiliates_helper.php';
			if ( JFile::exists($file) )
			{
				require_once($file);
			}
			else
			{
				return false;
			}
		
			$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]);
				}
			}
				
			$osePaymentCurrency = $curOrder->payment_currency;
		
			$options = oseMscPublic::generatePriceOption($node,$paymentInfos,$osePaymentCurrency);
			$product = "{$node->title}-{$options[0]['title']}";
		
			$helper = new oseAffiliatesHelper();
			$helper->setTotalCost($curOrder->payment_price);
			$helper->setOrderId($order_id);
			$helper->setProduct($product);
			$helper->setCurrency($osePaymentCurrency);
			$helper->setAffiliateId($curOrderParams->oseaffiliateID);
			$helper->setBannerId($curOrderParams->osebannerID);
			if(!$helper->createSale())
			{
				return false;
			}
		}
		
		return $result;
	}
Ejemplo n.º 2
0
	private static function joinFromPayment($params) {
		$db = oseDB::instance();
		$msc = oseRegistry::call('msc');
		$member_id = $params['member_id'];
		$msc_id = $params['msc_id'];
		$order_id = $params['order_id'];
		$result = array();
		if (empty($msc_id)) {
			$result['success'] = false;
			$result['title'] = 'Error';
			$result['content'] = JText::_('Please Select A Membership First');
			return $result;
		}
		$member = oseRegistry::call('member');
		$member->instance($member_id);
		$updated = $member->joinMsc($msc_id);
		if ($updated) {
			$list = oseMscAddon::getAddonList('join', false, 1, 'obj');
			foreach ($list as $addon) {
				$action_name = oseMscAddon::getActionName($addon, 'save', 'join');
				$result = oseMscAddon::runAction($action_name, $params, true, false);
				if (!$result['success']) {
					self::cancelMsc($params);
					return $result;
				}
			}
			$userInfo = $member->getBasicInfo('obj');
			$ext = $msc->getExtInfo($msc_id, 'msc', 'obj');
			if (oseObject::GetValue($ext, 'wel_email', false)) {
				$email = $member->getInstance('email');
				$emailTempDetail = $email->getDoc($ext->wel_email, 'obj');
				$variables = $email->getEmailVariablesWelcome($order_id, $msc_id);
				$emailParams = $email->buildEmailParams($emailTempDetail->type);
				$emailDetail = $email->transEmail($emailTempDetail, $variables, $emailParams);
				$email->sendEmail($emailDetail, $userInfo->email);
				$emailConfig = oseMscConfig::getConfig('email', 'obj');
				if ($emailConfig->sendWel2Admin) {
					$email->sendToAdminGroup($emailDetail, $emailConfig->admin_group);
				}
			}
			$result = array();
			$result['success'] = true;
			$result['title'] = 'Done';
			$result['content'] = JText::_('Joined Membership.');
		} else {
			$result['success'] = false;
			$result['title'] = 'Error';
			$result['content'] = JText::_('Fail Joining Membership.');
		}
		return $result;
	}
Ejemplo n.º 3
0
	public static function cancel($params)
	{
		$result = array();
		$result['success'] = true;

		if(empty($params['allow_work']))
		{
			$result['success'] = false;
			$result['title'] = JText::_('Error');
			$result['content'] = JText::_('Error Join.Order');

			return $result;
		}
		unset($params['allow_work']);

		$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');
		$curOrderParams = oseJson::decode($curOrder->params);
		
		$oseMscConfig = oseRegistry::call('msc')->getConfig('thirdparty','obj');
		
		if(oseObject::GetValue($config, 'oseaffiliate_enabled',true))
		{
			if(empty($curOrderParams->oseaffiliateID) || empty($curOrderParams->osebannerID))
			{
				return true;
			}
		
			$file = JPATH_ADMINISTRATOR.DS.'com_ose_affiliates'.DS.'helpers'.DS.'oseaffiliates_helper.php';
			if ( JFile::exists($file) )
			{
				require_once($file);
			}
			else
			{
				return false;
			}
		
			$helper = new oseAffiliatesHelper();
			$helper->setOrderId($order_id);
				
			if(!$helper->cancelSale())
			{
				return false;
			}
		}
		
		$result = array();
		$result['success'] = true;
		$result['title'] = JText::_('Done');
		$result['content'] = JText::_("Done");

		return $result;
	}
Ejemplo n.º 4
0
	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;
	    }
	}
Ejemplo n.º 5
0
 function displayMemberAuthor()
 {
     $db = oseDB::instance();
     ///$com = OSECPU_PATH_JS.'/com_ose_cpu/extjs';
     //oseHTML::script($com."/fileupload/field.js",'1.5');
     //oseHTML::stylesheet($com.'/fileupload/field.css','1.5');
     $result = array();
     $result['layout'] = 'member';
     $user = JFactory::getUser();
     $member = oseRegistry::call('member');
     $member->instance($user->id);
     $status = $member->getUserInfo('obj');
     /*
     $query = " SELECT muv.*,muv.block AS user_status,luv.* "
     		." FROM `#__osemsc_userinfo_view` AS muv "
     		." LEFT JOIN `#__oselic_userinfo_view` AS luv ON luv.user_id = muv.user_id"
     		." WHERE luv.user_id = {$user->id}"
     		;
     
     $db->setQuery($query);
     
     $item = oseDB::loadItem('obj');
     */
     //$objs = oseMscAddon::getAddonList($addon_type,false,null,'obj','name');
     $where = array();
     $where[] = "type LIKE 'member_%'";
     $where[] = 'frontend = 1';
     $where[] = 'frontend_enabled = 1';
     $where[] = ' action != "0" ';
     $where = oseDB::implodeWhere($where);
     $query = " SELECT * FROM `#__osemsc_addon`" . $where . " ORDER BY ordering ASC ";
     $db->setQuery($query);
     $objs = oseDB::loadList('obj', 'name');
     //oseExit($db->getQuery());
     $memInfos = $member->getAllOwnedMsc(false, 1, 'obj');
     if (count($memInfos) > 0) {
         $memberships = $member->getMemberOwnedMscInfo(false, 1, 'obj');
         $payment = oseRegistry::call('payment');
         $order_ids = array();
         foreach ($memberships as $membership) {
             $memParams = oseJson::decode($membership->params);
             if ($memParams->payment_mode == 'a') {
                 $orderInfo = $payment->getOrder(array("`order_id`=" . $db->Quote($memParams->order_id) . ""));
                 if (oseObject::GetValue($orderInfo, 'order_status') == 'confirmed') {
                     $order_ids[$memParams->order_id] = $db->Quote($memParams->order_id);
                 }
             }
         }
         if (count($order_ids) < 1) {
             unset($objs['msc_cancel']);
         }
         $memAllInfos = $member->getAllOwnedMsc(true, 0, 'obj');
         $renew = false;
         foreach ($memAllInfos as $memAllInfo) {
             $memParams = oseJson::decode($memAllInfo->params);
             if ($memParams->payment_mode == 'a') {
                 if ($memAllInfo->status == 0) {
                     $renew = true;
                 }
             } else {
                 $renew = true;
             }
         }
         if (!$renew) {
             unset($objs['msc_renew']);
         }
         //$objs['msc'] = 'msc';
         $result['addons'] = $objs;
         $result['tpl'] = 'master';
     } else {
         $query = " SELECT * FROM `#__osemsc_member` AS mem" . " WHERE mem.member_id = {$user->id}" . " LIMIT 1";
         $db->setQuery($query);
         $item = oseDB::loadItem();
         if (empty($item)) {
             $result['layout'] = 'default';
             $result['addons'] = array('juser' => $objs['juser'], 'billinginfo' => $objs['billinginfo']);
         } else {
             $result['addons'] = array();
             $result['addons']['juser'] = $objs['juser'];
             $result['addons']['billinginfo'] = $objs['billinginfo'];
             $result['addons']['msc_renew'] = $objs['msc_renew'];
             $result['addons']['join_history'] = $objs['join_history'];
             $result['tpl'] = 'expired';
             //if($addon_type == 'member_user')	oseExit($result);
         }
     }
     //oseExit($result);
     return $result;
 }