问题描述
我在Paytm中收到验证校验和错误到android应用程序,我已经在php中创建了校验和并将其从服务器发送到android 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上检查显示校验和错误的订单时
请帮助解决问题
可能有些事情可能出错了.
让我先简要说明一下分步过程,因此,如果您发现与您所做的不同的事情,我们可以迅速查明错误.
1)应用通常会触发付款,并发送所有需要生成checkSum的数据.
2)仅服务器必须生成校验和(纯粹出于安全原因)
3)付款和退款的校验和生成方法不同.至少在Java和Python中使用.(这对Paytm来说确实很愚蠢,虽然有点混乱,但这是另一回事了)
4)应用必须调用Paytm API(带有或不带有SDK),并且一旦收到响应,就必须要求服务器验证响应中发送的校验和.
注意事项:-
1)发送给Paytm的参数必须与checkSum生成中使用的参数相同.不少,不用多说,空格,输入,短划线所有计数,将使您的checkSum验证失败.
2)如果您正在处理退款,请不要在checkSum生成中发送REFID
,而是在调用Paytm API时发送.
i am getting verify checksum error in paytm to android app i have created check sum in php and sending from server to android app.once app received check sum again parameters will go to server to verify check sum
app code
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);
server code
generateChecksum.php
this function generates check sum and return to app with checksum value
<?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
this function will verify check sum with paytm server
Note:kindly ignore value of parameters of key mid they are given wrong
<?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>
when transaction is processing it gives error from pay session closed due to inactivity.when i checked on paytm for the order it says checksum error
pls help to solve the issue
There can be few things that may have gone wrong.
Let me briefly state step by step process first, so if you find something that is different than what you have done, we can pin point error quickly.
1) App usually triggers payment and with that sends all data with which checkSum needs to be generated.
2) Only server must generate checksum(purely for security reason)
3) Checksum generation method for payment and refund is different. At least in Java and Python.(This is really silly from Paytm and it is bit of a mess but that's a story for another day)
4) App must call Paytm API(with or without SDK), and once response is received must ask server to verify checksum send within response.
Cautions :-
1) Parameters that are send to Paytm must be same to those used in checkSum generation. Not less not more and Needless to say, white space, enter, dash all counts and will fail your checkSum verification.
2)If you are processing Refund, don't sent REFID
in checkSum generation but send it when calling Paytm API.
这篇关于paytm verifychecksum错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!