Browse Source

【综合】合并代码

tangchao 6 months ago
parent
commit
ec40782503

+ 14 - 6
PDF Office/PDF Master/Class/GuideInfo/KMFunctionGuideWindowController.swift

@@ -96,15 +96,23 @@ class KMFunctionGuideWindowController: NSWindowController {
                     if controller.currentNameKEY == controller.AIInfoKey {
 //                        var url = URL(string: AIProduct_Link)!
 //                        NSWorkspace.shared.open(url)
-                        let singleTon = KMPurchaseCompareDMGWindowController.init()
-                        singleTon.showWindow(nil)
-                        singleTon.window?.center()
+                        if AIInfoManager.default().aiInfoValid {
+                            self?.closeAction()
+                        } else {
+                            let singleTon = KMPurchaseCompareDMGWindowController.init()
+                            singleTon.showWindow(nil)
+                            singleTon.window?.center()
+                        }
                     } else if controller.currentNameKEY == controller.MeasureInfoKey {
 //                        var url = URL(string: Store_Link)!
 //                        NSWorkspace.shared.open(url)
-                        let singleTon = KMPurchaseCompareDMGWindowController.init()
-                        singleTon.showWindow(nil)
-                        singleTon.window?.center()
+                        if VerificationManager.default().status == ActivityStatusVerification {
+                            self?.closeAction()
+                        } else {
+                            let singleTon = KMPurchaseCompareDMGWindowController.init()
+                            singleTon.showWindow(nil)
+                            singleTon.window?.center()
+                        }
                     } else {
                         KMPrint("请配置Key...")
                     }

+ 2 - 0
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/CPDFAnnotationModel.m

@@ -267,6 +267,8 @@
         NSUserDefaults *userDefaults = [NSUserDefaults standardUserDefaults];
         switch (_annotationType) {
             case CAnnotationTypeFreeText:
+                color = [userDefaults PDFListViewColorForKey:CFreeTextNoteBorderColorKey] ? : NSColor.clearColor;
+                break;
             case CAnnotationTypeSignText:
             case CAnnotationTypeSignDate:
                 color = [userDefaults PDFListViewColorForKey:CFreeTextNoteBorderColorKey] ? : NSColor.whiteColor;

+ 5 - 1
PDF Office/PDF Master/Class/PDFWindowController/PDFListView/CPDFKitExtensions/CPDFAnnotationExtensions/CPDFFreeTextAnnotation+PDFListView.swift

@@ -19,7 +19,11 @@ import Foundation
             if ((red == 0) && (green == 0) && (blue == 0) && (alpha == 1)) {
                 self.color = nil
             } else {
-                self.color = model.color()
+                if model.color().isEqual(to: NSColor.clear) {
+                    self.color = nil
+                } else {
+                    self.color = model.color()
+                }
             }
             
             if let data = model.fontColor() {

+ 40 - 9
PDF Office/PDF Master/Class/Purchase/DMG/KMPurchaseCompareDMGWindowController.m

@@ -159,6 +159,7 @@ static NSString *const KMPurchaseCompareDMGCellIdentifier       = @"KMPurchaseCo
 @property (assign) IBOutlet NSTextField *parmanentVerInfoLbl7;
 @property (assign) IBOutlet NSTextField *parmanentVerInfoLbl8;
 @property (assign) IBOutlet NSTextField *parmanentVerInfoLbl9;
+@property (weak) IBOutlet NSImageView *parmanentVerInfoImage1;
 
 @property (weak) IBOutlet NSTextField *parmanentVerInfoLbl10;
 
@@ -260,6 +261,7 @@ static NSString *const KMPurchaseCompareDMGCellIdentifier       = @"KMPurchaseCo
     self.freeVersionInfoLbl8.stringValue = self.parmanentVerInfoLbl8.stringValue = NSLocalizedString(@"OCR PDFs", nil);
     self.freeVersionInfoLbl9.stringValue = self.parmanentVerInfoLbl9.stringValue = NSLocalizedString(@"Measuring Tools", nil);
     self.freeVersionInfoLbl10.stringValue = self.parmanentVerInfoLbl10.stringValue = NSLocalizedString(@"Ad-free", nil);
+    [self refreshParmanentVerInfo];
 
 //    self.parmanentVerinfoimg2.toolTip = NSLocalizedString(@"Support insert links and custom stamps", nil);
     self.parmanentVerInfoBtn2.mouseMoveCallback = ^(BOOL mouseEntered) {
@@ -593,6 +595,34 @@ static NSString *const KMPurchaseCompareDMGCellIdentifier       = @"KMPurchaseCo
 //    }
 //}
 
+- (void)refreshParmanentVerInfo {
+    if ([self.buySwitch state] == NSControlStateValueOn) {
+        self.parmanentVerInfoLbl1.stringValue = NSLocalizedString(@"View PDFs", nil);
+        self.parmanentVerInfoLbl2.stringValue = NSLocalizedString(@"Annotate PDFs (advanced)", nil);
+        self.parmanentVerInfoLbl3.stringValue = NSLocalizedString(@"Unlimited file conversion", nil);
+        self.parmanentVerInfoLbl4.stringValue = NSLocalizedString(@"Edit PDF text and images", nil);
+        self.parmanentVerInfoLbl5.stringValue = NSLocalizedString(@"Digital signature", nil);
+        self.parmanentVerInfoLbl6.stringValue = NSLocalizedString(@"Organize pages", nil);
+        self.parmanentVerInfoLbl7.stringValue = NSLocalizedString(@"Batch process", nil);
+        self.parmanentVerInfoLbl8.stringValue = NSLocalizedString(@"OCR PDFs", nil);
+        self.parmanentVerInfoLbl9.stringValue = NSLocalizedString(@"Measuring Tools", nil);
+        self.parmanentVerInfoLbl10.stringValue = NSLocalizedString(@"Ad-free", nil);
+        self.parmanentVerInfoImage1.image = [NSImage imageNamed:@"function_vip"];
+    } else {
+        self.parmanentVerInfoLbl1.stringValue = NSLocalizedString(@"Unlimited file conversion", nil);
+        self.parmanentVerInfoLbl2.stringValue = NSLocalizedString(@"Annotate PDFs (advanced)", nil);
+        self.parmanentVerInfoLbl3.stringValue = NSLocalizedString(@"View PDFs", nil);
+        self.parmanentVerInfoLbl4.stringValue = NSLocalizedString(@"Edit PDF text and images", nil);
+        self.parmanentVerInfoLbl5.stringValue = NSLocalizedString(@"Digital signature", nil);
+        self.parmanentVerInfoLbl6.stringValue = NSLocalizedString(@"Organize pages", nil);
+        self.parmanentVerInfoLbl7.stringValue = NSLocalizedString(@"Batch process", nil);
+        self.parmanentVerInfoLbl8.stringValue = NSLocalizedString(@"OCR PDFs", nil);
+        self.parmanentVerInfoLbl9.stringValue = NSLocalizedString(@"Measuring Tools", nil);
+        self.parmanentVerInfoLbl10.stringValue = NSLocalizedString(@"Ad-free", nil);
+        self.parmanentVerInfoImage1.image = [NSImage imageNamed:@"compare_nosupport"];
+    }
+}
+
 #pragma mark - Window Method
 - (void)showWindow:(id)sender {
     [super showWindow:nil];
@@ -712,10 +742,10 @@ static NSString *const KMPurchaseCompareDMGCellIdentifier       = @"KMPurchaseCo
     NSString *paidEventName = [self _buyNowEventToPaidEventName];
     NSDictionary *paidEventParams = [self _getPaidEventParamsWith:paidEventName];
     
-    NSString *thePaidEventName = paidEventParams.allValues.firstObject;
+    NSString *thePaidEventName = paidEventParams.allKeys.firstObject;
     NSDictionary *thePaidEventParams = nil;
-    if (paidEventName != nil && paidEventParams.allKeys.firstObject != nil) {
-        thePaidEventParams = @{paidEventParams.allKeys.firstObject : paidEventName};
+    if (paidEventName != nil && paidEventParams.allValues.firstObject != nil) {
+        thePaidEventParams = @{paidEventParams.allValues.firstObject : paidEventName};
     }
     
     [self close];
@@ -795,10 +825,10 @@ static NSString *const KMPurchaseCompareDMGCellIdentifier       = @"KMPurchaseCo
     [self trackEvent_buyNow];
     NSString *paidEventName = [self _buyNowEventToPaidEventName];
     NSDictionary *paidEventParams = [self _getPaidEventParamsWith:paidEventName];
-    NSString *thePaidEventName = paidEventParams.allValues.firstObject;
+    NSString *thePaidEventName = paidEventParams.allKeys.firstObject;
     NSDictionary *thePaidEventParams = nil;
-    if (paidEventName != nil && paidEventParams.allKeys.firstObject != nil) {
-        thePaidEventParams = @{paidEventParams.allKeys.firstObject : paidEventName};
+    if (paidEventName != nil && paidEventParams.allValues.firstObject != nil) {
+        thePaidEventParams = @{paidEventParams.allValues.firstObject : paidEventName};
     }
     
     [self close];
@@ -812,6 +842,7 @@ static NSString *const KMPurchaseCompareDMGCellIdentifier       = @"KMPurchaseCo
 }
 
 - (IBAction)buySwitchAction:(NSSwitch *)sender {
+    [self refreshParmanentVerInfo];
     [self updatePriceLabel];
 }
 
@@ -834,10 +865,10 @@ static NSString *const KMPurchaseCompareDMGCellIdentifier       = @"KMPurchaseCo
 
 - (void)trackEvent_buyNow {
     NSDictionary *params = [self _getBuyNowEventParams];
-    NSString *theEventName = params.allValues.firstObject;
+    NSString *theEventName = params.allKeys.firstObject;
     NSDictionary *theParams = nil;
-    if (self.kEventName != nil && params.allKeys.firstObject != nil) {
-        theParams = @{params.allKeys.firstObject : self.kEventName};
+    if (self.kEventName != nil && params.allValues.firstObject != nil) {
+        theParams = @{params.allValues.firstObject : self.kEventName};
     }
     
     [self trackEvent_dmgWithEventName:theEventName params:theParams platform:KMAnalyticsPlatformAppCenter];

+ 1 - 0
PDF Office/PDF Master/Class/Purchase/DMG/KMPurchaseCompareDMGWindowController.xib

@@ -45,6 +45,7 @@
                 <outlet property="parmanentInfoView" destination="pBx-aL-HB5" id="bES-gi-ZXJ"/>
                 <outlet property="parmanentVerBGView" destination="sMr-Hu-FgQ" id="qBw-GC-9u7"/>
                 <outlet property="parmanentVerInfoBtn2" destination="3mX-DM-Ssw" id="wor-Lh-GWC"/>
+                <outlet property="parmanentVerInfoImage1" destination="XEN-LV-Gvh" id="tdi-Sb-6ua"/>
                 <outlet property="parmanentVerInfoLbl1" destination="zlT-ii-WYi" id="DXw-7o-Se2"/>
                 <outlet property="parmanentVerInfoLbl10" destination="HWK-kT-yEA" id="Sb9-FY-5sU"/>
                 <outlet property="parmanentVerInfoLbl2" destination="xnv-Sf-nZ1" id="4ek-uc-drU"/>

+ 126 - 92
PDF Office/PDF Master/Class/Purchase/DMG/KMPurchaseEmbeddedWindowController.swift

@@ -212,6 +212,9 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
     private var handler: ((Int) -> Void)!
     static var currentWindowController: KMPurchaseEmbeddedWindowController!
     private var embeddedPaymentPopWC: KMEmbeddedPaymentPopWC?
+    private var successfulPaymentsNumber = 0
+    private var license1 = ""
+    private var licenseAI1 = ""
     
     @objc static func currentFirstTrialWC(_ productId: String) -> KMPurchaseEmbeddedWindowController {
         if currentWindowController != nil {
@@ -605,11 +608,11 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
                     let aiBinding_discount = Float(KMDMGProductsManager.shareInstance.getActivityPrice("com.brother.pdfreaderpro.mac.product_3+com.brother.pdfreaderpro.ai.product_1")) ?? 94.98
                     let aiBinding_original = Float(KMDMGProductsManager.shareInstance.getPrice("com.brother.pdfreaderpro.mac.product_3+com.brother.pdfreaderpro.ai.product_1")) ?? 94.98
                     let cross_discount = Float(KMDMGProductsManager.shareInstance.getActivityPrice("com.brother.pdfreaderpro.cross.platform.product_3")) ?? 119.98
-                    let cross_original = Float(KMDMGProductsManager.shareInstance.getPrice("com.brother.pdfreaderpro.cross.platform.product_3")) ?? 119.98
+                    let cross_original = Float(KMDMGProductsManager.shareInstance.getPrice("com.brother.pdfreaderpro.cross.platform.product_2")) ?? 119.98
                     discount2 = aiBinding_discount - discount1
                     original2 = aiBinding_original - original1
                     discount3 = cross_discount - discount1
-                    original3 = cross_original - original1
+                    original3 = cross_original
                     
                     listPrice = (original1 * Float(amountTextField1.stringValue)!)
                     paySum = (discount1 * Float(amountTextField1.stringValue)!)
@@ -626,13 +629,13 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
                 let aiBinding_discount = Float(KMDMGProductsManager.shareInstance.getActivityPrice("com.brother.pdfreaderpro.mac.product_3+com.brother.pdfreaderpro.ai.product_1")) ?? 94.98
                 let aiBinding_original = Float(KMDMGProductsManager.shareInstance.getPrice("com.brother.pdfreaderpro.mac.product_3+com.brother.pdfreaderpro.ai.product_1")) ?? 94.98
                 let cross_discount = Float(KMDMGProductsManager.shareInstance.getActivityPrice("com.brother.pdfreaderpro.cross.platform.product_3")) ?? 119.98
-                let cross_original = Float(KMDMGProductsManager.shareInstance.getPrice("com.brother.pdfreaderpro.cross.platform.product_3")) ?? 119.98
+                let cross_original = Float(KMDMGProductsManager.shareInstance.getPrice("com.brother.pdfreaderpro.cross.platform.product_2")) ?? 119.98
                 discount2 = aiBinding_discount - discount1
                 original2 = aiBinding_original - original1
                 discount3 = cross_discount - discount1
-                original3 = cross_original - original1
+                original3 = cross_original
                 
-                listPrice = (original1 * Float(amountTextField1.stringValue)!) + (original3 * Float(amountTextField3.stringValue)!)
+                listPrice = (original1 * Float(amountTextField1.stringValue)!) + (discount3 * Float(amountTextField3.stringValue)!)
                 paySum = (discount1 * Float(amountTextField1.stringValue)!) + (discount3 * Float(amountTextField3.stringValue)!)
                 discount = listPrice - paySum
             } else if productType == .ipaPremiumAI {
@@ -678,11 +681,11 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
                     let aiBinding_discount = Float(KMDMGProductsManager.shareInstance.getActivityPrice("com.brother.pdfreaderpro.mac.product_3+com.brother.pdfreaderpro.ai.product_1")) ?? 94.98
                     let aiBinding_original = Float(KMDMGProductsManager.shareInstance.getPrice("com.brother.pdfreaderpro.mac.product_3+com.brother.pdfreaderpro.ai.product_1")) ?? 94.98
                     let cross_discount = Float(KMDMGProductsManager.shareInstance.getActivityPrice("com.brother.pdfreaderpro.cross.platform.product_3")) ?? 119.98
-                    let cross_original = Float(KMDMGProductsManager.shareInstance.getPrice("com.brother.pdfreaderpro.cross.platform.product_3")) ?? 119.98
+                    let cross_original = Float(KMDMGProductsManager.shareInstance.getPrice("com.brother.pdfreaderpro.cross.platform.product_2")) ?? 119.98
                     discount2 = aiBinding_discount - discount1
                     original2 = aiBinding_original - original1
                     discount3 = cross_discount - discount1
-                    original3 = cross_original - original1
+                    original3 = cross_original
                     
                     listPrice = (original1 * Float(amountTextField1.stringValue)!) + (original2 * Float(amountTextField2.stringValue)!)
                     paySum = (discount1 * Float(amountTextField1.stringValue)!) + (discount2 * Float(amountTextField2.stringValue)!)
@@ -697,11 +700,11 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
                 let aiBinding_discount = Float(KMDMGProductsManager.shareInstance.getActivityPrice("com.brother.pdfreaderpro.mac.product_3+com.brother.pdfreaderpro.ai.product_1")) ?? 94.98
                 let aiBinding_original = Float(KMDMGProductsManager.shareInstance.getPrice("com.brother.pdfreaderpro.mac.product_3+com.brother.pdfreaderpro.ai.product_1")) ?? 94.98
                 let cross_discount = Float(KMDMGProductsManager.shareInstance.getActivityPrice("com.brother.pdfreaderpro.cross.platform.product_3")) ?? 119.98
-                let cross_original = Float(KMDMGProductsManager.shareInstance.getPrice("com.brother.pdfreaderpro.cross.platform.product_3")) ?? 119.98
+                let cross_original = Float(KMDMGProductsManager.shareInstance.getPrice("com.brother.pdfreaderpro.cross.platform.product_2")) ?? 119.98
                 discount2 = aiBinding_discount - discount1
                 original2 = aiBinding_original - original1
                 discount3 = cross_discount - discount1
-                original3 = cross_original - original1
+                original3 = cross_original
                 
                 listPrice = (original1 * Float(amountTextField1.stringValue)!) + (original2 * Float(amountTextField2.stringValue)!) + (original3 * Float(amountTextField3.stringValue)!)
                 paySum = (discount1 * Float(amountTextField1.stringValue)!) + (discount2 * Float(amountTextField2.stringValue)!) + (discount3 * Float(amountTextField3.stringValue)!)
@@ -1033,7 +1036,7 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
     }
     
     @IBAction func paddlePopUpAction(_ sender: NSPopUpButton) {
-        buyAction(sender)
+        
     }
     
     @IBAction func couponClearButton(_ sender: NSButton) {
@@ -1507,7 +1510,7 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
         DispatchQueue.main.asyncAfter(deadline: .now() + 1) { [weak self] in
             guard let self = self else { return }
             if self.orderID == "" { return }
-            self._getOrderStatus(tradeNo: self.orderID, callback: { info, err in
+            self._getOrderStatus(tradeNo: self.orderID, callback: { [self] info, err in
                 if err == nil {
                     if let dataInfo = info {
                         if dataInfo.keys.contains("status") {
@@ -1528,20 +1531,42 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
                                 } else {
                                     self.orderID = ""
                                     self.stopPolling()
-                                    if dataInfo.keys.contains("license") {
-                                        let license = dataInfo["license"] as? [String]
-                                        if license!.count > 0 {
-                                            self.verificationActivate(license: license![0])
-                                            self.embeddedPaymentPopWC?.close()
-                                            self.embeddedPaymentPopWC = nil
+                                    if (dataInfo.keys.contains("license") && dataInfo.keys.contains("ai_license")) {
+                                        self.successfulPaymentsNumber = 2
+                                        if dataInfo.keys.contains("license") {
+                                            let license = dataInfo["license"] as? [String]
+                                            if license!.count > 0 {
+                                                self.verificationActivate(license: license![0])
+//                                                self.embeddedPaymentPopWC?.close()
+//                                                self.embeddedPaymentPopWC = nil
+                                            }
                                         }
-                                    }
-                                    if dataInfo.keys.contains("ai_license") {
-                                        let ai_license = dataInfo["ai_license"] as? [String]
-                                        if ai_license!.count > 0 {
-                                            self.verificationActivateAIInfo(license: ai_license![0])
-                                            self.embeddedPaymentPopWC?.close()
-                                            self.embeddedPaymentPopWC = nil
+                                        if dataInfo.keys.contains("ai_license") {
+                                            let ai_license = dataInfo["ai_license"] as? [String]
+                                            if ai_license!.count > 0 {
+                                                self.verificationActivateAIInfo(license: ai_license![0])
+//                                                self.embeddedPaymentPopWC?.close()
+//                                                self.embeddedPaymentPopWC = nil
+                                            }
+                                        }
+                                    } else {
+                                        self.successfulPaymentsNumber = 1
+                                        if dataInfo.keys.contains("license") {
+                                            let license = dataInfo["license"] as? [String]
+                                            if license!.count > 0 {
+                                                self.verificationActivate(license: license![0])
+//                                                self.embeddedPaymentPopWC?.close()
+//                                                self.embeddedPaymentPopWC = nil
+                                            }
+                                        } else if dataInfo.keys.contains("ai_license") {
+                                            let ai_license = dataInfo["ai_license"] as? [String]
+                                            if ai_license!.count > 0 {
+                                                if !AIInfoManager.default().aiInfoValid {
+                                                    self.verificationActivateAIInfo(license: ai_license![0])
+                                                }
+//                                                self.embeddedPaymentPopWC?.close()
+//                                                self.embeddedPaymentPopWC = nil
+                                            }
                                         }
                                     }
                                 }
@@ -1595,11 +1620,13 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
         timer?.invalidate()
         timer = nil
         print("Polling task completed.")
-        if self.embeddedPaymentPopWC != nil {
-            DispatchQueue.main.async { [weak self] in
-                guard let self = self else { return }
-                self.embeddedPaymentPopWC?.close()
-                self.embeddedPaymentPopWC = nil
+        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
+                }
             }
         }
         pollCount = 0
@@ -1616,21 +1643,45 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
                 self._trackEvent_paid()
             }
 
+            self.successfulPaymentsNumber -= 1
             if self.paymentMethod == .wxpay || self.paymentMethod == .alipay {
                 self.qrCodeImageView.isHidden = true
                 self.successfullyView.isHidden = false
+                
+                if self.successfulPaymentsNumber == 0 {
+                    if let blockSelf = self.activityAlertViewController {
+                        blockSelf.alertTitle = NSLocalizedString("Successful Activation!", comment: "")
+                        blockSelf.alertMessage = NSLocalizedString("Congratulations! You can start using PDF Reader Pro AI features.", comment: "")
+                        
+                        var frame = self.window?.frame
+                        frame!.origin.y -= blockSelf.view.frame.size.height-frame!.size.height
+                        frame!.origin.x -= (blockSelf.view.frame.size.width-frame!.size.width)/2.0
+                        frame!.size.width = blockSelf.view.frame.size.width
+                        frame!.size.height = blockSelf.view.frame.size.height
+                        self.mainBox.contentView = blockSelf.view
+                        self.window?.setFrame(frame!, display: true, animate: true)
+                        
+                        self.embeddedPaymentPopWC?.close()
+                        self.embeddedPaymentPopWC = nil
+                    }
+                }
             } else {
-                if let blockSelf = self.activityAlertViewController {
-                    blockSelf.alertTitle = NSLocalizedString("Successful Activation!", comment: "")
-                    blockSelf.alertMessage = NSLocalizedString("Congratulations! You can start using PDF Reader Pro AI features.", comment: "")
-                    
-                    var frame = self.window?.frame
-                    frame!.origin.y -= blockSelf.view.frame.size.height-frame!.size.height
-                    frame!.origin.x -= (blockSelf.view.frame.size.width-frame!.size.width)/2.0
-                    frame!.size.width = blockSelf.view.frame.size.width
-                    frame!.size.height = blockSelf.view.frame.size.height
-                    self.mainBox.contentView = blockSelf.view
-                    self.window?.setFrame(frame!, display: true, animate: true)
+                if self.successfulPaymentsNumber == 0 {
+                    if let blockSelf = self.activityAlertViewController {
+                        blockSelf.alertTitle = NSLocalizedString("Successful Activation!", comment: "")
+                        blockSelf.alertMessage = NSLocalizedString("Congratulations! You can start using PDF Reader Pro AI features.", comment: "")
+                        
+                        var frame = self.window?.frame
+                        frame!.origin.y -= blockSelf.view.frame.size.height-frame!.size.height
+                        frame!.origin.x -= (blockSelf.view.frame.size.width-frame!.size.width)/2.0
+                        frame!.size.width = blockSelf.view.frame.size.width
+                        frame!.size.height = blockSelf.view.frame.size.height
+                        self.mainBox.contentView = blockSelf.view
+                        self.window?.setFrame(frame!, display: true, animate: true)
+                        
+                        self.embeddedPaymentPopWC?.close()
+                        self.embeddedPaymentPopWC = nil
+                    }
                 }
             }
         }
@@ -1644,47 +1695,6 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
         let infoDic = ["cdkey": license]
         VerificationManager.default().activateDevice(withInfo: infoDic) { status, info, error in
             if error != nil {
-//                let tTitle0 = NSLocalizedString("The license you have entered is not correct. Please enter valid license.", comment: "")
-//                let tTitle1 = NSLocalizedString("If you have already purchased PDF Reader Pro for Mac, you should find your license in an email confirmation.", comment: "")
-//                var message = String(format: "%@\n\n%@", tTitle0, tTitle1)
-//                if let err = error as? NSError {
-//                    if ActivityErrorType(UInt32(err.code)) == ActivityErrorTypeCDKeyEmpty {
-//                        message = String(format: "%@\n\n%@", NSLocalizedString("License number can not be empty.", comment:""), "")
-//                    } else if ActivityErrorType(UInt32(err.code)) == ActivityErrorTypeCDKeyNotExist {
-//                        message = String(format: "%@\n\n%@", NSLocalizedString("License number does not exist.", comment:""), "")
-//                    } else if ActivityErrorType(UInt32(err.code)) == ActivityErrorTypeOutNumber {
-//                        message = String(format: "%@\n\n%@", NSLocalizedString("The devices connected to the license number has outnumbered.", comment:""), "")
-//                    } else if ActivityErrorType(UInt32(err.code)) == ActivityErrorTypeOutNumber {
-//                        let tMsg0 = NSLocalizedString("The devices connected to the license number has outnumbered.", comment: "")
-//                        let tMsg1 = NSLocalizedString("Please deactivate license on one of them, to use PDF Reader Pro on this computer", comment: "")
-//                        message = String(format: "%@\n\n%@", tMsg0, tMsg1)
-//                    } else if ActivityErrorType(UInt32(err.code)) == ActivityErrorTypeNetworkDisable {
-//                        message = NSLocalizedString("The network is unavailable.", comment: "")
-//                    } else if ActivityErrorType(UInt32(err.code)) == ActivityErrorTypeCDKeyExpire {
-//                        message = NSLocalizedString("The license number expired.", comment: "")
-//                    } else if ActivityErrorType(UInt32(err.code)) == ActivityErrorTypeInvalidInfo {
-//                        message = NSLocalizedString("Activation error. Please try to input correct license, or contact us.", comment: "")
-//                    } else if ActivityErrorType(UInt32(err.code)) == ActivityErrorTypeNotMatchProduct {
-//                        message = NSLocalizedString("The license number is wrong, please input right license which is for this app.", comment: "")
-//                    } else if ActivityErrorType(UInt32(err.code)) == ActivityErrorTypeFormatError {
-//                        message = NSLocalizedString("The license format is wrong. Please input correct license.", comment: "")
-//                    }
-//                    if (ActivityErrorType(UInt32(err.code)) == ActivityErrorTypeUnknow) || (ActivityErrorType(UInt32(err.code)) == ActivityErrorTypeOutNumber) {
-//                        let alert = NSAlert()
-//                        alert.alertStyle = .critical
-//                        alert.messageText = NSLocalizedString("Activation Error", comment: "")
-//                        alert.informativeText = NSLocalizedString("Contact Us", comment: "")
-//                        alert.addButton(withTitle: NSLocalizedString("Try Again", comment: ""))
-//                        if alert.responds(to: #selector(alert.beginSheetModal(for:completionHandler:))) {
-//                            alert.beginSheetModal(for: self.window!, completionHandler: nil)
-//                        } else {
-//                            alert.runModal()
-//                        }
-//                        return
-//                    } else {
-//                        
-//                    }
-//                }
                 let alert = NSAlert()
                 alert.alertStyle = .critical
                 alert.messageText = NSLocalizedString("Activation Error", comment: "")
@@ -1700,21 +1710,45 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
                     self._trackEvent_paid()
                 }
 
+                self.successfulPaymentsNumber -= 1
                 if self.paymentMethod == .wxpay || self.paymentMethod == .alipay {
                     self.qrCodeImageView.isHidden = true
                     self.successfullyView.isHidden = false
+                    
+                    if self.successfulPaymentsNumber == 0 {
+                        if let blockSelf = self.activityAlertViewController {
+                            blockSelf.alertTitle = NSLocalizedString("Successful Activation!", comment: "")
+                            blockSelf.alertMessage = NSLocalizedString("Congratulations! You can start using PDF Reader Pro features.", comment: "")
+                            
+                            var frame = self.window?.frame
+                            frame!.origin.y -= blockSelf.view.frame.size.height-frame!.size.height
+                            frame!.origin.x -= (blockSelf.view.frame.size.width-frame!.size.width)/2.0
+                            frame!.size.width = blockSelf.view.frame.size.width
+                            frame!.size.height = blockSelf.view.frame.size.height
+                            self.mainBox.contentView = blockSelf.view
+                            self.window?.setFrame(frame!, display: true, animate: true)
+                            
+                            self.embeddedPaymentPopWC?.close()
+                            self.embeddedPaymentPopWC = nil
+                        }
+                    }
                 } else {
-                    if let blockSelf = self.activityAlertViewController {
-                        blockSelf.alertTitle = NSLocalizedString("Successful Activation!", comment: "")
-                        blockSelf.alertMessage = NSLocalizedString("Congratulations! You can start using PDF Reader Pro features.", comment: "")
-                        
-                        var frame = self.window?.frame
-                        frame!.origin.y -= blockSelf.view.frame.size.height-frame!.size.height
-                        frame!.origin.x -= (blockSelf.view.frame.size.width-frame!.size.width)/2.0
-                        frame!.size.width = blockSelf.view.frame.size.width
-                        frame!.size.height = blockSelf.view.frame.size.height
-                        self.mainBox.contentView = blockSelf.view
-                        self.window?.setFrame(frame!, display: true, animate: true)
+                    if self.successfulPaymentsNumber == 0 {
+                        if let blockSelf = self.activityAlertViewController {
+                            blockSelf.alertTitle = NSLocalizedString("Successful Activation!", comment: "")
+                            blockSelf.alertMessage = NSLocalizedString("Congratulations! You can start using PDF Reader Pro features.", comment: "")
+                            
+                            var frame = self.window?.frame
+                            frame!.origin.y -= blockSelf.view.frame.size.height-frame!.size.height
+                            frame!.origin.x -= (blockSelf.view.frame.size.width-frame!.size.width)/2.0
+                            frame!.size.width = blockSelf.view.frame.size.width
+                            frame!.size.height = blockSelf.view.frame.size.height
+                            self.mainBox.contentView = blockSelf.view
+                            self.window?.setFrame(frame!, display: true, animate: true)
+                            
+                            self.embeddedPaymentPopWC?.close()
+                            self.embeddedPaymentPopWC = nil
+                        }
                     }
                 }
             }