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
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?
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.
[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’
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.
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
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.
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 .
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.
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!
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.
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?
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).