Using IAP and for some reason, the restore purchases on the google play is restoring consumable items. That is not good since it will basically allow people to uninstall and install and get all of their in game gold again. I have noticed it is actually restoring on every load it appears but I have
Anyone experienced this problem?
I wouldn’t expect the processpurchase callback to be executed on consumable items. I have google play game services installed as well since I backup players data to playfab but at this time I am not loading data from playfab. Additionally with LogCat I can see it restoring the purchase of a consumable item.
Please provide the logcat logs as an attachment here. Also show how you are defining the product in your code and please provide a screenshot of how the product is defined on your Google Play Developer dashboard. Are you using Codeless IAP? If so, make sure the Consume Product checkbox is checked under the button properties.
Not using codeless. I am doing some additional testing. I don’t recall having this problem until after I added Google Play Services. Added that in for Playfab authentication rather than Facebook. Just did a quick test with GPGS commented out and didn’t see the restore process take the same path. I am now doing a test using the social api but not the GPGS plugins and will see if I get the same issue.
Here is the IAP and Google play scripts I am using. Did a test where I commented out the GPGS initialization and only used the Unity Social API and did not have an IAP restore problem. The main reason I was using GPGS is to get a server auth code for Playfab Authentication. However, it seems there is a problem with GPGS and Unity IAP on the same device with restore or I am doing it wrong.
I would expect your REMOVEADS product to be restored each time. IAP depends on the user who made the purchase, be logged into the Google Play app on the device as this user. Do any of those other libraries log the user off? Restore only happens for subscriptions and non-consumables on Android and there is no separate “Restore” button or functionality like on iOS. On Android it happens automatically, and you would expect ProcessPurchase to be called at IAP initialization for a new install for this product. Also, we need the logcat logs, can you attach them? IAP automatically writes debug information to the logs How To - Capturing Device Logs on Android
Let me restore the code to how it was breaking and I will run a new adb log. Give me a few. And yes even when it was restoring incorrectly it was restoring the removeads as expected. But I was also getting the restoration of the others that had been purchased as well. So a wipe and new install would result in it restoring a 250, 50, and 500 gold that I had previously purchased. I did just happen to stumble on this link that I have never come across before.
Is there a way I can email or send this logcat without posting on the public forum? I have recreated the issue.
Basically I have a startup scene that initializes my playerprefs and Unity Ads. And that async loads the mainentry scene. At that point I have the google play script that I have attached on scene level gameobject. The attached IAP script is basically initialized when someone clicks a “BuyGold” button. Based on the link I posted above it almost appears I should be using the GooglePlay billing instead of the standard store controller but I am not certain on that.
Sorry, please provide only the relevant logs as an attachment here. Please attach a screenshot of where you say the “Restore” is occurring. It would be in ProcessPurchase, so make sure to put clear Debug logs there.
I am doing more debugging and different approaches. I did find a situation where I have a null reference during the purchase callback because I was initializing the IAP and the callback has a reference to a UI item that was not available at that time. Could that have been causing the purchase to be left in pending and then the next time I opened the app it completed the purchase?
I have revamped my process and I am still not 100% certain what the scenario is. I know that I created a new build and installed that APK and then it did some crazy restoring. But it stopped after like the second load. I uninstalled and installed the same apk and have done that several times without issue. If I can identify what when the problem is recreated I will post back here.
Please debug as suggested. Is ProcessPurchase being called? It is not a Restore that is occurring, that only applies to Subscriptions and Non-Consumables. You may have a stuck transaction, debugging will show the issue. No need to share the full logs, go through them first and pull out all your debug statements. You can search for UnityIAP ( case insensitive) for the IAP system debug output in the logcat logs, please provide those lines too.
I have done that and it has been inconsistent on what it is doing. I will continue to research. Seems like it is something I am doing with it being inconsistent.
Please provide your updated code with the additional debug.log statements. One key question, is ProcessPurchase being fired? Let me know if you have any questions around that statement, it is very important. Place your debug statements there, and provide the results between each of your tests (just the debug output). ProcessPurchase is fired when you make a new purchase, and when products are restored. Tips for new Unity users
Okay I have spent a tremendous amount of time on this and of all things for some reason can’t get the ADB to pipe to a file with the filter of unityiap. However, I have recreated. So here is what the process was for this. And this is all testing with a test google account
Was within the game buying items via gold. Had a balance of 740 gold, made a purchase of 100 gold. Closed the app, not just suspend. Re-opened and it restored the last purchase I made of 100 gold and gave me a balance of 940 gold. In the app. This was the second occurence and the first time I recreated it also restored the last purchase I made. Not all purchases just the last purchase.
I have no idea why this won’t pipe to a file with unityiap as the filter. Done this 1000 times. It does fine with other items.
using the command
adb logcat | findstr -i unityIAP c:\temp\iaplog.txt
As requested, only copy your Debug.Log statements here, specifically the ones in ProcessPurchase. What was the result of your debugging? I’m not seeing any of your debug statements in the log? You are calling ReportPurchaseResult all the time, and it in turn calls OnIAPPurchaseCompleted. That could be causing your issue. Don’t do any of that, get the basics working first.Please use the Sample IAP Project, and get it working first. And PLEASE log from ProcessPurchase, you have the string already in purchaseResult. Use Debug.Log to track the flow of your code. The correct syntax for adb logcat is mentioned here How To - Capturing Device Logs on Android The Sample IAP Project is here Sample IAP Project