Пример #1
0
	private function toPaymentOS() {
		$model = $this->getModel('register');
		$post = JRequest::get('POST');
		$post['payment_method'] = $payment_method = oseMscPublic::getPaymentMethod();
		$cart = oseMscPublic::getCart();
		$items = $cart->get('items');
		$item = $items[0];
		$payment_mode = $cart->getParams('payment_mode');
		$msc_id = oseMscPublic::getEntryMscID($item);
		$allow_to_join = $this->checkJoiningControl($msc_id);
		if ($allow_to_join == false) {
			$result['success'] = false;
			$result['title'] = JText::_('Error');
			$result['content'] = JText::_('Permission denied, this membership is for members only!');
			$result = oseJson::encode($result);
			oseExit($result);
		}
		$msc_option = JRequest::getCmd('msc_option', null);
		if (empty($payment_mode)) {
			$result['success'] = false;
			$result['title'] = JText::_('Error!');
			$result['content'] = JText::_('Fail Paying...');
			return $result;
		}
		if (empty($msc_id)) {
			$result['success'] = false;
			$result['title'] = JText::_('Error!');
			$result['content'] = JText::_('Fail Paying...');
			return $result;
		}
		$list = oseMscAddon::getAddonList('registerOS_body', false, 1, 'obj');
		$list = oseMscPublic::filter($list, array('juser'), false);
		foreach ($list as $addon) {
			$action_name = oseMscAddon::getActionName($addon, 'formValidate', 'register');
			$updated = oseMscAddon::runAction($action_name, array('inner' => true));
			if (!$updated['success']) {
				return $updated;
			}
		}
		$user = oseMscPublic::getUser();
		$params['member_id'] = $user->id;
		$params['payment_method'] = $payment_method;
		oseRegistry::call('msc')->runAddonAction('member.billinginfo.save');
		oseRegistry::call('msc')->runAddonAction('register.profile.save', $params);
		$order = oseRegistry::call('msc')->runAddonAction('register.payment.save', $params);
		$order_id = $order['order_id'];
		if ($order_id) {
			$updated = $model->processPayment($order_id, $post, $msc_option);
			$result = $updated;
			if (is_array($result)) {
				$result['order_id'] = $order_id;
			}
		} else {
			$result['success'] = false;
			$result['title'] = JText::_('Error!');
			$result['content'] = JText::_('Fail Creating Order...');
		}
		return $result;
	}