1.添加框架
•AlipaySDK.framework.png
2.确保有框架在里面
• • AlipaySDK.framework.png
3在桥接文件中添加 头文件
Copyright © 2019 jiangpeng. All righ.png
4,
MEt IbnOreP appTEL, SDRSSNXNIKOIRU NOA a.png
Identifier AliPay.png
5 创建一个类 (这里的最下面的方法 里的fromScheme 参数 要和上面的URL 保持一致)
import UIKit
public class AliPayUtils: NSObject {
var context:UIViewController;
public init(context:UIViewController) {
self.context = context;
}
public func pay(sign:String){
let decodedData = sign.data(using: String.Encoding(rawValue: String.Encoding.utf8.rawValue))!
let decodedString:String = (NSString(data: decodedData, encoding: String.Encoding.utf8.rawValue))! as String
AlipaySDK.defaultService().payOrder(decodedString, fromScheme: "yuanmaoAliPay", callback: { (resp) in
print(resp as Any)
} )
}
}
6.调起支付
selectPayForView.zfbJump=.png
网友评论