跳至主要内容

博文

目前显示的是 十月, 2021的博文

iOS集成H5微信支付实现跳转与回调的解决方案

 原文链接 前言 最近有个需求,不能在iOS客户端内集成支付宝和微信的App支付SDK(为了防苹果审核检测SDK),因此使用H5支付,虽然微信和支付宝的H5支付文档都说不要在App内使用H5支付而是使用App支付,但办法总是有的。 这篇讲的是H5微信支付如何从App跳转微信以及如何从微信跳转回App,支付宝的见这篇: iOS集成支付宝H5支付实现跳转与回调的解决方案 实现的效果是:App→微信→支付(成功失败或取消)→App 前置准备 本项目使用WKWebView,前置动作是后端小伙伴已经处理好微信H5支付下单链接,客户端接收到下单链接后的操作。 下单链接即为 微信支付文档-统一下单API 中返回的  mweb_url ,格式为  https://wx.tenpay.com/cgi-bin/mmpayweb-bin/checkmweb?prepay_id=wx2016121516420242444321ca0631331346&package=1405458241 。 操作步骤 1. 添加 URL Scheme 并把微信加入白名单 添加 URL Scheme。在  xcodeproj  文件  Info  选项卡最下面的  URL Types 内设置。 注意此URL的一级域名需要与微信商户后台(微信商户平台-产品中心-开发配置-H5支付)设置的的一级域名一致,比如微信商户里设置的是 company.com ,那 URL Schemes 可以设为  a1.company.com ,此特性使得一套H5支付可以方便得集成到多个App。只有一个App需要H5支付的话也可以直接填与微信后台的一致的  company.com  。 2019年4月10日更新 如果像上图那样填的是  www.company.com ,那 URL Scheme 只能设为其三级域名如  a2.www.company.com  或同样的  www.company.com 把微信的 URL Scheme  weixin  和  wechat  填入项目的白名单。在  xcodeproj  文件...

iOS realizes H5 payment (WeChat, Alipay) native encapsulation

 原文链接 preface Payment is divided into app payment,  H5 payment  and code scanning payment. App payment is generally used in apps, and the corresponding payment SDK needs to be integrated. H5 payment is mostly used for web pages. If your app doesn’t want to integrate the payment SDK and wants to realize the payment function, you can use H5 payment in the project. This article mainly talks about how to package H5 payment into a native callable component. 1. H5 payment process Note: the following is the payment process of webpage H5, and the original call needs to modify some processes 1.1 wechat payment Unified order, access to wechat middle page address mweb_ url Page redirection to wechat middle page Wechat middle page initiates payment request Safari browser intercepts payment request and opens wechat app to start payment (if in app, you need to intercept payment request in shouldstartloadwithrequest: method and open wechat) Wechat middle page to redirect again_ url 1.2 ...