function savePaymentMode() { $cart = oseMscPublic::getCart(); $payment_mode = oseMscPublic::getPaymentMode(); $config = oseMscPublic::getConfig('global', 'obj'); if ($config->payment_mode != 'b') { $payment_mode = $config->payment_mode; } $register_form = oseRegistry::call('msc')->getConfig('register', 'obj')->register_form; // force to m if (empty($register_form) || $register_form == 'default') { $payment_mode = 'm'; } else { $items = $cart->get('items'); $msc = oseRegistry::call('msc'); foreach ($items as $item) { if (oseObject::getValue($item, 'recurrence_mode', 'period') == 'fixed') { $payment_mode = 'm'; } if (oseObject::getValue($item, 'entry_type', 'msc') == 'license') { $payment_mode = 'm'; } else { $extItem = $msc->getExtInfoItem(self::getEntryMscID($item), 'paymentAdv', 'obj'); $advItems = oseJson::decode(oseObject::getvalue($extItem, 'params', '{}'), true); $advItems = empty($advItems) ? array() : $advItems; $advOption = isset($advItems[oseObject::getvalue($item, 'msc_option')]) ? $advItems[oseObject::getvalue($item, 'msc_option')] : array(); if (oseObject::getValue($advOption, 'payment_mode', 'b') != 'b') { $payment_mode = $advOption['payment_mode']; } } $payment_method = oseMscPublic::getPaymentMethod(); if ($payment_method == 'paypal') { if (oseObject::getValue($item, 'p3', 0) >= 2 && strtolower(oseObject::getValue($item, 't3', 'day')) == 'year') { $payment_mode = 'm'; } if (oseObject::getValue($item, 'p3', 0) >= 24 && strtolower(oseObject::getValue($item, 't3', 'day')) == 'month') { $payment_mode = 'm'; } } } } if ($cart->get('total') <= 0 && $cart->get('next_total') <= 0) { $payment_mode = 'm'; } $cart->updateParams('payment_mode', $payment_mode); $cart->update(); return $payment_mode; }
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; }