Why Sandbox Testing Matters
You cannot (and should not) use real money to test in-app purchases during development. Both Apple and Google provide sandbox environments that simulate the entire purchase flow, including transactions, renewals, failures, and refunds, without charging real payment methods.
Thorough sandbox testing prevents embarrassing and costly production bugs: failed purchase flows, incorrect entitlement grants, double charges, and broken renewal logic. Every purchase code path should be tested in sandbox before release.
Apple Sandbox Testing
Apple provides three testing environments, each suited for different stages of development.
1. StoreKit Testing in Xcode (Local)
The fastest way to test. Uses a local StoreKit Configuration file instead of connecting to App Store Connect.
Setup:
- In Xcode, go to File > New > File > StoreKit Configuration File
- Add products manually (matching your App Store Connect product IDs or using test IDs)
- In your scheme's Run configuration, set the StoreKit Configuration to your file
Advantages:
- No App Store Connect setup required
- Works offline
- Instant subscription renewals (configurable time rate)
- Can simulate failures, interruptions, and refunds
- Transaction Manager in Xcode shows all transactions
Limitations:
- Does not test real App Store infrastructure
- No server-to-server notifications
- Product details (price, description) are from the local file, not App Store Connect
2. Sandbox Environment
Tests against Apple's actual sandbox servers using sandbox Apple IDs.
Setup:
- Create sandbox tester accounts in App Store Connect > Users and Access > Sandbox Testers
- On a physical device, go to Settings > App Store > Sandbox Account and sign in
- Run your app from Xcode on the device; purchases will use the sandbox environment
Sandbox Tester Features:
- Configure subscription renewal rate (monthly renewals can happen every 3-5 minutes in sandbox)
- Clear purchase history to test first-time purchase flows
- Test interrupted purchases and payment failures
- Supports Ask to Buy simulation
Time Compression:
| Real Duration | Sandbox Duration |
|---|---|
| 1 week | 3 minutes |
| 1 month | 5 minutes |
| 2 months | 10 minutes |
| 3 months | 15 minutes |
| 6 months | 30 minutes |
| 1 year | 1 hour |
Subscriptions auto-renew up to 6 times in sandbox, then stop.
3. TestFlight (Beta Sandbox)
TestFlight builds automatically use the sandbox environment. Testers use their real Apple ID but are not charged. Server-side validation should check the sandbox endpoint for TestFlight receipts.
Google Play Testing
Google provides multiple testing levels with increasing fidelity.
1. License Testers
The primary testing mechanism. License testers can make purchases without being charged.
Setup:
- Google Play Console > Settings > License testing
- Add tester email addresses (must be Google accounts)
- Testers must use these accounts on their test devices
Behavior:
- Purchases succeed but no charge is made
- All purchase states can be tested (success, canceled, refunded)
- Subscriptions renew at an accelerated rate
- License testers see "Test card, always approves" as the payment method
2. Static Responses (Deprecated)
Google previously offered reserved product IDs for testing basic flows. These are largely superseded by license testing and are no longer recommended.
3. Internal Testing Track
Upload your app to the internal testing track in Google Play Console. Internal testers (up to 100 email addresses) can install and test the app.
Key points:
- Combines license testing with real-world installation flow
- Tests the full Play Store download and update experience
- Internal test builds are available within minutes of upload
4. Closed/Open Testing Tracks
For wider beta testing. Purchases use real payment methods unless the tester is also a license tester.
Testing Checklist
Purchase Flows
- Successful purchase of each product type (consumable, non-consumable, subscription)
- User cancellation during purchase flow
- Declined card and pending purchase scenarios
- Interrupted purchase (network loss during purchase)
Subscription Lifecycle
- Free trial start, expiration, and trial-to-paid conversion
- Successful and failed renewals
- Grace period behavior and voluntary cancellation
- Upgrade, downgrade, and restore purchases on new device
Server-Side
- Webhook/notification delivery for all event types
- Receipt/token validation and refund handling
Common Sandbox Issues
- Apple sandbox is slow: Sandbox servers have high latency. Implement retry logic.
- Sandbox account gets stuck: Create a new sandbox account if one becomes unresponsive
- Google license tester not working: Device Google account must match the license tester email exactly
- Subscriptions not renewing: Apple sandbox subscriptions renew only 6 times, then stop
- Wrong environment detection: Server must check the correct endpoint (sandbox vs. production) per build type
Related Topics
- In-App Purchase Guide - IAP types and integration fundamentals
- StoreKit 2 and Play Billing Guide - Platform-specific implementation details
- RevenueCat Integration Guide - How RevenueCat simplifies sandbox testing