当前位置: 首页>>代码示例>>PHP>>正文


PHP CrowdfundingHelperRoute::getBackingRoute方法代码示例

本文整理汇总了PHP中CrowdfundingHelperRoute::getBackingRoute方法的典型用法代码示例。如果您正苦于以下问题:PHP CrowdfundingHelperRoute::getBackingRoute方法的具体用法?PHP CrowdfundingHelperRoute::getBackingRoute怎么用?PHP CrowdfundingHelperRoute::getBackingRoute使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CrowdfundingHelperRoute的用法示例。


在下文中一共展示了CrowdfundingHelperRoute::getBackingRoute方法的14个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: getCancelUrl

 protected function getCancelUrl($slug, $catslug)
 {
     $page = String::trim($this->params->get('cancel_url'));
     if (!$page) {
         $uri = \JUri::getInstance();
         $page = $uri->toString(array("scheme", "host")) . \JRoute::_(\CrowdfundingHelperRoute::getBackingRoute($slug, $catslug, "default"), false);
     }
     return $page;
 }
开发者ID:bharatthakkar,项目名称:CrowdFunding,代码行数:9,代码来源:Plugin.php

示例2: foreach

    ?>
    <div class="cfrewards<?php 
    echo $moduleclassSfx;
    ?>
">

        <div class="reward_title center"><?php 
    echo JText::_('MOD_CROWDFUNDINGREWARDS_PLEDGE_REWARDS');
    ?>
</div>
        <?php 
    foreach ($rewards as $reward) {
        ?>
            <div class="reward">
                <a href="<?php 
        echo JRoute::_(CrowdfundingHelperRoute::getBackingRoute($project->getSlug(), $project->getCatSlug(), 'default', $reward['id']));
        ?>
">
    			<span class="ramount">
    			<?php 
        echo JText::sprintf('MOD_CROWDFUNDINGREWARDS_INVEST_MORE', $amount->setValue($reward['amount'])->formatCurrency());
        ?>
    			</span>
                    <span class="rtitle"><?php 
        echo htmlspecialchars($reward['title'], ENT_QUOTES, 'UTF-8');
        ?>
</span>
                    <span class="rdesc"><?php 
        echo htmlspecialchars($reward['description'], ENT_QUOTES, 'UTF-8');
        ?>
</span>
开发者ID:sis-direct,项目名称:CrowdFunding,代码行数:31,代码来源:default.php

示例3: notifyAjax

 /**
  * Catch a request from payment plugin via AJAX and process a transaction.
  */
 public function notifyAjax()
 {
     $response = new Prism\Response\Json();
     // Check for disabled payment functionality
     if ($this->params->get('debug_payment_disabled', 0)) {
         $errorData = JText::sprintf('COM_CROWDFUNDING_TRANSACTION_DATA', var_export($_REQUEST, true));
         $this->log->add(JText::_('COM_CROWDFUNDING_ERROR_PAYMENT_HAS_BEEN_DISABLED'), 'ERROR_CONTROLLER_NOTIFIER_AJAX', $errorData);
         // Send response to the browser
         $response->setTitle(JText::_('COM_CROWDFUNDING_FAIL'))->setText(JText::_('COM_CROWDFUNDING_ERROR_PAYMENT_HAS_BEEN_DISABLED_MESSAGE'))->failure();
         echo $response;
         $this->app->close();
     }
     // Get model object.
     $model = $this->getModel();
     $paymentResult = null;
     $redirectUrl = null;
     $message = null;
     $project = null;
     /** @var Crowdfunding\Project $project */
     // Trigger the event
     try {
         // Import Crowdfunding Payment Plugins
         JPluginHelper::importPlugin('crowdfundingpayment');
         // Trigger onPaymentNotify event.
         $dispatcher = JEventDispatcher::getInstance();
         $results = $dispatcher->trigger('onPaymentNotify', array($this->context, &$this->params));
         if (is_array($results) and count($results) > 0) {
             foreach ($results as $result) {
                 if (is_object($result) and isset($result->transaction)) {
                     $paymentResult = $result;
                     $project = isset($result->project) ? $result->project : null;
                     $redirectUrl = isset($result->redirectUrl) ? $result->redirectUrl : null;
                     $message = isset($result->message) ? $result->message : null;
                     break;
                 }
             }
         }
         // If there is no transaction data, the status might be pending or another one.
         // So, we have to stop the script execution.
         if (!$paymentResult) {
             // Send response to the browser
             $response->setTitle(JText::_('COM_CROWDFUNDING_FAIL'))->setText(JText::_('COM_CROWDFUNDING_TRANSACTION_NOT_PROCESSED_SUCCESSFULLY'))->failure();
             echo $response;
             $this->app->close();
         }
         // Trigger the event onAfterPaymentNotify
         $dispatcher->trigger('onAfterPaymentNotify', array($this->context, &$paymentResult, &$this->params));
         // Trigger the event onAfterPayment
         $dispatcher->trigger('onAfterPayment', array($this->context, &$paymentResult, &$this->params));
     } catch (Exception $e) {
         // Store log data to the database.
         $error = 'AJAX NOTIFIER ERROR: ' . $e->getMessage() . "\n";
         $errorData = 'INPUT:' . var_export($this->app->input, true) . "\n";
         $this->log->add($error, 'ERROR_CONTROLLER_NOTIFIER_AJAX', $errorData);
         // Send response to the browser
         $response->failure()->setTitle(JText::_('COM_CROWDFUNDING_FAIL'))->setText(JText::_('COM_CROWDFUNDING_ERROR_SYSTEM'));
         // Send notification about the error to the administrator.
         $model->sendMailToAdministrator();
         echo $response;
         $this->app->close();
     }
     // Generate redirect URL
     if (!$redirectUrl and is_object($project)) {
         $uri = JUri::getInstance();
         $redirectUrl = $uri->toString(array('scheme', 'host')) . JRoute::_(CrowdfundingHelperRoute::getBackingRoute($project->getSlug(), $project->getCatSlug(), 'share'));
     }
     if (!$message) {
         $message = JText::_('COM_CROWDFUNDING_TRANSACTION_PROCESSED_SUCCESSFULLY');
     }
     // Send response to the browser
     $response->success()->setTitle(JText::_('COM_CROWDFUNDING_SUCCESS'))->setText($message)->setRedirectUrl($redirectUrl);
     echo $response;
     $this->app->close();
 }
开发者ID:ITPrism,项目名称:CrowdfundingDistribution,代码行数:77,代码来源:notifier.raw.php

示例4: void

    ?>
</a>
                    <?php 
}
?>
                </li>

                <li <?php 
echo $active["share"] ? 'class="active"' : '';
?>
>
                    <?php 
if (!empty($displayData->paymentSession->step2)) {
    ?>
                        <a href="<?php 
    echo JRoute::_(CrowdfundingHelperRoute::getBackingRoute($displayData->item->slug, $displayData->item->catslug, "share"));
    ?>
">
                            (3) <?php 
    echo JText::_("COM_CROWDFUNDING_STEP_SHARE");
    ?>
                        </a>
                    <?php 
} else {
    ?>
                        <a href="javascript: void(0);"
                           class="disabled">(3) <?php 
    echo JText::_("COM_CROWDFUNDING_STEP_SHARE");
    ?>
</a>
                    <?php 
开发者ID:pashakiz,项目名称:crowdf,代码行数:31,代码来源:payment_wizard.php

示例5: returnToStep1

 protected function returnToStep1(&$paymentSession, $message = "")
 {
     // Reset the flag for step 1
     $paymentSession->step1 = false;
     $this->app->setUserState($this->paymentSessionContext, $paymentSession);
     if (!empty($message)) {
         $this->app->enqueueMessage($message, "notice");
     }
     $this->app->redirect(JRoute::_(CrowdfundingHelperRoute::getBackingRoute($this->item->slug, $this->item->catslug), false));
 }
开发者ID:bharatthakkar,项目名称:CrowdFunding,代码行数:10,代码来源:view.html.php

示例6: htmlspecialchars

    ?>
</div>
		<div class="cf-frss pull-center"><?php 
    echo JHtml::_('crowdfunding.resultStateText', $project->getFundedPercent(), $project->getFundingType());
    ?>
</div>
	</div>
	<?php 
} else {
    ?>
	<div class="cfinfo-funding-action">
		<a class="btn btn-default btn-large btn-block <?php 
    echo !$isValidEndDate ? 'disabled' : '';
    ?>
" href="<?php 
    echo JRoute::_(CrowdfundingHelperRoute::getBackingRoute($project->getSlug(), $project->getCatSlug()));
    ?>
">
			<?php 
    if (!$params->get('button_title_custom')) {
        echo JText::_($params->get('button_title', 'MOD_CROWDFUNDINGINFO_BUTTON_CONTRIBUTE'));
    } else {
        echo htmlspecialchars($params->get('button_title_custom'), ENT_COMPAT, 'UTF-8');
    }
    ?>
        </a>
	</div>
	<?php 
}
?>
开发者ID:ITPrism,项目名称:CrowdfundingDistribution,代码行数:30,代码来源:layout2.php

示例7: foreach

    ?>
    <div class="cfrewards<?php 
    echo $moduleclassSfx;
    ?>
">

        <div class="reward_title center"><?php 
    echo JText::_("MOD_CROWDFUNDINGREWARDS_PLEDGE_REWARDS");
    ?>
</div>
        <?php 
    foreach ($rewards as $reward) {
        ?>
            <div class="reward">
                <a href="<?php 
        echo JRoute::_(CrowdfundingHelperRoute::getBackingRoute($project->getSlug(), $project->getCatSlug(), "default", $reward["id"]));
        ?>
">
    			<span class="ramount">
    			<?php 
        $amount = $currency->getAmountString($reward["amount"]);
        echo JText::sprintf("MOD_CROWDFUNDINGREWARDS_INVEST_MORE", $amount);
        ?>
    			</span>
                    <span class="rtitle"><?php 
        echo htmlspecialchars($reward["title"], ENT_QUOTES, "UTF-8");
        ?>
</span>
                    <span class="rdesc"><?php 
        echo htmlspecialchars($reward["description"], ENT_QUOTES, "UTF-8");
        ?>
开发者ID:bharatthakkar,项目名称:CrowdFunding,代码行数:31,代码来源:default.php

示例8: onPaymentExtras

    /**
     * This method prepares a payment gateway - buttons, forms,...
     * That gateway will be displayed on the summary page as a payment option.
     *
     * @param string    $context This string gives information about that where it has been executed the trigger.
     * @param object    $item    A project data.
     * @param Joomla\Registry\Registry $params  The parameters of the component
     *
     * @return null|string
     */
    public function onPaymentExtras($context, &$item, &$params)
    {
        if (strcmp("com_crowdfunding.payment.step2", $context) != 0) {
            return null;
        }
        if ($this->app->isAdmin()) {
            return null;
        }
        $doc = JFactory::getDocument();
        /**  @var $doc JDocumentHtml */
        // Check document type
        $docType = $doc->getType();
        if (strcmp("html", $docType) != 0) {
            return null;
        }
        // Get user ID.
        $userId = JFactory::getUser()->get("id");
        // Display login form
        if (!$userId) {
            // Get the form.
            JForm::addFormPath(JPATH_COMPONENT . '/models/forms');
            JForm::addFieldPath(JPATH_COMPONENT . '/models/fields');
            $form = JForm::getInstance('com_users.login', 'login', array('load_data' => false), false, false);
            $this->loginForm = $form;
            $this->returnUrl = CrowdfundingHelperRoute::getBackingRoute($item->slug, $item->catslug);
            // Get the path for the layout file
            $path = JPluginHelper::getLayoutPath('crowdfundingpayment', 'login');
            // Render the login form.
            ob_start();
            include $path;
            $html = ob_get_clean();
        } else {
            // Redirect to step "Payment".
            $componentParams = JComponentHelper::getParams("com_crowdfunding");
            /** @var  $componentParams Joomla\Registry\Registry */
            // Get the payment process object and
            // store the selected data from the user.
            $paymentProcessContext = Crowdfunding\Constants::PAYMENT_SESSION_CONTEXT . $item->id;
            $paymentSession = $this->app->getUserState($paymentProcessContext);
            $this->rewardId = $paymentSession->rewardId;
            $this->amount = $paymentSession->amount;
            $this->terms = $paymentSession->terms;
            // Get the path for the layout file
            $path = JPluginHelper::getLayoutPath('crowdfundingpayment', 'login', 'redirect');
            // Render the login form.
            ob_start();
            include $path;
            $html = ob_get_clean();
            // Include JavaScript code to redirect user to next step.
            $processUrl = JUri::base() . "index.php?option=com_crowdfunding&task=backing.process&id=" . (int) $item->id . "&rid=" . (int) $this->rewardId . "&amount=" . rawurldecode($this->amount) . "&" . JSession::getFormToken() . "=1";
            // Set the value of terms of use condition.
            if ($componentParams->get("backing_terms", 0) and !empty($this->terms)) {
                $processUrl .= "&terms=1";
            }
            $filter = JFilterInput::getInstance();
            $processUrl = $filter->clean($processUrl);
            $js = '
jQuery(document).ready(function() {
     window.location.replace("' . $processUrl . '");
});';
            $doc->addScriptDeclaration($js);
        }
        return $html;
    }
开发者ID:pashakiz,项目名称:crowdf,代码行数:74,代码来源:login.php

示例9: process

 public function process()
 {
     $app = JFactory::getApplication();
     /** @var $app JApplicationSite */
     // Check for request forgeries.
     $requestMethod = $app->input->getMethod();
     if (strcmp("POST", $requestMethod) == 0) {
         JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     } else {
         JSession::checkToken("get") or jexit(JText::_('JINVALID_TOKEN'));
     }
     // Get params
     $params = JComponentHelper::getParams("com_crowdfunding");
     /** @var  $params Joomla\Registry\Registry */
     // Get the data from the form
     $itemId = $this->input->getInt('id', 0);
     $rewardId = $this->input->getInt('rid', 0);
     // Get amount
     $amount = CrowdfundingHelper::parseAmount($this->input->getString("amount"));
     // Get user ID
     $user = JFactory::getUser();
     $userId = (int) $user->get("id");
     // Anonymous user ID
     $aUserId = "";
     $model = $this->getModel();
     /** @var $model CrowdfundingModelBacking */
     // Get the item
     $item = $model->getItem($itemId);
     $returnUrl = CrowdfundingHelperRoute::getBackingRoute($item->slug, $item->catslug);
     // Authorise the user
     if (!$user->authorise("crowdfunding.donate", "com_crowdfunding")) {
         $this->setRedirect(JRoute::_($returnUrl, false), JText::_('COM_CROWDFUNDING_ERROR_NO_PERMISSIONS'), "notice");
         return;
     }
     // Check for valid project
     if (empty($item->id)) {
         $this->setRedirect(JRoute::_(CrowdfundingHelperRoute::getDiscoverRoute()), JText::_('COM_CROWDFUNDING_ERROR_INVALID_PROJECT'), "notice");
         return;
     }
     // Check for maintenance (debug) state.
     if ($params->get("debug_payment_disabled", 0)) {
         $msg = Joomla\String\String::trim($params->get("debug_disabled_functionality_msg"));
         if (!$msg) {
             $msg = JText::_("COM_CROWDFUNDING_DEBUG_MODE_DEFAULT_MSG");
         }
         $this->setRedirect(JRoute::_($returnUrl, false), $msg, "notice");
         return;
     }
     // Check for agreed conditions from the user.
     if ($params->get("backing_terms", 0)) {
         $terms = $this->input->get("terms", 0, "int");
         if (!$terms) {
             $this->setRedirect(JRoute::_($returnUrl, false), JText::_("COM_CROWDFUNDING_ERROR_TERMS_NOT_ACCEPTED"), "notice");
             return;
         }
     }
     // Check for valid amount.
     if (!$amount) {
         $this->setRedirect(JRoute::_($returnUrl, false), JText::_("COM_CROWDFUNDING_ERROR_INVALID_AMOUNT"), "notice");
         return;
     }
     // Store payment process data
     // Get the payment process object and
     // store the selected data from the user.
     $paymentSessionContext = Crowdfunding\Constants::PAYMENT_SESSION_CONTEXT . $item->id;
     $paymentSessionLocal = $app->getUserState($paymentSessionContext);
     $paymentSessionLocal->step1 = true;
     $paymentSessionLocal->amount = $amount;
     $paymentSessionLocal->rewardId = $rewardId;
     $app->setUserState($paymentSessionContext, $paymentSessionLocal);
     // Generate hash user ID used for anonymous payment.
     if (!$userId) {
         $aUserId = $app->getUserState("auser_id");
         if (!$aUserId) {
             // Generate a hash ID for anonymous user.
             $anonymousUserId = new Prism\String();
             $anonymousUserId->generateRandomString(32);
             $aUserId = (string) $anonymousUserId;
             $app->setUserState("auser_id", $aUserId);
         }
     }
     $date = new JDate();
     // Create an intention record.
     $intentionId = 0;
     if (!empty($userId)) {
         $intentionKeys = array("user_id" => $userId, "project_id" => $item->id);
         $intention = new Crowdfunding\Intention(JFactory::getDbo());
         $intention->load($intentionKeys);
         $intentionData = array("user_id" => $userId, "project_id" => $item->id, "reward_id" => $rewardId, "record_date" => $date->toSql());
         $intention->bind($intentionData);
         $intention->store();
         $intentionId = $intention->getId();
     }
     // Create a payment session.
     $paymentSessionDatabase = new Crowdfunding\Payment\Session(JFactory::getDbo());
     $paymentSessionData = array("user_id" => $userId, "auser_id" => $aUserId, "project_id" => $item->id, "reward_id" => $rewardId, "record_date" => $date->toSql(), "session_id" => $paymentSessionLocal->session_id, "intention_id" => $intentionId);
     $paymentSessionDatabase->bind($paymentSessionData);
     $paymentSessionDatabase->store();
     // Redirect to next page
     $link = CrowdfundingHelperRoute::getBackingRoute($item->slug, $item->catslug, "payment");
//.........这里部分代码省略.........
开发者ID:Eautentik,项目名称:CrowdFunding,代码行数:101,代码来源:backing.php

示例10: array

echo $layout->render($this->layoutData);
?>
	
    	</div>
	</div>
	
	<div class="row">
		<div class="col-md-12">
            <div class="panel panel-default">
                <div class="panel-heading"><?php 
echo JText::_("COM_CROWDFUNDING_ENTER_YOUR_INVESTMENT_AMOUNT");
?>
</div>
                <div class="panel-body">
                    <form method="post" action="<?php 
echo JRoute::_(CrowdfundingHelperRoute::getBackingRoute($this->item->slug, $this->item->catslug));
?>
" class="mt-0" id="form-pledge" autocomplete="off">
    				<?php 
echo JHtml::_("crowdfunding.inputAmount", $this->rewardAmount, $this->amount, array("name" => "amount", "id" => "js-current-amount"));
?>
    				<?php 
if ($this->params->get("backing_terms", 0)) {
    $termsUrl = $this->params->get("backing_terms_url", "");
    ?>
                    <div class="checkbox">
                        <label>
                            <input type="checkbox" name="terms" value="1">&nbsp;
                            <?php 
    echo !$termsUrl ? JText::_("COM_CROWDFUNDING_TERMS_AGREEMENT") : JText::sprintf("COM_CROWDFUNDING_TERMS_AGREEMENT_URL", $termsUrl);
    ?>
开发者ID:Eautentik,项目名称:CrowdFunding,代码行数:31,代码来源:default.php

示例11: save

 public function save($key = null, $urlVar = null)
 {
     JSession::checkToken() or jexit(JText::_('JINVALID_TOKEN'));
     $app = JFactory::getApplication();
     /** @var $app JApplicationSite */
     $response = new Prism\Response\Json();
     $data = $this->input->post->get('jform', array(), 'array');
     $itemId = Joomla\Utilities\ArrayHelper::getValue($data, "project_id", 0, "int");
     $terms = $this->input->post->getInt("terms", 0);
     $project = new Crowdfunding\Project(JFactory::getDbo());
     $project->load($itemId);
     $returnUrl = CrowdfundingHelperRoute::getBackingRoute($project->getSlug(), $project->getCatSlug());
     if (!$project->getId()) {
         // Send response to the browser
         $response->setTitle(JText::_("COM_CROWDFUNDINGDATA_FAIL"))->setText(JText::_("COM_CROWDFUNDINGDATA_INVALID_ITEM"))->setRedirectUrl($returnUrl)->failure();
         echo $response;
         JFactory::getApplication()->close();
     }
     $model = $this->getModel();
     /** @var $model CrowdfundingDataModelRecord */
     $form = $model->getForm($data, false);
     /** @var $form JForm */
     if (!$form) {
         throw new Exception(JText::_("COM_CROWDFUNDINGDATA_ERROR_FORM_CANNOT_BE_LOADED"), 500);
     }
     // Validate the form data
     $validData = $model->validate($form, $data);
     // Check for errors
     if ($validData === false) {
         $errors_ = $form->getErrors();
         $errors = array();
         /** @var $error RuntimeException */
         foreach ($errors_ as $error) {
             $errors[] = $error->getMessage();
         }
         // Send response to the browser
         $response->setTitle(JText::_("COM_CROWDFUNDINGDATA_FAIL"))->setText(implode("\n", $errors))->setRedirectUrl($returnUrl)->failure();
         echo $response;
         JFactory::getApplication()->close();
     }
     // Get the payment session object and session ID.
     $paymentSessionContext = Crowdfunding\Constants::PAYMENT_SESSION_CONTEXT . $project->getId();
     $paymentSession = $app->getUserState($paymentSessionContext);
     try {
         $validData["session_id"] = $paymentSession->session_id;
         $model->save($validData);
     } catch (Exception $e) {
         $response->setTitle(JText::_("COM_CROWDFUNDINGDATA_FAIL"))->setText(JText::_('COM_CROWDFUNDINGDATA_ERROR_SYSTEM'))->setRedirectUrl($returnUrl)->failure();
         echo $response;
         JFactory::getApplication()->close();
     }
     $componentParams = JComponentHelper::getParams("com_crowdfunding");
     /** @var  $componentParams Joomla\Registry\Registry */
     $processUrl = JUri::base() . "index.php?option=com_crowdfunding&task=backing.process&id=" . (int) $project->getId() . "&rid=" . (int) $paymentSession->rewardId . "&amount=" . rawurldecode($paymentSession->amount) . "&" . JSession::getFormToken() . "=1";
     // Set the value of terms of use condition.
     if ($componentParams->get("backing_terms", 0) and !empty($terms)) {
         $processUrl .= "&terms=1";
     }
     $filter = JFilterInput::getInstance();
     $processUrl = $filter->clean($processUrl);
     $response->setTitle(JText::_("COM_CROWDFUNDINGDATA_SUCCESS"))->setText(JText::_("COM_CROWDFUNDINGDATA_DATA_SAVED_SUCCESSFULLY"))->setRedirectUrl($processUrl)->success();
     echo $response;
     JFactory::getApplication()->close();
 }
开发者ID:pashakiz,项目名称:crowdf,代码行数:64,代码来源:record.raw.php

示例12: onProjectPayment

 /**
  * This method prepare and return address to Blockchain,
  * where the user have to go to make a donation.
  *
  * @param string $context
  * @param stdClass $item
  *
  * @return null|string
  */
 public function onProjectPayment($context, &$item)
 {
     if (strcmp('com_crowdfunding.payment', $context) !== 0) {
         return null;
     }
     if ($this->app->isAdmin()) {
         return null;
     }
     $doc = JFactory::getDocument();
     /**  @var $doc JDocumentHtml */
     // Check document type
     $docType = $doc->getType();
     if (strcmp('html', $docType) !== 0) {
         return null;
     }
     // This is a URI path to the plugin folder
     $pluginURI = 'plugins/crowdfundingpayment/blockchain';
     $html = array();
     $html[] = '<div class="well">';
     // Open "well".
     $html[] = '<h4><img src="' . $pluginURI . '/images/blockchain_icon.png" width="38" height="32" /> ' . JText::_($this->textPrefix . '_TITLE') . '</h4>';
     // Check for valid data.
     $receivingAddress = JString::trim($this->params->get('receiving_address'));
     $callbackUrl = $this->getCallbackUrl();
     if (!$receivingAddress or !$callbackUrl) {
         $html[] = '<div class="bg-warning mtb-10"><span class="glyphicon glyphicon-warning-sign"></span> ' . JText::_($this->textPrefix . '_ERROR_PLUGIN_NOT_CONFIGURED') . '</div>';
         $html[] = '</div>';
         // Close "well".
         return implode("\n", $html);
     }
     // Get payment session
     $paymentSessionContext = Crowdfunding\Constants::PAYMENT_SESSION_CONTEXT . $item->id;
     $paymentSessionLocal = $this->app->getUserState($paymentSessionContext);
     $paymentSession = $this->getPaymentSession(array('session_id' => $paymentSessionLocal->session_id));
     // Prepare transaction ID.
     $txnId = Prism\Utilities\StringHelper::generateRandomString();
     $txnId = JString::strtoupper($txnId);
     // Store the unique key.
     $paymentSession->setUniqueKey($txnId);
     $paymentSession->storeUniqueKey();
     // Prepare callback URL data.
     $callbackUrl .= '&payment_session_id=' . (int) $paymentSession->getId() . '&txn_id=' . $txnId;
     // DEBUG DATA
     JDEBUG ? $this->log->add(JText::_($this->textPrefix . '_DEBUG_CALLBACK_URL'), $this->debugType, $callbackUrl) : null;
     // Send request for button
     jimport('Prism.libs.Blockchain.Blockchain');
     $blockchain = new Blockchain();
     $response = $blockchain->Receive->generate($receivingAddress, $callbackUrl);
     // DEBUG DATA
     $responseResult = @var_export($response, true);
     JDEBUG ? $this->log->add(JText::_($this->textPrefix . '_DEBUG_RECEIVE_GENERATE_RESPONSE'), $this->debugType, $responseResult) : null;
     // Check for test mode.
     if ($this->params->get('test_mode', 1)) {
         $html[] = '<div class="bg-info p-10-5"><span class="glyphicon glyphicon-info-sign"></span> ' . JText::_($this->textPrefix . '_ERROR_TEST_MODE') . '</div>';
         $html[] = '<label for="blockchain_callback_url">' . JText::_($this->textPrefix . '_CALLBACK_URL') . '</label>';
         $html[] = '<textarea name="callback_url" id="blockchain_callback_url" class="form-control">' . $callbackUrl . '</textarea>';
     } else {
         $html[] = '<div class="form-group">';
         $html[] = '<label for="blockchain_receiving_address">' . JText::_($this->textPrefix . "_RECEIVING_ADDRESS") . '</label>';
         $html[] = '<input class="form-control input-lg" type="text" value="' . $response->address . '" id="blockchain_receiving_address"/>';
         $html[] = '</div>';
         $html[] = '<p class="bg-info p-10-5 mt-10"><span class="glyphicon glyphicon-info-sign"></span> ' . JText::sprintf($this->textPrefix . '_SEND_COINS_TO_ADDRESS', $item->amountFormated) . '</p>';
         $html[] = '<a class="btn btn-primary" href="' . JRoute::_(CrowdfundingHelperRoute::getBackingRoute($item->slug, $item->catslug, 'share')) . '"><span class="glyphicon glyphicon-chevron-right"></span> ' . JText::_($this->textPrefix . '_CONTINUE_NEXT_STEP') . '</a>';
     }
     $html[] = '</div>';
     // Close "well".
     return implode("\n", $html);
 }
开发者ID:bellodox,项目名称:CrowdFundingPayment-Blockchain,代码行数:77,代码来源:blockchain.php

示例13: notifyAjax

 /**
  * Catch a request from payment plugin via AJAX and process a transaction.
  */
 public function notifyAjax()
 {
     $app = JFactory::getApplication();
     /** @var $app JApplicationSite */
     $response = new Prism\Response\Json();
     // Check for disabled payment functionality
     if ($this->params->get("debug_payment_disabled", 0)) {
         // Log the error.
         $error = JText::_("COM_CROWDFUNDING_ERROR_PAYMENT_HAS_BEEN_DISABLED") . "\n";
         $error .= JText::sprintf("COM_CROWDFUNDING_TRANSACTION_DATA", var_export($_REQUEST, true));
         $this->log->add($error, "CONTROLLER_NOTIFIER_AJAX_ERROR");
         // Send response to the browser
         $response->setTitle(JText::_("COM_CROWDFUNDING_FAIL"))->setText(JText::_("COM_CROWDFUNDING_ERROR_PAYMENT_HAS_BEEN_DISABLED_MESSAGE"))->failure();
         echo $response;
         $app->close();
     }
     // Get model object.
     $model = $this->getModel();
     $transaction = null;
     $project = null;
     $reward = null;
     $paymentSession = null;
     $redirectUrl = null;
     $message = null;
     // Trigger the event
     try {
         // Import Crowdfunding Payment Plugins
         JPluginHelper::importPlugin('crowdfundingpayment');
         // Trigger onPaymentNotify event.
         $dispatcher = JEventDispatcher::getInstance();
         $results = $dispatcher->trigger("onPaymentNotify", array($this->context, &$this->params));
         if (!empty($results)) {
             foreach ($results as $result) {
                 if (!empty($result) and isset($result["transaction"])) {
                     $transaction = Joomla\Utilities\ArrayHelper::getValue($result, "transaction");
                     $project = Joomla\Utilities\ArrayHelper::getValue($result, "project");
                     $reward = Joomla\Utilities\ArrayHelper::getValue($result, "reward");
                     $paymentSession = Joomla\Utilities\ArrayHelper::getValue($result, "payment_session");
                     $redirectUrl = Joomla\Utilities\ArrayHelper::getValue($result, "redirect_url");
                     $message = Joomla\Utilities\ArrayHelper::getValue($result, "message");
                     break;
                 }
             }
         }
         // If there is no transaction data, the status might be pending or another one.
         // So, we have to stop the script execution.
         if (!$transaction) {
             // Remove the record of the payment session from database.
             $model->closePaymentSession($paymentSession);
             // Send response to the browser
             $response->setTitle(JText::_("COM_CROWDFUNDING_FAIL"))->setText(JText::_("COM_CROWDFUNDING_TRANSACTION_NOT_PROCESSED_SUCCESSFULLY"))->failure();
             echo $response;
             $app->close();
         }
         // Trigger the event onAfterPayment
         $dispatcher->trigger('onAfterPayment', array($this->context, &$transaction, &$this->params, &$project, &$reward, &$paymentSession));
         // Remove the record of the payment session from database.
         $model->closePaymentSession($paymentSession);
     } catch (Exception $e) {
         // Store log data to the database.
         $error = "AJAX NOTIFIER ERROR: " . $e->getMessage() . "\n";
         $errorData = "INPUT:" . var_export($app->input, true) . "\n";
         $this->log->add($error, "CONTROLLER_NOTIFIER_AJAX_ERROR", $errorData);
         // Remove the record of the payment session from database.
         $model->closePaymentSession($paymentSession);
         // Send response to the browser
         $response->failure()->setTitle(JText::_("COM_CROWDFUNDING_FAIL"))->setText(JText::_("COM_CROWDFUNDING_ERROR_SYSTEM"));
         // Send notification about the error to the administrator.
         $model->sendMailToAdministrator();
         echo $response;
         $app->close();
     }
     // Generate redirect URL
     if (!$redirectUrl) {
         $uri = JUri::getInstance();
         $redirectUrl = $uri->toString(array("scheme", "host")) . JRoute::_(CrowdfundingHelperRoute::getBackingRoute($project->slug, $project->catslug, "share"));
     }
     if (!$message) {
         $message = JText::_("COM_CROWDFUNDING_TRANSACTION_PROCESSED_SUCCESSFULLY");
     }
     // Send response to the browser
     $response->success()->setTitle(JText::_("COM_CROWDFUNDING_SUCCESS"))->setText($message)->setRedirectUrl($redirectUrl);
     echo $response;
     $app->close();
 }
开发者ID:pashakiz,项目名称:crowdf,代码行数:88,代码来源:notifier.raw.php

示例14: onPaymentNotify

 /**
  * This method performs the transaction.
  *
  * @param string $context
  * @param Joomla\Registry\Registry $params
  *
  * @return null|array
  */
 public function onPaymentNotify($context, &$params)
 {
     if (strcmp("com_crowdfunding.notify.banktransfer", $context) != 0) {
         return null;
     }
     if ($this->app->isAdmin()) {
         return null;
     }
     $doc = JFactory::getDocument();
     /**  @var $doc JDocumentHtml */
     // Check document type
     $docType = $doc->getType();
     if (strcmp("raw", $docType) != 0) {
         return null;
     }
     $projectId = $this->app->input->getInt("pid");
     $amount = $this->app->input->getFloat("amount");
     // Prepare the array that will be returned by this method
     $result = array("project" => null, "reward" => null, "transaction" => null, "payment_session" => null, "redirect_url" => null, "message" => null);
     // Get project
     $project = new Crowdfunding\Project(JFactory::getDbo());
     $project->load($projectId);
     // DEBUG DATA
     JDEBUG ? $this->log->add(JText::_($this->textPrefix . "_DEBUG_PROJECT_OBJECT"), $this->debugType, $project->getProperties()) : null;
     // Check for valid project
     if (!$project->getId()) {
         // Log data in the database
         $this->log->add(JText::_($this->textPrefix . "_ERROR_INVALID_PROJECT"), $this->debugType, array("PROJECT OBJECT" => $project->getProperties(), "REQUEST METHOD" => $this->app->input->getMethod(), "_REQUEST" => $_REQUEST));
         return null;
     }
     $currencyId = $params->get("project_currency");
     $currency = Crowdfunding\Currency::getInstance(JFactory::getDbo(), $currencyId, $params);
     // Prepare return URL
     $result["redirect_url"] = Joomla\String\String::trim($this->params->get('return_url'));
     if (!$result["redirect_url"]) {
         $filter = JFilterInput::getInstance();
         $uri = JUri::getInstance();
         $domain = $filter->clean($uri->toString(array("scheme", "host")));
         $result["redirect_url"] = $domain . JRoute::_(CrowdfundingHelperRoute::getBackingRoute($project->getSlug(), $project->getCatslug(), "share"), false);
     }
     // DEBUG DATA
     JDEBUG ? $this->log->add(JText::_($this->textPrefix . "_DEBUG_RETURN_URL"), $this->debugType, $result["redirect_url"]) : null;
     // Payment Session
     $userId = JFactory::getUser()->get("id");
     $aUserId = $this->app->getUserState("auser_id");
     // Reset anonymous user hash ID,
     // because the payment session based in it will be removed when transaction completes.
     if (!empty($aUserId)) {
         $this->app->setUserState("auser_id", "");
     }
     $paymentSessionContext = Crowdfunding\Constants::PAYMENT_SESSION_CONTEXT . $project->getId();
     $paymentSessionLocal = $this->app->getUserState($paymentSessionContext);
     $paymentSession = $this->getPaymentSession(array("session_id" => $paymentSessionLocal->session_id));
     // DEBUG DATA
     JDEBUG ? $this->log->add(JText::_($this->textPrefix . "_DEBUG_PAYMENT_SESSION_OBJECT"), $this->debugType, $paymentSession->getProperties()) : null;
     // Validate payment session record.
     if (!$paymentSession->getId()) {
         // Log data in the database
         $this->log->add(JText::_($this->textPrefix . "_ERROR_INVALID_PAYMENT_SESSION"), $this->debugType, $paymentSession->getProperties());
         // Send response to the browser
         $response = array("success" => false, "title" => JText::_($this->textPrefix . "_FAIL"), "text" => JText::_($this->textPrefix . "_ERROR_INVALID_PROJECT"));
         return $response;
     }
     // Validate a reward and update the number of distributed ones.
     // If the user is anonymous, the system will store 0 for reward ID.
     // The anonymous users can't select rewards.
     $rewardId = $paymentSession->isAnonymous() ? 0 : (int) $paymentSession->getRewardId();
     if (!empty($rewardId)) {
         $validData = array("reward_id" => $rewardId, "project_id" => $projectId, "txn_amount" => $amount);
         $reward = $this->updateReward($validData);
         // Validate the reward.
         if (!$reward) {
             $rewardId = 0;
         }
     }
     // Prepare transaction data
     $transactionId = new Prism\String();
     $transactionId->generateRandomString(12, "BT");
     $transactionId = Joomla\String\String::strtoupper($transactionId);
     $transactionData = array("txn_amount" => $amount, "txn_currency" => $currency->getCode(), "txn_status" => "pending", "txn_id" => $transactionId, "project_id" => $projectId, "reward_id" => $rewardId, "investor_id" => (int) $userId, "receiver_id" => (int) $project->getUserId(), "service_provider" => "Bank Transfer");
     // DEBUG DATA
     JDEBUG ? $this->log->add(JText::_($this->textPrefix . "_DEBUG_TRANSACTION_DATA"), $this->debugType, $transactionData) : null;
     // Auto complete transaction
     if ($this->params->get("auto_complete", 0)) {
         $transactionData["txn_status"] = "completed";
         $project->addFunds($amount);
         $project->storeFunds();
     }
     // Store transaction data
     $transaction = new Crowdfunding\Transaction(JFactory::getDbo());
     $transaction->bind($transactionData);
     $transaction->store();
//.........这里部分代码省略.........
开发者ID:pashakiz,项目名称:crowdf,代码行数:101,代码来源:banktransfer.php


注:本文中的CrowdfundingHelperRoute::getBackingRoute方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。