# Fix StoreKit 2 & Play Billing v8 Restore Purchases & 3-Day Refund Bugs

> Canonical URL: https://stackquota.com/guides/storekit2-play-billing-v8-restore-purchases-bugs/
> Checked: 2026-12-04 · Published: 2026-12-04

Stop Guideline 3.1.1 rejections and Play Billing v8 3-day auto-refunds using AppStore.sync(), acknowledgePurchase, and offline-safe IAP caching.

A `$2.99` (`₩3,900`) **Remove Forced Ads** non-consumable IAP is the highest-margin monetization lever in hybrid casual games and utility apps, often contributing `18%–35%` of net studio revenue alongside AdMob rewarded video. Yet two subtle SDK bugs routinely wipe out that revenue or stall store launches: iOS App Review Guideline `3.1.1` rejections over missing restore flows in StoreKit 2, and Google Play Billing Library v8 silently refunding 100% of one-time purchases exactly 72 hours after checkout. Before projecting your hybrid conversion curve in the [App Store, Google Play & AdMob Revenue Calculator](/calculators/app-store-play-admob-revenue/), lock down these cross-platform entitlement invariants in Swift and Kotlin.

## Why does apple reject StoreKit 2 apps under guideline 3.1.1 for restore purchases?

**Quick answer:** Even though StoreKit 2 automatically refreshes signed JWS transactions via `Transaction.currentEntitlements`, Apple App Review Guideline `3.1.1` still mandates a visible, tappable **Restore Purchases** button on your paywall and Settings screen that explicitly calls `try await AppStore.sync()`. Omitting the button (or wiring it to a no-op reload of local cache) triggers immediate binary rejection during human sandbox review.

When Apple introduced StoreKit 2 (`Product`, `Transaction.updates`, and `Transaction.currentEntitlements`), many iOS engineers read that entitlements sync automatically across devices signed into the same Apple Account and deleted their legacy `SKPaymentQueue.default().restoreCompletedTransactions()` button. In production, two edge cases break silent restoration:

1. **Fresh device migration & App Review sandbox lag:** When a user restores an iCloud backup onto a brand-new iPhone, or when an App Reviewer signs into a clean sandbox Apple Account right before tapping your paywall, the local on-device StoreKit receipt database may not yet hold every historical non-consumable JWS token.
2. **User expectation & support deflection:** Paying customers who reinstall your app and briefly see a banner slot look immediately for a "Restore Purchases" button; if none exists, they assume you deleted their unlock and leave a 1-star review requesting an Apple refund.

| Capability / Lifecycle Hook | Apple StoreKit 2 (iOS 17+ / Swift) | Google Play Billing v8.0+ (Android / Kotlin) | Fatal Mistake to Avoid |
| --- | --- | --- | --- |
| **Cold-launch silent check** | Iterate `Transaction.currentEntitlements` + listen to `Transaction.updates` | `billingClient.queryPurchasesAsync` (`ProductType.INAPP`) | Calling `AppStore.sync()` on launch (triggers Apple ID login popup!) |
| **User-tapped Restore button** | `try await AppStore.sync()` then re-scan `currentEntitlements` | Reconnect `BillingClient` + `queryPurchasesAsync` + UI status toast | Omitting visible Restore button on paywall/Settings (`3.1.1` rejection) |
| **Post-checkout finalization** | Verify `.verified(let tx)` JWS signature, grant unlock, `await tx.finish()` | Verify `PurchaseState.PURCHASED`, grant unlock, `acknowledgePurchase` | Skipping `acknowledgePurchase` on non-consumables (**72h auto-refund**) |
| **Pending / Ask-to-Buy state** | Handle `.pending` result without granting entitlement; wait on `Transaction.updates` | Configure `enableOneTimeProducts()` & wait while `PurchaseState == PENDING` | Unlocking ad-free on `PENDING` before parental approval or cash voucher clears |
| **Offline / Airplane launch** | Seed initial `@Published` state from `UserDefaults` + cached JWS | Seed initial `StateFlow` from `SharedPreferences`; ignore non-`OK` errors | Overwriting `isAdFree = false` when `SERVICE_UNAVAILABLE` returns empty list |
| **Refund / Revocation check** | Check `tx.revocationDate == nil` while iterating `currentEntitlements` | Absent from `purchasesList` when `BillingResponseCode.OK` succeeds | Leaving refunded fraud accounts unlocked forever after verified `OK` sync |

Keep `AppStore.sync()` strictly inside your button action handler, never inside `init()` or `.task {}` on your root view. Calling `AppStore.sync()` programmatically at cold launch prompts unauthenticated or sandbox-switched users with a system Apple Account sign-in modal before they have even seen your gameplay loop, which itself triggers an App Review rejection under Guideline `5.1.1` / `3.1.1`.

## How do you implement a guideline-compliant StoreKit 2 non-consumable manager in SwiftUI?

**Quick answer:** Start a long-lived `Transaction.updates` listener task at initialization, read `UserDefaults` synchronously so frame zero renders without banner flicker, iterate `Transaction.currentEntitlements` checking `tx.revocationDate == nil`, and bind a dedicated **Restore Purchases** button on both your Remove Ads sheet and Settings screen to `AppStore.sync()`.

Here is the complete `@MainActor` StoreKit 2 pattern used across native iOS `17.0+` hybrid puzzle apps for a `$2.99` (`com.example.game.remove_ads`) non-consumable unlock:

```swift
import StoreKit
import SwiftUI

@MainActor
final class RemoveForcedAdsStore: ObservableObject {
    @Published private(set) var isAdFree: Bool
    @Published private(set) var displayPrice: String = "$2.99"
    @Published private(set) var isBusy: Bool = false
    @Published var statusMessage: String?

    let productID: String
    private let cacheKey: String
    private var product: Product?
    private var updatesTask: Task<Void, Never>?

    init(productID: String) {
        self.productID = productID
        self.cacheKey = "entitlement.adfree.\(productID)"
        // Synchronous boot read: zero banner flicker during offline cold launch
        self.isAdFree = UserDefaults.standard.bool(forKey: cacheKey)

        // Required for Ask-to-Buy, Strong Customer Auth (3DS), and cross-device buys
        self.updatesTask = Task { [weak self] in
            for await verification in Transaction.updates {
                if case .verified(let tx) = verification {
                    await tx.finish()
                    await self?.refreshCurrentEntitlements()
                }
            }
        }

        Task { [weak self] in
            await self?.loadProductMetadata()
            await self?.refreshCurrentEntitlements()
        }
    }

    deinit { updatesTask?.cancel() }

    func loadProductMetadata() async {
        guard let fetched = try? await Product.products(for: [productID]).first else { return }
        product = fetched
        displayPrice = fetched.displayPrice
    }

    func refreshCurrentEntitlements() async {
        var active = false
        var sawMatchingRecord = false

        for await verification in Transaction.currentEntitlements {
            guard case .verified(let tx) = verification, tx.productID == productID else { continue }
            sawMatchingRecord = true
            if tx.revocationDate == nil {
                active = true
            }
        }

        if active {
            persist(true)
        } else if sawMatchingRecord {
            // Explicit Apple refund revocation detected on device
            persist(false)
        }
    }

    func purchase() async {
        guard !isBusy else { return }
        isBusy = true
        statusMessage = nil
        defer { isBusy = false }

        if product == nil { await loadProductMetadata() }
        guard let product else {
            statusMessage = "App Store is temporarily unreachable. Please try again."
            return
        }

        do {
            switch try await product.purchase() {
            case .success(let verification):
                guard case .verified(let tx) = verification else {
                    statusMessage = "Could not verify purchase signature."
                    return
                }
                await tx.finish()
                persist(true)
                statusMessage = "Unlocked! All banners and forced interstitials are disabled."
            case .pending:
                statusMessage = "Purchase is pending approval (Ask to Buy)."
            case .userCancelled:
                break
            @unknown default:
                break
            }
        } catch {
            statusMessage = "Purchase could not be completed."
        }
    }

    /// Invoked ONLY when the user explicitly taps "Restore Purchases"
    func restorePurchases() async {
        guard !isBusy else { return }
        isBusy = true
        statusMessage = nil
        defer { isBusy = false }

        do {
            try await AppStore.sync()
            await refreshCurrentEntitlements()
            statusMessage = isAdFree
                ? "Purchases restored! Forced ads are disabled."
                : "No previous Remove Ads purchase found for this Apple Account."
        } catch {
            statusMessage = "Could not connect to the App Store to restore purchases."
        }
    }

    private func persist(_ unlocked: Bool) {
        isAdFree = unlocked
        UserDefaults.standard.set(unlocked, forKey: cacheKey)
    }
}
```

Notice two subtle production details in `refreshCurrentEntitlements()`. First, `Transaction.updates` must start listening immediately inside `init()`: if a child triggers Apple Family Sharing **Ask to Buy** or a European buyer completes bank 3D Secure (`SCA`) outside the app, the delayed `.verified` transaction arrives asynchronously on next launch via `Transaction.updates`. Second, when `Transaction.currentEntitlements` returns zero records on an unauthenticated airplane-mode cold boot, we do **not** wipe out `UserDefaults` (`persist(false)` only fires if a revoked record is observed or if you choose to reconcile after an authenticated `AppStore.sync()`).

## Why does Google Play billing V8 silently auto-refund one-time purchases after 3 days?

**Quick answer:** Google Play requires every non-consumable `INAPP` purchase (`Remove Forced Ads`, `Pro Upgrade`, `Level Pack`) to be acknowledged within 3 days via `billingClient.acknowledgePurchase` (or server-side `purchases.products.acknowledge`); otherwise Google automatically cancels the order, refunds 100% of the customer's payment, and revokes the purchase token.

Engineers migrating from consumables (where `consumeAsync` implicitly acknowledges delivery) or coming from iOS often set `isAdFree = true` inside `onPurchasesUpdated` and stop. Worse, Google Play License Tester accounts compress the unacknowledged refund timer from **3 days to 5 minutes**: tricking developers into assuming test purchases simply auto-reset for convenience! In production, customers buy your `$2.99` Remove Ads unlock on Friday, and by Monday Play Console fills with `Canceled` orders and `$0.00` net proceeds.

**Google Play Billing Library v8 (`8.0.0+`)** adds three mandatory wiring rules alongside acknowledgment:

1. **`PendingPurchasesParams` builder:** The no-arg `enablePendingPurchases()` is removed in v8. Pass `PendingPurchasesParams.newBuilder().enableOneTimeProducts().build()` and chain `.enableAutoServiceReconnection()` so Play Store restarts do not drop `queryPurchasesAsync` calls.
2. **`oneTimePurchaseOfferDetailsList` selection:** Play Billing v8 returns a list of offers per `INAPP` SKU. Pick the base offer (`offerId == null` with non-blank `formattedPrice`, falling back to the first valid offer) and pass its `offerToken` to `BillingFlowParams.ProductDetailsParams`.
3. **Strict `PurchaseState.PURCHASED` gate:** Cash-voucher checkouts (OXXO, Boleto, Konbini) fire `onPurchasesUpdated` with `PurchaseState.PENDING` (`2`). Calling `acknowledgePurchase` on `PENDING` throws `DEVELOPER_ERROR`, and unlocking early grants free upgrades on unpaid vouchers.

## How do you build an offline-safe Play billing V8 acknowledgment and restore flow in Kotlin?

**Quick answer:** Run an idempotent `reconcileOwnedPurchases()` routine both at app startup and after `onPurchasesUpdated` that checks `purchaseState == PurchaseState.PURCHASED`, calls `acknowledgePurchase` whenever `!purchase.isAcknowledged`, handles `ITEM_ALREADY_OWNED` by triggering a restore sweep, and preserves `SharedPreferences` state whenever `billingResult.responseCode != BillingResponseCode.OK`.

Here is the battle-tested Kotlin Coroutines implementation for Play Billing v8 (`com.android.billingclient:billing-ktx:8.0.0`):

```kotlin
class PlayBillingRemoveAdsManager(
    context: Context,
    private val removeAdsProductId: String,
) : PurchasesUpdatedListener {

    private val appContext = context.applicationContext
    private val prefs = appContext.getSharedPreferences("iap_entitlements", Context.MODE_PRIVATE)
    private val scope = CoroutineScope(SupervisorJob() + Dispatchers.IO)

    private val _isAdFree = MutableStateFlow(prefs.getBoolean(KEY_AD_FREE, false))
    val isAdFree: StateFlow<Boolean> = _isAdFree.asStateFlow()

    private val billingClient: BillingClient = BillingClient.newBuilder(appContext)
        .setListener(this)
        .enablePendingPurchases(
            PendingPurchasesParams.newBuilder().enableOneTimeProducts().build()
        )
        .enableAutoServiceReconnection()
        .build()

    suspend fun reconcileOwnedPurchases(): Boolean {
        val params = QueryPurchasesParams.newBuilder()
            .setProductType(BillingClient.ProductType.INAPP)
            .build()

        val result = runCatching { billingClient.queryPurchasesAsync(params) }.getOrNull()
            ?: return _isAdFree.value // Exception / timeout: keep cached offline state!

        if (result.billingResult.responseCode != BillingClient.BillingResponseCode.OK) {
            // Airplane mode, Play Store updating, or logged-out Play Services: NEVER revoke!
            return _isAdFree.value
        }

        var entitled = false
        for (purchase in result.purchasesList) {
            if (purchase.products.contains(removeAdsProductId) &&
                purchase.purchaseState == Purchase.PurchaseState.PURCHASED
            ) {
                entitled = true
                if (!purchase.isAcknowledged) {
                    val ackParams = AcknowledgePurchaseParams.newBuilder()
                        .setPurchaseToken(purchase.purchaseToken)
                        .build()
                    val ackResult = billingClient.acknowledgePurchase(ackParams)
                    // If network drops mid-ack, next app launch retries automatically
                    if (ackResult.responseCode != BillingClient.BillingResponseCode.OK) {
                        // Log telemetry metric: billing_ack_retry_scheduled
                    }
                }
            }
        }

        // Safe to persist true OR false here because Play returned authoritative OK
        prefs.edit().putBoolean(KEY_AD_FREE, entitled).apply()
        _isAdFree.value = entitled
        return entitled
    }

    override fun onPurchasesUpdated(result: BillingResult, purchases: MutableList<Purchase>?) {
        when (result.responseCode) {
            BillingClient.BillingResponseCode.OK -> {
                val unlockedNow = purchases.orEmpty().any {
                    it.products.contains(removeAdsProductId) &&
                        it.purchaseState == Purchase.PurchaseState.PURCHASED
                }
                if (unlockedNow) {
                    // Optimistic instant UI tear-down of banners, followed by async ack
                    prefs.edit().putBoolean(KEY_AD_FREE, true).apply()
                    _isAdFree.value = true
                    scope.launch { reconcileOwnedPurchases() }
                }
            }
            BillingClient.BillingResponseCode.ITEM_ALREADY_OWNED -> {
                // Reinstalled user tapped Buy instead of Restore: auto-recover seamlessly
                scope.launch { reconcileOwnedPurchases() }
            }
        }
    }

    companion object {
        private const val KEY_AD_FREE = "remove_forced_ads_owned"
    }
}
```

Why run `acknowledgePurchase` inside `reconcileOwnedPurchases()` on every cold launch as well as `onPurchasesUpdated`? Mobile connections frequently drop right as the Play checkout sheet closes. If a subway commuter buys Remove Ads offline-bound, `SharedPreferences` collapses banners immediately while the initial `acknowledgePurchase` network call fails; the next session launch inside the 72-hour window finishes acknowledgment automatically, driving 3-day auto-refunds to `0.0%`.

## How should remove forced ads interact with rewarded video boosters and offline Play?

**Quick answer:** Unlocking **Remove Forced Ads** (`$2.99`) must immediately collapse bottom Anchored Adaptive Banners and disable forced between-level Interstitials (stopping even background interstitial preload requests) while keeping user-initiated **Rewarded** boosters (`+1 Extra Slot`, `Revive`, `Hint`) available whenever the player chooses to tap them.

Keep three hybrid UX and telemetry rules aligned:

- **Clear paywall scope:** Title the SKU **"Remove Forced Ads"** rather than "Remove All Ads" and state explicitly on the sheet that bottom banners and between-level interstitials are permanently removed while optional reward boosters remain available on tap.
- **Stop interstitial preloads:** Once `isAdFree == true`, cancel interstitial retry timers and skip `InterstitialAd.load()` while still preloading `RewardedAd`. Eliminating unused interstitial bid requests improves your AdMob `show rate`, protecting auction priority, see our [AdMob ad serving limit, UMP & app-ads.txt fix guide](/guides/admob-ad-serving-limit-new-app-ump-app-ads-txt-fix/).
- **CI test flags:** Support a debug-only launch flag (`-adFreeDemo` / `BuildConfig.DEBUG` toggle) so UI test suites verify both free and ad-free layouts cleanly alongside our [GitHub Actions macOS runner minutes & cache guide](/guides/github-actions-macos-runner-minutes-burn-ios-cache-fix/).

Once your non-consumable IAP holds a `0%` auto-refund rate and cleanly converts `1.5%–4%` of active players, remember that a `$2.99` checkout does **not** deposit `$2.54` (`85%`) into your bank account in EU, UK, Korean, or Japanese storefronts. Walk through our [App Store & Google Play payout vs gross sales VAT & FX breakdown](/guides/app-store-google-play-payout-lower-than-sales-vat-fx/) and plug your regional split into the [App Store, Google Play & AdMob Revenue Calculator](/calculators/app-store-play-admob-revenue/) to forecast exact net cash flow.

*Independent engineering documentation: StackQuota is not affiliated with, endorsed by, or sponsored by Apple Inc. or Google LLC. StoreKit 2, App Review Guidelines, and Google Play Billing Library behaviors reflect public developer documentation as of December 2026.*
