How It Works
WhensyncStoreKitTransactions is enabled (the default), the SDK’s StoreKitManager automatically:
- Listens for StoreKit transaction updates in the background
- Syncs completed StoreKit transactions to your ZeroSettle backend
- Merges StoreKit entitlements with web checkout entitlements
restoreEntitlements() on any device — alongside their web checkout purchases.
Configuration
StoreKit sync is enabled by default:Purchasing via StoreKit
UsepurchaseViaStoreKit() to trigger a native StoreKit 2 purchase:
Hybrid Purchase Flow
A common pattern is to offer web checkout as the primary option with StoreKit as a fallback:Product model tells you whether a StoreKit product is available:
product.storeKitAvailable—trueif the product is synced to App Store Connectproduct.storeKitPrice— the App Store price (may differ fromwebPrice)product.appStorePrice— same asstoreKitPrice
StoreKit Sync Delegate
WhensyncStoreKitTransactions is enabled, the SDK automatically syncs StoreKit purchases to your ZeroSettle backend. You can listen for these sync events:
Sync failures don’t affect the StoreKit purchase itself — the user gets their purchase through Apple immediately. Failed syncs are handled by a persistent retry queue:
- Automatic retries: Failed syncs are enqueued to
StoreKitSyncQueuewith exponential backoff (1s → 5s → 30s → 5min delays between attempts) - Persistence: The retry queue is stored in
UserDefaults, so pending syncs survive app restarts and device reboots - Max attempts: Each sync is retried up to 5 times before being abandoned
- Transaction safety: On sync failure,
transaction.finish()is not called — StoreKit will redeliver the unfinished transaction on the next app launch, providing an additional safety net beyond the retry queue - No user impact: The purchase succeeds immediately through Apple; only the backend sync (entitlement creation, revenue tracking) is retried in the background
Entitlement Sources
Entitlements track where each purchase came from:Error Types
StoreKitPurchaseError
| Error | Description |
|---|---|
.productNotFound(String) | Product ID not found in App Store Connect |
.verificationFailed(Error) | StoreKit transaction verification failed |
.userCancelled | User tapped Cancel in the StoreKit purchase dialog |
.pending | Purchase requires approval (Ask to Buy) |
.unknown | Unexpected error |
Requirements
| Requirement | Version |
|---|---|
| iOS | 17.0+ |
| StoreKit | StoreKit 2 |
| Xcode | 15.0+ |
| App Store Connect | Products must be configured and approved |

