|
@@ -143,9 +143,9 @@ public class PurchaseManager: NSObject {
|
|
|
}
|
|
|
|
|
|
@objc public var isVip: Bool {
|
|
|
- #if DEBUG
|
|
|
- return true
|
|
|
- #endif
|
|
|
+// #if DEBUG
|
|
|
+// return true
|
|
|
+// #endif
|
|
|
guard let expiresDate = expiredDate else {
|
|
|
return false
|
|
|
}
|
|
@@ -252,6 +252,8 @@ extension PurchaseManager {
|
|
|
purchase(self, didChaged: .restoreing, object: nil)
|
|
|
SKPaymentQueue.default().restoreCompletedTransactions()
|
|
|
debugPrint("PurchaseManager restoreCompletedTransactions")
|
|
|
+
|
|
|
+ subscriptionApple(type: .created, jsonString: "Payment restore")
|
|
|
}
|
|
|
|
|
|
/// 购买支付
|
|
@@ -271,6 +273,8 @@ extension PurchaseManager {
|
|
|
let payment = SKPayment(product: product)
|
|
|
SKPaymentQueue.default().add(payment)
|
|
|
debugPrint("PurchaseManager pay period = \(period)")
|
|
|
+
|
|
|
+ subscriptionApple(type: .created, jsonString: "Payment period = \(product)")
|
|
|
}else{
|
|
|
purchase(self, didChaged: .payFail, object: "Payment failed, no this item")
|
|
|
}
|
|
@@ -339,7 +343,7 @@ extension PurchaseManager: SKPaymentTransactionObserver {
|
|
|
message = "The subscription was canceled"
|
|
|
}
|
|
|
purchase(self, didChaged: .payFail, object: message)
|
|
|
-
|
|
|
+ subscriptionApple(type: .result, jsonString: message)
|
|
|
case .restored:
|
|
|
SKPaymentQueue.default().finishTransaction(transaction)
|
|
|
//同样的原始订单,只处理一次.
|
|
@@ -357,6 +361,7 @@ extension PurchaseManager: SKPaymentTransactionObserver {
|
|
|
#endif
|
|
|
} else {
|
|
|
purchase(self, didChaged: .restoreFail, object: "Failed to restore subscribe, please try again")
|
|
|
+ subscriptionApple(type: .result, jsonString: "Failed to restore subscribe, please try again")
|
|
|
}
|
|
|
|
|
|
case .deferred: // The transaction is in the queue, but its final status is pending external action.
|
|
@@ -484,6 +489,8 @@ extension PurchaseManager {
|
|
|
self.purchase(self, didChaged: .paySuccess, object: nil)
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ subscriptionApple(type: .result, jsonString: simplifyVerifyPayResult(resp: resp))
|
|
|
}
|
|
|
|
|
|
// 终生会员过期时间:100年
|