function checkout() { $Itemid=JRequest::getInt('Itemid'); $price=JRequest::getFloat('amount'); if ($price<=0){ JError::raiseWarning(510,JText::_("FACTORY_AMOUNT_MUST_BE")); $this->setRedirect("index.php?option=".APP_EXTENSION."&task=balance.addfunds&Itemid=".$Itemid); return; } $currency= JModelLegacy::getInstance('currency','JTheFactoryModel'); $default_currency=$currency->getDefault(); $modelorder=JTheFactoryPricingHelper::getModel('orders'); $item=new stdClass(); $item->itemname=$this->name; $item->itemdetails=JText::_($this->description); $item->iteminfo=null; $item->price=$price; $item->currency=$default_currency; $item->quantity=1; $item->params=''; $order=$modelorder->createNewOrder($item,$price,$default_currency,null,'P'); $this->setRedirect("index.php?option=".APP_EXTENSION."&task=orderprocessor.checkout&orderid=$order->id&Itemid=".$Itemid); }
function onDefaultCurrencyChange() { $db = JFactory::getDbo(); $db->setQuery('SELECT * FROM #__' . APP_PREFIX . '_payment_balance'); $balances = $db->loadObjectList(); $currency = JTheFactoryPricingHelper::getModel('currency'); $newCurrency = $currency->getDefault(); foreach ($balances as $b) { $balance = JTable::getInstance('BalanceTable', 'JTheFactory'); $balance->bind($b); $balance->balance = $currency->convertCurrency($balance->balance, $balance->currency, $newCurrency); $balance->currency = $newCurrency; $balance->store(); } }
function History() { $Itemid=JRequest::getInt('Itemid'); $user= JFactory::getUser(); $modelorder=JTheFactoryPricingHelper::getModel('orders'); $orders=$modelorder->getOrdersList($user->username); $view=$this->getView('payments'); $view->assign('orders',$orders); $view->assign('pagination',$modelorder->pagination); $view->assign('Itemid',$Itemid); $view->display('history'); }
static function registerModule($app=null) { if (!$app) $app= JTheFactoryApplication::getInstance(); if ($app->getIniValue('use_payment_gateways')){ JLoader::register('JTheFactoryPricingHelper',$app->app_path_admin.'payments'.DS.'helper'.DS.'pricing.php'); JLoader::register('JTheFactoryBalanceController',$app->app_path_front.'payments'.DS.'controllers'.DS.'balance.php'); JLoader::register('JTheFactoryOrderProcessorController',$app->app_path_front.'payments'.DS.'controllers'.DS.'processor.php'); JLoader::register('JTheFactoryOrder',$app->app_path_admin.'payments'.DS.'classes'.DS.'orders.php'); if ($app->getIniValue('use_events')){ JTheFactoryPricingHelper::registerEvents(); JTheFactoryEventsHelper::registerEvents($app->app_path_admin.'payments'.DS.'events'); } $lang=JFactory::getLanguage(); $lang->load('thefactory.payments',JPATH_ADMINISTRATOR); } }
static function registerModule($app = null) { if (!$app) { $app = JTheFactoryApplication::getInstance(); } if ($app->getIniValue('use_payment_gateways')) { JLoader::register('JTheFactoryPricingHelper', $app->app_path_admin . 'payments' . DS . 'helper' . DS . 'pricing.php'); JLoader::register('JTheFactoryPaymentsHtmlHelper', $app->app_path_admin . 'payments' . DS . 'helper' . DS . 'paymentshtml.php'); JLoader::register('JTheFactoryBalancesController', $app->app_path_admin . 'payments' . DS . 'controllers' . DS . 'balances.php'); JLoader::register('JTheFactoryCurrenciesController', $app->app_path_admin . 'payments' . DS . 'controllers' . DS . 'currencies.php'); JLoader::register('JTheFactoryGatewaysController', $app->app_path_admin . 'payments' . DS . 'controllers' . DS . 'gateways.php'); JLoader::register('JTheFactoryOrdersController', $app->app_path_admin . 'payments' . DS . 'controllers' . DS . 'orders.php'); JLoader::register('JTheFactoryPricingController', $app->app_path_admin . 'payments' . DS . 'controllers' . DS . 'pricing.php'); if ($app->getIniValue('use_events')) { JTheFactoryPricingHelper::registerEvents(); JTheFactoryEventsHelper::registerEvents($app->app_path_admin . 'payments' . DS . 'events'); } } }
function onBeforeExecuteTask(&$stopexecution) { $app = JFactory::getApplication(); if ($app->isAdmin()) { return; } $task = JRequest::getCmd('task', 'listauctions'); if ($task == 'paycomission') { $stopexecution = true; //task is fully processed here $app = JFactory::getApplication(); $user = JFactory::getUser(); $modelbalance = JTheFactoryPricingHelper::getModel('balance'); $balance = $modelbalance->getUserBalance(); if ($balance->balance >= 0) { JError::raiseNotice(501, JText::_("COM_BIDS_YOU_HAVE_A_POSITIVE_BALANCE")); $app->redirect(BidsHelperRoute::getAddFundsRoute()); return; } $model = self::getModel(); $modelorder = JTheFactoryPricingHelper::getModel('orders'); $item = $model->getOderitemFromBalance($balance); $order = $modelorder->createNewOrder($item, $item->price, $item->currency, null, 'P'); $app->redirect(BidsHelperRoute::getCheckoutRoute($order->id, false)); return; } }
function onPaymentForOrder($paylog, $order) { if (!$order->status == 'C') { return; } $modelorder = JTheFactoryPricingHelper::getModel('orders'); $items = $modelorder->getOrderItems($order->id, self::getItemName()); if (!is_array($items) || !count($items)) { return; } //no Listing items in order $cfg = BidsHelperTools::getConfig(); $nowDate = new JDate(); $auction = JTable::getInstance('auction'); foreach ($items as $item) { if (!$item->iteminfo) { continue; } //AuctionID is stored in iteminfo if ($item->itemname != self::getItemName()) { continue; } if (!$auction->load($item->iteminfo)) { continue; } //auction no longer exists $auction->modified = $nowDate->toMySQL(); $auction->published = 1; if (!$cfg->bid_opt_enable_date) { $startDate = new JDate($auction->start_date); $diff = $nowDate->toUnix() - $startDate->toUnix(); if ($diff > 0) { $auction->start_date = $nowDate->toMySQL(); $endDate = new JDate($auction->end_date); $endDate->add(new DateInterval('PT' . $diff . 'S')); $auction->end_date = $endDate->toMySQL(); } } $auction->store(); JTheFactoryEventsHelper::triggerEvent('onAfterSaveAuctionSuccess', array($auction)); //for email notifications } }
function onPaymentForOrder($paylog, $order) { if (!$order->status == 'C') { return; } $modelorder = JTheFactoryPricingHelper::getModel('orders'); $items = $modelorder->getOrderItems($order->id, self::getItemName()); if (!is_array($items) || !count($items)) { return; } //no Listing items in order $date = new JDate(); $auction = JTable::getInstance('auction'); foreach ($items as $item) { if (!$item->iteminfo) { continue; } //AuctionID is stored in iteminfo if ($item->itemname != self::getItemName()) { continue; } if (!$auction->load($item->iteminfo)) { continue; } //auction no longer exists $auction->modified = $date->toMySQL(); $auction->featured = 'featured'; $auction->store(); } }
private function generateOrder($bid, $catid, $needsPositiveBalance) { $app = JFactory::getApplication(); $model = self::getModel(); $price = $model->getItemPrice($catid); if (!floatval($price->price)) { return; } // Free publishing $modelbalance = JTheFactoryPricingHelper::getModel('balance'); $balance = $modelbalance->getUserBalance($bid->userid); if ($needsPositiveBalance) { if (BidsHelperPrices::comparePrices($price, array("price" => $balance->balance, "currency" => $balance->currency)) > 0) { $app->enqueueMessage(JText::_('COM_BIDS_NOT_ENOUGH_FUNDS_TO_BID'), 'notice'); $modelorder = JTheFactoryPricingHelper::getModel('orders'); $item = $model->getOderitem($bid); $order = $modelorder->createNewOrder($item, $price->price, $price->currency, null, 'P'); $app->redirect(BidsHelperRoute::getCheckoutRoute($order->id, false)); } } //get funds from account, create confirmed order $balance_minus = BidsHelperPrices::convertCurrency($price->price, $price->currency, $balance->currency); $modelbalance->decreaseBalance($balance_minus, $bid->userid); $modelorder = JTheFactoryPricingHelper::getModel('orders'); $item = $model->getOderitem($bid); $modelorder->createNewOrder($item, $price->price, $price->currency, $bid->userid, 'C'); }
function onPaymentForOrder($paylog, $order) { if ($order->status != 'C') { return; } $modelorder = JTheFactoryPricingHelper::getModel('orders'); $items = $modelorder->getOrderItems($order->id, self::getItemName()); if (!is_array($items) || !count($items)) { return; } //no Listing items in order $model = self::getModel(); $date = new JDate(); foreach ($items as $item) { if (!$item->iteminfo) { continue; } //AuctionID is stored in iteminfo if ($item->itemname != self::getItemName()) { continue; } $model->addContact($item->iteminfo, $order->userid); } }
function doUpload() { $userfile = JRequest::getVar('pack', null, 'files', 'array'); $lang = JFactory::getLanguage(); $lang->load('com_installer'); // Make sure that file uploads are enabled in php if (!(bool) ini_get('file_uploads')) { JError::raiseWarning('', JText::_('COM_BIDS_COM_INSTALLER_MSG_INSTALL_WARNINSTALLFILE')); $this->setRedirect("index.php?option=" . APP_EXTENSION . "&task=pricing.install"); return true; } // Make sure that zlib is loaded so that the package can be unpacked if (!extension_loaded('zlib')) { JError::raiseWarning('', JText::_('COM_BIDS_COM_INSTALLER_MSG_INSTALL_WARNINSTALLZLIB')); $this->setRedirect("index.php?option=" . APP_EXTENSION . "&task=pricing.install"); return true; } // If there is no uploaded file, we have a problem... if (!is_array($userfile)) { JError::raiseWarning('', JText::_('COM_BIDS_COM_INSTALLER_MSG_INSTALL_NO_FILE_SELECTED')); $this->setRedirect("index.php?option=" . APP_EXTENSION . "&task=pricing.install"); return true; } // Check if there was a problem uploading the file. if ($userfile['error'] || $userfile['size'] < 1) { JError::raiseWarning('', JText::_('COM_BIDS_COM_INSTALLER_MSG_INSTALL_WARNINSTALLUPLOADERROR')); $this->setRedirect("index.php?option=" . APP_EXTENSION . "&task=pricing.install"); return true; } // Build the appropriate paths $config = JFactory::getConfig(); $tmp_dest = $config->get('tmp_path') . '/' . $userfile['name']; $tmp_src = $userfile['tmp_name']; // Move uploaded file jimport('joomla.filesystem.file'); $uploaded = JFile::upload($tmp_src, $tmp_dest); jimport('joomla.installer.helper'); $package = JTheFactoryPricingHelper::unpackPricingPack($tmp_dest); // Was the package unpacked? if (!$package) { JError::raiseWarning('', JText::_('COM_BIDS_COM_INSTALLER_UNABLE_TO_FIND_INSTALL_PACKAGE')); $this->setRedirect("index.php?option=" . APP_EXTENSION . "&task=pricing.install"); return true; } JTheFactoryPricingHelper::installPricingPack($package['dir']); if (!is_file($package['packagefile'])) { $config = JFactory::getConfig(); $package['packagefile'] = $config->get('tmp_path') . '/' . $package['packagefile']; } JInstallerHelper::cleanupInstall($package['packagefile'], $package['extractdir']); $this->setRedirect("index.php?option=" . APP_EXTENSION . "&task=pricing.listing", JText::_("FACTORY_PRICING_ITEM_INSTALLED")); }