| | |
| | | /// 微信AppID |
| | | private var weChat_appID: String? |
| | | |
| | | private var weChat_Mini:String? |
| | | |
| | | private var didReceivePaymentInfos: ((_ result: YYPaymentResult) -> Void)? |
| | | |
| | | } |
| | |
| | | /// 配置微信AppID |
| | | /// |
| | | /// - Parameter appID: 微信AppID |
| | | func configuredWeChat(appID: String,universalLink:String) { |
| | | func configuredWeChat(appID: String,universalLink:String,weChat_Mini:String? = nil) { |
| | | |
| | | weChat_appID = appID |
| | | self.weChat_Mini = weChat_Mini |
| | | WXApi.registerApp(appID, universalLink: universalLink) |
| | | } |
| | | } |
| | |
| | | } |
| | | } |
| | | |
| | | // /// 拉起小程序支付 |
| | | // func sendWXPaymentRequest(_ request: YYWeChatMiniProgramPayRequest,didReceive result: @escaping (YYPaymentResult) -> Void) { |
| | | // |
| | | // guard WXApi.isWXAppInstalled() else { |
| | | // self.delegate?.paymentManager(self, didReceivePayment: .failure(NSError(domain: "com.paymentManager.error", code: -9999, userInfo: [NSLocalizedDescriptionKey: "未安装微信"]))) |
| | | // result(.failure(NSError(domain: "com.paymentManager.error", code: -9999, userInfo: [NSLocalizedDescriptionKey: "未安装微信"]))) |
| | | // return |
| | | // } |
| | | // let launchMiniProgramReq = WXLaunchMiniProgramReq.object() |
| | | // // /拉起的小程序的username-原始ID |
| | | // launchMiniProgramReq.userName = "gh_33e52f44fac0" |
| | | // // 拉起小程序页面的可带参路径,不填默认拉起小程序首页 |
| | | // launchMiniProgramReq.path = "/pages/appPay/appPay?orderId=\(request.orderId ?? 0)&orderType=\(request.orderType ?? 0)&type=\(request.type)&uid=\(request.uid)&userType=\(request.userType)&content=\(request.content ?? "")" |
| | | // launchMiniProgramReq.miniProgramType = .release |
| | | //// launchMiniProgramReq.extMsg = request.toJSONString() |
| | | // WXApi.send(launchMiniProgramReq) { (success) in |
| | | // |
| | | // } |
| | | // } |
| | | /// 拉起小程序支付 |
| | | func sendWXPaymentRequest(_ request: YYWeChatMiniProgramPayRequest,didReceive result: @escaping (YYPaymentResult) -> Void) { |
| | | |
| | | guard WXApi.isWXAppInstalled() else { |
| | | self.delegate?.paymentManager(self, didReceivePayment: .failure(NSError(domain: "com.paymentManager.error", code: -9999, userInfo: [NSLocalizedDescriptionKey: "未安装微信"]))) |
| | | result(.failure(NSError(domain: "com.paymentManager.error", code: -9999, userInfo: [NSLocalizedDescriptionKey: "未安装微信"]))) |
| | | return |
| | | } |
| | | let launchMiniProgramReq = WXLaunchMiniProgramReq.object() |
| | | // /拉起的小程序的username-原始ID |
| | | launchMiniProgramReq.userName = weChat_Mini ?? "" |
| | | // 拉起小程序页面的可带参路径,不填默认拉起小程序首页 |
| | | launchMiniProgramReq.path = "/pages/appPay/appPay?orderId=\(request.orderId ?? 0)&orderType=\(request.orderType ?? 0)&type=\(request.type)&uid=\(request.uid)&userType=\(request.userType)&content=\(request.content ?? "")" |
| | | launchMiniProgramReq.miniProgramType = .release |
| | | // launchMiniProgramReq.extMsg = request.toJSONString() |
| | | WXApi.send(launchMiniProgramReq) { (success) in |
| | | |
| | | } |
| | | } |
| | | |
| | | /// 发送微信支付请求 |
| | | /// |
| | |
| | | |
| | | return handle(open: url) |
| | | } |
| | | |
| | | @discardableResult |
| | | func handleApplication(_ userActivity: NSUserActivity)->Bool{ |
| | | return WXApi.handleOpenUniversalLink(userActivity, delegate: self) |
| | | } |
| | | |
| | | private func handle(open url: URL) -> Bool { |
| | | if url.host == "safepay" { |
| | |
| | | } |
| | | } |
| | | } |
| | | |
| | | func onReq(_ req: BaseReq) { |
| | | |
| | | } |
| | | |
| | | } |
| | | |