public function doVoid() { // Get component parameters $params = JComponentHelper::getParams('com_crowdfunding'); /** @var $params Joomla\Registry\Registry */ // Check for disabled payment functionality if ($params->get('debug_payment_disabled', 0)) { throw new Exception(JText::_($this->text_prefix . '_ERROR_PAYMENT_HAS_BEEN_DISABLED_MESSAGE')); } $cid = $this->input->get('cid', array(), 'array'); $cid = Joomla\Utilities\ArrayHelper::toInteger($cid); $messages = array(); try { if (count($cid) > 0) { $options = array('ids' => $cid, 'txn_status' => 'pending'); $items = new Crowdfunding\Transactions(JFactory::getDbo()); $items->load($options); if (count($items) === 0) { throw new UnexpectedValueException(JText::_($this->text_prefix . '_ERROR_INVALID_TRANSACTIONS')); } // Import Crowdfunding Payment Plugins $dispatcher = JEventDispatcher::getInstance(); JPluginHelper::importPlugin('crowdfundingpayment'); foreach ($items as $item) { $item = Joomla\Utilities\ArrayHelper::toObject($item); $context = $this->option . '.payments.void.' . $item->service_alias; // Trigger onContentPreparePayment event. $results = $dispatcher->trigger('onPaymentsVoid', array($context, &$item, &$params)); foreach ($results as $message) { if ($message !== null and is_array($message)) { $messages[] = $message; } } } } } catch (UnexpectedValueException $e) { $this->setMessage($e->getMessage(), 'notice'); $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=transactions', false)); return; } catch (Exception $e) { // Store log data in the database $this->log->add(JText::_($this->text_prefix . '_ERROR_SYSTEM'), 'CONTROLLER_PAYMENTS_DOCAPTURE_ERROR', $e->getMessage()); throw new Exception(JText::_($this->text_prefix . '_ERROR_SYSTEM')); } // Set messages. if (count($messages) > 0) { foreach ($messages as $message) { $this->app->enqueueMessage($message['text'], $message['type']); } } $this->setRedirect(JRoute::_('index.php?option=' . $this->option . '&view=transactions', false)); }
public function dovoid() { // Get component parameters $params = JComponentHelper::getParams("com_crowdfunding"); /** @var $params Joomla\Registry\Registry */ // Check for disabled payment functionality if ($params->get("debug_payment_disabled", 0)) { throw new Exception(JText::_($this->text_prefix . "_ERROR_PAYMENT_HAS_BEEN_DISABLED_MESSAGE")); } $app = JFactory::getApplication(); /** @var $app JApplicationAdministrator */ $cid = $this->input->get("cid", array(), "array"); JArrayHelper::toInteger($cid); $messages = array(); try { if (!empty($cid)) { $options = array("ids" => $cid, "txn_status" => "pending"); $items = new Crowdfunding\Transactions(JFactory::getDbo()); $items->load($options); if (count($items) == 0) { throw new UnexpectedValueException(JText::_($this->text_prefix . "_ERROR_INVALID_TRANSACTIONS")); } // Import Crowdfunding Payment Plugins $dispatcher = JEventDispatcher::getInstance(); JPluginHelper::importPlugin('crowdfundingpayment'); foreach ($items as $item) { $context = $this->option . '.payments.void.' . Joomla\String\String::strtolower(str_replace(" ", "", $item->service_provider)); // Trigger onContentPreparePayment event. $results = $dispatcher->trigger("onPaymentsVoid", array($context, &$item, &$params)); foreach ($results as $message) { if (!is_null($message) and is_array($message)) { $messages[] = $message; } } } } } catch (UnexpectedValueException $e) { $this->setMessage($e->getMessage(), "notice"); $this->setRedirect(JRoute::_("index.php?option=" . $this->option . "&view=transactions", false)); return; } catch (Exception $e) { // Store log data in the database $this->log->add(JText::_($this->text_prefix . "_ERROR_SYSTEM"), "CONTROLLER_PAYMENTS_DOCAPTURE_ERROR", $e->getMessage()); throw new Exception(JText::_($this->text_prefix . "_ERROR_SYSTEM")); } // Set messages. if (!empty($messages)) { foreach ($messages as $message) { $app->enqueueMessage($message["text"], $message["type"]); } } $this->setRedirect(JRoute::_("index.php?option=" . $this->option . "&view=transactions", false)); }