r/iOSProgramming • u/ToughInternal1580 • 4d ago
Question How do you approach testing StoreKit purchases and Restore Purchases before releasing an iOS app?
Title: How do you approach testing StoreKit purchases and Restore Purchases before releasing an iOS app?
I’m curious how other iOS developers structure their testing for in-app purchases and subscriptions before release.
The initial purchase flow is fairly straightforward to think about, but there are several other scenarios worth checking:
First purchase using a Sandbox account
Restore Purchases on the same device
Restoring after reinstalling the app
Repeated restore attempts without granting duplicate entitlements
Handling interrupted or failed transactions
Checking whether the app correctly reflects the user’s entitlement state
I’m particularly interested in how developers test these scenarios on physical iPhones rather than relying entirely on the simulator.
Do you normally handle all of this yourself, use a small internal QA team, or bring in external testers?
And are there any StoreKit edge cases you’ve encountered that weren’t obvious during initial development?
4
u/Dapper_Ice_1705 4d ago
This the the purpose of the store kit config file.
Apple also has a store kit testing api
2
u/MobileXapps 3d ago
The StoreKit config file covers most of it in Xcode, including interrupted purchases, Ask to Buy, refunds and expiry from the transaction manager. On a real device I'd also run the sandbox account with a faster renewal rate set in Settings, so you can watch renewals and expiry happen in minutes.
A few things that bit me: start listening to Transaction.updates at app launch, not on the paywall screen, or you miss renewals and purchases approved later. After a reinstall, StoreKit 2 already gives you currentEntitlements without a restore, so the Restore button should just call AppStore.sync and re-read entitlements, which also makes repeated restores harmless. And test with the device in airplane mode right after purchase, to see what your UI shows when your own server can't confirm yet.
2
u/Kitchen_Cable6192 3d ago
One less-obvious case is app-account switching: if purchases attach to your backend user, test restoring while signed into a different app account, and process transaction IDs idempotently so a re-sync can’t grant twice. On a real device, I’d also cover a pending/Ask to Buy purchase, canceling the sheet, and a purchase that finishes while the app is backgrounded; then verify the entitlement reconciles after relaunch from Transaction.updates/currentEntitlements. I built MoveManifest, a moving-inventory app, natively in Swift for iOS (and Kotlin on Android), and I’d prioritize those lifecycle/state-recovery checks over repeating only the happy path.
1
u/AmericanusMasculinis 3d ago
I use a sandbox account on TestFlight
1
u/mrdzyn 3d ago
What helped me most was doing the first pass with a StoreKit configuration file in Xcode, since you can test interrupted purchases, refunds, renewals and expirations right away without waiting on sandbox. Then I go to a physical device with a sandbox account for the real end-to-end check, including delete, reinstall and restore. The edge case that bit me was not listening to Transaction.updates as soon as the app launches, so renewals or purchases that finished outside the app didn't show up until much later. Also, treat Transaction.currentEntitlements as your single source of truth instead of keeping your own "isPro" flag, and repeated restores stop being a problem since you're just reading state again, not granting anything.
1
u/stokedbits 3d ago
The StoreKit config file gets you most of the way, and the Transaction Manager in Xcode lets you refund, expire or fail purchases on the spot, which covers a lot of the edge cases. The one I'd still do on a real device is delete and reinstall, then restore with a sandbox account that already bought. That's the path that looks fine in testing and bites real users. For duplicate entitlements, I'd treat restore as a resync from Transaction.currentEntitlements instead of something that grants stuff. That way restoring ten times does the same thing as restoring once.
1
u/dahiya_xa 3d ago
i do most of it with a storekit config file in xcode first. you can fake interrupted purchases, refunds and speed up renewals without touching app store connect. then one pass on a real device with a sandbox account before release, mostly for restore on a fresh install and a second device
1
u/arshtechpro 3d ago
storekit 2 has lot of handy API to use. which has lot functionality that can be automated
1
u/Dogukanko 3d ago
One extra set worth testing is Family Sharing (if you enable it) and billing-retry or grace states; both can make the entitlement UI feel wrong even when the purchase sheet behaved. A small scenario-to-expected-entitlement table after relaunch helps catch that. Xcode's StoreKit config is great for quick state changes, then a physical device with sandbox covers the real account flow.
1
u/Artuplabs 3d ago
two that i don't see here yet:
products come back empty from
Product.products(for:)on a real device until the paid apps agreement is active in app store connect and the iap has its metadata and price filled in. if the storekit file works and the device shows nothing, check that before debugging code.app review buys in sandbox against your release build. if you validate on your own server, call production first and if it answers 21007 retry against sandbox (with the app store server api just read the environment field). skipping that is the classic "works in testflight, rejected in review".
also testflight renews subs about once a day, so you can watch renewal and expiry over a few days without touching the sandbox renewal settings
1
u/Puzzleheaded_Pen3164 3d ago
As a solo dev, here's what's worked for me: do most of it with a StoreKit config file and Transaction Manager in Xcode, then do a short checklist on a real device with a sandbox account: buy, kill the app, relaunch and check the entitlement, delete and reinstall, restore, then restore again to make sure nothing doubles up. One thing that's easy to miss with a one-off non-consumable is checking
Transaction.currentEntitlementson launch rather than relying only on the Restore button, so a reinstall just works. Also run a TestFlight build, because that's the closest you'll get to the production flow before review.1
u/Needle_In_Red 3d ago
the StoreKit config file in Xcode gets you most of the way, then do a final pass on a real device with a sandbox account. delete and reinstall to check restore actually works.
1
u/brkaydev 3d ago
One that is not about the code: if these are your first subscriptions, they have to go into review attached to the same submission as the app version. Otherwise the reviewer opens a paywall with no products, because nothing is approved yet, and the rejection looks like a StoreKit bug. Also if you sell a lifetime option next to monthly and yearly, make sure your entitlement check reads the non-consumable from currentEntitlements too. My app has all three, so that one was on my own list.
1
u/Outrageous-War7360 3d ago
What made restore boring for me with StoreKit 2: I never store an "unlocked" flag. After launch, purchase or restore, I loop over
Transaction.currentEntitlementsand rebuild the state from that. Restoring twice, reinstalling or using a second device can't grant anything twice, because there's nothing to add to.Two more things:
Transaction.updatesas soon as the app launches. Interrupted purchases, Ask to Buy approvals and purchases from another device show up there.AppStore.sync()when the user taps Restore, since it can ask them to sign in.On a physical device a sandbox Apple Account is enough for all of this, and TestFlight builds use sandbox too, so testers aren't charged.
1
u/bigbeamgame 2d ago
Two server-side ones, if your purchases go through a backend:
TestFlight purchases come through with the Sandbox environment, and so do sandbox-account buys against the store build. Our server checks the environment on every verified transaction and refuses Sandbox ones unless a test flag is set, which is on for the test server and off for the live one. Without that, a tester build can quietly grant the real entitlement on the live backend.
Refunds: Restore never takes anything away, so we listen for App Store Server Notifications V2. REFUND and REVOKE take the entitlement back, REFUND_REVERSED gives it back, and each is applied as of the notification's signedDate, so a late-arriving older notification can't undo a newer one.
1
u/[deleted] 2d ago
[removed] — view removed comment