【问题标题】:What is the link to redirect after successful payment at payment gateway in opencart?在opencart的支付网关成功支付后重定向的链接是什么?
【发布时间】:2013-03-07 19:20:58
【问题描述】:

我在 Opencart 中基于 BankTransfer 模块实现了支付模块。 支付网关的要求是通过获取请求提交 successurlerrorurl。这些 URL 用于成功的订单和取消的订单。

算法:

  1. 客户进入订单结账处。
  2. 点击确认订单
  3. 被重定向到 localhost/opencart/testkzm.php,其中的值被打印出来,并且有一个链接,如果成功,我应该重定向到该链接。

问题:在支付网关成功支付后重定向的链接是什么?

方法: 我天真地认为http://example.com/opencart/index.php?route=checkout/success 是成功的链接。它只显示确认信息,但系统不会下订单。我知道没有办法提供自动知道要确认哪个订单的外部链接,所以我应该在successurl中传递加密的唯一值,所以返回时我可以解密它们并确认订单?

文件说明:

  • banktransfer.php 是文件 opencart 从系统中获取信息,例如 订单编号、订单金额等。
  • banktransfer.tpl 是模板 用于在浏览器中渲染页面的文件。(实际前端)
  • testkzm.php 是 我写的一个简单的文件来测试我从中得到正确的值 系统。

testkzm.php 是 我写的一个简单的文件来测试我从中得到正确的值 系统。

controller/payment 中的banktransfer.php

 class ControllerPaymentBankTransfer extends Controller {
  protected function index() {
   $this->language->load('payment/bank_transfer');

   $this->data['text_instruction'] = $this->language->get('text_instruction');
   $this->data['text_description'] = $this->language->get('text_description');
   $this->data['text_payment'] = $this->language->get('text_payment');

   //Modified things for KZM
   $order_info = $this->model_checkout_order->getOrder($this->session->data['order_id']);
   $this->data['orderIdKZM'] = $this->session->data['order_id'];
   $this->data['amountKZM'] = $order_info['total'];

   $this->data['merchantIdKZM'] = $this->language->get('merchantIdKZM');
   $this->data['currencyKZM'] = $this->language->get('currencyKZM');
   $this->data['titleKZM'] = $this->language->get('titleKZM');
   $this->data['successuUlKZM'] = $this->language->get('successUrlKZM');
   $this->data['errorUrlKZM'] = $this->language->get('errorUrlKZM');
   $this->data['dateKZM'] = $this->language->get('dateKZM');
   $this->data['signstrKZM'] = $this->language->get('signstrKZM');
   $this->data['verKZM'] = $this->language->get('verKZM');
   //KZM

   $this->data['button_confirm'] = $this->language->get('button_confirm');

   $this->data['bank'] = nl2br($this->config->get('bank_transfer_bank_' . $this->config->get('config_language_id')));

   $this->data['continue'] = $this->url->link('checkout/success');

   if (file_exists(DIR_TEMPLATE . $this->config->get('config_template') . '/template/payment/bank_transfer.tpl')) {
    $this->template = $this->config->get('config_template') . '/template/payment/bank_transfer.tpl';
   } else {
    $this->template = 'default/template/payment/bank_transfer.tpl';
   } 

   $this->render(); 
  }

  public function confirm() {
   $this->language->load('payment/bank_transfer');

   $this->load->model('checkout/order');

   $comment  = $this->language->get('text_instruction') . "\n\n";
   $comment .= $this->config->get('bank_transfer_bank_' . $this->config->get('config_language_id')) . "\n\n";
   $comment .= $this->language->get('text_payment');

   $this->model_checkout_order->confirm($this->session->data['order_id'], $this->config->get('bank_transfer_order_status_id'), $comment, true);
  }
 }

banktransfer.tpl

<h2><?php echo $text_instruction; ?></h2>
 <div class="content">
    <p><?php echo $text_description; ?></p>
    <p><?php echo $bank; ?></p>
    <p><?php echo $text_payment; ?></p>
    <p><?php echo $orderIdKZM; ?></p>
    <p>
    <?php 
     $titleKZM = $titleKZM.$orderIdKZM; 
       $merchantIdKZM = '23';
   $currencyKZM = 'KZT';
   $successUrlKZM = '';
   $erroUrlKZM = '';
   $dateKZM = $merchantIdKZM.$orderIdKZM.$amountKZM.$currencyKZM;

    ?></p>
 </div>
 <div class="buttons">
   <div class="right">
 <form action="http://example.com/opencart/testkzm.php" method="get">
 <input type="hidden" name="merchantIdKZM" value="<?php echo $merchantIdKZM; ?>">
 <input type="hidden" name="orderIdKZM" value="<?php echo $orderIdKZM; ?>">
 <input type="hidden" name="amountKZM" value="<?php echo $amountKZM; ?>">
 <input type="hidden" name="currencyKZM" value="<?php echo $currencyKZM; ?>">
 <input type="hidden" name="successUrlKZM" value="<?php echo $successUrlKZM; ?>">
 <input type="hidden" name="errorUrlKZM" value="<?php echo $errorUrlKZM; ?>">
 <input type="hidden" name="signstrKZM" value="<?php echo $signstrKZM; ?>">
 <input type="hidden" name="verKZM"  value="<?php echo $verKZM; ?>">

 <input type="button" value="<?php echo $button_confirm; ?>" id="button-confirm" class="button" />
 </form>
     </div>
 </div>
 <script type="text/javascript"><!--
 $('#button-confirm-s').bind('click', function() {
  $.ajax({ 
   type: 'get',
   url: 'index.php?route=payment/bank_transfer/confirm',
   success: function() {
    location = '<?php echo $continue; ?>';
   }  
  });
 });
 //--></script

testkzm.php

merchantID <?php echo $_GET["merchantIdKZM"]; ?><br>
  orderID <?php echo $_GET["orderIdKZM"]; ?> <br> 
  amount <?php echo $_GET["amountKZM"]; ?><br>
  currency <?php echo $_GET["currencyKZM"]; ?> <br> 
  successURL <?php echo $_GET["successUrlKZM"]; ?><br>
  errorURL <?php echo $_GET["errorUrlKZM"]; ?> <br> 
  signstr <?php echo $_GET["signstrKZM"]; ?><br>
  ver <?php echo $_GET["verKZM"]; ?> <br> 

  <div class="buttons">
            <div class="right">
          <a href="http://example.com/opencart/index.php?route=checkout/success">asdfas</a>
         </div>
      </div>

【问题讨论】:

    标签: get payment-gateway opencart


    【解决方案1】:

    如你所想,成功的 url 就是 checkout/success。

    支付模块在进入成功页面前应确认支付。银行转帐模块通过使用 AJAX(如您在 banktransfer.tpl 中看到的)调用 banktransfer.php 中的确认函数来进行确认。

    如果您使用其他支付网关模块(如 pp_standard、moneybookers、paymate 等)作为您的起点,而不是银行转账,则更好,因为它们更符合您的自定义支付网关模块要求。

    【讨论】:

      【解决方案2】:

      支付网关的返回 URL 完全取决于您自己和支付网关的方法。通常,如果您可以将 url 传递给支付网关以返回 true 和/或 false 以表示交易成功,您将使用支付网关控制器的方法,例如http://yourstore.com/index.php?route=payment/payment_gateway/success,您可以然后处理付款,并相应地更新订单状态

      如果您想进入结帐成功页面,您可以使用$this-&gt;redirect($this-&gt;url-&gt;link('checkout/success', '', 'SSL'))。如果失败,您应该重定向回结帐页面,客户可以快速跳过应该已经填写了详细信息的各个页面,然后他们可以再试一次

      【讨论】:

      • 问题:让我们想象一下这个场景:1.我已经通过get发送参数到支付网关,2.然后网关处理它,然后它给我发回签名,它已经加密了交易状态。 3.我用我写的php脚本解密这个签名,然后我需要发送成功或失败到bank_transfer模块。问题:如何将外部 php 脚本的值解析到模块?
      【解决方案3】:

      我做这个只是添加了简单的重定向代码开始

      <?php
        header('Location:http://yoursite location');
        exit;
      ?>
      

      在视图/模板/yourtemplate/common/success.tpl

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2012-07-17
        • 2014-01-13
        • 1970-01-01
        • 2013-10-16
        • 1970-01-01
        • 2015-08-31
        • 2014-08-20
        • 2019-05-30
        相关资源
        最近更新 更多