【Java开发|js 解决Safari浏览器中实现支付宝网页支付无法拉取支付宝APP的问题】简单介绍项目情况:
支付宝支付
第三方公司提供支付接口,返回结果是一个加密的完整的网页。
自己写的下单业务这些。但是在页面上实现支付过程的时候,在Android手机上面无论哪种类型的浏览器都能实现自动拉取支付宝APP进行支付
返回结果:
result:{"payOrderId":"P0020190604110618000381","sign":"8288C95DB8A511E82B08FBB4FC1EA260","resCode":"SUCCESS","payParams":"PCFET0NUWVBFIGh0bWw+CjxodG1sIGxhbmc9InpoLWNtbi1IYW5zIj4KPGhlYWQ+CiAgICA8bWV0YSBjaGFyc2V0PSJVVEYtOCI+CiAgICA8bWV0YSBodHRwLWVxdWl2PSJDb250ZW50LVR5cGUiIGNvbnRlbnQ9InRleHQvaHRtbDsgY2hhcnNldD1VVEYtOCI+CiAgICA8bWV0YSBuYW1lPSJ2aWV3cG9ydCIgY29udGVudD0id2lkdGg9ZGV2aWNlLXdpZHRoLGluaXRpYWwtc2NhbGU9MSx1c2VyLXNjYWxhYmxlPTAiPgogICAgPHRpdGxlPuWOu+aUr+S7mDwvdGl0bGU+CiAgICA8bGluayByZWw9InN0eWxlc2hlZXQiIGhyZWY9Imh0dHA6Ly9jZG4uYm9vdGNzcy5jb20vd2V1aS8xLjEuMS9zdHlsZS93ZXVpLm1pbi5jc3MiPgogICAgPGxpbmsgcmVsPSJzdHlsZXNoZWV0IiBocmVmPSJodHRwOi8vY2RuLmJvb3Rjc3MuY29tL2pxdWVyeS13ZXVpLzEuMC4xL2Nzcy9qcXVlcnktd2V1aS5taW4uY3NzIj4KPC9oZWFkPgo8Ym9keSBvbnRvdWNoc3RhcnQ+CjxkaXYgY2xhc3M9IndldWktbXNnIj4KICAgIDxkaXYgY2xhc3M9IndldWktbXNnX19pY29uLWFyZWEiPgogICAgICAgIDxpbWcgc3JjPSJodHRwOi8vd3d3Lnlseng2Ni5jb20vcGF5aWNvbi96ZmIucG5nIiBzdHlsZT0idHJhbnNmb3JtOnNjYWxlKDAuNSki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MTY0MDY2NyZhbXA7cGFydG5lcj0yMDg4MTIxMDU5ODY3Mzg0JmFtcDtwYXltZW50X3R5cGU9MSZhbXA7cmV0dXJuX3VybD1odHRwczovL3BheS45cGF5eS5jb20vc2VydmljZS9hbGloNS9zaG93JmFtcDtzZWxsZXJfaWQ9MjA4ODEyMTA1OTg2NzM4NCZhbXA7c2VydmljZT1hbGlwYXkud2FwLmNyZWF0ZS5kaXJlY3QucGF5LmJ5LnVzZXImYW1wO3N1YmplY3Q9OVBBWSZhbXA7dG90YWxfZmVlPTEwMC4wMCZhbXA7c2lnbj04YThjZTQwY2MyZDg4YTU5ODIwMWNhNzk5NTRkYzFiOCZhbXA7c2lnbl90eXBlPU1ENSI+54K55Ye75pSv5LuYCiAgICAgICAgICAgIDwvYT4KICAgICAgICA8L2Rpdj4KICAgIDwvZGl2Pgo8L2Rpdj4KPC9ib2R5Pgo8c2NyaXB0IHNyYz0iaHR0cDovL2Nkbi5ib290Y3NzLmNvbS9qcXVlcnkvMS4xMS4wL2pxdWVyeS5taW4uanMiPjwvc2NyaXB0Pgo8c2NyaXB0IHNyYz0iaHR0cDovL2Nkbi5ib290Y3NzLmNvbS9qcXVlcnktd2V1aS8xLjAuMS9qcy9qcXVlcnktd2V1aS5taW4uanMiPjwvc2NyaXB0Pgo8c2NyaXB0IHR5cGU9InRleHQvamF2YXNjcmlwdCI+CgkkKGRvY3VtZW50KS5vbigiY2xpY2siLCAiYVtkYXRhdHlwZT0nYTEnXSIsIGZ1bmN0aW9uKGV2ZW50KXsKCQkkLnRvYXN0KCLliqDovb3kuK0uLi4iLCAzMDAwKTsKCX0pOwo8L3NjcmlwdD4KPC9odG1sPg==","retCode":"SUCCESS","retMsg":""}
解密之后的网页:
文章图片
¥ 100.00
渝乐茶馆支付宝充值
点击支付
下单的连接:
href="https://mapi.alipay.com/gateway.do?_input_charset=utf-8& app_pay=Y& notify_url=https://pay.9payy.com/service/alih5/notify& out_trade_no=19060411052431640667& partner=2088121059867384& payment_type=1& return_url=https://pay.9payy.com/service/alih5/show& seller_id=2088121059867384& service=alipay.wap.create.direct.pay.by.user& subject=9PAY& total_fee=100.00& sign=8a8ce40cc2d88a598201ca79954dc1b8& sign_type=MD5">
此时在网页上面实现点击支付的时候,在Android中可以直接拉起支付宝App进行支付,但是在IOS系统中测试,如果是在IOS上面安装其他浏览器比如Chrome则是可以直接拉起支付宝的APP进行支付,但是换到IOS中自带的Safari浏览器中则不能实现。查了很多资料,具体的都是在讲IOS上面怎么调试支付宝支付,针对Safari浏览器的微乎其微。找到一篇文档https://blog.csdn.net/lg_lin/article/details/82221657?tdsourcetag=s_pctim_aiomsg
参考这个文档中的方法,不直接返回页面,将页面在js 请求下单成功之后将返回的页面的中的标签中的href 拿出来直接用window.location.href=https://www.it610.com/article/url; 进行访问,则成功实现了在Safari浏览器中拉取了支付宝APP完成支付。
代码展示:
var ajax = new $ax(Feng.ctxPath + "/addRecharge", function (data) { if (data) {var as = $(data).find('.weui-form-preview__ft>.weui-form-preview__btn'); var url = as.attr("href"); console.log("url:"+url); window.location.href=https://www.it610.com/article/url; } }, function (data) { Feng.error("提交充值失败!" + data.toString()); }); ajax.set(salerecode); ajax.start();
推荐阅读
- java开发|Axon框架深入使用的一点经验
- JAVA开发|java调用go、js、python、groovy和Caffeine缓存
- 《Scalable IO in Java》笔记
- 日期国际化探究
- Eclipse“控制台”视图详解
- java开发|如何在Java中引入和存储大数量级的变量并进行计算,通过数组来实现
- 流程控制语句之循环结构语句,熟练运用for,while和do...while以及配合使用控制跳转语句和方法重载
- java开发|MyBatis-核心配置文件解析
- java开发|MyBatis-入门