我在paytm中获得验证校验和错误到Android应用程序我已经在php中创建了校验和并从服务器发送到Android app.once app收到校验和再次参数将转到服务器验证校验和
应用代码
public void onStartTransaction (View view){
String orderId = pref.getoId();
String uid = pref.getuid();
String email = pref.getemail();
String mobile = pref.getMobileNumber();
String checksum = pref.getchecksum();
PaytmPGService Service = PaytmPGService.getProductionService();
Map<String, String> paramMap = new HashMap<String, String>();
paramMap.put("MID", "Goa3038161");
paramMap.put("ORDER_ID", orderId);
paramMap.put("CUST_ID", uid);
paramMap.put("INDUSTRY_TYPE_ID", "Retail109");
paramMap.put("CHANNEL_ID", "WAP");
paramMap.put("TXN_AMOUNT", "99");
paramMap.put("WEBSITE", "GWEB");
paramMap.put("CALLBACK_URL", "https://goalert.in/verifyChecksum.php ");
paramMap.put("EMAIL", email);
paramMap.put("MOBILE_NO", mobile);
paramMap.put("CHECKSUMHASH", checksum);
PaytmOrder Order = new PaytmOrder(paramMap);
Service.initialize(Order, null);
服务器代码
generateChecksum.php
此函数生成校验和并返回具有校验和值的应用程序
<?php
header("Pragma: no-cache");
header("Cache-Control: no-cache");
header("Expires: 0");
require_once("./lib/config_paytm.php");
require_once("./lib/encdec_paytm.php");
require_once 'include/DB_Functions.php';
$db = new DB_Functions();
if (isset($_POST['email']) && isset($_POST['mobile']) && isset($_POST['uid']) && isset($_POST['orderId'])){
$email = $_POST['email'];
$mobile = $_POST['mobile'];
$uid = $_POST['uid'];
$orderId = $_POST['orderId'];
}else {
// required post params is missing
$response["error"] = TRUE;
$response["error_msg"] = "Unknown error";
echo json_encode($response);
}
$checkSum = "";
// below code snippet is mandatory, so that no one can use your checksumgeneration url for other purpose .
$findme = 'REFUND';
$findmepipe = '|';
$paramList = array();
$paramList["MID"] = 'Goa8161';
$paramList["ORDER_ID"] = $orderId;
$paramList["CUST_ID"] = $uid;
$paramList["INDUSTRY_TYPE_ID"] = 'Retail109';
$paramList["CHANNEL_ID"] = 'WAP';
$paramList["TXN_AMOUNT"] = '99';
$paramList["WEBSITE"] = 'GoB';
foreach($_POST as $key=>$value)
{
$pos = strpos($value, $findme);
$pospipe = strpos($value, $findmepipe);
if ($pos === false || $pospipe === false)
{
$paramList[$key] = $value;
}
}
//Here checksum string will return by getChecksumFromArray() function.
$checkSum= getChecksumFromArray($paramList,"gPFC");
//print_r($_POST);
$response["user"]= array("CHECKSUMHASH" => $checkSum,"orderId" => $_POST["orderId"], "payt_STATUS" => "1");
echo json_encode($response);
verifyChecksum.php
此函数将验证与paytm服务器的校验和
注意:请错误地忽略键中间参数的值
<?php
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;
$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, "gPFZSi", $paytmChecksum); //will return TRUE or FALSE string.
if ($isValidChecksum===TRUE){
$return_array["IS_CHECKSUM_VALID"] = "Y";
else
$return_array["IS_CHECKSUM_VALID"] = "N";
}
$return_array["IS_CHECKSUM_VALID"] = $isValidChecksum ? "Y" : "N";
$return_array["TXNTYPE"] = "";
$return_array["REFUNDAMT"] = "";
unset($return_array["CHECKSUMHASH"]);
$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>
Redirect 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>
当交易正在处理时,由于不活动而导致支付会话关闭时出错。当我在paytm上检查订单时它表示校验和错误
请帮助解决问题
答案 0 :(得分:1)
可能有些事情可能出错。
让我先简单说明一步一步的过程,所以如果你找到的东西与你所做的不同,我们可以快速找出错误点。
1)应用程序通常会触发付款,然后发送需要生成checkSum的所有数据。
2)只有服务器必须生成校验和(纯粹出于安全原因)
3)支票和退款的校验和生成方法不同。至少在Java和Python中。(这在Paytm中真的很傻,而且有点乱,但那是另一天的故事)
4)应用程序必须调用Paytm API(带或不带SDK),一旦收到响应,必须要求服务器验证响应中的校验和发送。
注意事项: -
1)发送给Paytm的参数必须与checkSum生成中使用的参数相同。不用多说也不用说,空格,输入,破坏所有计数,并且将无法通过checkSum验证。
2)如果您正在处理退款,请不要在checkSum生成中发送REFID
,但在调用Paytm API时发送。{/ p>
答案 1 :(得分:0)
我看不到您在任何地方生成校验和,应该对计划发送的所有参数进行校验和。
似乎您:String checksum = pref.getchecksum();
的实现在哪里?将其保留在主要对象之外,然后重试。
答案 2 :(得分:0)
在春季使用paytm校验和很简单。
运行时会导致一些问题。
3个简单步骤即可解决所有问题。
1:-向您添加此依赖项pom.xml
<Route path="/shop">
<Shop> </Shop>
</Route>
<Route path="*">
<NotFound></NotFound>
</Route>
<Route path="/review">
<Review> </Review>
</Route>
2:下载“ pg-checksum-1.0.jar”文件并重命名“ pg-checksum-1.0”
3:将pg-checksum-1.0.jar粘贴到“ C:\ Users \ xyz.m2 \ repository \ com \ paytm \ pg \ pg-checksum \ 1.0”
现在清理并构建您的项目,您将获得校验和字符串。
乐于助人;-)