public Amazon_InAppPurchasePlugin_Android(InAppPurchaseDesc desc, InAppPurchaseCreatedCallbackMethod createdCallback)
        {
            this.createdCallback = createdCallback;
            try
            {
                testTrialMode = desc.TestTrialMode;
                InAppIDs      = desc.Android_Amazon_InAppIDs;

                native = new AndroidJavaClass("com.reignstudios.reignnativeamazon.Amazon_InAppPurchaseNative");
                string skus = "", types = "";
                foreach (var app in desc.Android_Amazon_InAppIDs)
                {
                    if (app != desc.Android_Amazon_InAppIDs[0])
                    {
                        skus  += ":";
                        types += ":";
                    }

                    skus  += app.ID;
                    types += app.Type == InAppPurchaseTypes.NonConsumable ? "ENTITLED" : "CONSUMABLE";
                }
                native.CallStatic("Init", skus, types, desc.Testing);
            }
            catch (Exception e)
            {
                Debug.LogError(e.Message);
                if (createdCallback != null)
                {
                    createdCallback(false);
                }
            }
        }
Beispiel #2
0
        public GooglePlay_InAppPurchasePlugin_Android(InAppPurchaseDesc desc, InAppPurchaseCreatedCallbackMethod createdCallback)
        {
            this.createdCallback = createdCallback;
            try
            {
                testTrialMode = desc.TestTrialMode;
                InAppIDs      = desc.Android_GooglePlay_InAppIDs;

                native = new AndroidJavaClass("com.reignstudios.reignnativegoogleplay.GooglePlay_InAppPurchaseNative");
                string skus = "", types = "";
                foreach (var app in desc.Android_GooglePlay_InAppIDs)
                {
                    if (app != desc.Android_GooglePlay_InAppIDs[0])
                    {
                        skus  += ":";
                        types += ":";
                    }

                    skus  += app.ID;
                    types += app.Type == InAppPurchaseTypes.NonConsumable ? "NonConsumable" : "Consumable";
                }
                native.CallStatic("Init", desc.Android_GooglePlay_Base64Key, skus, types, desc.Testing, desc.ClearNativeCache);
            }
            catch (Exception e)
            {
                Debug.LogError(e.Message);
                if (createdCallback != null)
                {
                    createdCallback(false);
                }
            }
        }
		public AppleStore_InAppPurchasePlugin_iOS(InAppPurchaseDesc desc, InAppPurchaseCreatedCallbackMethod callback)
		{
			bool pass = true;
			try
			{
				InAppIDs = desc.iOS_AppleStore_InAppIDs;
				native = InitInAppPurchase(desc.Testing, desc.iOS_AppleStore_SharedSecretKey + '\0');
				
				unsafe
				{
					byte** dataPtr = (byte**)Marshal.AllocHGlobal(desc.iOS_AppleStore_InAppIDs.Length * IntPtr.Size).ToPointer();
					int i = 0;
					foreach (var id in desc.iOS_AppleStore_InAppIDs)
					{
						var data = Encoding.ASCII.GetBytes(id.ID);
						dataPtr[i] = (byte*)Marshal.AllocHGlobal(data.Length+1).ToPointer();
						Marshal.Copy(data, 0, new IntPtr(dataPtr[i]), data.Length);
						dataPtr[i][data.Length] = 0;
						
						++i;
					}
					
					CreateInAppPurchase(native, dataPtr, desc.iOS_AppleStore_InAppIDs.Length);
				}
			}
			catch (Exception e)
			{
				Debug.LogError(e.Message);
				pass = false;
			}
			
			if (callback != null) callback(pass);
		}
		public Amazon_InAppPurchasePlugin_Android(InAppPurchaseDesc desc, InAppPurchaseCreatedCallbackMethod createdCallback)
		{
			this.createdCallback = createdCallback;
			try
			{
				testTrialMode = desc.TestTrialMode;
				InAppIDs = desc.Android_Amazon_InAppIDs;
				
				native = new AndroidJavaClass("com.reignstudios.reignnativeamazon.Amazon_InAppPurchaseNative");
				string skus = "", types = "";
				foreach (var app in desc.Android_Amazon_InAppIDs)
				{
					if (app != desc.Android_Amazon_InAppIDs[0])
					{
						skus += ":";
						types += ":";
					}
					
					skus += app.ID;
					types += app.Type == InAppPurchaseTypes.NonConsumable ? "ENTITLED" : "CONSUMABLE";
				}
				native.CallStatic("Init", skus, types, desc.Testing);
			}
			catch (Exception e)
			{
				Debug.LogError(e.Message);
				if (createdCallback != null) createdCallback(false);
			}
		}
		public GooglePlay_InAppPurchasePlugin_Android(InAppPurchaseDesc desc, InAppPurchaseCreatedCallbackMethod createdCallback)
		{
			this.createdCallback = createdCallback;
			try
			{
				testTrialMode = desc.TestTrialMode;
				InAppIDs = desc.Android_GooglePlay_InAppIDs;
				
				native = new AndroidJavaClass("com.reignstudios.reignnativegoogleplay.GooglePlay_InAppPurchaseNative");
				string skus = "", types = "";
				foreach (var app in desc.Android_GooglePlay_InAppIDs)
				{
					if (app != desc.Android_GooglePlay_InAppIDs[0])
					{
						skus += ":";
						types += ":";
					}
					
					skus += app.ID;
					types += app.Type == InAppPurchaseTypes.NonConsumable ? "NonConsumable" : "Consumable";
				}
				native.CallStatic("Init", desc.Android_GooglePlay_Base64Key, skus, types, desc.Testing, desc.ClearNativeCache);
			}
			catch (Exception e)
			{
				Debug.LogError(e.Message);
				if (createdCallback != null) createdCallback(false);
			}
		}
Beispiel #6
0
        public MicrosoftStore_InAppPurchasePlugin_Native(InAppPurchaseDesc desc, InAppPurchaseCreatedCallbackMethod createdCallback)
        {
            testing       = desc.Testing;
            testTrialMode = desc.TestTrialMode;

                        #if WINDOWS_PHONE
            InAppIDs = desc.WP8_MicrosoftStore_InAppIDs;
                        #else
            InAppIDs = desc.WinRT_MicrosoftStore_InAppIDs;
                        #endif

            if (desc.Testing)
            {
                loadTestData(desc, createdCallback);
            }
            else
            {
                licenseInformation = CurrentApp.LicenseInformation;
                licenseInformation.LicenseChanged += licenseChanged;
                if (createdCallback != null)
                {
                    createdCallback(true);
                }
            }
        }
Beispiel #7
0
        private async void loadTestData(InAppPurchaseDesc desc, InAppPurchaseCreatedCallbackMethod createdCallback)
        {
            bool pass = true;

            try
            {
                // create xml obj
                var currentApp = new InAppTestObjects.CurrentApp();
                currentApp.ListingInformation.Products = new InAppTestObjects.ListingInformation_Product[desc.WinRT_MicrosoftStore_InAppIDs.Length];
                currentApp.LicenseInformation.Products = new InAppTestObjects.LicenseInformation_Product[desc.WinRT_MicrosoftStore_InAppIDs.Length];
                for (int i = 0; i != currentApp.ListingInformation.Products.Length; ++i)
                {
                    var listingProduct = new InAppTestObjects.ListingInformation_Product();
                    listingProduct.ProductId                  = desc.WinRT_MicrosoftStore_InAppIDs[i].ID;
                    listingProduct.ProductType                = desc.WinRT_MicrosoftStore_InAppIDs[i].Type == InAppPurchaseTypes.NonConsumable ? null : "Consumable";
                    listingProduct.MarketData.Name            = desc.WinRT_MicrosoftStore_InAppIDs[i].ID;
                    listingProduct.MarketData.Description     = null;
                    listingProduct.MarketData.Price           = desc.WinRT_MicrosoftStore_InAppIDs[i].Price.ToString();
                    listingProduct.MarketData.CurrencySymbol  = desc.WinRT_MicrosoftStore_InAppIDs[i].CurrencySymbol;
                    currentApp.ListingInformation.Products[i] = listingProduct;

                    var licenseProduct = new InAppTestObjects.LicenseInformation_Product();
                    licenseProduct.ProductId = desc.WinRT_MicrosoftStore_InAppIDs[i].ID;
                    currentApp.LicenseInformation.Products[i] = licenseProduct;
                }

                // serialize obj
                var    xml  = new XmlSerializer(typeof(InAppTestObjects.CurrentApp));
                byte[] data = null;
                using (var stream = new MemoryStream())
                {
                    xml.Serialize(stream, currentApp);
                    stream.Position = 0;
                    data            = new byte[stream.Length];
                    stream.Read(data, 0, data.Length);
                }

                // write and read test InApp data
                StorageFile writeFile = await ApplicationData.Current.LocalFolder.CreateFileAsync("TEST_InAppPurchase.xml", CreationCollisionOption.ReplaceExisting);

                await FileIO.WriteBytesAsync(writeFile, data);

                StorageFile readFile = await ApplicationData.Current.LocalFolder.GetFileAsync("TEST_InAppPurchase.xml");

                await CurrentAppSimulator.ReloadSimulatorAsync(readFile);

                licenseInformation = CurrentAppSimulator.LicenseInformation;
                licenseInformation.LicenseChanged += licenseChanged;
            }
            catch (Exception e)
            {
                Debug.LogError(e.Message);
                pass = false;
            }

            if (createdCallback != null)
            {
                createdCallback(pass);
            }
        }
 /// <summary>
 /// Dumy Constructor.
 /// </summary>
 /// <param name="desc"></param>
 /// <param name="callback"></param>
 public Dumy_InAppPurchasePlugin(InAppPurchaseDesc desc, InAppPurchaseCreatedCallbackMethod callback)
 {
     IsTrial  = desc.TestTrialMode;
     InAppIDs = new InAppPurchaseID[0];
     if (callback != null)
     {
         callback(true);
     }
 }
 public InAppPurchasePlugin(InAppPurchaseDesc desc, InAppPurchaseCreatedCallbackMethod callback)
 {
     testTrialMode = desc.TestTrialMode;
     InAppIDs      = desc.Editor_InAppIDs;
     if (callback != null)
     {
         callback(true);
     }
 }
Beispiel #10
0
        private async void loadTestData(InAppPurchaseDesc desc, InAppPurchaseCreatedCallbackMethod createdCallback)
        {
            bool pass = true;

            try
            {
                MockIAPLib.MockIAP.Init();
                MockIAPLib.MockIAP.RunInMockMode(true);
                MockIAPLib.MockIAP.SetListingInformation(1, "en-us", "Some description", "1", "TestApp");

                int i = 1;
                foreach (var inApp in desc.WP8_MicrosoftStore_InAppIDs)
                {
                    var product = new MockIAPLib.ProductListing
                    {
                        Name           = inApp.ID,
                        ImageUri       = new Uri("/Res/ReignIcon.png", UriKind.Relative),
                        ProductId      = inApp.ID,
                        ProductType    = inApp.Type == InAppPurchaseTypes.NonConsumable ? ProductType.Durable : ProductType.Consumable,
                        Keywords       = new string[] { "image" },
                        Description    = "Product Desc " + i,
                        FormattedPrice = inApp.CurrencySymbol + inApp.Price,
                        Tag            = string.Empty
                    };

                    MockIAPLib.MockIAP.AddProductListing(inApp.ID, product);
                    ++i;
                }

                wp8TestListingInformation = await CurrentAppSimulator.LoadListingInformationAsync();

                MockIAPLib.MockIAP.ClearCache();
                wp8TestLicenseInformation = CurrentAppSimulator.LicenseInformation;
                wp8TestLicenseInformation.LicenseChanged += licenseChanged;
            }
            catch (Exception e)
            {
                Debug.LogError(e.Message);
                pass = false;
            }

            if (createdCallback != null)
            {
                createdCallback(pass);
            }
        }
		public InAppPurchasePlugin_BB10(InAppPurchaseDesc desc, InAppPurchaseCreatedCallbackMethod callback)
		{
			bool pass = true;
			try
			{
				InAppIDs = desc.BB10_BlackBerryWorld_InAppIDs;
				
				testing = desc.Testing;
				paymentservice_set_connection_mode(desc.Testing);
			}
			catch (Exception e)
			{
				Debug.LogError(e.Message);
				pass = false;
			}
			
			if (callback != null) callback(pass);
		}
        public InAppPurchasePlugin_BB10(InAppPurchaseDesc desc, InAppPurchaseCreatedCallbackMethod callback)
        {
            bool pass = true;

            try
            {
                InAppIDs = desc.BB10_BlackBerryWorld_InAppIDs;

                testing = desc.Testing;
                paymentservice_set_connection_mode(desc.Testing);
            }
            catch (Exception e)
            {
                Debug.LogError(e.Message);
                pass = false;
            }

            if (callback != null)
            {
                callback(pass);
            }
        }
        public AppleStore_InAppPurchasePlugin_iOS(InAppPurchaseDesc desc, InAppPurchaseCreatedCallbackMethod callback)
        {
                        #if !IOS_DISABLE_APPLE_IAP
            bool pass = true;
            try
            {
                InAppIDs = desc.iOS_AppleStore_InAppIDs;
                native   = InitInAppPurchase(desc.Testing, desc.iOS_AppleStore_SharedSecretKey + '\0');

                unsafe
                {
                    byte **dataPtr = (byte **)Marshal.AllocHGlobal(desc.iOS_AppleStore_InAppIDs.Length * IntPtr.Size).ToPointer();
                    int    i       = 0;
                    foreach (var id in desc.iOS_AppleStore_InAppIDs)
                    {
                        var data = Encoding.ASCII.GetBytes(id.ID);
                        dataPtr[i] = (byte *)Marshal.AllocHGlobal(data.Length + 1).ToPointer();
                        Marshal.Copy(data, 0, new IntPtr(dataPtr[i]), data.Length);
                        dataPtr[i][data.Length] = 0;

                        ++i;
                    }

                    CreateInAppPurchase(native, dataPtr, desc.iOS_AppleStore_InAppIDs.Length);
                }
            }
            catch (Exception e)
            {
                Debug.LogError(e.Message);
                pass = false;
            }

            if (callback != null)
            {
                callback(pass);
            }
                        #endif
        }
		private async void loadTestData(InAppPurchaseDesc desc, InAppPurchaseCreatedCallbackMethod createdCallback)
		{
			bool pass = true;
			try
			{
				// create xml obj
				var currentApp = new InAppTestObjects.CurrentApp();
				currentApp.ListingInformation.Products = new InAppTestObjects.ListingInformation_Product[desc.WinRT_MicrosoftStore_InAppIDs.Length];
				currentApp.LicenseInformation.Products = new InAppTestObjects.LicenseInformation_Product[desc.WinRT_MicrosoftStore_InAppIDs.Length];
				for (int i = 0; i != currentApp.ListingInformation.Products.Length; ++i)
				{
					var listingProduct = new InAppTestObjects.ListingInformation_Product();
					listingProduct.ProductId = desc.WinRT_MicrosoftStore_InAppIDs[i].ID;
					listingProduct.ProductType = desc.WinRT_MicrosoftStore_InAppIDs[i].Type == InAppPurchaseTypes.NonConsumable ? null : "Consumable";
					listingProduct.MarketData.Name = desc.WinRT_MicrosoftStore_InAppIDs[i].ID;
					listingProduct.MarketData.Description = null;
					listingProduct.MarketData.Price = desc.WinRT_MicrosoftStore_InAppIDs[i].Price.ToString();
					listingProduct.MarketData.CurrencySymbol = desc.WinRT_MicrosoftStore_InAppIDs[i].CurrencySymbol;
					currentApp.ListingInformation.Products[i] = listingProduct;

					var licenseProduct = new InAppTestObjects.LicenseInformation_Product();
					licenseProduct.ProductId = desc.WinRT_MicrosoftStore_InAppIDs[i].ID;
					currentApp.LicenseInformation.Products[i] = licenseProduct;
				}

				// serialize obj
				var xml = new XmlSerializer(typeof(InAppTestObjects.CurrentApp));
				byte[] data = null;
				using (var stream = new MemoryStream())
				{
					xml.Serialize(stream, currentApp);
					stream.Position = 0;
					data = new byte[stream.Length];
					stream.Read(data, 0, data.Length);
				}

				// write and read test InApp data
				StorageFile writeFile = await ApplicationData.Current.LocalFolder.CreateFileAsync("TEST_InAppPurchase.xml", CreationCollisionOption.ReplaceExisting);
				await FileIO.WriteBytesAsync(writeFile, data);
			
				StorageFile readFile = await ApplicationData.Current.LocalFolder.GetFileAsync("TEST_InAppPurchase.xml");
				await CurrentAppSimulator.ReloadSimulatorAsync(readFile);
				licenseInformation = CurrentAppSimulator.LicenseInformation;
				licenseInformation.LicenseChanged += licenseChanged;
			}
			catch (Exception e)
			{
				Debug.LogError(e.Message);
				pass = false;
			}

			if (createdCallback != null) createdCallback(pass);
		}
		/// <summary>
		/// Dumy Constructor.
		/// </summary>
		/// <param name="desc"></param>
		/// <param name="callback"></param>
		public Dumy_InAppPurchasePlugin(InAppPurchaseDesc desc, InAppPurchaseCreatedCallbackMethod callback)
		{
			IsTrial = desc.TestTrialMode;
			InAppIDs = new InAppPurchaseID[0];
			if (callback != null) callback(true);
		}
		/// <summary>
		/// Used by the Reign plugin.
		/// </summary>
		/// <param name="desc">IAP Desc.</param>
		/// <param name="callback">The callback fired when done.</param>
		/// <returns>Returns IAP plugin interface</returns>
		public static IInAppPurchasePlugin New(InAppPurchaseDesc desc, InAppPurchaseCreatedCallbackMethod callback)
		{
			#if DISABLE_REIGN
			return new Dumy_InAppPurchasePlugin(desc, callback);
			#elif UNITY_EDITOR
			return new InAppPurchasePlugin(desc, callback);
			#elif UNITY_WP8
			if (desc.WP8_InAppPurchaseAPI == InAppPurchaseAPIs.None) return new Dumy_InAppPurchasePlugin(desc, callback);
			else if (desc.WP8_InAppPurchaseAPI == InAppPurchaseAPIs.MicrosoftStore) return new MicrosoftStore_InAppPurchasePlugin_WinRT(desc, callback);
			else throw new Exception("Unsuported WP8_InAppPurchaseAPI " + desc.WP8_InAppPurchaseAPI);
			#elif UNITY_METRO
			if (desc.WinRT_InAppPurchaseAPI == InAppPurchaseAPIs.None) return new Dumy_InAppPurchasePlugin(desc, callback);
			else if (desc.WinRT_InAppPurchaseAPI == InAppPurchaseAPIs.MicrosoftStore) return new MicrosoftStore_InAppPurchasePlugin_WinRT(desc, callback);
			else throw new Exception("Unsuported WinRT_InAppPurchaseAPI: " + desc.WinRT_InAppPurchaseAPI);
			#elif UNITY_BLACKBERRY
			if (desc.BB10_InAppPurchaseAPI == InAppPurchaseAPIs.None) return new Dumy_InAppPurchasePlugin(desc, callback);
			else if (desc.BB10_InAppPurchaseAPI == InAppPurchaseAPIs.BlackBerryWorld) return new InAppPurchasePlugin_BB10(desc, callback);
			else throw new Exception("Unsuported BB10_InAppPurchaseAPI: " + desc.BB10_InAppPurchaseAPI);
			#elif UNITY_IOS
			if (desc.iOS_InAppPurchaseAPI == InAppPurchaseAPIs.None) return new Dumy_InAppPurchasePlugin(desc, callback);
			else if (desc.iOS_InAppPurchaseAPI == InAppPurchaseAPIs.AppleStore) return new AppleStore_InAppPurchasePlugin_iOS(desc, callback);
			else throw new Exception("Unsuported iOS_InAppPurchaseAPI: " + desc.iOS_InAppPurchaseAPI);
			#elif UNITY_ANDROID
			if (desc.Android_InAppPurchaseAPI == InAppPurchaseAPIs.None) return new Dumy_InAppPurchasePlugin(desc, callback);
			else if (desc.Android_InAppPurchaseAPI == InAppPurchaseAPIs.GooglePlay) return new GooglePlay_InAppPurchasePlugin_Android(desc, callback);
			else if (desc.Android_InAppPurchaseAPI == InAppPurchaseAPIs.Amazon) return new Amazon_InAppPurchasePlugin_Android(desc, callback);
			else if (desc.Android_InAppPurchaseAPI == InAppPurchaseAPIs.Samsung) return new Samsung_InAppPurchasePlugin_Android(desc, callback);
			else throw new Exception("Unsuported Android_InAppPurchaseAPI: " + desc.Android_InAppPurchaseAPI);
			#else
			return new Dumy_InAppPurchasePlugin(desc, callback);
			#endif
		}
 /// <summary>
 /// Used by the Reign plugin.
 /// </summary>
 /// <param name="desc">IAP Desc.</param>
 /// <param name="callback">The callback fired when done.</param>
 /// <returns>Returns IAP plugin interface</returns>
 public static IInAppPurchasePlugin New(InAppPurchaseDesc desc, InAppPurchaseCreatedCallbackMethod callback)
 {
                 #if DISABLE_REIGN
     return(new Dumy_InAppPurchasePlugin(desc, callback));
                 #elif UNITY_EDITOR
     return(new InAppPurchasePlugin(desc, callback));
                 #elif UNITY_WP8
     if (desc.WP8_InAppPurchaseAPI == InAppPurchaseAPIs.None)
     {
         return(new Dumy_InAppPurchasePlugin(desc, callback));
     }
     else if (desc.WP8_InAppPurchaseAPI == InAppPurchaseAPIs.MicrosoftStore)
     {
         return(new MicrosoftStore_InAppPurchasePlugin_WinRT(desc, callback));
     }
     else
     {
         throw new Exception("Unsuported WP8_InAppPurchaseAPI " + desc.WP8_InAppPurchaseAPI);
     }
                 #elif UNITY_METRO
     if (desc.WinRT_InAppPurchaseAPI == InAppPurchaseAPIs.None)
     {
         return(new Dumy_InAppPurchasePlugin(desc, callback));
     }
     else if (desc.WinRT_InAppPurchaseAPI == InAppPurchaseAPIs.MicrosoftStore)
     {
         return(new MicrosoftStore_InAppPurchasePlugin_WinRT(desc, callback));
     }
     else
     {
         throw new Exception("Unsuported WinRT_InAppPurchaseAPI: " + desc.WinRT_InAppPurchaseAPI);
     }
                 #elif UNITY_BLACKBERRY
     if (desc.BB10_InAppPurchaseAPI == InAppPurchaseAPIs.None)
     {
         return(new Dumy_InAppPurchasePlugin(desc, callback));
     }
     else if (desc.BB10_InAppPurchaseAPI == InAppPurchaseAPIs.BlackBerryWorld)
     {
         return(new InAppPurchasePlugin_BB10(desc, callback));
     }
     else
     {
         throw new Exception("Unsuported BB10_InAppPurchaseAPI: " + desc.BB10_InAppPurchaseAPI);
     }
                 #elif UNITY_IOS
     if (desc.iOS_InAppPurchaseAPI == InAppPurchaseAPIs.None)
     {
         return(new Dumy_InAppPurchasePlugin(desc, callback));
     }
     else if (desc.iOS_InAppPurchaseAPI == InAppPurchaseAPIs.AppleStore)
     {
         return(new AppleStore_InAppPurchasePlugin_iOS(desc, callback));
     }
     else
     {
         throw new Exception("Unsuported iOS_InAppPurchaseAPI: " + desc.iOS_InAppPurchaseAPI);
     }
                 #elif UNITY_ANDROID
     if (desc.Android_InAppPurchaseAPI == InAppPurchaseAPIs.None)
     {
         return(new Dumy_InAppPurchasePlugin(desc, callback));
     }
     else if (desc.Android_InAppPurchaseAPI == InAppPurchaseAPIs.GooglePlay)
     {
         return(new GooglePlay_InAppPurchasePlugin_Android(desc, callback));
     }
     else if (desc.Android_InAppPurchaseAPI == InAppPurchaseAPIs.Amazon)
     {
         return(new Amazon_InAppPurchasePlugin_Android(desc, callback));
     }
     else if (desc.Android_InAppPurchaseAPI == InAppPurchaseAPIs.Samsung)
     {
         return(new Samsung_InAppPurchasePlugin_Android(desc, callback));
     }
     else
     {
         throw new Exception("Unsuported Android_InAppPurchaseAPI: " + desc.Android_InAppPurchaseAPI);
     }
                 #else
     return(new Dumy_InAppPurchasePlugin(desc, callback));
                 #endif
 }
Beispiel #18
0
    void Start()
    {
        // bind button events
        BuyDurableButton.Select();
        BuyDurableButton.onClick.AddListener(buyDurableClicked);
        BuyConsumableButton.onClick.AddListener(buyConsumableClicked);
        RestoreButton.onClick.AddListener(restoreClicked);
        GetPriceInfoButton.onClick.AddListener(getPriceInfoClicked);
        BackButton.onClick.AddListener(backClicked);

        // make sure we don't init the same IAP items twice
        if (created)
        {
            return;
        }
        created = true;

        // InApp-Purchases - NOTE: you can set different "In App IDs" for each platform.
        var inAppIDs = new InAppPurchaseID[3];

        inAppIDs[0] = new InAppPurchaseID(item1, 1.99m, "$", InAppPurchaseTypes.NonConsumable);
        inAppIDs[1] = new InAppPurchaseID(item2, 0.99m, "$", InAppPurchaseTypes.NonConsumable);
        inAppIDs[2] = new InAppPurchaseID(item3, 2.49m, "$", InAppPurchaseTypes.Consumable);

        // create desc object
        var desc = new InAppPurchaseDesc();

        // Global
        desc.Testing          = true;
        desc.ClearNativeCache = false;

        // Editor
        desc.Editor_InAppIDs = inAppIDs;

        // WinRT
        desc.WinRT_InAppPurchaseAPI        = InAppPurchaseAPIs.MicrosoftStore;
        desc.WinRT_MicrosoftStore_InAppIDs = inAppIDs;

        // WP8
        desc.WP8_InAppPurchaseAPI        = InAppPurchaseAPIs.MicrosoftStore;
        desc.WP8_MicrosoftStore_InAppIDs = inAppIDs;

        // BB10
        desc.BB10_InAppPurchaseAPI         = InAppPurchaseAPIs.BlackBerryWorld;
        desc.BB10_BlackBerryWorld_InAppIDs = inAppIDs;

        // iOS
        desc.iOS_InAppPurchaseAPI           = InAppPurchaseAPIs.AppleStore;
        desc.iOS_AppleStore_InAppIDs        = inAppIDs;
        desc.iOS_AppleStore_SharedSecretKey = "";        // NOTE: Must set SharedSecretKey, even for Testing!

        // Android
        // Choose for either GooglePlay or Amazon.
        // NOTE: Use "player settings" to define compiler directives.
                #if AMAZON
        desc.Android_InAppPurchaseAPI = InAppPurchaseAPIs.Amazon;
                #elif SAMSUNG
        desc.Android_InAppPurchaseAPI = InAppPurchaseAPIs.Samsung;
                #else
        desc.Android_InAppPurchaseAPI = InAppPurchaseAPIs.GooglePlay;
                #endif

        desc.Android_GooglePlay_InAppIDs  = inAppIDs;
        desc.Android_GooglePlay_Base64Key = "";        // NOTE: Must set Base64Key for GooglePlay in Apps to work, even for Testing!
        desc.Android_Amazon_InAppIDs      = inAppIDs;
        desc.Android_Samsung_InAppIDs     = inAppIDs;
        desc.Android_Samsung_ItemGroupID  = "";

        // init
        InAppPurchaseManager.Init(desc, createdCallback);
    }
		public MicrosoftStore_InAppPurchasePlugin_WinRT(InAppPurchaseDesc desc, InAppPurchaseCreatedCallbackMethod createdCallback)
		{
			InitNative(this, desc, createdCallback);
		}
		public MicrosoftStore_InAppPurchasePlugin_Native(InAppPurchaseDesc desc, InAppPurchaseCreatedCallbackMethod createdCallback)
		{
			testing = desc.Testing;
			testTrialMode = desc.TestTrialMode;

			#if WINDOWS_PHONE
			InAppIDs = desc.WP8_MicrosoftStore_InAppIDs;
			#else
			InAppIDs = desc.WinRT_MicrosoftStore_InAppIDs;
			#endif

			if (desc.Testing)
			{
				loadTestData(desc, createdCallback);
			}
			else
			{
				licenseInformation = CurrentApp.LicenseInformation;
				licenseInformation.LicenseChanged += licenseChanged;
				if (createdCallback != null) createdCallback(true);
			}
		}
Beispiel #21
0
 public MicrosoftStore_InAppPurchasePlugin_WinRT(InAppPurchaseDesc desc, InAppPurchaseCreatedCallbackMethod createdCallback)
 {
     InitNative(this, desc, createdCallback);
 }
		private async void loadTestData(InAppPurchaseDesc desc, InAppPurchaseCreatedCallbackMethod createdCallback)
		{
			bool pass = true;
			try
			{
				MockIAPLib.MockIAP.Init();
				MockIAPLib.MockIAP.RunInMockMode(true);
				MockIAPLib.MockIAP.SetListingInformation(1, "en-us", "Some description", "1", "TestApp");

				int i = 1;
				foreach (var inApp in desc.WP8_MicrosoftStore_InAppIDs)
				{
					var product = new MockIAPLib.ProductListing
					{
						Name = inApp.ID,
						ImageUri = new Uri("/Res/ReignIcon.png", UriKind.Relative),
						ProductId = inApp.ID,
						ProductType = inApp.Type == InAppPurchaseTypes.NonConsumable ? ProductType.Durable : ProductType.Consumable,
						Keywords = new string[] {"image"},
						Description = "Product Desc " + i,
						FormattedPrice = inApp.CurrencySymbol + inApp.Price,
						Tag = string.Empty
					};

					MockIAPLib.MockIAP.AddProductListing(inApp.ID, product);
					++i;
				}

				wp8TestListingInformation = await CurrentAppSimulator.LoadListingInformationAsync();
				MockIAPLib.MockIAP.ClearCache();
				wp8TestLicenseInformation = CurrentAppSimulator.LicenseInformation;
				wp8TestLicenseInformation.LicenseChanged += licenseChanged;
			}
			catch (Exception e)
			{
				Debug.LogError(e.Message);
				pass = false;
			}

			if (createdCallback != null) createdCallback(pass);
		}
		public InAppPurchasePlugin(InAppPurchaseDesc desc, InAppPurchaseCreatedCallbackMethod callback)
		{
			testTrialMode = desc.TestTrialMode;
			InAppIDs = desc.Editor_InAppIDs;
			if (callback != null) callback(true);
		}