Test App Store purchases
Documents @snap4id-sdk/app-embed 1.0.0 · @snap4id-sdk/purchase-verifier 1.0.0
Simulators cannot buy from the real App Store (sandbox, TestFlight): check those purchases and kill-after-pay on a phone. Xcode’s StoreKit testing (below) also works on a simulator.
| Stage | How | Receipt environment | Accepted by |
|---|---|---|---|
| Local, no account | an Xcode StoreKit configuration (.storekit file) with your consumable product; run from Xcode |
xcode |
the fake Snap4ID page and test deployments only |
| Sandbox | a sandbox Apple account (App Store Connect → Users and Access → Sandbox) signed in under Settings → App Store on the phone | sandbox |
production while a sandbox window is open |
| TestFlight | a TestFlight build; testers buy with sandbox receipts | sandbox |
production while a sandbox window is open |
StoreKit in Xcode
Section titled “StoreKit in Xcode”A StoreKit configuration file (.storekit) declares products locally (id, type, price, localized names). When
Xcode launches your app with that file selected in the scheme, StoreKit serves those products from the file instead
of the App Store: purchases show the real system purchase sheet, need no Apple account and no App Store Connect
product, and work on a simulator. Each transaction is signed by a local Xcode certificate and carries the receipt
environment xcode; the sheet’s confirmation reads [Environment: Xcode].
- File → New → File → StoreKit Configuration File; add a consumable product with your product id and price.
- Product → Scheme → Edit Scheme → Run → Options → StoreKit Configuration: select the file.
- Run the app from Xcode (Product → Run). Only a launch from Xcode applies the file; an app started otherwise
(from the home screen,
xcrun simctl launch, or a command-line run such asnpx expo run:ios) talks to the real store. - Buy in the app: the purchase sheet appears and ends in “[Environment: Xcode]”. Debug → StoreKit → Manage Transactions lists the transactions, which is how you check a purchase stays unfinished until the unlock.
Expo and React Native: expo prebuild regenerates the Xcode project and its scheme, so a file selected by hand is lost
on the next prebuild. Add it to the scheme with a small config plugin, development builds only. The SDK’s partner-app
example has one, a StoreKit file and a script that prepares the run (examples/partner-app/README.md, “Real purchase
sheet”).
Xcode receipts are refused by production (environment_not_allowed), so use this against the
fake Snap4ID page (its partners sell dev.snap4id.test.photo: use that
product id in the StoreKit file) or a test deployment.
Sandbox against production
Section titled “Sandbox against production”Production accepts sandbox receipts only while your sandbox window is open: ask Snap4ID for one, with an end
date, for your own testing and for App Review (which buys with sandbox receipts against production). It expires
by itself. When Snap4ID checks purchases, Snap4ID opens it; when you check, it is allowed_environments /
sandbox_in_prod_until in your own configuration.
Check: buy, kill the app right after paying, reopen it: the photo still arrives and the transaction is finished only then.
