|
@@ -18,6 +18,8 @@ import Cocoa
|
|
|
|
|
|
class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
|
|
|
|
|
|
+ @IBOutlet weak var mainBox: NSBox!
|
|
|
|
+
|
|
@IBOutlet weak var yourOrderLabel: NSTextField!
|
|
@IBOutlet weak var yourOrderLabel: NSTextField!
|
|
|
|
|
|
@IBOutlet weak var pdfReaderProLabel: NSTextField!
|
|
@IBOutlet weak var pdfReaderProLabel: NSTextField!
|
|
@@ -141,6 +143,8 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
private let maxPolls = 18
|
|
private let maxPolls = 18
|
|
private let interval: TimeInterval = 5.0
|
|
private let interval: TimeInterval = 5.0
|
|
|
|
|
|
|
|
+ private var _activityAlertViewController: KMActivityALertViewController?
|
|
|
|
+
|
|
private let countryKeys = [
|
|
private let countryKeys = [
|
|
"Afghanistan", "Aland Islands", "Albania", "Algeria", "American Samoa",
|
|
"Afghanistan", "Aland Islands", "Albania", "Algeria", "American Samoa",
|
|
"Andorra", "Angola", "Anguilla", "Antigua and Barbuda", "Argentina",
|
|
"Andorra", "Angola", "Anguilla", "Antigua and Barbuda", "Argentina",
|
|
@@ -1583,13 +1587,39 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
|
|
|
|
let infoDic = ["cdkey": license]
|
|
let infoDic = ["cdkey": license]
|
|
AIInfoManager.default().activateAI(withInfo: infoDic) { info, error in
|
|
AIInfoManager.default().activateAI(withInfo: infoDic) { info, error in
|
|
- if self.paymentMethod == .wxpay || self.paymentMethod == .alipay {
|
|
|
|
- self.qrCodeImageView.isHidden = true
|
|
|
|
- self.successfullyView.isHidden = false
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if info.isEmpty == false {
|
|
|
|
- self._trackEvent_paid()
|
|
|
|
|
|
+ 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 {
|
|
|
|
+ alert.runModal()
|
|
|
|
+ }
|
|
|
|
+ return
|
|
|
|
+ } else {
|
|
|
|
+ if info.isEmpty == false {
|
|
|
|
+ self._trackEvent_paid()
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if self.paymentMethod == .wxpay || self.paymentMethod == .alipay {
|
|
|
|
+ self.qrCodeImageView.isHidden = true
|
|
|
|
+ self.successfullyView.isHidden = false
|
|
|
|
+ } 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)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1601,13 +1631,80 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
|
|
|
|
let infoDic = ["cdkey": license]
|
|
let infoDic = ["cdkey": license]
|
|
VerificationManager.default().activateDevice(withInfo: infoDic) { status, info, error in
|
|
VerificationManager.default().activateDevice(withInfo: infoDic) { status, info, error in
|
|
- if self.paymentMethod == .wxpay || self.paymentMethod == .alipay {
|
|
|
|
- self.qrCodeImageView.isHidden = true
|
|
|
|
- self.successfullyView.isHidden = false
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
- if let data = info, data.isEmpty == false {
|
|
|
|
- self._trackEvent_paid()
|
|
|
|
|
|
+ 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: "")
|
|
|
|
+ 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()
|
|
|
|
+ }
|
|
|
|
+ return
|
|
|
|
+ } else {
|
|
|
|
+ if let data = info, data.isEmpty == false {
|
|
|
|
+ self._trackEvent_paid()
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ if self.paymentMethod == .wxpay || self.paymentMethod == .alipay {
|
|
|
|
+ self.qrCodeImageView.isHidden = true
|
|
|
|
+ self.successfullyView.isHidden = false
|
|
|
|
+ } 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)
|
|
|
|
+ }
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|
|
@@ -1657,6 +1754,17 @@ class KMPurchaseEmbeddedWindowController: NSWindowController {
|
|
coupomErrorTopLayout.constant = coupomErrorLabel.isHidden ? -CGRectGetHeight(coupomErrorLabel.bounds) : 8.0
|
|
coupomErrorTopLayout.constant = coupomErrorLabel.isHidden ? -CGRectGetHeight(coupomErrorLabel.bounds) : 8.0
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ var activityAlertViewController: KMActivityALertViewController? {
|
|
|
|
+ if _activityAlertViewController == nil {
|
|
|
|
+ let blockSelf = self
|
|
|
|
+ _activityAlertViewController = KMActivityALertViewController()
|
|
|
|
+ _activityAlertViewController?.callback = {
|
|
|
|
+ blockSelf.close()
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ return _activityAlertViewController
|
|
|
|
+ }
|
|
|
|
+
|
|
// MARK: Show Methods
|
|
// MARK: Show Methods
|
|
|
|
|
|
// @IBAction private func dismissSheet(_ sender: NSButton) {
|
|
// @IBAction private func dismissSheet(_ sender: NSButton) {
|