This commit is contained in:
2025-12-16 16:00:00 +08:00
parent 30f2e4f24f
commit 4a474e9b44

View File

@@ -117,23 +117,6 @@ final class KBStoreKitBridge: NSObject, StoreKitDelegate {
@MainActor
private func fetchPayload(for productId: String) async -> String? {
if let payload = manager.consumeRecentPayload(for: productId) {
return payload
}
return await Self.latestJWSPayload(for: productId, retryCount: 3)
}
private static func latestJWSPayload(for productId: String, retryCount: Int = 1) async -> String? {
var attempts = 0
while attempts < retryCount {
if let result = await Transaction.latest(for: productId), case .verified = result {
return result.jwsRepresentation
}
attempts += 1
if attempts < retryCount {
try? await Task.sleep(nanoseconds: 300_000_000) // 0.3s
}
}
return nil
return manager.consumeRecentPayload(for: productId)
}
}