Error still happens even though its stated as fixed in changelog;
(Happens when user attempts to “restore” purchased product by performing product purchase);
Does anyone have a solution, or the only one is to downgrade / remove package and use legacy store version?
Edit: This does not occur when build is downloaded from the Google Play. Make sure to test restore only on the beta / store versions.
Please provide steps to reproduce in your situation. You don’t “restore” a purchase by attempting to purchase again, you would get an error. Only consumable products can be purchased a second time. Otherwise, if you reinstall the game, on Android the Restore is automatic, and ProcessPurchase will be called for each subscription and non-consumable. On iOS, you need to implement a Restore button, then is enforced by Apple https://docs.unity3d.com/Manual/UnityIAPRestoringTransactions.html
Now that I think about it, it could be caused by debug / development build environment.
We haven’t tested in release / from Play store yet.
Because if you attempt to purchase on clean account, you’d get an actual error stating this.
While if you have that non-consumable on account, you’d get DuplicateTransaction instead.
So:
Its non-consumable purchase;
Non-consumable purchase made on prior version (already on user account);
Purchase is not restored (dev / debug environment) after initialization;
User attempts to purchase that non-consumable;
Gets DuplicateTransaction;
If its caused by development build - its fine, because only recently we upgraded IAP from store to package version.
(Also, need to double check with QA if they were restoring on previous versions)
If not, then I don’t know why purchases are not restored after initialization (no callback received).
What prior version are you using? And what do you mean, dev /debug environment? Are you using Closed or Internal testing on Google? This would be required.
Start with a new test account
Ensure this user accepts the test invite in email on the device. It will then prompt the tester to download the test game from Google Play
Purchase a non-consumable
Uninstall the game
Install the game again. Please Debug.Log statements in ProcessPurchase to confirm the restore, these logs will show in the logcat/device logs
Note - Once the user accepts the test invite, you can subsequently side-load app updates directly from your PC, and no need to download from Google Play again.
I was referring builds as APK / built with development build checkmark.
Not the ones that are uploaded to the store / AABs then downloaded from to the device.
Regarding asset version - not too sure, something legacy from the Asset Store.
Just contacted with QA, got more adequate WTR (or not). There’s more than one issue it seems.
[Purchase is non-consumable, in both cases test accounts were used]
First case (does not happen all the time):
Account with performed purchases.
Launch game without connection enabled;
Enable connection (wifi) in-game. Wait for a while.
Attempts to purchase → gets DuplicateTransaction.
(Purchase is not restored correctly it seems)
After game restart - IAP initializes → Purchase restores automatically;
Second case:
Happens when switching account without purchase to the one that has it;
Launch game on account that does not have purchase.
Play for a while;
Turn off game, switch account to the one that has purchase;
Launch game again, wait for a while;
Attempt to purchase → gets DuplicateTransaction;
After game restart → IAP initializes → Purchase restores automatically;
These are expected. IAP requires a network for restore to work. In your second case, IAP uses the user logged into the Play Store on the device, not just another email account on the phone. Typically if a user has already purchased a non-consumable or subscription, you should disable the purchase button so they won’t be able to purchase again. You don’t want your users to see an error if you can avoid it. That error is from the store API, we don’t create the error in Unity IAP, we are a pass-through service for the store API. You can use PlayerPrefs or saving to the cloud to persist purchase history. You can also check the receipts in the product controller. You might want to compare to the Sample IAP Project v2 here https://discussions.unity.com/t/700293/3 . Also ensure to capture device logs that would include your Debug.Log statements and provide the logcat logs here if you continue to have issues https://discussions.unity.com/t/699654 and https://discussions.unity.com/t/748729/14
It should attempt to restore purchases after internet / connection goes back online, right?
Otherwise why would purchasing throw “initialized” callback without restoring purchases?
The problem is that its clean install. Meaning no local data available. Also, no server available.
Please provide exact steps to reproduce with your device logs and show your Debug.Log statements as requested. Before you test the failure flow, let’s get the normal flow working first! Please follow my steps I listed above to ensure the basics are working first.
So my steps above are working for you? You are receiving the restore ProcessPurchase callback? You didn’t confirm how you are switching accounts, etc. To avoid confusion moving forward, please share your device logs and the associated Debug.Log statements along with the specific steps you are following.
Both purchase and restore works fine, unless you start messing around with network connection or switching accounts it seems. And even after game reboot restore works fine.
Restore doesn’t seems to work when enabling network in-game / waiting.
I’ll try on v4+, if its not working there as well, I’ll let you know.
As for the logs and how account is changed, that’s QA mystery. And it takes time.
Do you initialize IAP after you connect the network? I have a “Initialize IAP” button on my test project. If I start the game without the network, then start the network, then click the initialize button, it works and I get my restore callbacks. If you try to initialize IAP without the network, you should receive the OnInitializeFailed callback.
Initialization is called from Awake at application start;
Manual states that purchasing should be initialized automatically later on if network is not available at the time of initialization. Which it does. Except restore is not performed for some reason [sometimes]. Which is [probably] the cause of DuplicateTransaction.
The same behaviour occurs with 4.0.3, this log was made with 4.0.3 to speed things up;
Here’s the first case:
(No internet start → then toggling internet back on, waiting for the store to initialize, and purchase attempt (no restore occurs after initialization callback));
Please show your code here, using Code tags. Do you receive OnInitialized or OnInitializedFailed? Please provide more detail in your steps, when exactly do you initialize. I just tested IAP 4.0.3 and tried to initialize with no network. I immediately get OnInitializedFailed with NoProductsAvailable. IAP won’t continue to try to connect in this case.
Please provide complete steps to reproduce. If you need, send me a private message. So you DO initialize, THEN kill the network? Please be specific. IAP won’t initialize with no network.
I received your email message, I’m not able to reproduce. When I turn off WiFi on the device and try to connect using IAP 4.0.3, I immediately get OnInitializedFailed, as expected. Are you switching to your phone data plan by chance?