Hello everyone, I am having an error related to IAP not responding when testing on the device.
The old IAP code works normally, I updated to a higher IAP and edited many things in the new version, it crashed again. Since this error has no log, I don’t know how to find it.
I noticed there are 2 differences in the log of the code, I don’t know if it’s the cause.
In the old code when I make the payment, it outputs a log with such structure “purchase({0}): com.xxx.xxx.gold20”. In the new code, it outputs the log “purchase(com.xxx.xxx.gold20)”.
(xxx is my example)
Looking forward to hearing from you
P/s: Sorry my english is not good, i am using google translate.
I found the problem with the package name.
When I change the new package name, IAP doesn’t work. It still works when reverting to the old package. Please let me know how to fix it. Thanks very much
The package name for your app in Google Play or App Store needs to be the same as entered in Unity > Player Settings. If you change it on one side, you also need to change it on the other.
I realized one thing, that after changing package name. localizedPriceString API commands do not work. There seems to be some link between the old package and this API. I’ve checked all the code but unfortunately can’t find anything
That would be expected. If you change the package name, it’s a new game. And there is a link between the package name and the list of your IAP products, for security. If you change the package name, Google has no information on the products you’ve defined on the Google Dashboard for your game. This may help https://docs.unity3d.com/Packages/com.unity.purchasing@3.2/manual/UnityIAPGoogleConfiguration.html
Well, I think this doesn’t really help me. I have added packages on google play console. The problem I’m having is that the purchase buttons work fine on the editor but when testing on the device it doesn’t respond to anything. You can take a look at the attached script file. Thanks very much
What do you mean “I have added packages to google play console”? Did you change the package name? If so, did you create a new application on your Google dashboard? IAP doesn’t actually connect to Google when running in the Editor, only on your phone. So here’s a good test. Please add me as a tester for your app on your Google dashboard for your Closed testing release. Send me a private email, and I’ll provide my tester email. You should be testing the same way. You need to publish your app to Google Play testing before IAP will work.
And publishing the app on an alpha/beta track takes a while before IAPs are actually available by Google, so if you did this very recently, expect to wait 24-48 hours before testing.
My app is showing the price and can pay now. But when I try to pay with real money → successful payment → but I don’t receive the item. I have created a closed test. Can you give me your email I will send it to you.
//Script related to post-purchase activity. It works perfectly on Editor
Sorry, what do you mean “don’t receive the item”. This would be in your code if the purchase was successful. You will want to debug. Did the Debug.Log show? It will be in the adb logcat logs. This may help https://discussions.unity.com/t/699654