123456789101112131415161718192021222324252627282930313233343536373839404142434445 |
- //
- // KMDMGPurchaseManager.swift
- // PDF Master
- //
- // Created by lizhe on 2023/6/8.
- //
- import Cocoa
- class KMDMGPurchaseManager: NSObject {
- public static let manager = KMDMGPurchaseManager()
- var fetchProductCompletion: KMPurchaseFetchProductCompletion?
-
- var availableProducts: [KMProduct] = []
-
- func purchaseProduct(productIdentifier: String, email: String, completion: KMPurchaseCompletion) {
- // NSWorkspace.shared.open(URL(string: "http://test-pdf-pro.kdan.cn:3021/master/checkout?email=\(email)")!)
- #if DEBUG
- NSWorkspace.shared.open(URL(string: "\(KMLightMemberManager.manager.config.kStoreServerURL)/store/master-subscription?email=\(email)")!)
- #else
- NSWorkspace.shared.open(URL(string: "\(KMLightMemberManager.manager.config.kStoreServerURL)/store/master-subscription?email=\(email)")!)
- #endif
- completion(false, .success)
- }
-
- func fetchProducts(completion: @escaping KMPurchaseFetchProductCompletion) {
- self.fetchProductCompletion = completion
-
-
- }
-
- func restorePurchases() {
- KMRequestServerManager.manager.getUserInfo { [unowned self] success, data, error, isLocal in
- if success {
- KMPrint("DMG刷新用户信息成功")
- if KMLightMemberManager.manager.purchaseState == .subscription {
- let controller = KMSubscribeWaterMarkWindowController.isSampleController()
- controller.closeWindow()
- }
- } else {
- KMPrint("DMG刷新用户信息失败")
- }
- }
- }
- }
|