首页 文章

在opencart的支付网关成功付款后重定向的链接是什么?

提问于
浏览
2

我在OpenTraart中实现了基于BankTransfer模块的支付模块 . 支付网关的要求是使用get请求提交 successurlerrorurl . 这些URL用于成功订购和取消订单 .

算法:

  • 客户进入订单结账 .

  • 点击确认订单

  • 被重定向到localhost / opencart / testkzm.php,其中打印出值,并且有一个链接,以便在成功的情况下重定向到该链接 .

QUESTION: 在支付网关成功付款后,重定向的链接是什么?

方法:我天真地认为http://example.com/opencart/index.php?route=checkout/success是成功的链接 . 它's only shows confirmation message, but order is not placed in the system. I understand that there'无法给出外部链接,它会自动知道要确认的订单,所以我应该成功传递加密的唯一值,所以在返回时我可以解密它们并确认订单吗?

文件说明:

  • banktransfer.php是文件opencart从系统获取信息,如订单ID,订单金额等 .

  • banktransfer.tpl是用于在浏览器中呈现页面的模板文件 . (实际前端)

  • testkzm.php是我编写的简单文件,用于测试我从系统中获取正确的值 .

testkzm.php是我编写的简单文件,用于测试我从系统中获取正确的值 .

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>

3 回答

  • 0

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

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

  • 1

    成功的网址是你想到的结帐/成功 .

    付款模块应在转到成功页面之前确认付款 . Bank Transfer模块使用AJAX(如banktransfer.tpl中所示)进行确认,以调用banktransfer.php中的确认功能 .

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

  • 0

    我做了这个只是添加了简单的重定向代码来启动

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

    在view / template / yourtemplate / common / success.tpl中

相关问题