Skip to main content

Sandbox Testing

Test your in-app purchase implementation using Apple's StoreKit sandbox environment before going to production.

Testing Optionsโ€‹

MethodEnvironmentRequires App Store Connect
StoreKit Configuration FileXcode Simulator / DeviceNo
Sandbox AccountDevice onlyYes
TestFlightDevice onlyYes

The fastest way to test purchases locally without needing App Store Connect.

  1. In Xcode, go to File โ†’ New โ†’ File
  2. Select StoreKit Configuration File
  3. Add your products (subscriptions, consumables, etc.)
  4. In your scheme, set the StoreKit Configuration under Run โ†’ Options โ†’ StoreKit Configuration
tip

The StoreKit configuration file lets you test the full purchase flow in the simulator โ€” including renewals, cancellations, refunds, and Ask to Buy.

Sandbox Testing (Device)โ€‹

For more realistic testing on a physical device:

  1. Create a Sandbox Apple ID in App Store Connect โ†’ Users and Access โ†’ Sandbox Testers
  2. On your test device, sign out of the App Store
  3. Run your app and make a purchase โ€” you'll be prompted to sign in with the sandbox account

Sandbox Subscription Behaviorโ€‹

Sandbox subscriptions renew at an accelerated rate:

DurationSandbox Renewal
1 week3 minutes
1 month5 minutes
2 months10 minutes
3 months15 minutes
6 months30 minutes
1 year1 hour

Subscriptions auto-renew up to 6-12 times in sandbox, then expire.

Debugging Tipsโ€‹

Enable SDK Loggingโ€‹

// Local mode
AppActor.configure(
projectKey: "myapp",
logLevel: .debug, // Enable verbose SDK logging
offerings: { /* ... */ },
entitlements: { /* ... */ }
)

// Payment mode
AppActor.configure(
apiKey: "pk_test_your_key",
options: .init(logLevel: .debug)
)

SDK logs appear in Xcode's console with the [AppActor] prefix. Key events logged:

EventLevel
Configuration success/failureinfo/error
Product fetch resultsinfo/warning
Transaction processinginfo
Purchase outcomesinfo
Entitlement rebuildsdebug
Cache operationsdebug

Common Issuesโ€‹

Products not loading:

  • Verify product IDs match App Store Connect exactly
  • Check that your Paid Applications agreement is signed
  • Ensure the StoreKit configuration file is selected in your scheme

Purchases failing:

  • Check that you're signed in with a sandbox account (not a production Apple ID)
  • Verify your app's bundle ID matches App Store Connect

Entitlements not updating:

  • Call onAppForeground() to refresh state
  • Use getCustomerInfo(forceRefresh: true) for an immediate check
  • Check SDK logs for transaction processing details

Sandbox renewals not working:

  • Sandbox renewals happen every 3-5 minutes (not at production intervals)
  • Each subscription renews 6-12 times, then expires with autoRenew: false
  • Make sure Transaction.updates listener is active (call onAppForeground())

TestFlight Testingโ€‹

TestFlight uses the sandbox environment automatically. Your testers can make purchases without being charged.

  1. Upload your build to App Store Connect
  2. Add testers (internal or external)
  3. Testers install via TestFlight and can test purchases
info

TestFlight builds use the sandbox environment. Purchases are free and subscriptions renew at accelerated rates.

Next Stepsโ€‹