Browse Source

3.6.2(4)
1.完善内购支付失败原因为已订阅后,主动帮用户回复购买
2.恢复保持所有的会员商品 ID 存储逻辑

100Years 2 months ago
parent
commit
cc4aac2ce7

+ 2 - 2
TSLiveWallpaper.xcodeproj/project.pbxproj

@@ -1273,7 +1273,7 @@
 				ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
 				CODE_SIGN_IDENTITY = "Apple Development";
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 3;
+				CURRENT_PROJECT_VERSION = 4;
 				DEVELOPMENT_TEAM = 65UD255J84;
 				ENABLE_APP_SANDBOX = NO;
 				ENABLE_USER_SCRIPT_SANDBOXING = NO;
@@ -1313,7 +1313,7 @@
 				ASSETCATALOG_COMPILER_GLOBAL_ACCENT_COLOR_NAME = AccentColor;
 				CODE_SIGN_IDENTITY = "Apple Development";
 				CODE_SIGN_STYLE = Automatic;
-				CURRENT_PROJECT_VERSION = 3;
+				CURRENT_PROJECT_VERSION = 4;
 				DEVELOPMENT_TEAM = 65UD255J84;
 				ENABLE_APP_SANDBOX = NO;
 				ENABLE_USER_SCRIPT_SANDBOXING = NO;

+ 2 - 2
TSLiveWallpaper/Common/Purchase/TSPurchaseBusiness.swift

@@ -120,9 +120,9 @@ extension TSPurchaseBusiness{
         PurchaseManager.default.password = "155c8104e2b041c0abae43ace199124c"
         PurchaseManager.default.purchaseProducts = [
             PurchaseProduct(productId: "1006", period:.week),
-//            PurchaseProduct(productId: "1001", period:.month),
+            PurchaseProduct(productId: "1001", period:.month),
             PurchaseProduct(productId: "1002", period:.year),
-//            PurchaseProduct(productId: "003", period:.lifetime)
+            PurchaseProduct(productId: "003", period:.lifetime)
         ]
         
         PurchaseManager.default.requestProducts()

+ 26 - 3
TSLiveWallpaper/Common/Purchase/TSPurchaseManager.swift

@@ -307,10 +307,33 @@ extension PurchaseManager: SKPaymentTransactionObserver {
                 
                 SKPaymentQueue.default().finishTransaction(transaction)
                 // Transaction was cancelled or failed before being added to the server queue.
+                
+                
+                if let error = transaction.error as NSError? {
+                    // 1. 检查内层错误
+                    if let underlyingError = error.userInfo[NSUnderlyingErrorKey] as? NSError {
+                        if underlyingError.domain == "ASDServerErrorDomain" && underlyingError.code == 3532 {
+                            print("用户已订阅,禁止重复购买")
+                            restorePremium()
+                            return
+                        }
+                    }
+                    // 2. 检查外层 SKError
+                    else if error.domain == SKErrorDomain {
+                        switch SKError.Code(rawValue: error.code) {
+                        case .unknown:
+                            print("未知错误,可能是服务器问题")
+                        default:
+                            break
+                        }
+                    }
+                }
+                
                 var message = "Payment Failed"
-                if let error = transaction.error as? SKError,
-                   error.code == SKError.paymentCancelled {
-                    message = "The subscription was canceled"
+                if let error = transaction.error as? SKError{
+                    if error.code == SKError.paymentCancelled {
+                        message = "The subscription was canceled"
+                    }
                 }
                 purchase(self, didChaged: .payFail, object: message)