Ver Fonte

【内嵌支付】修复优惠卷使用场景优化

wanjun há 6 meses atrás
pai
commit
5e93bad978

+ 35 - 1
PDF Office/PDF Master/Class/Purchase/DMG/KMPurchaseEmbeddedWindowController.swift

@@ -1003,6 +1003,20 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
                             self.refreshCouponError(isReveal: true)
                         }
                     } else {
+                        if dataInfo.keys.contains("limit_product_code") {
+                            if let limit_product_code = dataInfo["limit_product_code"] {
+                                if let limitCode = limit_product_code as? String {
+                                    if limitCode.count > 0 {
+                                        if self.productID != limitCode {
+                                            self.couponClearButton.isHidden = false
+                                            self.coupomErrorLabel.stringValue = NSLocalizedString("The coupon code is invalid. Please try again.", comment: "")
+                                            self.refreshCouponError(isReveal: true)
+                                            return
+                                        }
+                                    }
+                                }
+                            }
+                        }
                         if dataInfo["discount"] is NSNull && dataInfo["price"] is NSNull {
                             self.coupomErrorLabel.stringValue = NSLocalizedString("The coupon code is invalid. Please try again.", comment: "")
                             self.refreshCouponError(isReveal: true)
@@ -1606,6 +1620,13 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
 
     @objc private func performTask() {
         guard pollCount < maxPolls else {
+            timer?.invalidate()
+            timer = nil
+            DispatchQueue.main.async { [weak self] in
+                guard let self = self else { return }
+                self.embeddedPaymentPopWC?.close()
+                self.embeddedPaymentPopWC = nil
+            }
             return
         }
         
@@ -1620,7 +1641,20 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
         timer?.invalidate()
         timer = nil
         print("Polling task completed.")
-        if !AIInfoManager.default().aiInfoValid {
+        if productID == "com.brother.pdfreaderpro.ai.product_1" ||
+            productID == "com.brother.pdfreaderpro.mac.product_1+com.brother.pdfreaderpro.ai.product_1" ||
+            productID == "com.brother.pdfreaderpro.mac.product_3+com.brother.pdfreaderpro.ai.product_1" ||
+            productID == "com.brother.pdfreaderpro.cross.platform.product_3+com.brother.pdfreaderpro.ai.product_1"{
+            if !AIInfoManager.default().aiInfoValid {
+                if self.embeddedPaymentPopWC != nil {
+                    DispatchQueue.main.async { [weak self] in
+                        guard let self = self else { return }
+                        self.embeddedPaymentPopWC?.close()
+                        self.embeddedPaymentPopWC = nil
+                    }
+                }
+            }
+        } else {
             if self.embeddedPaymentPopWC != nil {
                 DispatchQueue.main.async { [weak self] in
                     guard let self = self else { return }