Search Unity

  1. We are migrating the Unity Forums to Unity Discussions by the end of July. Read our announcement for more information and let us know if you have any questions.
    Dismiss Notice
  2. Dismiss Notice

Can't implement interface member 'IStoreListener'

Discussion in 'Unity IAP' started by swifter14, Nov 27, 2019.

  1. swifter14

    swifter14

    Joined:
    Mar 2, 2017
    Posts:
    166
    I tried to upgrade UNITY from 2019.1.8f1 to 2019.2.13f1, and started to get a lot of compiler errors about IAP
    also upgraded IAP to the latest version
    -Can't implement interface member 'IStoreListener'
    using UnityEngine.Purchasing.Security -The name security does not exist in the namespace

    I downgraded back to 2019.1.8f1 but having the same error
    I'm currently stuck with my project. Everything was perfect until that update :\
     
    siddharth3322 likes this.
  2. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    For the time being, you'll likely want to use a project backup before the upgrade. Keep in mind that IAP requires both the In App Purchasing package in Package Manager, and the IAP asset store package. Make sure you have both installed.
     
  3. swifter14

    swifter14

    Joined:
    Mar 2, 2017
    Posts:
    166
    I did upgrade both Package Manager and IAP asset store (also removed the plugin folder and reimported)
     
  4. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    So the backup solution would be the path forward. There should be no need to upgrade the package in Package Manager, or removing plugin folders. What file is the error in? I might suggest to try with a brand new/empty project and import IAP to compare, for testing.
     
  5. swifter14

    swifter14

    Joined:
    Mar 2, 2017
    Posts:
    166
    OK now I'm using my backup (entire Unity project folder backup which I stored before all upgrades), using Unity 2019.1.8f1, Now I'm getting different errors with UnityPurcheshing scripts, what a nightmare, this is why I'm afraid to update Unity,
    so now it's the same old backup, but maybe something is different with Unity 2019.1.8f1 app when I updated the IAP?
    Errors:
    Assets\Plugins\UnityChannel\XiaomiSupport\AppStoreSettings.cs(7,19): error CS0234: The type or namespace name 'Store' does not exist in the namespace 'UnityEngine' (are you missing an assembly reference?)
    Assets\Plugins\UnityPurchasing\script\IAPDemo.cs(20,19): error CS0234: The type or namespace name 'Store' does not exist in the namespace 'UnityEngine' (are you missing an assembly reference?)
    Assets\Plugins\UnityChannel\XiaomiSupport\AppStoreSettings.cs(28,16): error CS0246: The type or namespace name 'AppInfo' could not be found (are you missing a using directive or an assembly reference?)
    Assets\Plugins\UnityPurchasing\script\CodelessIAPStoreListener.cs(21,19): error CS0246: The type or namespace name 'ProductCatalog' could not be found (are you missing a using directive or an assembly reference?)
    Assets\Plugins\UnityPurchasing\script\IAPConfigurationHelper.cs(12,91): error CS0246: The type or namespace name 'ProductCatalog' could not be found (are you missing a using directive or an assembly reference?)
    Assets\Plugins\UnityPurchasing\script\IAPDemo.cs(36,13): error CS0246: The type or namespace name 'IAppleExtensions' could not be found (are you missing a using directive or an assembly reference?)
    Assets\Plugins\UnityPurchasing\script\IAPDemo.cs(37,13): error CS0246: The type or namespace name 'IMoolahExtension' could not be found (are you missing a using directive or an assembly reference?)
    Assets\Plugins\UnityPurchasing\script\IAPDemo.cs(38,13): error CS0246: The type or namespace name 'ISamsungAppsExtensions' could not be found (are you missing a using directive or an assembly reference?)
    Assets\Plugins\UnityPurchasing\script\IAPDemo.cs(39,13): error CS0246: The type or namespace name 'IMicrosoftExtensions' could not be found (are you missing a using directive or an assembly reference?)
    Assets\Plugins\UnityPurchasing\script\IAPDemo.cs(40,13): error CS0246: The type or namespace name 'IUnityChannelExtensions' could not be found (are you missing a using directive or an assembly reference?)
    Assets\Plugins\UnityPurchasing\script\IAPDemo.cs(41,13): error CS0246: The type or namespace name 'ITransactionHistoryExtensions' could not be found (are you missing a using directive or an assembly reference?)
    Assets\Plugins\UnityPurchasing\script\IAPDemo.cs(42,13): error CS0246: The type or namespace name 'IGooglePlayStoreExtensions' could not be found (are you missing a using directive or an assembly reference?)
    Assets\Plugins\UnityPurchasing\script\IAPDemo.cs(630,38): error CS0246: The type or namespace name 'ILoginListener' could not be found (are you missing a using directive or an assembly reference?)
    Assets\Plugins\UnityPurchasing\script\IAPDemo.cs(647,29): error CS0246: The type or namespace name 'UserInfo' could not be found (are you missing a using directive or an assembly reference?)
    Assets\Plugins\UnityPurchasing\script\IAPDemo.cs(634,25): error CS0246: The type or namespace name 'UserInfo' could not be found (are you missing a using directive or an assembly reference?)
     
  6. SamOYUnity3D

    SamOYUnity3D

    Unity Technologies

    Joined:
    May 12, 2019
    Posts:
    626
    Maybe you can try to delete the Library folder under the project and reopen the project (please make a backup first).
     
  7. swifter14

    swifter14

    Joined:
    Mar 2, 2017
    Posts:
    166
    I tried, same errors
     
  8. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    We have heard of reports of users having issues when upgrading between 2019 versions. We are looking into it.
     
  9. swifter14

    swifter14

    Joined:
    Mar 2, 2017
    Posts:
    166
    But it doesn't work with the old version as well, I saved the entire UNITY project folder as a backup before the upgrade, and now when opening it (in the same location) I'm getting all those namespace errors, why? I'm using the same project, same unity version and the same folder that already worked before, what else is different? Does Unity change other files in the system that I need to restore? Some personal settings? Packages? I technically can restore those too if you tell me what other changes happened to my system since I installed the new IAP versions and new unity version
     
  10. swifter14

    swifter14

    Joined:
    Mar 2, 2017
    Posts:
    166
    Another thing -I noticed that after deleting UnityPurchasing and UnityChannel folders and installing IAP from services and asset store, I don't see that UnityChannel folder is being created.

    Update: I'm using now a very old version of the project, and returned to the first problem of this thread- errors on MyIAPManager script, can't implement istorelistener, I can't fix this problem
     
    Last edited: Dec 2, 2019
  11. swifter14

    swifter14

    Joined:
    Mar 2, 2017
    Posts:
    166
    OK I found a backup that worked, the problem is now fixed, I'm not going to upgrade IAP or Unity versions anytime soon, very unstable
     
  12. exzizt

    exzizt

    Joined:
    Sep 30, 2017
    Posts:
    78
    Having the same issue!
     
  13. SamOYUnity3D

    SamOYUnity3D

    Unity Technologies

    Joined:
    May 12, 2019
    Posts:
    626
    Did you open the project with a different version of the editor? What version of the editor and IAP are you using?
     
  14. xxluky

    xxluky

    Joined:
    Dec 4, 2014
    Posts:
    19
    Same problem here. Everything was working fine until I upgraded IAP to 4.6.0 through the Update Button in Services window.
    Now I have this error: 'MyIAPInit' does not implement interface member 'IStoreListener.OnInitializeFailed(InitializationFailureReason, string?)'
     
  15. PhilG-Unity

    PhilG-Unity

    Unity Technologies

    Joined:
    Mar 17, 2022
    Posts:
    26
    Hi @xxluky

    The error you're seeing is because a new method was added to the IStoreListener interface in 4.6.0. A variant of OnInitializedFailed() that takes two args: an InitializationFailureReason as 1st arg, and a string as 2nd arg.

    In your code, if you do highlight IStoreListener, right-click and do "Go To Definition" (assuming Visual Studio), you will see the definition of the IStoreListener interface. Which looks like this as of 4.6.0

    Code (CSharp):
    1.  
    2. public interface IStoreListener
    3.     {
    4.         [Obsolete]
    5.         void OnInitializeFailed(InitializationFailureReason error);
    6.  
    7.         void OnInitializeFailed(InitializationFailureReason error, string? message);
    8.  
    9.         PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs purchaseEvent);
    10.  
    11.         void OnPurchaseFailed(Product product, PurchaseFailureReason failureReason);
    12.  
    13.         void OnInitialized(IStoreController controller, IExtensionProvider extensions);
    14.     }
    15.  

    In your class that inherits from IStoreListener you need to have a method defined for both variants of OnInitializedFailed() in order to make the error you listed go away. The variant with just one arg is marked as Obsolete but you still need to have a definition for it in your class to fully implement this interface. Until the old method is removed you need have both.
     
  16. hamman8888

    hamman8888

    Joined:
    Mar 23, 2016
    Posts:
    4
    I also went through the same thing with version 4.6.
    The solution was to add this
    public class MyStoreListener : MonoBehaviour, IStoreListener
    {
    // ...
    public void OnInitializeFailed(InitializationFailureReason error)
    {
    // Implementation for old version
    }
    public void OnInitializeFailed(InitializationFailureReason error, string message)
    {
    // Implementation for new version
    }
     
  17. Enrique48k

    Enrique48k

    Joined:
    Apr 30, 2019
    Posts:
    10
    I have the same problem. If I display IStoreListener I see the following:

    Code (CSharp):
    1. #region ensamblado UnityEngine.Purchasing, Version=0.0.0.0, Culture=neutral, PublicKeyToken=null
    2. // UnityEngine.Purchasing.dll
    3. #endregion
    4.  
    5.  
    6. namespace UnityEngine.Purchasing
    7. {
    8.     public interface IStoreListener
    9.     {
    10.         void OnInitialized(IStoreController controller, IExtensionProvider extensions);
    11.         void OnInitializeFailed(InitializationFailureReason error);
    12.         void OnPurchaseFailed(Product product, PurchaseFailureReason failureReason);
    13.         PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs purchaseEvent);
    14.     }
    15. }

    I tried the following example from a new project and the exact same thing happens: Assets\Samples\In App Purchasing\4.7.0\01 Buying Consumables\BuyingConsumables.cs

    Assets\Samples\In App Purchasing\4.7.0\01 Buying Consumables\BuyingConsumables.cs(9,53): error CS0535: 'BuyingConsumables' does not implement interface member 'IStoreListener.OnInitializeFailed(InitializationFailureReason)'
     
  18. Yannick_D

    Yannick_D

    Unity Technologies

    Joined:
    Feb 21, 2022
    Posts:
    269
    yolomobile likes this.
  19. yolomobile

    yolomobile

    Joined:
    Jan 13, 2023
    Posts:
    3
  20. Ali-Imran7

    Ali-Imran7

    Joined:
    Feb 17, 2022
    Posts:
    1
    Had the same issue.
    Just copy the IStoreListener.OnInitializeFailed(InitializationFailureReason) duplicate the block and add (InitializationFailureReason, string message).
    Your problem will be solved.
     
    SonerAltincit and Deleted User like this.
  21. AliHassan09

    AliHassan09

    Joined:
    Mar 1, 2023
    Posts:
    3
    Solved!!!
    Facing the same issue for last hour. finally found the solution down grading In app purchase(IAP) from package manager. the suitable version will remove the error keep changing versions if the problem did not solve. Here's the attach file for installing different versions.
     

    Attached Files:

    • IAP.PNG
      IAP.PNG
      File size:
      67.1 KB
      Views:
      470
  22. Arnaud_Gorain

    Arnaud_Gorain

    Unity Technologies

    Joined:
    Jun 28, 2022
    Posts:
    184
    To keep in mind about downgrading:
    4.4.0 -> Google billing v4 support was added
    4.8.0 -> Google billing v5.1 support was added
     
  23. qtbdinfaiz

    qtbdinfaiz

    Joined:
    Sep 16, 2022
    Posts:
    3
    I Updated in-app-purchase package from package manager from version 4.7 to 4.5 and problem have been solved
     
  24. siddharth3322

    siddharth3322

    Joined:
    Nov 29, 2013
    Posts:
    1,049
    Thank you for more specific reply :)
     
  25. Chethan007

    Chethan007

    Joined:
    Dec 3, 2020
    Posts:
    60
    Yeah , you need to use Google billing v5.1 now and it is mandatory. I tried many things , finally came up with this solution

    Code (CSharp):
    1.  void IStoreListener.OnInitializeFailed(InitializationFailureReason error)
    2. {
    3.      OnInitializeFailed(error, null);
    4. }
    5.  
    6. public void OnInitializeFailed(InitializationFailureReason error, string message)
    7. {
    8.      MyDebug("IAP Initialization Failed: " + error + " - " + message);
    9. }
    Is this correct? @Arnaud_Gorain
     
  26. Arnaud_Gorain

    Arnaud_Gorain

    Unity Technologies

    Joined:
    Jun 28, 2022
    Posts:
    184
    Chethan007 likes this.
  27. razzaq94

    razzaq94

    Joined:
    Jul 19, 2016
    Posts:
    4
    This is what just worked for me, I added the 2nd Function in class MyStoreListener : MonoBehaviour, IStoreListenerand it's working fine now.
     
  28. magsoftware

    magsoftware

    Joined:
    Feb 7, 2019
    Posts:
    123
  29. Arnaud_Gorain

    Arnaud_Gorain

    Unity Technologies

    Joined:
    Jun 28, 2022
    Posts:
    184
  30. miraycalskn

    miraycalskn

    Joined:
    Jun 28, 2020
    Posts:
    10
    Anyone still facing the issue with easy mobile, just add this code to inherited class. Should fix
    Code (CSharp):
    1.             public void OnInitializeFailed(InitializationFailureReason error, string message)
    2.             {
    3.                 // Purchasing set-up has not succeeded. Check error for reason. Consider sharing this reason with the user.
    4.                 Debug.Log("In-App Purchasing OnInitializeFailed. InitializationFailureReason:" + error);
    5.  
    6.                 // Done initializing.
    7.                 sIsInitializing = false;
    8.  
    9.                 // Fire event
    10.                 if (InitializeFailed != null)
    11.                     InitializeFailed();
    12.             }
     
  31. abdullahNA

    abdullahNA

    Joined:
    Mar 13, 2022
    Posts:
    5
    in previous purchaser script we only have one function of OnInitializedFailed () as shown in image
    upload_2024-6-19_4-12-24.png
    - but now in new istorelistener required two methods in purchaser script as shown in image below
    it works for me
     

    Attached Files: