|
@@ -216,7 +216,8 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
|
private var successfulPaymentsNumber = 0
|
|
|
private var license1 = ""
|
|
|
private var licenseAI1 = ""
|
|
|
-
|
|
|
+ private var isApplyCoupon: Bool = false
|
|
|
+
|
|
|
@objc static func currentFirstTrialWC(_ productId: String) -> KMPurchaseEmbeddedWindowController {
|
|
|
if currentWindowController != nil {
|
|
|
currentWindowController.productID = productId
|
|
@@ -520,11 +521,7 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
|
alert.messageText = NSLocalizedString("Error Information", comment: "")
|
|
|
alert.informativeText = NSLocalizedString("Please make sure your internet connection is available.", comment: "")
|
|
|
alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
|
|
|
- if alert.responds(to: #selector(alert.beginSheetModal(for:completionHandler:))) {
|
|
|
- alert.beginSheetModal(for: self.window!, completionHandler: nil)
|
|
|
- } else {
|
|
|
- alert.runModal()
|
|
|
- }
|
|
|
+ alert.runModal()
|
|
|
return
|
|
|
}
|
|
|
|
|
@@ -773,7 +770,11 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
|
couponView.isHidden = false
|
|
|
} else {
|
|
|
discountView.isHidden = false
|
|
|
- couponView.isHidden = true
|
|
|
+ if self.discountScale == "" && self.discountAmount == "" {
|
|
|
+ couponView.isHidden = true
|
|
|
+ } else {
|
|
|
+ couponView.isHidden = false
|
|
|
+ }
|
|
|
}
|
|
|
discountLayoutConstraint.constant = discountView.isHidden ? -CGRectGetHeight(discountView.bounds) : 8
|
|
|
}
|
|
@@ -935,11 +936,7 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
|
alert.messageText = NSLocalizedString("Error Information", comment: "")
|
|
|
alert.informativeText = NSLocalizedString("Please enter a coupon code.", comment: "")
|
|
|
alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
|
|
|
- if alert.responds(to: #selector(alert.beginSheetModal(for:completionHandler:))) {
|
|
|
- alert.beginSheetModal(for: self.window!, completionHandler: nil)
|
|
|
- } else {
|
|
|
- alert.runModal()
|
|
|
- }
|
|
|
+ alert.runModal()
|
|
|
return
|
|
|
}
|
|
|
self.refreshCouponError(isReveal: false)
|
|
@@ -1063,16 +1060,6 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
|
|
|
|
@IBAction func buyAction(_ sender: NSButton) {
|
|
|
if emailTextField.stringValue == "" {
|
|
|
-// let alert = NSAlert()
|
|
|
-// alert.alertStyle = .critical
|
|
|
-// alert.messageText = NSLocalizedString("Connection Error", comment: "")
|
|
|
-// alert.informativeText = NSLocalizedString("The email address is empty.", comment: "")
|
|
|
-// alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
|
|
|
-// if alert.responds(to: #selector(alert.beginSheetModal(for:completionHandler:))) {
|
|
|
-// alert.beginSheetModal(for: self.window!, completionHandler: nil)
|
|
|
-// } else {
|
|
|
-// alert.runModal()
|
|
|
-// }
|
|
|
emailErrorLabel(isReveal: true)
|
|
|
return
|
|
|
}
|
|
@@ -1083,11 +1070,8 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
|
alert.messageText = NSLocalizedString("Error Information", comment: "")
|
|
|
alert.informativeText = NSLocalizedString("Please enter the correct postcode.", comment: "")
|
|
|
alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
|
|
|
- if alert.responds(to: #selector(alert.beginSheetModal(for:completionHandler:))) {
|
|
|
- alert.beginSheetModal(for: self.window!, completionHandler: nil)
|
|
|
- } else {
|
|
|
- alert.runModal()
|
|
|
- }
|
|
|
+ alert.runModal()
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
}
|
|
@@ -1103,16 +1087,16 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
|
weChatBox.fillColor = NSColor(named: "KMPurchaseBoxColor1") ?? NSColor.blue
|
|
|
}
|
|
|
DispatchQueue.main.asyncAfter(deadline: .now() + 1.0) { [weak self] in
|
|
|
- guard let self = self else { return }
|
|
|
- if self.paymentMethod == .paypal {
|
|
|
- self.paypalBox.fillColor = NSColor(named: "KMPurchaseBoxColor") ?? NSColor.blue
|
|
|
- } else if self._paymentMethod == .paddle {
|
|
|
- self.paddleView.wantsLayer = true
|
|
|
- self.paddleView.layer?.backgroundColor = NSColor(named: "KMPurchaseBoxColor")?.cgColor ?? NSColor.blue.cgColor
|
|
|
- } else if self._paymentMethod == .wxpay {
|
|
|
- self.weChatBox.fillColor = NSColor(named: "KMPurchaseBoxColor") ?? NSColor.blue
|
|
|
- } else if self._paymentMethod == .alipay {
|
|
|
- self.weChatBox.fillColor = NSColor(named: "KMPurchaseBoxColor") ?? NSColor.blue
|
|
|
+ guard let strongSelf = self else { return }
|
|
|
+ if strongSelf.paymentMethod == .paypal {
|
|
|
+ strongSelf.paypalBox.fillColor = NSColor(named: "KMPurchaseBoxColor") ?? NSColor.blue
|
|
|
+ } else if strongSelf.paymentMethod == .paddle {
|
|
|
+ strongSelf.paddleView.wantsLayer = true
|
|
|
+ strongSelf.paddleView.layer?.backgroundColor = NSColor(named: "KMPurchaseBoxColor")?.cgColor ?? NSColor.blue.cgColor
|
|
|
+ } else if strongSelf.paymentMethod == .wxpay {
|
|
|
+ strongSelf.weChatBox.fillColor = NSColor(named: "KMPurchaseBoxColor") ?? NSColor.blue
|
|
|
+ } else if strongSelf.paymentMethod == .alipay {
|
|
|
+ strongSelf.weChatBox.fillColor = NSColor(named: "KMPurchaseBoxColor") ?? NSColor.blue
|
|
|
}
|
|
|
}
|
|
|
|
|
@@ -1126,11 +1110,8 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
|
alert.messageText = NSLocalizedString("Error Information", comment: "")
|
|
|
alert.informativeText = NSLocalizedString("Input license code previously activated the app", comment: "")
|
|
|
alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
|
|
|
- if alert.responds(to: #selector(alert.beginSheetModal(for:completionHandler:))) {
|
|
|
- alert.beginSheetModal(for: self.window!, completionHandler: nil)
|
|
|
- } else {
|
|
|
- alert.runModal()
|
|
|
- }
|
|
|
+ alert.runModal()
|
|
|
+
|
|
|
return
|
|
|
}
|
|
|
if let license = VerificationManager.default().originLicenseCode, license.count > 0 {
|
|
@@ -1144,12 +1125,13 @@ 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 {
|
|
|
- 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()
|
|
|
-
|
|
|
+ DispatchQueue.main.async {
|
|
|
+ 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 {
|
|
@@ -1166,11 +1148,13 @@ 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()
|
|
|
+ DispatchQueue.main.async {
|
|
|
+ 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()
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
}
|
|
@@ -1486,6 +1470,11 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
|
guard let self = self else { return }
|
|
|
// let wc = KMEmbeddedPaymentPopWC.init(windowNibName: "KMEmbeddedPaymentPopWC")
|
|
|
self.embeddedPaymentPopWC = KMEmbeddedPaymentPopWC.currentFirstTrialWC(urlPath)
|
|
|
+ if self.paymentMethod == .paddle {
|
|
|
+ self.embeddedPaymentPopWC?.isPaddle = true
|
|
|
+ self.embeddedPaymentPopWC?.countryCode = self.countryAbbreviationValues[self.paddlePopUpButton.indexOfSelectedItem]
|
|
|
+ self.embeddedPaymentPopWC?.postCode = self.paddleTextField.stringValue
|
|
|
+ }
|
|
|
self.embeddedPaymentPopWC?.showWindow(nil)
|
|
|
self.embeddedPaymentPopWC?.callback = { isClose in
|
|
|
// let alert = NSAlert()
|
|
@@ -1742,13 +1731,11 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
|
let infoDic = ["cdkey": license]
|
|
|
VerificationManager.default().activateDevice(withInfo: infoDic) { status, info, error in
|
|
|
if error != nil {
|
|
|
- let alert = NSAlert()
|
|
|
- alert.alertStyle = .critical
|
|
|
- alert.messageText = NSLocalizedString("Activation Error", comment: "")
|
|
|
- alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
|
|
|
- if alert.responds(to: #selector(alert.beginSheetModal(for:completionHandler:))) {
|
|
|
- alert.beginSheetModal(for: self.window!, completionHandler: nil)
|
|
|
- } else {
|
|
|
+ DispatchQueue.main.async {
|
|
|
+ let alert = NSAlert()
|
|
|
+ alert.alertStyle = .critical
|
|
|
+ alert.messageText = NSLocalizedString("Activation Error", comment: "")
|
|
|
+ alert.addButton(withTitle: NSLocalizedString("OK", comment: ""))
|
|
|
alert.runModal()
|
|
|
}
|
|
|
return
|
|
@@ -1818,6 +1805,7 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
|
addButton1.isEnabled = true
|
|
|
aiAddOnButton1.isEnabled = true
|
|
|
extendedButton1.isEnabled = true
|
|
|
+ coupomTextField.isEnabled = true
|
|
|
couponButton.isEnabled = true
|
|
|
emailTextField.isEnabled = true
|
|
|
licenseCodeTextField.isEnabled = true
|