校验和不匹配错误 paytm 支付集成

Posted

技术标签:

【中文标题】校验和不匹配错误 paytm 支付集成【英文标题】:Checksum mismatch error paytm payment integration 【发布时间】:2019-05-21 13:23:07 【问题描述】:

我正在尝试在我的应用程序中实施 Paytm 支付网关,但它正在提供 Bundle[STATUS=TXN_FAILURE, ORDERID=order1, TXNAMOUNT=7.00, MID=cdBOMy65033449597261, RESPCODE=330, BANKTXNID=, CURRENCY=INR, RESPMSG=Paytm checksum mismatch.] 这个错误,适用于 TEST 和 Production 环境。

这是我生成校验和的 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);

这是我的安卓端代码,

     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 QA 论坛上浏览了各种主题,但他们没有为主题提供任何足够的答案(与我的主题相同)。

【问题讨论】:

你解决了吗? 您好,您找到解决方案了吗? 错误来自服务器端。然后我将 Paytm sdk 目录移出 laravel 目录。 【参考方案1】:

在 PHP 中 改变这个

$paytmParams["ORDER_ID"] = "order1";

到这里

$paytmParams["ORDERID"] = "order1";

在应用程序中 改变这个

paramMap.put( "ORDER_ID" , "order1");

到这里

paramMap.put( "ORDERID" , "order1");

【讨论】:

以上是关于校验和不匹配错误 paytm 支付集成的主要内容,如果未能解决你的问题,请参考以下文章

尝试运行 svnadmin verify 会导致校验和不匹配

ClickHouse 失败并出现错误“DirectoryMonitor:额外信息的校验和不匹配:损坏的数据”

svn:校验和不匹配

更新校验和不匹配:SVN v1.8.10

CentOS 6 - YUM 不起作用 - primary.sqlite.bz2 [错误 -1] 元数据文件与校验和不匹配

TCP 校验和与wireshark 校验和不匹配(正好相差1)