人到中年有点甜
将默认的回调 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(); } }