"Your session has been expired. Please re-initiate your transaction. Don't worry... It happens to the best of us." 当我尝试使用Android webview从CC Avenue支付网关使用paytm钱包付款时,会显示错误消息 .

以下是我用于支付网关的代码:

@Override
protected void onCreate(Bundle savedInstanceState) {
    progressBarPB = (ProgressBar) findViewById(R.id.progressBarPB);
    progressBarPB.setVisibility(View.VISIBLE);
    WebView webView = (WebView) findViewById(R.id.paymentGatewayWV);
    webView.getSettings().setJavaScriptEnabled(true);
    webView.getSettings().setJavaScriptCanOpenWindowsAutomatically(true);
    webView.setWebViewClient(new HelloWebViewClient());
    webView.clearCache(true);
    webView.clearHistory();
    clearCookies(this);
    webView.loadUrl("payment gateway url");
}


@SuppressWarnings("deprecation")
public static void clearCookies(Context context) {
    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP_MR1) {
        CookieManager.getInstance().removeAllCookies(null);
        CookieManager.getInstance().flush();
    } else {
        CookieSyncManager cookieSyncMngr = CookieSyncManager.createInstance(context);
        cookieSyncMngr.startSync();
        CookieManager cookieManager = CookieManager.getInstance();
        cookieManager.removeAllCookie();
        cookieManager.removeSessionCookie();
        cookieSyncMngr.stopSync();
        cookieSyncMngr.sync();
    }
}

public class HelloWebViewClient extends WebViewClient {
    public HelloWebViewClient() {
        // do nothing
    }

    @Override
    public boolean shouldOverrideUrlLoading(WebView view, String url) {
        view.loadUrl(url);
        return true;
    }

    @Override
    public void onPageFinished(WebView view, String url) {
        super.onPageFinished(view, url);
        progressBarPB.setVisibility(View.GONE);
    }
}

有时付款成功完成,如果我再次尝试付款,则显示上述错误 . 我正在清除浏览器中的所有cookie数据,甚至为什么显示这个错误我不明白 . 请帮我一个好的解决方案 . 谢谢 :) .