nixzhu / MonkeyKing

MonkeyKing helps you to post messages to Chinese Social Networks.
MIT License
2.76k stars 240 forks source link

支付宝支付相关 #191

Open sjxt opened 3 years ago

sjxt commented 3 years ago

MonkeyKing 对于后台返回了签名字符串进行支付宝支付没有进行相关的文档,只是在【请问支持现在支付宝最新的APP支付吗?】这个问题的回复中找到了相关步骤说明,已成功调起支付,在此贡献一下粗略的代码,给后面集成支付宝支付的朋友节省点时间

// 1、拿到服务端生成的字符串 let dataString = json["data"].stringValue

// 2、拼接成一个json let json: [String: Any] = ["fromAppUrlScheme":"ap11111111","requestType":"SafePay","dataString":dataString]

// 3、拼接完后,对整个json进行 url encode let encodeString = json.jsonString()?.addingPercentEncoding(withAllowedCharacters: .urlQueryAllowed)

// 4、最前面加上:alipay://alipayclient/? let url = URL(string: "alipay://alipayclient/?(encodeString ?? "")") let order = MonkeyKing.Order.alipay(url: url!) MonkeyKing.deliver(order) { (result) in

}

nixzhu commented 3 years ago

@sjxt 你可考虑增加一个 Alipay.md 把你的经验整理出来作为文档(步骤和常见疑问点),然后发个 PR

sjxt commented 3 years ago

@nixzhu 好的呢 之后把微信支付弄好了,有时间的话一起弄一个

CoderLGL commented 3 years ago

@nixzhu @sjxt 感谢,我也遇到同样的问题,正好借此解决