2
This commit is contained in:
@@ -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)
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user