我正在尝试在我的应用中实现paytm支付网关,但是
对于测试和生产环境,Bundle[{STATUS=TXN_FAILURE, ORDERID=order1, TXNAMOUNT=7.00, MID=cdBOMy65033449597261, RESPCODE=330, BANKTXNID=, CURRENCY=INR, RESPMSG=Paytm checksum mismatch.}]
均出现此错误。
这是我的PHP代码,用于生成校验和。
$paytmParams = array();
$paytmParams["MID"] = "cdBOMy65033449597261";
$paytmParams["ORDER_ID"] = "order1";
$paytmParams["CUST_ID"] = "cust1";
$paytmParams["MOBILE_NO"] = "9799990168";
$paytmParams["EMAIL"] = "droidwithme@gmail.com";
$paytmParams["CHANNEL_ID"] = "WAP";
$paytmParams["TXN_AMOUNT"] = "7.00";
$paytmParams["WEBSITE"] = "DEFAULT"; //tried WEBSTAGING and APPSTAGING
$paytmParams["INDUSTRY_TYPE_ID"] = "Retail";
$paytmParams["CALLBACK_URL"] = "https://securegw.paytm.in/theia/paytmCallback?ORDER_ID=order1";
//Here checksum string will return by getChecksumFromArray() function.
$paytmChecksum = EndecPaytm::getChecksumFromArray($paytmParams, $merchantKey);
$responseBody = [
'message' => 'Checksum Generated.',
'data' => [
"CHECKSUMHASH" => $paytmChecksum,
"ORDER_ID" => "order1",
"payt_STATUS" => "1"
]
];
return ApiMethods::apiResponse('success', $responseBody);
这是我的android辅助代码,
private void getPaytmWindow(String chkSm) {
PaytmPGService Service = PaytmPGService.getProductionService();
//Kindly create complete Map and checksum on your server side and then put it here in paramMap.
HashMap<String, String> paramMap = new HashMap<>();
paramMap.put( "MID" , "cdBOMy65033449597261"); //cdBOMy65033449597261
// Key in your staging and production MID available in your dashboard
paramMap.put( "ORDER_ID" , "order1");
paramMap.put( "CUST_ID" , "cust1");
paramMap.put( "MOBILE_NO" , "9799990168");
paramMap.put( "EMAIL" , "droidwithme@gmail.com");
paramMap.put( "CHANNEL_ID" , "WAP");
paramMap.put( "TXN_AMOUNT" , "7.00");
paramMap.put( "WEBSITE" , "DEFAULT");
// This is the staging value. Production value is available in your dashboard
paramMap.put( "INDUSTRY_TYPE_ID" , "Retail");
// This is the staging value. Production value is available in your dashboard
paramMap.put( "CALLBACK_URL", "https://securegw.paytm.in/theia/paytmCallback?ORDER_ID=order1");
paramMap.put( "CHECKSUMHASH" , chkSm);
PaytmOrder Order = new PaytmOrder(paramMap);
Service.initialize(Order, null);
Service.startPaymentTransaction(this, true, true,
new PaytmPaymentTransactionCallback() {
@Override
public void someUIErrorOccurred(String inErrorMessage) {
// Some UI Error Occurred in Payment Gateway Activity.
// // This may be due to initialization of views in
// Payment Gateway Activity or may be due to //
// initialization of webview. // Error Message details
// the error occurred.
Utils.logD(TAG, "someUIErrorOccurred : " + inErrorMessage);
}
@Override
public void onTransactionResponse(Bundle inResponse) {
Log.d("LOG123444", "Payment Transaction : " + inResponse);
if (Objects.requireNonNull(inResponse.getString("STATUS")).contains("TXN_SUCCESS")) {
Toast.makeText(getApplicationContext(), "Transaction completed", Toast.LENGTH_LONG).show();
}
Utils.logD(TAG, inResponse.getString("STATUS"));
// Toast.makeText( getApplicationContext(), "Payment Transaction response " + inResponse.toString(), Toast.LENGTH_LONG ).show();
}
@Override
public void networkNotAvailable() {
// If network is not
// available, then this
// method gets called.
}
@Override
public void clientAuthenticationFailed(String inErrorMessage) {
// This method gets called if client authentication
// failed. // Failure may be due to following reasons //
// 1. Server error or downtime. // 2. Server unable to
// generate checksum or checksum response is not in
// proper format. // 3. Server failed to authenticate
// that client. That is value of payt_STATUS is 2. //
// Error Message describes the reason for failure.
Utils.logD(TAG, "clientAuthenticationFailed " + inErrorMessage);
}
@Override
public void onErrorLoadingWebPage(int iniErrorCode,
String inErrorMessage, String inFailingUrl) {
Utils.logD(TAG, "inErrorMessage " + inErrorMessage);
Utils.logD(TAG, "inFailingUrl " + inFailingUrl);
}
// had to be added: NOTE
@Override
public void onBackPressedCancelTransaction() {
// TODO Auto-generated method stub
}
@Override
public void onTransactionCancel(String inErrorMessage, Bundle inResponse) {
Utils.logD(TAG, "Payment Transaction Failed " + inErrorMessage);
Toast.makeText(getBaseContext(), "Payment Transaction Failed ", Toast.LENGTH_LONG).show();
}
});
}
这是gradle依赖项
implementation('com.paytm:pgplussdk:1.2.3') {
transitive = true
}
我也尝试过测试环境和生产环境,但是每次都会遇到校验和不匹配错误。 为了测试目的,我设置了硬编码的值。我在paytm质量检查论坛上浏览了多个线程,但是它们对线程(与我的线程相同)没有提供足够的答案。
答案 0 :(得分:0)
在PHP中 更改
$paytmParams["ORDER_ID"] = "order1";
对此
$paytmParams["ORDERID"] = "order1";
在APP中 更改
paramMap.put( "ORDER_ID" , "order1");
对此
paramMap.put( "ORDERID" , "order1");