Purchasing: the name StandardPurchasingModule does not exist in current context

using System;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Purchasing;


// Deriving the Purchaser class from IStoreListener enables it to receive messages from Unity Purchasing.
public class Purchaser : MonoBehaviour, IStoreListener
{

public void InitializePurchasing()
    {
        // If we have already connected to Purchasing ...
        if (IsInitialized())
        {
            // ... we are done here.
            return;
        }

        // Create a builder, first passing in a suite of Unity provided stores.
        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?

2 Likes

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?

1 Like

I am getting this same error but i DO have IAP enabled

2 Likes

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.

42 Likes

Hi @Skyboard_Studios it really helped.
Thanks allot

1 Like

This worked for me too…
But I require to manually import both Unity Packages: UnityPurchasing and UnityConnect

2 Likes

@Skyboard_Studios
Hepled me too.
Thanks man.

1 Like

[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().

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 @Skyboard_Studios 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?

1 Like

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

2 Likes

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.

34 Likes

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 .

3 Likes

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.

2 Likes

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!

3 Likes

@SkyboardSoftware
it works!!! thank you!!!

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!

1 Like

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.

7 Likes

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?

thank you!
ur solution works well

1 Like

This may help also, there should not be any need to edit any files. IAP Troubleshooting - Remove and Reinstall Unity IAP and the video with this may help also Sample IAP Project . You MUST confirm the dialog that prompts you to update Unity API (note that this dialog mentions API, not IAP).