解决在android中使用微信H5支付,提示商家参数格式有误
2017-10-18 14:01
561 查看
解决在APP中使用微信H5支付,提示“商家参数格式有误…”
昨天抽空研究了一下微信H5支付,发现的确很方便,如果只使用浏览器做H5支付, 没什么问题,市面上主流的手机浏览器应该都可以调起微信支付(虽然我只测试了UC和QQ浏览器 - -! ) [微信H5支付](https://pay.weixin.qq.com/wiki/doc/api/H5.php?chapter=15_1) 但是当我接入到APP中的时候,一直出现“商家参数格式有误,请联系商家解决”,why? 我什么都没有修改啊。上网也找了很多文章,说是需要在WebView的shouldOverrideUrlLoading方法中写成这样:
if (url.startsWith("weixin://wap/pay?")) { Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setData(Uri.parse(url)); startActivity(intent); return true; } else { Map<String, String> extraHeaders = new HashMap<>(); extraHeaders.put("Referer", "http://wxpay.wxutil.com"); view.loadUrl(url, extraHeaders); } return true;
我也尝试了,这样在华为Mate 9 pro 以及小米5 上的确可以(android7.0) 但是在华为CL10(android4.4.4)上面还是提示这个错误。。(¬_¬) 最终解决方案:
webView.setWebViewClient(new WebViewClient() { @Override public boolean shouldOverrideUrlLoading(WebView view, String url) { if (url.startsWith("weixin://wap/pay?")) { //如果return false 就会先提示找不到页面,然后跳转微信 Intent intent = new Intent(); intent.setAction(Intent.ACTION_VIEW); intent.setData(Uri.parse(url)); startActivity(intent); return true; } return false; } @Override public void onReceivedSslError(WebView view, SslErrorHandler handler, SslError error) { //此方法是为了处理在5.0以上Htts的问题,必须加上 handler.proceed(); } });
相关文章推荐
- 微信h5支付接口开发,出现错误‘商家参数格式有误,请联系商家解决’,访问无法mweb_url
- 微信H5支付:商家参数格式有误
- android webview拉起微信h5支付错误解决办法
- Android在使用过程中出现The connection to adb is down, and a severe error has occured提示问题的解决
- android switch不能使用参数String,View等类的解决方法
- android客户端通过Get方式提交参数给服务器,使用URL和HttpURLConnection实现,以及乱码问题解决
- android使用ksoap2解析webservice的值为anyType{}格式的解决办法
- Android 使用JSON格式与服务器交互 中文乱码问题解决
- android xml布局文件中使用RelativeLayout,明明有这个id,却提示找不到---->解决办法
- 微信 chooseWXPay fail问题解决(非支付目录配置问题),支付接口参数问题
- 使用Appium做手机app自动化时,红米2手机(已ROOT)时不时的弹出覆盖安装Appium Android Input Manager for Unicode的输入法的提示的解决办法
- android 微信扫码支付模式一生成二维码 原生支付url参数错误
- android xml布局文件中使用RelativeLayout,明明有这个id,却提示找不到---->解决办法
- 微信开发 提示 Redirect_uri参数错误解决方法
- 微信开发 提示 Redirect_uri参数错误解决方法
- 微信开发 支付开发redirect_uri参数错误解决办法
- C#使用String.Format()方法时,出现异常"输入的字符串格式有误"的解决方法
- 微信端支付宝支付,iframe改造,解决微信中无法使用支付宝付款和弹出“长按地址在浏览器中打开”
- silverlight中饼状图使用时提示“输入的字符串格式不正确” 解决办法
- android webview 调用微信 h5 支付方式