1
This commit is contained in:
@@ -80,6 +80,9 @@ public class StoreKit2Manager {
|
||||
/// 每个产品的最新交易记录集合
|
||||
public private(set) var latestTransactions: [Transaction] = []
|
||||
|
||||
/// 最近一次完成购买的交易签名缓存(按产品ID)
|
||||
private var recentJWSPayloads: [String: String] = [:]
|
||||
|
||||
// MARK: - 按类型分类的产品(计算属性)
|
||||
|
||||
/// 非消耗品
|
||||
@@ -379,6 +382,14 @@ public class StoreKit2Manager {
|
||||
return latestTransactions
|
||||
}
|
||||
|
||||
/// 获取指定产品最近一次完成的 JWS(仅限 StoreKitService 捕获到的交易)
|
||||
/// - Parameter productId: 产品 ID
|
||||
/// - Returns: 若存在则返回并移除缓存
|
||||
@MainActor
|
||||
func consumeRecentPayload(for productId: String) -> String? {
|
||||
return recentJWSPayloads.removeValue(forKey: productId)
|
||||
}
|
||||
|
||||
/// 获取交易历史
|
||||
/// - Parameter productId: 可选的产品ID,如果提供则只返回该产品的交易历史
|
||||
/// - Returns: 交易历史记录数组,按购买日期倒序排列
|
||||
@@ -532,5 +543,9 @@ extension StoreKit2Manager: StoreKitServiceDelegate {
|
||||
// 通知闭包回调
|
||||
onPurchasedTransactionsUpdated?(efficient, latests)
|
||||
}
|
||||
|
||||
@MainActor
|
||||
func service(_ service: StoreKitService, didCompletePurchaseFor productId: String, payload: String) {
|
||||
recentJWSPayloads[productId] = payload
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user