function _execute() { $mainframe =& JFactory::getApplication(); $option = 'com_rsmembership'; $task = JRequest::getVar('task', ''); if ($task == 'upgrade') { $this->_bindId(); } else { $this->_setId(); if ($task == 'upgradepayment') { // empty session $this->_emptySession(); $extras = array(); $upgrade = $this->getUpgrade(); $membership = $this->getMembership($upgrade->membership_to_id); $paymentplugin = JRequest::getCmd('payment', 'none'); // calculate the total price $total = $upgrade->price; $user =& JFactory::getUser(); $user_id = $user->get('id'); $row =& JTable::getInstance('RSMembership_Transactions', 'Table'); $row->user_id = $user_id; $row->user_email = $user->get('email'); $this->_data = new stdClass(); $this->_data->username = $user->get('username'); $this->_data->name = $user->get('name'); $this->_data->email = $user->get('email'); $this->_data->fields = RSMembershipHelper::getUserFields($user->get('id')); $row->user_data = serialize($this->_data); $row->type = 'upgrade'; $params = array(); $params[] = 'id=' . $this->_id; $params[] = 'from_id=' . $upgrade->membership_from_id; $params[] = 'to_id=' . $upgrade->membership_to_id; $row->params = implode(';', $params); // params, membership, extras etc $date = JFactory::getDate(); $row->date = $date->toUnix(); $row->ip = $_SERVER['REMOTE_ADDR']; $row->price = $total; $row->currency = RSMembershipHelper::getConfig('currency'); $row->hash = ''; $row->gateway = $paymentplugin == 'none' ? 'No Gateway' : RSMembership::getPlugin($paymentplugin); $row->status = 'pending'; $this->_html = ''; // trigger the payment plugin $paymentpluginClass = $paymentplugin; if (preg_match('#rsmembershipwire([0-9]+)#', $paymentplugin, $match)) { $paymentpluginClass = 'rsmembershipwire'; } $className = 'plgSystem' . $paymentpluginClass; $delay = false; if (class_exists($className) && method_exists($className, 'onMembershipPayment')) { $dispatcher =& JDispatcher::getInstance(); $plugin = new $className($dispatcher, array()); $args = array('plugin' => $paymentplugin, 'data' => &$this->_data, 'extras' => $extras, 'membership' => $membership, 'transaction' => &$row); $this->_html = call_user_func_array(array($plugin, 'onMembershipPayment'), $args); if (method_exists($className, 'hasDelayTransactionStoring')) { $delay = $plugin->hasDelayTransactionStoring(); if (method_exists($className, 'delayTransactionStoring')) { $plugin->delayTransactionStoring($row->getProperties()); } } } // plugin can delay the transaction storing if (!$delay) { // store the transaction $row->store(); // store the transaction id $this->transaction_id = $row->id; // finalize the transaction (send emails) RSMembership::finalize($this->transaction_id); // approve the transaction if ($row->status == 'completed' || $row->price == 0 && $membership->activation != 0) { RSMembership::approve($this->transaction_id, true); } if ($row->price == 0) { $mainframe->redirect(JRoute::_('index.php?option=com_rsmembership&task=thankyou', false)); } } } } }
function _execute() { $app = JFactory::getApplication(); $task = $app->input->get('task', '', 'string'); if ($task == 'addextra') { $this->_bindId(); } else { $this->_setId(); if ($task == 'addextrapayment') { // empty session $this->_emptySession(); $membership = $this->getMembership(); $extra = $this->getExtra(); $paymentplugin = $app->input->get('payment', 'none', 'cmd'); // calculate the total price $total = $extra->price; $user = JFactory::getUser(); $user_id = $user->get('id'); $row = JTable::getInstance('Transaction', 'RSMembershipTable'); $row->user_id = $user_id; $row->user_email = $user->get('email'); $this->_data = new stdClass(); $this->_data->username = $user->get('username'); $this->_data->name = $user->get('name'); $this->_data->email = $user->get('email'); $this->_data->fields = RSMembershipHelper::getUserFields($user->get('id')); $membership_fields = RSMembershipHelper::getTransactionMembershipFields($user->get('id'), $membership->last_transaction_id); if (count($membership_fields)) { $this->_data->membership_fields = $membership_fields; } $row->user_data = serialize($this->_data); $row->type = 'addextra'; $params = array(); $params[] = 'id=' . $this->_id; $params[] = 'membership_id=' . $membership->id; $params[] = 'extras=' . $extra->id; $row->params = implode(';', $params); // params, membership, extras etc $row->date = JFactory::getDate()->toSql(); $row->ip = $_SERVER['REMOTE_ADDR']; $row->price = $total; $row->currency = RSMembershipHelper::getConfig('currency'); $row->hash = ''; $row->gateway = $paymentplugin == 'none' ? 'No Gateway' : RSMembership::getPlugin($paymentplugin); $row->status = 'pending'; $this->_html = ''; // trigger the payment plugin $delay = false; $args = array('plugin' => $paymentplugin, 'data' => &$this->_data, 'extras' => array(), 'membership' => $membership, 'transaction' => &$row, 'html' => &$this->_html); $returns = $app->triggerEvent('onMembershipPayment', $args); // PHP 5.4 fix... if (version_compare(PHP_VERSION, '5.4.0', '>=')) { foreach ($returns as $value) { if ($value) { $this->_html = $value; } } } $properties = $row->getProperties(); $returns = $app->triggerEvent('delayTransactionStoring', array(array('plugin' => $paymentplugin, 'properties' => &$properties, 'delay' => &$delay))); // PHP 5.4 fix... if (version_compare(PHP_VERSION, '5.4.0', '>=')) { foreach ($returns as $value) { if ($value) { $delay = true; } } } // plugin can delay the transaction storing if (!$delay) { // store the transaction $row->store(); // store the transaction id $this->transaction_id = $row->id; // finalize the transaction (send emails) RSMembership::finalize($this->transaction_id); // approve the transaction if ($row->status == 'completed' || $row->price == 0 && $membership->activation != 0) { RSMembership::approve($this->transaction_id, true); } if ($row->price == 0) { $app->redirect(JRoute::_(RSMembershipRoute::ThankYou(), false)); } } } } }