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 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);
			}
		}
Exemplo n.º 5
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);
                }
            }
        }
Exemplo n.º 6
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>
 /// Use to init a single IAP system.
 /// </summary>
 /// <param name="desc">IAP Desc.</param>
 /// <param name="createdCallback">The callback that fires when done.</param>
 /// <returns>Returns IAP API object</returns>
 public static InAppAPI Init(InAppPurchaseDesc desc, InAppPurchaseCreatedCallbackMethod createdCallback)
 {
     InAppAPIs    = new InAppAPI[1];
     InAppAPIs[0] = new InAppAPI();
     InAppAPIs[0].init(desc, createdCallback);
     return(InAppAPIs[0]);
 }
Exemplo n.º 8
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 InAppPurchasePlugin(InAppPurchaseDesc desc, InAppPurchaseCreatedCallbackMethod callback)
 {
     testTrialMode = desc.TestTrialMode;
     InAppIDs      = desc.Editor_InAppIDs;
     if (callback != null)
     {
         callback(true);
     }
 }
Exemplo n.º 10
0
 /// <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);
     }
 }
Exemplo n.º 11
0
        /// <summary>
        /// Use to init the IAP system.
        /// NOTE: This method is normaly used when you don't have any IAP items and only want to check if the app is in trial mode.
        /// </summary>
        /// <param name="testTrialMode">Set true to test trial mode.</param>
        /// <param name="createdCallback">The callback that gets fired when done.</param>
        /// <returns>Returns IAP API object</returns>
        public static InAppAPI Init(bool testTrialMode, InAppPurchaseCreatedCallbackMethod createdCallback)
        {
            var desc = new InAppPurchaseDesc()
            {
                Testing       = testTrialMode,
                TestTrialMode = testTrialMode
            };

            return(Init(desc, createdCallback));
        }
Exemplo n.º 12
0
        /// <summary>
        /// Use to init a multiple IAP systems.
        /// </summary>
        /// <param name="desc">IAP Desc.</param>
        /// <param name="createdCallback">The callback that fires when done.</param>
        /// <returns>Returns array of IAP API objects</returns>
        public static InAppAPI[] Init(InAppPurchaseDesc[] descs, InAppPurchaseCreatedCallbackMethod createdCallback)
        {
            var inAppAPIs = new InAppAPI[descs.Length];

            for (int i = 0; i != descs.Length; ++i)
            {
                inAppAPIs[i] = new InAppAPI();
                inAppAPIs[i].init(descs[i], createdCallback);
            }

            return(inAppAPIs);
        }
Exemplo n.º 13
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);
		}
		internal void init(InAppPurchaseDesc desc, InAppPurchaseCreatedCallbackMethod createdCallback)
		{
			#if DISABLE_REIGN
			pluginAPI = InAppPurchaseAPIs.None;
			#elif UNITY_WP8
			pluginAPI = desc.WP8_InAppPurchaseAPI;
			#elif UNITY_METRO
			pluginAPI = desc.WinRT_InAppPurchaseAPI;
			#elif UNITY_IOS
			pluginAPI = desc.iOS_InAppPurchaseAPI;
			#elif UNITY_ANDROID
			pluginAPI = desc.Android_InAppPurchaseAPI;
			#elif UNITY_BLACKBERRY
			pluginAPI = desc.BB10_InAppPurchaseAPI;
			#else
			pluginAPI = InAppPurchaseAPIs.None;
			#endif

			this.createdCallback = createdCallback;
			plugin = InAppPurchaseAPI.New(desc, async_CreatedCallback);
		}
Exemplo n.º 16
0
        internal void init(InAppPurchaseDesc desc, InAppPurchaseCreatedCallbackMethod createdCallback)
        {
                        #if DISABLE_REIGN
            pluginAPI = InAppPurchaseAPIs.None;
                        #elif UNITY_WP8
            pluginAPI = desc.WP8_InAppPurchaseAPI;
                        #elif UNITY_METRO
            pluginAPI = desc.WinRT_InAppPurchaseAPI;
                        #elif UNITY_IOS
            pluginAPI = desc.iOS_InAppPurchaseAPI;
                        #elif UNITY_ANDROID
            pluginAPI = desc.Android_InAppPurchaseAPI;
                        #elif UNITY_BLACKBERRY
            pluginAPI = desc.BB10_InAppPurchaseAPI;
                        #else
            pluginAPI = InAppPurchaseAPIs.None;
                        #endif

            this.createdCallback = createdCallback;
            plugin = InAppPurchaseAPI.New(desc, async_CreatedCallback);
        }
Exemplo n.º 17
0
        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
        }
		/// <summary>
		/// Use to init the IAP system.
		/// NOTE: This method is normaly used when you don't have any IAP items and only want to check if the app is in trial mode.
		/// </summary>
		/// <param name="testTrialMode">Set true to test trial mode.</param>
		/// <param name="createdCallback">The callback that gets fired when done.</param>
		/// <returns>Returns IAP API object</returns>
		public static InAppAPI Init(bool testTrialMode, InAppPurchaseCreatedCallbackMethod createdCallback)
		{
			var desc = new InAppPurchaseDesc()
			{
				Testing = testTrialMode,
				TestTrialMode = testTrialMode
			};
			return Init(desc, createdCallback);
		}
		public MicrosoftStore_InAppPurchasePlugin_WinRT(InAppPurchaseDesc desc, InAppPurchaseCreatedCallbackMethod createdCallback)
		{
			InitNative(this, desc, createdCallback);
		}
		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>
		/// 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
		}
Exemplo n.º 23
0
		private static void init_MicrosoftStore_InAppPurchasePlugin(MicrosoftStore_InAppPurchasePlugin_WinRT plugin, InAppPurchaseDesc desc, InAppPurchaseCreatedCallbackMethod createdCallback)
		{
			plugin.Native = new MicrosoftStore_InAppPurchasePlugin_Native(desc, createdCallback);
		}
		public InAppPurchasePlugin(InAppPurchaseDesc desc, InAppPurchaseCreatedCallbackMethod callback)
		{
			testTrialMode = desc.TestTrialMode;
			InAppIDs = desc.Editor_InAppIDs;
			if (callback != null) callback(true);
		}
		/// <summary>
		/// Use to init a single IAP system.
		/// </summary>
		/// <param name="desc">IAP Desc.</param>
		/// <param name="createdCallback">The callback that fires when done.</param>
		/// <returns>Returns IAP API object</returns>
		public static InAppAPI Init(InAppPurchaseDesc desc, InAppPurchaseCreatedCallbackMethod createdCallback)
		{
			InAppAPIs = new InAppAPI[1];
			InAppAPIs[0] = new InAppAPI();
			InAppAPIs[0].init(desc, createdCallback);
			return InAppAPIs[0];
		}
		/// <summary>
		/// Use to init a multiple IAP systems.
		/// </summary>
		/// <param name="desc">IAP Desc.</param>
		/// <param name="createdCallback">The callback that fires when done.</param>
		/// <returns>Returns array of IAP API objects</returns>
		public static InAppAPI[] Init(InAppPurchaseDesc[] descs, InAppPurchaseCreatedCallbackMethod createdCallback)
		{
			var inAppAPIs = new InAppAPI[descs.Length];
			for (int i = 0; i != descs.Length; ++i)
			{
				inAppAPIs[i] = new InAppAPI();
				inAppAPIs[i].init(descs[i], createdCallback);
			}

			return inAppAPIs;
		}
Exemplo n.º 27
0
 private static void init_MicrosoftStore_InAppPurchasePlugin(MicrosoftStore_InAppPurchasePlugin_WinRT plugin, InAppPurchaseDesc desc, InAppPurchaseCreatedCallbackMethod createdCallback)
 {
                 #if !WINRT_DISABLE_MS_IAP
     plugin.Native = new MicrosoftStore_InAppPurchasePlugin_Native(desc, createdCallback);
                 #endif
 }
Exemplo n.º 28
0
		private static void init_MicrosoftStore_InAppPurchasePlugin(MicrosoftStore_InAppPurchasePlugin_WinRT plugin, InAppPurchaseDesc desc, InAppPurchaseCreatedCallbackMethod createdCallback)
		{
			#if !WINRT_DISABLE_MS_IAP
			plugin.Native = new MicrosoftStore_InAppPurchasePlugin_Native(desc, createdCallback);
			#endif
		}
		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);
			}
		}
		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);
		}
Exemplo n.º 31
0
 public MicrosoftStore_InAppPurchasePlugin_WinRT(InAppPurchaseDesc desc, InAppPurchaseCreatedCallbackMethod createdCallback)
 {
     InitNative(this, desc, createdCallback);
 }
		/// <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);
		}
Exemplo n.º 33
0
 private static void init_MicrosoftStore_InAppPurchasePlugin(MicrosoftStore_InAppPurchasePlugin_WinRT plugin, InAppPurchaseDesc desc, InAppPurchaseCreatedCallbackMethod createdCallback)
 {
     plugin.Native = new MicrosoftStore_InAppPurchasePlugin_Native(desc, createdCallback);
 }
Exemplo n.º 34
0
 /// <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
 }