//-------------------------------------- // Methods //-------------------------------------- public void Purchase(string productId) { UM_InAppProduct p = UltimateMobileSettings.Instance.GetProductById(productId); if (p != null) { switch (Application.platform) { case RuntimePlatform.Android: AndroidInAppPurchaseManager.instance.purchase(p.AndroidId); break; case RuntimePlatform.IPhonePlayer: IOSInAppPurchaseManager.instance.buyProduct(p.IOSId); break; case RuntimePlatform.WP8Player: WP8InAppPurchasesManager.instance.purchase(p.WP8Id); break; } } else { Debug.LogWarning("UM_InAppPurchaseManager product not found: " + productId); } }
//-------------------------------------- // Event Handlers //-------------------------------------- private void OnProductPurchased(BillingResult result) { UM_InAppProduct p = UltimateMobileSettings.Instance.GetProductByAndroidId(result.Purchase.SKU); if (p != null) { if (p.IsConsumable && result.IsSuccess) { AndroidInAppPurchaseManager.Client.Consume(result.Purchase.SKU); } else { UM_PurchaseResult r = new UM_PurchaseResult(); r.isSuccess = result.IsSuccess; r.product = p; r.SetResponceCode(result.Response); r.Google_PurchaseInfo = result.Purchase; SendPurchaseFinishedEvent(r); } } else { SendNoTemplateEvent(); } }
//-------------------------------------- // Event Handlers //-------------------------------------- private void IOS_OnTransactionComplete(PurchaseResult responce) { UM_InAppProduct p = UltimateMobileSettings.Instance.GetProductByIOSId(responce.ProductIdentifier); if (p != null) { UM_PurchaseResult r = new UM_PurchaseResult(); r.product = p; r.IOS_PurchaseInfo = responce; switch (r.IOS_PurchaseInfo.State) { case PurchaseState.Purchased: case PurchaseState.Restored: r.isSuccess = true; break; case PurchaseState.Deferred: case PurchaseState.Failed: r.isSuccess = false; break; } SendPurchaseFinishedEvent(r); } else { SendNoTemplateEvent(); } }
//-------------------------------------- // Private Methods //-------------------------------------- private static void AddToANSettings(UM_InAppProduct prod) { if (prod.AndroidId.Equals(string.Empty)) { return; } GoogleProductTemplate newTpl = new GoogleProductTemplate(); newTpl.SKU = prod.AndroidId; newTpl.Title = prod.DisplayName; newTpl.Description = prod.Description; newTpl.Texture = prod.Texture; newTpl.LocalizedPrice = prod.LocalizedPrice; if (prod.Type == UM_InAppType.Consumable) { newTpl.ProductType = AN_InAppType.Consumable; } if (prod.Type == UM_InAppType.NonConsumable) { newTpl.ProductType = AN_InAppType.NonConsumable; } AndroidNativeSettings.Instance.InAppProducts.Add(newTpl); }
private static void AddToISNSettings(UM_InAppProduct prod) { if (prod.IOSId.Equals(string.Empty)) { return; } IOSProductTemplate newTpl = new IOSProductTemplate(); newTpl.Id = prod.IOSId; newTpl.Description = prod.Description; newTpl.DisplayName = prod.DisplayName; newTpl.PriceTier = prod.PriceTier; newTpl.Texture = prod.Texture; newTpl.IsOpen = false; if (prod.Type == UM_InAppType.Consumable) { newTpl.ProductType = ISN_InAppType.Consumable; } if (prod.Type == UM_InAppType.NonConsumable) { newTpl.ProductType = ISN_InAppType.NonConsumable; } IOSNativeSettings.Instance.InAppProducts.Add(newTpl); }
private static void AddToAMMSettings(UM_InAppProduct prod) { if (prod.AmazonId.Equals(string.Empty)) { return; } AmazonProductTemplate newTpl = new AmazonProductTemplate(); newTpl.Sku = prod.AmazonId; newTpl.Description = prod.Description; newTpl.Title = prod.DisplayName; newTpl.LocalizedPrice = prod.LocalizedPrice; newTpl.Texture = prod.Texture; newTpl.IsOpen = false; if (prod.Type == UM_InAppType.Consumable) { newTpl.ProductType = AMN_InAppType.CONSUMABLE; } if (prod.Type == UM_InAppType.NonConsumable) { newTpl.ProductType = AMN_InAppType.ENTITLED; } AmazonNativeSettings.Instance.InAppProducts.Add(newTpl); }
//-------------------------------------- // Android Listners //-------------------------------------- void Android_ActionProductPurchased(BillingResult result) { UM_InAppProduct p = UltimateMobileSettings.Instance.GetProductByAndroidId(result.purchase.SKU); if (p != null) { if (p.IsConsumable) { AndroidInAppPurchaseManager.instance.consume(result.purchase.SKU); } else { UM_PurchaseResult r = new UM_PurchaseResult(); r.isSuccess = result.isSuccess; r.product = p; r.Google_PurchaseInfo = result.purchase; SendPurchaseEvent(r); } } else { SendNoTemplateEvent(); } }
public void UpdateBikeInfo(int d) { star[GameData.selectedBike].spriteName = "noStar"; BikerGarageRotate.instance.bikeList[GameData.selectedBike].SetActive(false); GameData.selectedBike = (GameData.selectedBike + d + 7) % 7; PlayerPrefs.SetInt("selectedBike", GameData.selectedBike); star[GameData.selectedBike].spriteName = "star"; BikerGarageRotate.instance.bikeList[GameData.selectedBike].SetActive(true); BikeData bike = (BikeData)(LoadData.BikeList[GameData.selectedBike]); level.spriteName = bike.level; if (GameData.selectedBike > 0) { price.text = bike.price.ToString(); UM_InAppProduct product = UM_InAppPurchaseManager.Instance.GetProductById("spaceship" + GameData.selectedBike.ToString()); IAPprice.text = "$ " + product._price; } speed.text = bike.speed.ToString() + "m/s"; health.text = bike.health.ToString(); force.text = bike.force.ToString(); speedBar.fillAmount = bike.speed / 40f; healthBar.fillAmount = (bike.health) / 500; controlSpeedBar.fillAmount = bike.force / 20f; buyBtn.SetActive(!GameData.GetBike(GameData.selectedBike)); rBuyBtn.SetActive(!GameData.GetBike(GameData.selectedBike)); startBtn.SetActive(GameData.GetBike(GameData.selectedBike)); }
public static void SaveNonConsumableItemPurchaseInfo(UM_InAppProduct product) { #if ATC_SUPPORT_ENABLED ObscuredPrefs.SetInt(PREFS_KEY + product.id, 1); #else PlayerPrefs.SetInt(PREFS_KEY + product.id, 1); #endif }
private void FakePurchaseEvent(UM_InAppProduct product) { UM_PurchaseResult r = new UM_PurchaseResult(); r.isSuccess = true; r.product = product; SendPurchaseEvent(r); }
public void DeleteNonConsumablePurchaseRecord(UM_InAppProduct product) { #if ATC_SUPPORT_ENABLED ObscuredPrefs.DeleteKey(PREFS_KEY + product.id); #else PlayerPrefs.DeleteKey(PREFS_KEY + product.id); #endif }
public bool IsProductPurchased(UM_InAppProduct product) { if (product == null) { return(false); } switch (Application.platform) { case RuntimePlatform.OSXEditor: case RuntimePlatform.WindowsEditor: #if ATC_SUPPORT_ENABLED return(ObscuredPrefs.HasKey(PREFS_KEY + product.id)); #else return(PlayerPrefs.HasKey(PREFS_KEY + product.id)); #endif case RuntimePlatform.Android: if (AndroidInAppPurchaseManager.instance.IsInventoryLoaded) { return(AndroidInAppPurchaseManager.Instance.Inventory.IsProductPurchased(product.AndroidId)); } else { #if ATC_SUPPORT_ENABLED return(ObscuredPrefs.HasKey(PREFS_KEY + product.id)); #else return(PlayerPrefs.HasKey(PREFS_KEY + product.id)); #endif } case RuntimePlatform.IPhonePlayer: #if ATC_SUPPORT_ENABLED return(ObscuredPrefs.HasKey(PREFS_KEY + product.id)); #else return(PlayerPrefs.HasKey(PREFS_KEY + product.id)); #endif case RuntimePlatform.WP8Player: if (WP8InAppPurchasesManager.Instance.IsInitialized) { return(product.WP8Template.IsPurchased); } else { #if ATC_SUPPORT_ENABLED return(ObscuredPrefs.HasKey(PREFS_KEY + product.id)); #else return(PlayerPrefs.HasKey(PREFS_KEY + product.id)); #endif } } return(false); }
public void Consume(string productId) { UM_InAppProduct product = UM_InAppPurchaseManager.GetProductById(productId); if (product != null) { Consume(product); } else { SendNoTemplateEvent(); } }
public void FinishTransaction(string productId) { UM_InAppProduct product = UM_InAppPurchaseManager.GetProductById(productId); if (product != null) { FinishTransaction(product); } else { SendNoTemplateEvent(); } }
public override bool IsProductPurchased(UM_InAppProduct product) { if (product == null) { return(false); } if (AndroidInAppPurchaseManager.Client.Inventory == null) { return(false); } return(AndroidInAppPurchaseManager.Client.Inventory.IsProductPurchased(product.AndroidId)); }
public bool IsProductPurchased(string productId) { UM_InAppProduct product = UM_InAppPurchaseManager.GetProductById(productId); if (product != null) { return(IsProductPurchased(product)); } else { return(false); } }
//-------------------------------------- // IOS Listners //-------------------------------------- private void IOS_OnTransactionComplete(IOSStoreKitResponse responce) { UM_InAppProduct p = UltimateMobileSettings.Instance.GetProductByIOSId(responce.productIdentifier); if (p != null) { UM_PurchaseResult r = new UM_PurchaseResult(); r.product = p; r.IOS_PurchaseInfo = responce; SendPurchaseEvent(r); } else { SendNoTemplateEvent(); } }
private void WP8_OnProductPurchased(WP8PurchseResponce resp) { UM_InAppProduct p = UltimateMobileSettings.Instance.GetProductByWp8Id(resp.ProductId); if (p != null) { UM_PurchaseResult r = new UM_PurchaseResult(); r.product = p; r.WP8_PurchaseInfo = resp; SendPurchaseEvent(r); } else { SendNoTemplateEvent(); } }
private void Android_OnProductConsumed(BillingResult result) { UM_InAppProduct p = UltimateMobileSettings.Instance.GetProductByAndroidId(result.purchase.SKU); if (p != null) { UM_PurchaseResult r = new UM_PurchaseResult(); r.isSuccess = result.isSuccess; r.product = p; r.SetResponceCode(result.response); r.Google_PurchaseInfo = result.purchase; SendPurchaseEvent(r); } else { SendNoTemplateEvent(); } }
//-------------------------------------- // Static Methods //-------------------------------------- public static bool IsLocalPurchaseRecordExists(UM_InAppProduct product) { if (product == null) { return(false); } if (product.IsConsumable) { return(false); } #if ATC_SUPPORT_ENABLED return(ObscuredPrefs.HasKey(PREFS_KEY + product.id)); #else return(PlayerPrefs.HasKey(PREFS_KEY + product.id)); #endif }
private void OnBillingInited() { UM_InAppProduct tpl = UM_InAppPurchaseManager.instance.GetProductById(productIdentifier.Value); if (tpl != null) { title.Value = tpl.template.title; description.Value = tpl.template.description; price.Value = tpl.template.price; Fsm.Event(productFoundEvent); } else { Fsm.Event(productNotFoundEvent); } Finish(); }
//-------------------------------------- // Event Handlers //-------------------------------------- private void HandleAmazonPurchaseProductReceived(AMN_PurchaseResponse response) { Debug.Log("[Amazon] HandleAmazonPurchaseProductReceived"); UM_InAppProduct p = UltimateMobileSettings.Instance.GetProductByAmazonId(response.Sku); if (p != null) { UM_PurchaseResult result = new UM_PurchaseResult(); result.Amazon_PurchaseInfo = response; result.product = p; result.isSuccess = response.isSuccess; SendPurchaseFinishedEvent(result); } else { SendNoTemplateEvent(); } }
public bool IsProductPurchased(UM_InAppProduct product) { if (product == null) { return(false); } switch (Application.platform) { case RuntimePlatform.Android: if (AndroidInAppPurchaseManager.instance.IsInventoryLoaded) { return(AndroidInAppPurchaseManager.instance.inventory.IsProductPurchased(product.AndroidId)); } else { return(PlayerPrefs.HasKey(PREFS_KEY + product.id)); } case RuntimePlatform.IPhonePlayer: return(PlayerPrefs.HasKey(PREFS_KEY + product.id)); case RuntimePlatform.WP8Player: if (WP8InAppPurchasesManager.instance.IsInitialized) { return(product.WP8Template.isPurchased); } else { return(PlayerPrefs.HasKey(PREFS_KEY + product.id)); } } return(false); }
public void Purchase(string productId) { UM_InAppProduct p = UltimateMobileSettings.Instance.GetProductById(productId); if (p != null) { switch (Application.platform) { case RuntimePlatform.OSXEditor: case RuntimePlatform.WindowsEditor: FakePurchaseEvent(p); break; case RuntimePlatform.Android: AndroidInAppPurchaseManager.instance.Purchase(p.AndroidId); break; case RuntimePlatform.IPhonePlayer: IOSInAppPurchaseManager.instance.BuyProduct(p.IOSId); break; case RuntimePlatform.WP8Player: WP8InAppPurchasesManager.Instance.Purchase(p.WP8Id); break; } } else { SendNoTemplateEvent(); Debug.LogWarning("UM_InAppPurchaseManager product not found: " + productId); } }
private void Actions() { settings.IsMoreActionsOpen = EditorGUILayout.Foldout(settings.IsMoreActionsOpen, "More Actions"); if(settings.IsMoreActionsOpen) { EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); if(GUILayout.Button("Open Manifest ", GUILayout.Width(140))) { UnityEditorInternal.InternalEditorUtility.OpenFileAtLineExternal("Assets" + AN_ManifestManager.MANIFEST_FILE_PATH, 1); } if(GUILayout.Button("Reinstall ", GUILayout.Width(140))) { InstallUltimateMobile(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); EditorGUILayout.BeginHorizontal(); EditorGUILayout.Space(); if(GUILayout.Button("Load Example Settings", GUILayout.Width(140))) { UltimateMobileSettings.Instance.Leaderboards.Clear(); UM_Leaderboard lb = new UM_Leaderboard(); lb.id = "LeaderBoardSample_1"; lb.AndroidId = "CgkIipfs2qcGEAIQAA"; UltimateMobileSettings.Instance.Leaderboards.Add(lb); lb = new UM_Leaderboard(); lb.id = "LeaderBoardSample_2"; lb.AndroidId = "CgkIipfs2qcGEAIQFQ"; UltimateMobileSettings.Instance.Leaderboards.Add(lb); settings.InAppProducts.Clear(); UM_InAppProduct p; p = new UM_InAppProduct(); p.id = "coins_bonus"; p.IOSId = "purchase.example.coins_bonus"; p.AndroidId = "coins_bonus"; p.IsConsumable = false; settings.AddProduct(p); p = new UM_InAppProduct(); p.id = "coins_pack"; p.IOSId = "purchase.example.small_coins_bag"; p.AndroidId = "pm_coins"; p.IsConsumable = true; settings.AddProduct(p); #if UNITY_IOS || UNITY_IPHONE PlayerSettings.bundleIdentifier = "com.iosnative.preview"; #endif #if UNITY_ANDROID PlayerSettings.bundleIdentifier = "com.unionassets.android.plugin.preview"; #endif AndroidNativeSettingsEditor.LoadExampleSettings(); } if(GUILayout.Button("Remove", GUILayout.Width(140))) { SA_RemoveTool.RemovePlugins(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.Space(); } }
public override void Subscribe(UM_InAppProduct product) { AndroidInAppPurchaseManager.Client.Subscribe(product.AndroidId); }
public override void Subscribe(UM_InAppProduct product) { SA_AmazonBillingManager.Instance.Purchase(product.AmazonId); }
public void RemoveProduct(UM_InAppProduct p) { InAppProducts.Remove(p); }
//-------------------------------------- // IN Apps //-------------------------------------- public void AddProduct(UM_InAppProduct p) { InAppProducts.Add(p); }
public override void Consume(UM_InAppProduct product) { }
public override void FinishTransaction(UM_InAppProduct product) { }