【问题标题】:Android paytm payment gateway responseAndroid paytm 支付网关响应
【发布时间】:2020-01-29 15:57:56
【问题描述】:

我已经实施了 Paytm 支付系统,并且在我的意图之上使用网络意图一切正常,钱从客户的账户中扣除并添加到我的帐户中,但在交易完成后它卡在白页上说“重定向到应用程序”,我相信我应该编写代码以重定向回我的应用程序,但我不知道该怎么做,因为我找不到 onTransactionSucess() 事件或任何类似的事件,我也尝试过 onTransactionResponse但仍然没有回应。我检查了所有 paytm 文档并尝试联系 paytm 支持,但找不到方法。

【问题讨论】:

    标签: java android payment gateway paytm


    【解决方案1】:

    希望您已添加验证校验和所需的“CALLBACK_URL”。 如 paytm 文档中所述

    CALLBACK_URL - 避免篡改的安全参数。使用生成 Paytm 提供的服务器端校验和实用程序。商家必须确保 这总是在服务器上生成。生成的实用程序 checksumhash 可用here

    希望这能起到神奇的作用。

    【讨论】:

      【解决方案2】:

      我希望您已将此变量添加到您的代码中 -

      PaytmPGService service;
      

      如果您正在使用它,那么您可以获得所有与付款相关的方法:

      service.startPaymentTransaction(this, true,
                  true, new PaytmPaymentTransactionCallback() {
      
                      @Override
                      public void onTransactionResponse(Bundle inResponse) {
                          System.out.println("===== onTransactionResponse " + inResponse.toString());
                          if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) {
                              if (Objects.equals(inResponse.getString("STATUS"), "TXN_SUCCESS")) {
                                  //    Payment Success
                              } else if (!inResponse.getBoolean("STATUS")) {
                                  //    Payment Failed
                              }
                          }
                      }
      
                      @Override
                      public void networkNotAvailable() {
                          // network error
                      }
      
                      @Override
                      public void clientAuthenticationFailed(String inErrorMessage) {
                          // AuthenticationFailed
                      }
      
                      @Override
                      public void someUIErrorOccurred(String inErrorMessage) {
                          // UI Error
                      }
      
                      @Override
                      public void onErrorLoadingWebPage(int iniErrorCode, String inErrorMessage, String inFailingUrl) {
                          //  Web page loading error
                      }
      
                      @Override
                      public void onBackPressedCancelTransaction() {
                          // on cancelling transaction
                      }
      
                      @Override
                      public void onTransactionCancel(String inErrorMessage, Bundle inResponse) {
                          // maybe same as onBackPressedCancelTransaction()
                      }
                  });
      

      希望对你有所帮助。

      【讨论】:

      • 一切正常,但问题是我的应用程序卡在后端的 verifyCheckSum.php 页面中。它不会自动重定向回我的应用程序。我可以在我的 php 页面中添加一些东西来关闭它或重定向回我的应用程序吗?
      • 如果一切正常并且您只想重定向到后台页面,您可以使用 onTransactionResponse() 方法(请参阅我的代码),如果您能找到任何方法从该页面返回而不是可能是你可以传递背部活动的意图,我希望这会有所帮助
      • 事务正在运行。钱已记入我的帐户,但我的应用程序卡在后端 php 页面 verifychecksum.php。
      【解决方案3】:

      将默认回调 URL 更改为假设,'http://yourdomain(如果在本地主机上检查的 IP 地址)/pgResponse.php';。 将以下代码添加到 pgResponse.php

       <?php
              session_start(); 
              header("Pragma: no-cache");
              header("Cache-Control: no-cache");
              header("Expires: 0");
      
      
      
              // following files need to be included
              require_once("./lib/config_paytm.php");
              require_once("./lib/encdec_paytm.php");
      
              $paytmChecksum = "";
              $paramList = array();
              $isValidChecksum = "FALSE";
      
              $paramList = $_POST;
              $return_array= $_POST;
              $checkSum = getChecksumFromArray($paramList,PAYTM_MERCHANT_KEY);//generate new checksum
              $paytmChecksum = isset($_POST["CHECKSUMHASH"]) ? $_POST["CHECKSUMHASH"] : ""; //Sent by Paytm pg
      
      
              //Verify all parameters received from Paytm pg to your application. Like MID received from paytm pg is same as your applicationís MID, TXN_AMOUNT and ORDER_ID are same as what was sent by you to Paytm PG for initiating transaction etc.
              $isValidChecksum = verifychecksum_e($paramList, PAYTM_MERCHANT_KEY, $paytmChecksum); //will return TRUE or FALSE string.
              $return_array["IS_CHECKSUM_VALID"] = $isValidChecksum ? "Y" : "N";
              unset($return_array["CHECKSUMHASH"]);
              $mid = $_POST['MID'];
            $orderid = $_POST['ORDERID']; 
      
      
              $curl = curl_init();
      
              curl_setopt_array($curl, array(
                  CURLOPT_RETURNTRANSFER => 1,
                  CURLOPT_URL => 'https://securegw-stage.paytm.in/order/status?JsonData={"MID":"'.$mid.'","ORDERID":"'.$orderid.'","CHECKSUMHASH":"'.$checkSum.'"}',
                  CURLOPT_USERAGENT => 'Make Request'
              ));
      
              $resp = curl_exec($curl);
              $status= json_decode($resp)->STATUS;
      
      //do something in your database
      
      
              $encoded_json = htmlentities(json_encode($return_array));
      
      
      
              ?>
      
              <html>
              <head>
                   <meta http-equiv="Content-Type" content="text/html;charset=ISO-8859-I">
                   <title>Paytm</title>
                   <script type="text/javascript">
                          function response(){
                                  return document.getElementById('response').value;
                          }
                   </script>
              </head>
              <body>
                Redirecting back to the app.....</br>
                <form name="frm" method="post">
                  <input type="hidden" id="response" name="responseField" value='<?php echo $encoded_json?>'>
                </form>
              </body>
              </html>
      

      在安卓工作室中:

      public void onTransactionResponse(Bundle inResponse) {
                                  Log.d("Create Response", inResponse.toString());
      
                                  String response = inResponse.getString("RESPMSG");
                                  if (response.equals("Txn Successful.")) {
                                      Toast.makeText(Bag.this,"Payment done",Toast.LENGTH_LONG).show();
      
                                  }
                                  else{
                                      Toast.makeText(Bag.this,response,Toast.LENGTH_LONG).show();
                                  }
                              }
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 2016-01-27
        • 2019-11-24
        • 2022-07-18
        • 2020-09-03
        • 2018-08-22
        • 2022-06-19
        • 2018-08-15
        • 2020-09-11
        相关资源
        最近更新 更多