示例#1
0
 /**
  * @param JApplicationSite $app
  * @param array $paymentProcessData
  */
 protected function prepareCurrency($app, $paymentProcessData)
 {
     // Load currencies
     $options = array("state" => 1);
     jimport("virtualcurrency.currencies");
     $this->currencies = new VirtualCurrencyCurrencies(JFactory::getDbo());
     $this->currencies->load($options);
     // Get amount from session
     $this->currencyAmount = $paymentProcessData["amount"];
     // Get item if there is one
     $itemId = $paymentProcessData["item_id"];
     if (!empty($itemId)) {
         $item = new VirtualCurrencyCurrency(JFactory::getDbo());
         $item->load($itemId);
         // Compare amount with the minimum allowed amount.
         if ($this->currencyAmount < $item->getParam("minimum")) {
             // Reset payment data.
             $paymentProcessData = $this->paymentData;
             $app->setUserState("payment.data", $paymentProcessData);
             $this->layoutData->flagStep1 = false;
         }
     }
     // Check days left. If there is no days, disable the button.
     $this->disabledButton = "";
     // Check for debug mode
     if ($this->params->get("debug_payment_disabled", 0)) {
         $msg = JString::trim($this->params->get("debug_disabled_functionality_msg"));
         if (!$msg) {
             $msg = JText::_("COM_VIRTUALCURRENCY_DEBUG_MODE_DEFAULT_MSG");
         }
         $app->enqueueMessage($msg, "notice");
         $this->disabledButton = 'disabled="disabled"';
     }
 }
示例#2
0
                            <h3><?php 
    echo JText::sprintf("COM_VIRTUALCURRENCY_BUY_CURRENCY", $this->escape($currency->getTitle()));
    ?>
</h3>
                            <label><?php 
    echo JText::sprintf("COM_VIRTUALCURRENCY_NUMBER_OF_CURRENCY", $this->escape($currency->getTitle()));
    ?>
</label>
                            <?php 
    echo JHtml::_("virtualcurrency.inputAmount", $this->currencyAmount, $currency_, array("name" => "amount"));
    ?>

                            <span class="help-block">
    				            <?php 
    echo JText::sprintf("COM_VIRTUALCURRENCY_HELP_MIN_AMOUNT", $this->escape($currency->getTitle()), $currency->getParam("minimum"));
    ?>
    			            </span>

                            <input type="hidden" name="id" value="<?php 
    echo $currency->getId();
    ?>
"/>
                            <input type="hidden" name="task" value="payment.step1"/>
                            <?php 
    echo JHtml::_('form.token');
    ?>

                            <?php 
    if ($this->params->get("ordering_service_terms", 0)) {
        ?>
示例#3
0
 /**
  * Process step 1.
  */
 public function step1()
 {
     // Check for request forgeries.
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     $userId = JFactory::getUser()->get("id");
     if (!$userId) {
         $redirectOptions = array("force_direction" => "login_form");
         $this->displayNotice(JText::_('COM_VIRTUALCURRENCY_ERROR_NOT_LOG_IN'), $redirectOptions);
         return;
     }
     $app = JFactory::getApplication();
     /** @var $app JApplicationSite */
     // Get the data from the form
     $itemId = $this->input->post->getInt('id', 0);
     $redirectOptionsError = array("view" => "peyment");
     // Check for maintenance (debug) state
     $params = JComponentHelper::getParams($this->option);
     /** @var $params Joomla\Registry\Registry */
     if ($this->inDebugMode($params)) {
         return;
     }
     // Check terms and use
     if ($params->get("ordering_service_terms", 0)) {
         $terms = $app->input->post->get("terms", 0);
         if (!$terms) {
             $this->displayNotice(JText::_("COM_VIRTUALCURRENCY_ERROR_TERMS_NOT_ACCEPTED"), $redirectOptionsError);
             return;
         }
     }
     // Check for valid number of units.
     $amount = $app->input->post->get("amount", 0, "float");
     if (!$amount) {
         $this->displayNotice(JText::_('COM_VIRTUALCURRENCY_ERROR_INVALID_AMOUNT'), $redirectOptionsError);
         return;
     }
     // Check for valid item
     $item = new VirtualCurrencyCurrency(JFactory::getDbo());
     $item->load($itemId);
     if (!$item->getId()) {
         $this->displayNotice(JText::_('COM_VIRTUALCURRENCY_ERROR_INVALID_CURRENCY'), $redirectOptionsError);
         return;
     }
     // Check for valid allowed items for buying
     if ($amount < $item->getParam("minimum")) {
         $this->displayNotice(JText::_('COM_VIRTUALCURRENCY_ERROR_INVALID_AMOUNT'), $redirectOptionsError);
         return;
     }
     $paymentProcessData = $app->getUserState("payment.data");
     $paymentProcessData["item_id"] = $item->getId();
     $paymentProcessData["amount"] = $amount;
     $paymentProcessData["step1"] = true;
     // Store data to temporary table
     $data = array("user_id" => $userId, "currency_id" => $item->getId(), "amount" => $amount);
     jimport("virtualcurrency.payment.session");
     $paymentSession = new VirtualCurrencyPaymentSession(JFactory::getDbo());
     if (!empty($paymentProcessData["payment_id"])) {
         $paymentSession->load($paymentProcessData["payment_id"]);
     }
     $paymentSession->bind($data);
     $paymentSession->store();
     // Remove old payment session records
     $paymentSession->cleanOld();
     $paymentProcessData["payment_id"] = $paymentSession->getId();
     // Set payment data to the sessions
     $app->setUserState("payment.data", $paymentProcessData);
     // Redirect to next page
     $redirectOptions = array("view" => "payment", "layout" => "services");
     $link = $this->prepareRedirectLink($redirectOptions);
     $this->setRedirect(JRoute::_($link, false));
 }