During WWDC 2020 Apple announced a new way to test in-app purchases using StoreKit configuration file.
At the moment, in-app purchases validation made using StoreKit configuration file is not yet supported. We will announce when this feature becomes available in Apphud.
If you want to change sandbox Apple ID in order to test in-app purchases from scratch, like testing Trials or paid Introductory Offers, please follow these steps:
Create new sandbox account
Delete the app from iOS device
Delete your test user in Apphud (To find yourself go to Users > View Sandbox Users)
Change Apple ID in device
Run the app again and make purchases
Please read here.
Apphud.setFinishTransactions() before SDK initialization to tell Apphud to finish all transactions, even those that are stuck in the queue for some reason.
This is useful when you test purchases a lot / change sandbox Apple IDs / break execution during purchases, etc.
This method is also helpful in production, sometimes it reduces errors in purchasing a subscription.
If you want to change User ID / Device ID in order to test a new sandbox account, there is no need to write this paragraph; please read How to Change Sandbox Apple ID instead.
Currently, User ID and Device ID values are being saved in keychain on your device. Even if you change User ID, you will still have the same user with changed User ID. You can initialize Apphud SDK with different Device ID to force a fresh install.
func startManually(apiKey: String, userID: String? = nil, deviceID: String? = nil)
To test in app purchases you need to create sandbox user. Go to App Store Connect and open "Users and Access", then – "Sandbox Testers":
You can sign in to Sandbox account separately from your App Store account since iOS 12. Sign in to sandbox here:
Purchasing process is the same as real in-app purchases. The only difference is accelerated time and impossibility to cancel subscription manually. Subscriptions in sandbox renew 6 times per day maximum.
Duration in sandbox
If after purchase in Apphud you can see a user with active subscription, it means that payment process work correctly.
You can test following events in sandbox:
Intro Expired (if payment mode is "Pay as you go" and number of introductory periods is at least six)