微信支付回调不执行application(_ app:, open url: , options: )方法

微信回调可能会走两个方法:

1.scheme回调

    func application(_ app: UIApplication, open url: URL, options: [UIApplication.OpenURLOptionsKey : Any] = [:]) -> Bool {
        
        if url.host == "safepay"{
            AlipaySDK.defaultService()?.processOrder(withPaymentResult: url, standbyCallback: { (result) in
                printLogDebug(result)
                if result!["resultStatus"] as! String == "9000"{
                    NotificationCenter.default.post(name: NSNotification.Name("PaySuccess"), object: self, userInfo: nil)
                }
            })
        }
        if url.scheme == "wx0000000000" {
            if url.host == "pay"{
                let components = NSURLComponents.init(string: url.relativeString)
                let s = components?.queryItems?.last
                printLogDebug(components?.queryItems?.last)
                if s?.value == "0" {
                    NotificationCenter.default.post(name: NSNotification.Name("PaySuccess"), object: self, userInfo: nil)
                }
            }
            // 微信 的回调
            return WXApi.handleOpen(url, delegate: self)
        }
        return true
    }

2.Universal Link回调

 func application(_ application: UIApplication, continue userActivity: NSUserActivity, restorationHandler: @escaping ([UIUserActivityRestoring]?) -> Void) -> Bool {
       if userActivity.activityType == NSUserActivityTypeBrowsingWeb {
           if let url = userActivity.webpageURL {
               let urlStr: String = String(url.absoluteString)

               if urlStr.contains("wx000000000/pay") { // 微信支付
                   guard let range: Range = urlStr.range(of: "ret=") else { return true }
                   // 截取url返回的状态值
                   let code: Substring = urlStr[range.upperBound..

3.支付宝网页支付回调

支付宝网页支付,不会走APPDelegate回调,需要在以下方法中处理回调事件:

AlipaySDK.defaultService()?.payOrder(payParams, fromScheme: appScheme, callback: { (dict) in
           self.zhifubaoPay(resultDic: dict ?? [:])
})

你可能感兴趣的:(微信支付回调不执行application(_ app:, open url: , options: )方法)