KMDMGPurchaseManager.swift 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. //
  2. // KMDMGPurchaseManager.swift
  3. // PDF Master
  4. //
  5. // Created by lizhe on 2023/6/8.
  6. //
  7. import Cocoa
  8. class KMDMGPurchaseManager: NSObject {
  9. public static let manager = KMDMGPurchaseManager()
  10. var fetchProductCompletion: KMPurchaseFetchProductCompletion?
  11. var availableProducts: [KMProduct] = []
  12. func purchaseProduct(productIdentifier: String, email: String, completion: KMPurchaseCompletion) {
  13. NSWorkspace.shared.open(URL(string: "http://test-pdf-pro.kdan.cn:3021/master/checkout?email=\(email)")!)
  14. completion(false, .success)
  15. }
  16. func fetchProducts(completion: @escaping KMPurchaseFetchProductCompletion) {
  17. self.fetchProductCompletion = completion
  18. }
  19. func restorePurchases() {
  20. KMRequestServerManager.manager.getUserInfo { [unowned self] success, data, error, isLocal in
  21. if success {
  22. KMPrint("DMG刷新用户信息成功")
  23. if KMLightMemberManager.manager.purchaseState == .subscription {
  24. let controller = KMSubscribeWaterMarkWindowController.isSampleController()
  25. controller.closeWindow()
  26. }
  27. } else {
  28. KMPrint("DMG刷新用户信息失败")
  29. }
  30. }
  31. }
  32. }