KMDMGPurchaseManager.swift 1.2 KB

123456789101112131415161718192021222324252627282930313233343536373839
  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. }
  15. func fetchProducts(completion: @escaping KMPurchaseFetchProductCompletion) {
  16. self.fetchProductCompletion = completion
  17. }
  18. func restorePurchases() {
  19. KMRequestServerManager.manager.getUserInfo { [unowned self] success, data, error, isLocal in
  20. if success {
  21. KMPrint("DMG刷新用户信息成功")
  22. if KMLightMemberManager.manager.purchaseState == .subscription {
  23. let controller = KMSubscribeWaterMarkWindowController.isSampleController()
  24. controller.closeWindow()
  25. }
  26. } else {
  27. KMPrint("DMG刷新用户信息失败")
  28. }
  29. }
  30. }
  31. }