Procházet zdrojové kódy

【内嵌支付】修复PDF To Office购买失败,提示产品无效

wanjun před 6 měsíci
rodič
revize
493a83fb9c

+ 1 - 1
PDF Office/PDF Master/AppDelegate.swift

@@ -718,7 +718,7 @@ class AppDelegate: NSObject, NSApplicationDelegate, iRateDelegate{
 //        if tWorkSpace.open(url!) == false {
 //            tWorkSpace.open(url!)
 //        }
-        let embeddedWC = KMPurchaseEmbeddedWindowController(windowNibName: "com.brother.pdfreaderpro.mac.product_2.checkout")
+        let embeddedWC = KMPurchaseEmbeddedWindowController(windowNibName: "com.brother.pdfreaderpro.mac.product_2")
         embeddedWC.showWindow(nil)
 #endif
     }

+ 1 - 1
PDF Office/PDF Master/Class/PDFTools/Convert/NewController/KMToolCompareWindowController.swift

@@ -249,7 +249,7 @@ var currentWindowController: KMToolCompareWindowController? = nil
 //        var url = URL(string: Store_Link + "?product_code=product_2&utm_source=MacAppDmg&utm_campaign=OfficeStoreLink&utm_medium=PdfOfficeStore")
 //        NSWorkspace.shared.open(url!)
 //        FMTrackEventManager.defaultManager.trackOnceEvent(event: "PUW", withProperties: ["PUW_Btn":"Btn_PUW_PDFtoOffice_Buy"])
-        let embeddedWC = KMPurchaseEmbeddedWindowController(windowNibName: "com.brother.pdfreaderpro.mac.product_2.checkout")
+        let embeddedWC = KMPurchaseEmbeddedWindowController(windowNibName: "com.brother.pdfreaderpro.mac.product_2")
         embeddedWC.showWindow(nil)
 #endif
     }

+ 7 - 36
PDF Office/PDF Master/Class/Purchase/DMG/KMPurchaseEmbeddedWindowController.swift

@@ -240,11 +240,11 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
         originalPriceLabel1.font = NSFont.SFProTextRegularFont(16.0)
         discountPriceLabel1.textColor = NSColor(named: "KMPurchaseDiscountColor")
         discountPriceLabel1.font = NSFont.SFProTextRegularFont(9.0)
-        if productType == .ipaConvert_checkout || productType == .ipaAI {
+        if productType == .ipaConvert || productType == .ipaAI {
             aiAddOnView.isHidden = true
             extendedView.isHidden = true
             
-            if productType == .ipaConvert_checkout {
+            if productType == .ipaConvert {
                 pdfReaderProLabel.stringValue = NSLocalizedString("PDF to Office", comment: "")
                 prmiumLabel.stringValue = NSLocalizedString("Export PDF to Word(.docx), Excel (.xlsx), PowerPoint(.pptx) and more offline. It's one time purchase.", comment: "")
                 oneLicenseLabel.isHidden = true
@@ -924,7 +924,11 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
                 return
             }
         }
-        self._buyProduct(productID, count: pdfCount, discountId: coupomTextField.stringValue, payment: paymentMethod, license: VerificationManager.default().licenseCode, email: emailTextField.stringValue) { [weak self] info, err in
+        var licenseCode = ""
+        if let license = VerificationManager.default().originLicenseCode, license.count > 0 {
+            licenseCode = license
+        }
+        self._buyProduct(productID, count: pdfCount, discountId: coupomTextField.stringValue, payment: paymentMethod, license: licenseCode, email: emailTextField.stringValue) { [weak self] info, err in
             guard let self = self else { return }
             if err != nil {return}
             if let dataInfo = info {
@@ -1017,39 +1021,6 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
     
     // MARK: ——
     
-    @objc func btnAction() {
-        // 升级产品
-        let productCode = "com.brother.pdfreaderpro.windows.product_1"
-        let email = "tangchao@kdanmobile.com"
-        self._buyProduct(productCode, count: 1, discountId: "", payment: .alipay, license: "", email: email, username: "") { [weak self] info, err in
-//            // paypal_order
-//            // page_pay_url 链接
-//            // https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_express-checkout&token=EC-3V503434MD108282U
-//            // trade_no 订单id 用于校验订单 【22024083006591098】
-            if let dataInfo = info {
-                let trade_no = info?["trade_no"]
-                let page_pay_url = info?["page_pay_url"]
-
-                DispatchQueue.main.asyncAfter(deadline: .now() + 1) {
-                    self?._getOrderStatus(tradeNo: trade_no as? String ?? "", callback: { info, err in
-                        KMPrint("")
-                    })
-                }
-            } else {
-                // 数据错误
-            }
-        }
-        self._getProductDatas { info, err in
-            /*
-             activity_cny_price 优惠价(人民币)
-             activity_price 优惠价(美元)
-             price 原价(美元)
-             cny_price 原价(人民币)
-             */
-            print("111")
-        }
-    }
-    
     // 获取价格
     private func _getProductDatas(callback: @escaping (([String:Any]?, Any?)->Void)) {
 //    func getPriceUrl() {

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

@@ -161,7 +161,7 @@ class KMPurchaseLimitWindowController: NSWindowController {
 //        var url = URL(string: Store_Link + "?product_code=product_2&utm_source=MacAppDmg&utm_campaign=OfficeStoreLink&utm_medium=PdfOfficeStore")!
 //        NSWorkspace.shared.open(url)
 //        FMTrackEventManager.defaultManager.trackOnceEvent(event: "PUW", withProperties: ["PUW_Btn":"Btn_PUW_PDFtoOffice_Buy"])
-        let embeddedWC = KMPurchaseEmbeddedWindowController(windowNibName: "com.brother.pdfreaderpro.mac.product_2.checkout")
+        let embeddedWC = KMPurchaseEmbeddedWindowController(windowNibName: "com.brother.pdfreaderpro.mac.product_2")
         embeddedWC.showWindow(nil)
     }
     

+ 2 - 2
PDF Office/PDF Master/Class/Purchase/DMG/Verification/KMVerificationMessageViewController.m

@@ -485,7 +485,7 @@ NSPopoverDelegate>
 //            NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@?product_code=product_2", Swift_oc_Tool.Store_Link_OC]];
 //            [[NSWorkspace sharedWorkspace] openURL:url];
 //            [[FMTrackEventManager defaultManager] trackEventWithEvent:@"Tbr" withProperties:@{@"Tbr_Btn":@"Btn_Tbr_PDFtoOffice"}];
-            KMPurchaseEmbeddedWindowController *embeddedWC = [KMPurchaseEmbeddedWindowController currentFirstTrialWC:@"com.brother.pdfreaderpro.mac.product_2.checkout"];
+            KMPurchaseEmbeddedWindowController *embeddedWC = [KMPurchaseEmbeddedWindowController currentFirstTrialWC:@"com.brother.pdfreaderpro.mac.product_2"];
             [embeddedWC showWindow:nil];
         }
     } else {
@@ -493,7 +493,7 @@ NSPopoverDelegate>
 //            NSURL *url = [NSURL URLWithString:[NSString stringWithFormat:@"%@?product_code=product_2", Swift_oc_Tool.Store_Link_OC]];
 //            [[NSWorkspace sharedWorkspace] openURL:url];
 //            [[FMTrackEventManager defaultManager] trackEventWithEvent:@"Tbr" withProperties:@{@"Tbr_Btn":@"Btn_Tbr_PDFtoOffice"}];
-            KMPurchaseEmbeddedWindowController *embeddedWC = [KMPurchaseEmbeddedWindowController currentFirstTrialWC:@"com.brother.pdfreaderpro.mac.product_2.checkout"];
+            KMPurchaseEmbeddedWindowController *embeddedWC = [KMPurchaseEmbeddedWindowController currentFirstTrialWC:@"com.brother.pdfreaderpro.mac.product_2"];
             [embeddedWC showWindow:nil];
         } else {
             KMVerificationWindowController *vc = [KMVerificationWindowController verificationWithType:KMVerificationTypeNormal];

+ 2 - 0
PDF Office/PDF Master/Class/Purchase/DMG/Verification/VerificationManager/VerificationManager.h

@@ -64,6 +64,7 @@ typedef void(^ActivityComplention)(ActivityStatus status, NSDictionary *info, NS
 @property (nonatomic, readonly) ActivityStatus status;
 @property (nonatomic, readonly) BOOL needUpgradeLicense;
 @property (nonatomic, readonly) NSString *licenseCode;
+@property (nonatomic, readonly) NSString *originLicenseCode;
 @property (nonatomic, readonly) NSDictionary *detailInfo;
 
 @property (nonatomic, readonly) BOOL secondTrialEnabled;
@@ -145,6 +146,7 @@ typedef void(^ActivityComplention)(ActivityStatus status, NSDictionary *info, NS
 @property (nonatomic, readonly) NSDate *createDate;
 @property (nonatomic, readonly) NSDate *expireDate;
 @property (nonatomic, readonly) NSString *licenseCode;
+@property (nonatomic, readonly) NSString *originLicenseCode;
 
 @property (nonatomic, readonly) NSString *shareCode;
 @property (nonatomic, readonly) NSUInteger invateUsersCount;

+ 8 - 0
PDF Office/PDF Master/Class/Purchase/DMG/Verification/VerificationManager/VerificationManager.m

@@ -95,6 +95,10 @@ static VerificationManager *__verificationManager = nil;
     return self.detailInfo.licenseCode;
 }
 
+- (NSString *)originLicenseCode {
+    return self.detailInfo.originLicenseCode;
+}
+
 - (NSString *)email {
     return self.detailInfo.email?:@"";
 }
@@ -1067,6 +1071,10 @@ static VerificationManager *__verificationManager = nil;
     return self[@"device"][@"cdkey"];
 }
 
+- (NSString*)originLicenseCode {
+    return self[@"device"][@"origin_cdkey"];
+}
+
 - (NSString*)shareCode {
     return self[@"invite"][@"share_code"]?:@"";
 }