|
@@ -56,6 +56,7 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
|
@IBOutlet weak var discountPriceLabel3: NSTextField! // 折扣
|
|
|
@IBOutlet weak var extendedButton1: NSButton!
|
|
|
|
|
|
+ @IBOutlet weak var couponView: NSView!
|
|
|
@IBOutlet weak var couponButton: NSButton!
|
|
|
@IBOutlet weak var couponBox: NSBox!
|
|
|
@IBOutlet weak var coupomTextField: NSTextField!
|
|
@@ -762,9 +763,6 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
|
paySumLabel1.stringValue = String(format: "%@ %@", abbreviation, String(format: "%.2f", paySum))
|
|
|
|
|
|
if self.discountScale == "" && self.discountAmount == "" {
|
|
|
- if lastPriceLabel1.stringValue != paySumLabel1.stringValue {
|
|
|
- couponButton.isHidden = true
|
|
|
- }
|
|
|
refreshApplyButton(isReveal: true)
|
|
|
} else {
|
|
|
refreshApplyButton(isReveal: false)
|
|
@@ -772,8 +770,10 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
|
|
|
|
if discount == 0 {
|
|
|
discountView.isHidden = true
|
|
|
+ couponView.isHidden = false
|
|
|
} else {
|
|
|
discountView.isHidden = false
|
|
|
+ couponView.isHidden = true
|
|
|
}
|
|
|
discountLayoutConstraint.constant = discountView.isHidden ? -CGRectGetHeight(discountView.bounds) : 8
|
|
|
}
|
|
@@ -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)
|
|
@@ -1129,7 +1143,15 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
|
}
|
|
|
self._buyProduct(productID, count: pdfCount, discountId: couponCode, payment: paymentMethod, license: licenseCode, email: emailTextField.stringValue) { [weak self] info, err in
|
|
|
guard let self = self else { return }
|
|
|
- if err != nil {return}
|
|
|
+ if err != nil {
|
|
|
+ let alert = NSAlert()
|
|
|
+ alert.alertStyle = .critical
|
|
|
+ alert.messageText = NSLocalizedString("Please check if the information is wrong or the network is error.", comment: "")
|
|
|
+ alert.addButton(withTitle: NSLocalizedString("Yes", comment: ""))
|
|
|
+ alert.runModal()
|
|
|
+
|
|
|
+ return
|
|
|
+ }
|
|
|
if let dataInfo = info {
|
|
|
self.orderID = dataInfo["trade_no"] as! String
|
|
|
let page_pay_url = dataInfo["page_pay_url"] as! String
|
|
@@ -1144,6 +1166,11 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
|
}
|
|
|
} else {
|
|
|
// 数据错误
|
|
|
+ let alert = NSAlert()
|
|
|
+ alert.alertStyle = .critical
|
|
|
+ alert.messageText = NSLocalizedString("Please check if the information is wrong or the network is error.", comment: "")
|
|
|
+ alert.addButton(withTitle: NSLocalizedString("Yes", comment: ""))
|
|
|
+ alert.runModal()
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1606,6 +1633,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 +1654,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 }
|