Search Unity

Purchasing: the name StandardPurchasingModule does not exist in current context.

Discussion in 'iOS and tvOS' started by Voloda2, Feb 19, 2017.

  1. Voloda2

    Voloda2

    Joined:
    Jan 7, 2017
    Posts:
    5
    Code (CSharp):
    1. using System;
    2. using System.Collections.Generic;
    3. using UnityEngine;
    4. using UnityEngine.Purchasing;
    5.  
    6.  
    7. // Deriving the Purchaser class from IStoreListener enables it to receive messages from Unity Purchasing.
    8. public class Purchaser : MonoBehaviour, IStoreListener
    9. {
    10.  
    11. public void InitializePurchasing()
    12.     {
    13.         // If we have already connected to Purchasing ...
    14.         if (IsInitialized())
    15.         {
    16.             // ... we are done here.
    17.             return;
    18.         }
    19.  
    20.         // Create a builder, first passing in a suite of Unity provided stores.
    21.         var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());
    I have some errors.

    The name StandardPurchasingModule.Instance does not exist in current context.
    The type or namespace IAppleExtensions could not be found

    xamarin studio 6.1.5 on osx

    What is wrong?
     
    IgorAherne and BAIZOR like this.
  2. Voloda2

    Voloda2

    Joined:
    Jan 7, 2017
    Posts:
    5
    UnityPurchasing Class is available to compiler and runtime when Unity IAP is enabled in Editor's Services window. So I enabled and it solved problem. Unity why do you use so absurd solutions?
     
    gonzalezsp likes this.
  3. ev3d

    ev3d

    Joined:
    Apr 19, 2013
    Posts:
    327
    I am getting this same error but i DO have IAP enabled

    Screenshot 2017-02-23 at 01.32.14 PM.png
     
    F3ND1MUS and BAIZOR like this.
  4. Skyboard_Studios

    Skyboard_Studios

    Joined:
    Jul 20, 2013
    Posts:
    51
    When you hit the Reimport button you will see that in your Plugins\UnityPurchasing folder you have a singular file that you can further import.

    On import you will see



    Interesting how I did this a couple times as I had the same error as you and nothing worked until I ran the UnityIAP manually...

    Hope that helps.

    Update in 2018 I ran across this anoying message saying must update.. and I ignored it for a few months... and then just today I decided to walk down the road up updating my IAP and I had to delete the UnityPurchasing Folder / restart Unity.. / Import the Asset from the Above Image. / then manually importing the secondary asset that is in the root of the UnityPurchasing directory.






    This last go of reupdating took a couple tries and I had to per persistent. Felt like at least 3 cycles of the "Hey your IAP is outdated... You want to update?" dialogues.... But at this momement all seems ok.
     
    Last edited: Dec 15, 2018
  5. zero_null

    zero_null

    Joined:
    Mar 11, 2014
    Posts:
    159
    Skyboard_Studios likes this.
  6. siddharth3322

    siddharth3322

    Joined:
    Nov 29, 2013
    Posts:
    1,049
    This worked for me too...
    But I require to manually import both Unity Packages: UnityPurchasing and UnityConnect
     
    Skyboard_Studios and Loomabox like this.
  7. sarthakshah

    sarthakshah

    Joined:
    Jun 27, 2013
    Posts:
    3
    Skyboard_Studios likes this.
  8. kreso

    kreso

    Joined:
    Sep 7, 2013
    Posts:
    147
    [EDIT: solved]: Wow, I was using UnityPurchasing instead of 'StandardPurchasingModule' for getting the Instance. I guess the code for IAP changed slightly sometime in the past, and I wasn't paying attention to this. All is well now.

    ---

    I noticed IAP wasn't working on Android (after making an update to my game), so I went to the service tab and it said it has an update for IAP. Suddenly it stopped working, and ow my code no longer compiles (even though it worked very fine before).

    Problem that I keep getting is:
    UnityEngine.Purchasing.UnityPurchasing does not contain a definition for 'Instance'




    When I inspect the DLL, I simply do not see the freakin code in it for Instance().
     
    Last edited: Apr 25, 2018
  9. mattbrandmm

    mattbrandmm

    Joined:
    Jun 5, 2018
    Posts:
    90
    I am having this same issue in 2018.2.7:

    The name StandardPurchasingModule.Instance does not exist in current context.
    The type or namespace IAppleConfiguration could not be found
    The type or namespace IAppleExtensions could not be found

    I tried removing and reinstalling the In App Purchasing package in the Unity Package Manager, to no avail.

    The solution that @SkyboardSoftware posted is no longer relevant, as with Unity Package Manager you can no longer hit a button to reimport, and you can no longer import with options to select/deselect.

    Anyone know what to do?
     
    Last edited: Sep 7, 2018
    meghs91 likes this.
  10. AlCaTrAzzGames

    AlCaTrAzzGames

    Joined:
    May 17, 2017
    Posts:
    25
    make sure that after turning on IAP under services, that you import the package as well. ran into the same issue on 2018.2.5f1 here, this fixed it up for us

     
    lovk4ch and IgorAherne like this.
  11. mattbrandmm

    mattbrandmm

    Joined:
    Jun 5, 2018
    Posts:
    90
    Yes I did that. Thank you.

    The solution ended up being to comment out the lines that were preventing compilation, then Unity gave a popup to install IAP, which I did, including importing, and then I was able to uncomment out the lines that it was complaining about.
     
  12. vaishakh_r

    vaishakh_r

    Joined:
    Jun 22, 2018
    Posts:
    1
    What really worked for me after trying many things for couple of hours is the solution suggested by @mattbrandmm . Thanks Matt . It was a great relief to see it working.

    For those who would like to get logs from Unity on Android device is
    adb logcat -s Unity PackageManager dalvikvm DEBUG

    You need to have adb installed for this which usually comes with Android Studio or you can download it .
     
    DhiaSendi, Astirian and mattbrandmm like this.
  13. Tom-Atom

    Tom-Atom

    Joined:
    Jun 29, 2014
    Posts:
    153
    Solution by @mattbrandmm worked for me.

    In my case I added script for handling IAPs form another game before I enabled IAPs in Services. It looks, like it creates kind of deadlock: IAP service does not finish installation before you remove errors in code and errors are not removed before IAP service is imported. Commenting error lines of code out temporarilly allows Services to import IAPs.
     
    Astirian and mattbrandmm like this.
  14. Astirian

    Astirian

    Joined:
    Apr 28, 2018
    Posts:
    15
    J3sus, Mary and Joseph, I wasted days on this. Whole Sunday evenings gone. You've just about saved my sanity @mattbrandmm ... If I wasn't working for myself, I would have been fired over this. I still might fire myself, we'll see!

    Thank you!
     
    Last edited: Oct 20, 2023
  15. kmsjkh

    kmsjkh

    Joined:
    Jan 31, 2016
    Posts:
    14
    @SkyboardSoftware
    it works!!!! thank you!!!
     
  16. Skyboard_Studios

    Skyboard_Studios

    Joined:
    Jul 20, 2013
    Posts:
    51
    It is quite amazing on how much time one can spend on such activities!
    Latest Version is all working now.



    @mattbrandmm commenting out the lines of code that have the issue before updating would smooth-en out the process for sure. Great catch!
     
    Last edited: Dec 15, 2018
    mattbrandmm likes this.
  17. Janibasha

    Janibasha

    Joined:
    Mar 7, 2017
    Posts:
    8
    To fixed it, just go the folder 'UnityPurchasing' folder in 'Plugins' folder. Then double click on the package Unity IAP. Import all and the problem solved. If it does fix your problem just try Dong Nguyen solution.
     
    nhanc18, sarebots2, monark and 4 others like this.
  18. martin_unity660

    martin_unity660

    Joined:
    Feb 15, 2019
    Posts:
    22
    Hi,

    I run into the same error. I tried now all of the solutions here without any success. If I create a new project or load the SurvivalShooter_IAP_Demo it seems to work totally fine. But as soon as I add it to my existing project this error will show up. Any suggestions?
     
  19. greenyello

    greenyello

    Joined:
    Apr 19, 2013
    Posts:
    18
    thank you!
    ur solution works well
     
    CrandellWS likes this.
  20. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
  21. Jonsi

    Jonsi

    Joined:
    May 21, 2013
    Posts:
    45
    Thanks!This worked for me.
     
  22. shoridevel

    shoridevel

    Joined:
    Jan 28, 2015
    Posts:
    1
    Solve: You must import in this order.
    1. IAP On.
    1. IAP import.
    2. Your sourcecode import.
     
    Rem777 and sarathak like this.
  23. austinborden

    austinborden

    Joined:
    Aug 5, 2016
    Posts:
    24
    In my case I was getting the error from a test class that has an asmdef. I had to add UnityEngine.Purchasing.dll and Stores.dll to the references and the error went away.

    assembly_reference.png
     
    Neohun, arcandio, koblavi and 2 others like this.
  24. jimbojimbo82

    jimbojimbo82

    Joined:
    May 22, 2019
    Posts:
    6
    Thank you this worked a treat!!!
     
  25. JeddJedd

    JeddJedd

    Joined:
    Jul 15, 2017
    Posts:
    1
    Skyboard you're a lifesaver. Importing manually fixed it. Thank you.
     
  26. ferranases

    ferranases

    Joined:
    Feb 27, 2017
    Posts:
    11
    That work for me.
    Commented the lanes that give me errors, then the project compile in Unity and show you to install things, and then come back to uncoment the code :)
     
  27. Darknesssss

    Darknesssss

    Joined:
    Jun 19, 2019
    Posts:
    1
    Thanks in 2020 my friend
     
  28. wa4lnut

    wa4lnut

    Joined:
    Apr 26, 2020
    Posts:
    2

    Thanks, that worked for me in unity 2019.3
     
  29. aldawoodimustafa

    aldawoodimustafa

    Joined:
    Dec 7, 2018
    Posts:
    1
    Great + BIG LIKE
     
  30. JeffDUnity3D

    JeffDUnity3D

    Joined:
    May 2, 2017
    Posts:
    14,446
    I noticed the same thing! I just deleted the files that were showing the errors. After deleting the last one, the installer magically started. Interesting. FYI the best forum to post IAP issues is here https://forum.unity.com/forums/unity-iap.112/
     
  31. sama-van

    sama-van

    Joined:
    Jun 2, 2009
    Posts:
    1,734
    Very good catch, it didn't even cross my mind P_P...!! Works a charm now!
     
  32. dean0

    dean0

    Joined:
    Mar 7, 2014
    Posts:
    10
    Yes! Many thanks for that tip.

    If you are using unity purchasing from an assembly, make sure you add Assembly Definition References to Unity.Purchasing, AND UnityEngine.Purchasing.Stores
     
  33. Golkar_Asghar

    Golkar_Asghar

    Joined:
    Jun 17, 2015
    Posts:
    10

    It's working solution. Tnk u.
     
  34. DhiaSendi

    DhiaSendi

    Joined:
    May 16, 2018
    Posts:
    42
    Unity 2020.3.34
    For anyone upgrading to a newer Unity version I managed to fix the issue by :
    1- Make sure the IAP is on under "Services" (Window/General/Services)
    2- Delete the folder "Assets/Plugins/UnityPurchasing
    3- Comment the lines with errors or simply cut/past the whole class somewhere else, wait the editor to recompile then get back the class
     
  35. andrew_pearce_

    andrew_pearce_

    Joined:
    Nov 5, 2018
    Posts:
    169
    Since I migrate from Unity 2018.4 to 2020.3 I faced the problem with missing StandardPurchasingModule (the same error was with 2021). If you are also using assemblies, then do not forget to add another assembly "UnityEngine.Purchasing.Stores". In past, it was enough to have only "UnityEngine.Purchasing". I hope it will saves sometimes time.