android webview中CC Avenue支付网关会话过期问题
“您的会话已过期。请重新启动您的交易。别担心……这会发生在我们当中最好的人身上。”当我尝试使用android webview从CC Avenue支付网关使用paytm钱包支付时,会显示错误消息 以下是我用于支付网关的代码:android webview中CC Avenue支付网关会话过期问题,android,webview,payment-gateway,ccavenue,paytm,Android,Webview,Payment Gateway,Ccavenue,Paytm,“您的会话已过期。请重新启动您的交易。别担心……这会发生在我们当中最好的人身上。”当我尝试使用android webview从CC Avenue支付网关使用paytm钱包支付时,会显示错误消息 以下是我用于支付网关的代码: @Override protected void onCreate(Bundle savedInstanceState) { progressBarPB = (ProgressBar) findViewById(R.id.progressBarPB); pro
@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数据,即使我不明白为什么会显示此错误。请帮我找到一个好的解决办法。谢谢:)。你成功了吗?