IAP works in editor but not on Android/iPhone

Hi
I thought I had got my IAPs sorted as I was getting the relevant messages and pop ups in my app. However when I build the app and run on phone (either iphone or android) nothing appears to happen

I have installed IAP and set up with my account
Analytics is turned on and I have my unique identifier
When I click the button in Editor I get:
IAPButton.PurchaseProduct() with product ID: com.beriro.masterchange.R1
UnityEngine.EventSystems.EventSystem:Update() (at C:/Program Files/Unity/Hub/Editor/2019.4.0f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/EventSystem.cs:377)
purchase({0}): com.beriro.masterchange.R1
UnityEngine.EventSystems.EventSystem:Update() (at C:/Program Files/Unity/Hub/Editor/2019.4.0f1/Editor/Data/Resources/PackageManager/BuiltInPackages/com.unity.ugui/Runtime/EventSystem/EventSystem.cs:377)

with no errors

I would really appreciate some help in understanding where I have gone wrong (happy to provide more info but not sure what I need to give)

thanks

I would suggest that you start with the Sample IAP Project here, and provide the device logs. Easiest to start on Android. Ensure to place plenty of Debug.Log statements throughout your purchasing code to help debug any issues, they will show in the device logs. I would recommend Scripted IAP instead of Codeless, we still need to update Codeless.

https://discussions.unity.com/t/700293/3

https://discussions.unity.com/t/699654

https://docs.unity3d.com/Manual/UnityIAPGoogleConfiguration.html

1 Like

thank you - will get on it :slight_smile:

unfortunately I think this over estimates my abilities
I have opened up the sample IAP project, running on a later version of Editor, one that I cannot use with my project due to problems with XR manager. I use 2019

Assuming that isn’t a problem I can’t run the sample scene as I get “not initialised” error. I don’t particularly want to be uploading the app to Google Play but it seems that might be necessary to get the key under IAP options.

This is the output i get:
Hello

Starting Initialized…
OnInitialized: PASS
Purchasing product:nonconsume1
Error is The type initializer for ‘UnityEngine.Purchasing.Security.GooglePlayTangle’ threw an exception.
ProcessPurchase: nonconsume1
Purchasing product:weeklysub
Error is The type initializer for ‘UnityEngine.Purchasing.Security.GooglePlayTangle’ threw an exception.
ProcessPurchase: weeklysub
Restore purchases succeeded.

I have no idea what to do next! Do you have a tutorial I can follow?
thanks

I have a same Issue…
IAP Current Version: 3.1.0
Fake Store is works fine in Editor.
however, When building on android mobile, a problem occurs.
IAP Button Script seems to disappear.Only on objects with IAP button scripts, The following warning appears.
unity iap purchasing not initialized correctly

Nothing happens when I click the IAP button.
Help~!!!

Sample Scene is also works fine in Editor.
However, When building on android mobile, The following warning appears.
Unavailable product product.ID
Billing failed to initialize.
No Products available for purchase.

Please, open and run the Sample IAP Project. This code is provided in a single file, IAPManager.cs. You’ve changed it in your code. Specifically, you need a Try/Catch block around receipt validation. It’s not supported in the Editor, only on devices.

Start with the Sample IAP Project. Publish it, and test. Then apply lessons learned to your own project. This way, your game is never “broken”

Google login, Initailize IAP, etc… I used all the methods, but it didn’t work.
However, it was solved when I deleted the item in the Play Store and created a new one.
I am using a system called SG pathcer, and It did not Initialize in this Patch system.
It was a really hard day…If it helps someone.

unfortunately this isn’t much help. I haven’t touched the code in the sample project. How do you build the apk when there is no GUID in the IAP settings? Do I really have to publish the app to Play Store to do this?

7077274--841918--2021-04-26 (2).png

You don’t need that GUID, that’s only for reporting in the Unity Dashboard. You can safely ignore that for now. Yes, you need to publish to Google Play to test and use IAP. https://docs.unity3d.com/Manual/UnityIAPGoogleConfiguration.html (the screenshots are a bit outdated, we are working on that)

1 Like

anyone coming across this post and being left completely lost, check out this tutorial (and the second part) which clearly and helpfully explains how to implement. No confusion, just simple step by step guide

Nice! However, I might not suggest an enum for your product list. Although you certainly can. I often add new products during testing since you can only purchase a non-consumable or subscription once. Also, you will want to add receipt validation and a deferred purchase listener as described in my Sample IAP Project https://discussions.unity.com/t/700293/3 . Also, I think most people are having problems upgrading/installing IAP, that would be a good video too. We are working on that with the documentation team, but it’s likely a couple of months out.

sure but can you see the difference in how he explains this in the video and your language? It will be so helpful if you could dumb down how you describe the solution. For example I have no idea what any of this post means! Enum? deferred purchase listener?

I can’t speak for anyone else, but I am looking for idiot’s guides. In my experience of learning from scratch, there is always someone who is able to do this but it is rarely Unity. Perhaps you could try with the upcoming documentation?

I thought that was your video! He put in the enum. I was making a comment, I would not recommend doing that as you point out, it’s confusing. And I’ve provided a complete working example that you can download, I’ve written the code for you. And yes, we are working on improved documentation. This may help, but the screenshots are a bit outdated https://docs.unity3d.com/Manual/UnityIAPGoogleConfiguration.html A deferred purchase is a new purchasing option from Google where the user can purchase the IAP in the game, and then has 3 days to pay at a physical store, approved by Google. A deferred listener allows you the developer to catch that type of purchase, and not wait on ProcessPurchase nor OnPurchaseFailed. Those will come later, when the user pays.

6 at August, publish date - 15… All works fine, all online features from PlayFab works pefect, all tests passed, but IAP still work only in editor. I don’t know what I need to do… Buttons do not anything. I am stuck. Maybe this problem on Play Console side, I don’t know… I am really tired.
Unity 2012.1.15f.

Sorry, we don’t know either. Please provide more information, probably best in a new thread. Are you using the Sample IAP project? Are you testing in Closed testing on Google, after the review? Have you configured your testers, browsed to the opt-in link on the device, and download the test version of your game from Google Play? Do you have the adb logcat device logs to share? What version of Unity and IAP are you using? What have you tried? Please start a new thread.

Updated documentation here How to Set Up | In App Purchasing | 4.0.3