private static void OnPurchase(string productId, bool bazaar) { string s = productId.ToLower(); if (s.Trim().Contains("doubler")) { var playerController = Singleton.Instance.PlayerController; PlayerInfo playerInfo = playerController.PlayerInfo; playerInfo.HasDubler = true; playerInfo.Dirty = true; Singleton.Instance.PlayerController.ChangePlayerInfo(playerInfo); } if (s.ToLower().Contains("coin")) { string id = s.Replace("coin", "").Trim(); Debug.Log(id); id = id.Replace("coin", "").Trim(); Debug.Log(id); int count = int.Parse(id); Singleton.Instance.PlayerController.ChangeCoin(count); } if (bazaar) { BazaarIAB.consumeProduct(s); } }
//-------------------------------------------- Consume section public override void ConsumePurchasedItem(string sku) { Debug.Log(string.Format("cafebazaar: request consume sku: {0}", sku)); #if UNITY_ANDROID_CAFE if (CheckBillingSupported()) { BazaarIAB.consumeProduct(sku); } #endif setBillingProgress(BillingProgress.WAIT); StartCoroutine(WaitForResponse()); }
private void purchaseSucceededEvent(BazaarPurchase purchase) { BazaarIAB.consumeProduct(products[productIndex].Id); PlayerPrefs.SetInt("Coin", PlayerPrefs.GetInt("Coin") + products[productIndex].Coin); CoinTxt.text = PlayerPrefs.GetInt("Coin").ToString(); }
void Start() { BazaarIAB.init("MIHNMA0GCSqGSIb3DQEBAQUAA4G7ADCBtwKBrwCsKayLopsdltsho45vsaVhWeamm89xS62xwub2QU8DF9AOndmaLr3yP+lP53tdwNc5V4wVEyb6/EIZWMEZdWAYH2oNOhLNkK2MBSaQ0fHWnXnVTnAoJUnzVJxzCVPOpXAtOK5SVZiDMjlx3q16eYZe6y1ams6+mIcTDpCogHBeQlKT3jWzhTIdyGsz+d7MhwYa5rNU/CzRN09L70XNWctFdF0VCXZkCCFhIgszExUCAwEAAQ=="); BTN_close.onClick.AddListener(() => { BazaarIAB.unbindService(); Destroy(gameObject); }); BTN_buy_800.onClick.AddListener(() => { BazaarIAB.purchaseProduct("CH-V-C"); }); BTN_buy_1600.onClick.AddListener(() => { BazaarIAB.purchaseProduct("CH-V-C-1"); }); BTN_buy_38000.onClick.AddListener(() => { BazaarIAB.purchaseProduct("CH-V-C-2"); }); BTN_buy_72000.onClick.AddListener(() => { BazaarIAB.purchaseProduct("72000"); }); BTN_buy_120000.onClick.AddListener(() => { BazaarIAB.purchaseProduct("120000"); }); BTN_buy_205000.onClick.AddListener(() => { BazaarIAB.purchaseProduct("205000"); }); BTN_buy_233000.onClick.AddListener(() => { BazaarIAB.purchaseProduct("23300"); }); BTN_buy_280000.onClick.AddListener(() => { BazaarIAB.purchaseProduct("280000"); }); //event manager bazaar IABEventManager.purchaseFailedEvent += Event_faild; IABEventManager.purchaseSucceededEvent += Even_success; void Event_faild(string faild) { Instantiate(Raw_model_message_notifaction).GetComponent <Raw_model_massage_notifaction>().Change_value("Payment failed", $"{faild}", Raw_model_massage_notifaction.Type.ERRoR, Raw_model_massage_notifaction.Theme.Night); } void Even_success(BazaarPurchase success) { //control product switch (success.ProductId) { case "CH-V-C": { inject_coin_to_server(75); BazaarIAB.consumeProduct("CH-V-C"); Instantiate(Raw_model_message_notifaction).GetComponent <Raw_model_massage_notifaction>().Change_value("Payment Successful", "75 coins have been added to your account\n" + "Thank you for your purchase", Raw_model_massage_notifaction.Type.Success, Raw_model_massage_notifaction.Theme.Night); } break; case "CH-V-C-1": { inject_coin_to_server(150); BazaarIAB.consumeProduct("CH-V-C-1"); Instantiate(Raw_model_message_notifaction).GetComponent <Raw_model_massage_notifaction>().Change_value("Payment Successful", "800 coins have been added to your account\n" + "Thank you for your purchase", Raw_model_massage_notifaction.Type.Success, Raw_model_massage_notifaction.Theme.Night); } break; case "CH-V-C-2": { inject_coin_to_server(350); BazaarIAB.consumeProduct("CH-V-C-2"); Instantiate(Raw_model_message_notifaction).GetComponent <Raw_model_massage_notifaction>().Change_value("Payment Successful", "350 coins have been added to your account\n" + "Thank you for your purchase", Raw_model_massage_notifaction.Type.Success, Raw_model_massage_notifaction.Theme.Night); } break; case "72000": { inject_coin_to_server(1500); BazaarIAB.consumeProduct("72000"); Instantiate(Raw_model_message_notifaction).GetComponent <Raw_model_massage_notifaction>().Change_value("Payment Successful", "1500 coins have been added to your account\n" + "Thank you for your purchase", Raw_model_massage_notifaction.Type.Success, Raw_model_massage_notifaction.Theme.Night); } break; case "120000": { inject_coin_to_server(1550); BazaarIAB.consumeProduct("120000"); Instantiate(Raw_model_message_notifaction).GetComponent <Raw_model_massage_notifaction>().Change_value("Payment Successful", "1550 coins have been added to your account\n" + "Thank you for your purchase", Raw_model_massage_notifaction.Type.Success, Raw_model_massage_notifaction.Theme.Night); } break; case "205000": { inject_coin_to_server(2700); BazaarIAB.consumeProduct("205000"); Instantiate(Raw_model_message_notifaction).GetComponent <Raw_model_massage_notifaction>().Change_value("Payment Successful", "2700 coins have been added to your account\n" + "Thank you for your purchase", Raw_model_massage_notifaction.Type.Success, Raw_model_massage_notifaction.Theme.Night); } break; case "23300": { inject_coin_to_server(6000); BazaarIAB.consumeProduct("23300"); Instantiate(Raw_model_message_notifaction).GetComponent <Raw_model_massage_notifaction>().Change_value("Payment Successful", "6000 coins have been added to your account\n" + "Thank you for your purchase", Raw_model_massage_notifaction.Type.Success, Raw_model_massage_notifaction.Theme.Night); } break; case "280000": { inject_coin_to_server(10000); BazaarIAB.consumeProduct("280000"); Instantiate(Raw_model_message_notifaction).GetComponent <Raw_model_massage_notifaction>().Change_value("Payment Successful", "10000 coins have been added to your account\n" + "Thank you for your purchase", Raw_model_massage_notifaction.Type.Success, Raw_model_massage_notifaction.Theme.Night); } break; } //update coin panel shop Text_coin_panel_shop.text = PlayerPrefs.GetInt("Coin").ToString(); //add history to server Data_buy data_purchase = new Data_buy { developerid = success.DeveloperPayload, Orderid = success.OrderId, orginal_Json = success.OriginalJson, Purchasses_pakage = success.PackageName, Purchasses_productid = success.ProductId, Purchasses_state = success.PurchaseState.ToString(), Purchasses_time = success.PurchaseTime.ToString(), Purchasses_token = success.PurchaseToken, Signuture = success.Signature, Type = success.Type, }; Chilligames_SDK.API_Client.Add_purchasses_history(new Req_add_purchasses_history { _id = _id, data_purchass = ChilligamesJson.SerializeObject(data_purchase), Name_app = "Venomic" }, () => { }, err => { }); } }
void OnGUI() { GUILayout.BeginArea(new Rect(10f, 10f, Screen.width - 15f, Screen.height - 15f)); GUI.skin.button.fixedHeight = 50; GUI.skin.button.fontSize = 20; if (Button("Initialize IAB")) { var key = "MIHNMA0GCSqGSIb3DQEBAQUAA4G7ADCBtwKBrwDN72wlPXo4pFK78rElKD+nwc9OnHHL+YYAt0o2Fm6H+7pNoOKLk/fbXrmV3jaL2cz99IClllFKEAvo6VbyRyIOD5cWpBCV+IFVobCPs9dtCV0M4DDqpVY2NUR9WownlNMwr/AwmwW750xS8BvQ9zt5+u7VEhLkAJPVxWJfr+kLHI7519s9T5eb58cdAM+bvJ1vT0pGx6te5DrV8IHUUCKpDYPy7kBfc9wdcT6EBUMCAwEAAQ=="; BazaarIAB.init(key); } if (Button("Query Inventory")) { BazaarIAB.queryInventory(skus); } if (Button("Query SkuDetails")) { BazaarIAB.querySkuDetails(skus); } if (Button("Query Purchases")) { BazaarIAB.queryPurchases(); } if (Button("Are subscriptions supported?")) { Debug.Log("subscriptions supported: " + BazaarIAB.areSubscriptionsSupported()); } if (Button("Purchase Product Test1")) { BazaarIAB.purchaseProduct("com.fanafzar.bazaarplugin.test1"); } if (Button("Purchase Product Test2")) { BazaarIAB.purchaseProduct("com.fanafzar.bazaarplugin.test2"); } if (Button("Consume Purchase Test1")) { BazaarIAB.consumeProduct("com.fanafzar.bazaarplugin.test1"); } if (Button("Consume Purchase Test2")) { BazaarIAB.consumeProduct("com.fanafzar.bazaarplugin.test2"); } if (Button("Consume Multiple Purchases")) { var skus = new string[] { "com.fanafzar.bazaarplugin.test1", "com.fanafzar.bazaarplugin.test2" }; BazaarIAB.consumeProducts(skus); } if (Button("Test Unavailable Item")) { BazaarIAB.purchaseProduct("com.fanafzar.bazaarplugin.unavailable"); } if (Button("Purchase Monthly Subscription")) { BazaarIAB.purchaseProduct("com.fanafzar.bazaarplugin.monthly_subscribtion_test", "subscription payload"); } if (Button("Purchase Annually Subscription")) { BazaarIAB.purchaseProduct("com.fanafzar.bazaarplugin.annually_subscribtion_test", "subscription payload"); } if (Button("Enable High Details Logs")) { BazaarIAB.enableLogging(true); } GUILayout.EndArea(); }
public void ConsumeProduct(string productId) { BazaarIAB.consumeProduct(FilterAlias(productId)); }
private void Start() { //step1 StartCoroutine(Destroy_offer()); BTN_reject.onClick.AddListener(() => { anim = 1; }); BTN_accept.onClick.AddListener(() => { anim = 2; StopAllCoroutines(); }); //step_2 BTN_close_step_2.onClick.AddListener(() => { anim = 3; }); BTN_pluse_freeze.onClick.AddListener(() => { if (PlayerPrefs.GetInt("Coin") >= 4) { PlayerPrefs.SetInt("Freeze", PlayerPrefs.GetInt("Freeze") + 1); PlayerPrefs.SetInt("Coin", PlayerPrefs.GetInt("Coin") - 4); } else { anim = 4; } }); BTN_pluse_minuse.onClick.AddListener(() => { if (PlayerPrefs.GetInt("Coin") >= 2) { PlayerPrefs.SetInt("Minuse", PlayerPrefs.GetInt("Minuse") + 1); PlayerPrefs.SetInt("Coin", PlayerPrefs.GetInt("Coin") - 2); } else { anim = 4; } }); BTN_pluse_delete.onClick.AddListener(() => { if (PlayerPrefs.GetInt("Coin") >= 3) { PlayerPrefs.SetInt("Delete", PlayerPrefs.GetInt("Delete") + 1); PlayerPrefs.SetInt("Coin", PlayerPrefs.GetInt("Coin") - 3); } else { anim = 4; } }); BTN_pluse_chance.onClick.AddListener(() => { if (PlayerPrefs.GetInt("Coin") >= 2) { PlayerPrefs.SetInt("Chance", PlayerPrefs.GetInt("Chance") + 1); PlayerPrefs.SetInt("Coin", PlayerPrefs.GetInt("Coin") - 2); } else { anim = 4; } }); BTN_pluse_reset.onClick.AddListener(() => { if (PlayerPrefs.GetInt("Coin") >= 4) { PlayerPrefs.SetInt("Reset", PlayerPrefs.GetInt("Reset") + 1); PlayerPrefs.SetInt("Coin", PlayerPrefs.GetInt("Coin") - 4); } else { anim = 4; } }); //step_3 BazaarIAB.init("MIHNMA0GCSqGSIb3DQEBAQUAA4G7ADCBtwKBrwCsKayLopsdltsho45vsaVhWeamm89xS62xwub2QU8DF9AOndmaLr3yP+lP53tdwNc5V4wVEyb6/EIZWMEZdWAYH2oNOhLNkK2MBSaQ0fHWnXnVTnAoJUnzVJxzCVPOpXAtOK5SVZiDMjlx3q16eYZe6y1ams6+mIcTDpCogHBeQlKT3jWzhTIdyGsz+d7MhwYa5rNU/CzRN09L70XNWctFdF0VCXZkCCFhIgszExUCAwEAAQ=="); BTN_close.onClick.AddListener(() => { anim = 5; }); BTN_buy_800.onClick.AddListener(() => { BazaarIAB.purchaseProduct("CH-V-C"); }); BTN_buy_1600.onClick.AddListener(() => { BazaarIAB.purchaseProduct("CH-V-C-1"); }); BTN_buy_38000.onClick.AddListener(() => { BazaarIAB.purchaseProduct("CH-V-C-2"); }); BTN_buy_72000.onClick.AddListener(() => { BazaarIAB.purchaseProduct("72000"); }); BTN_buy_120000.onClick.AddListener(() => { BazaarIAB.purchaseProduct("120000"); }); BTN_buy_205000.onClick.AddListener(() => { BazaarIAB.purchaseProduct("205000"); }); BTN_buy_233000.onClick.AddListener(() => { BazaarIAB.purchaseProduct("23300"); }); BTN_buy_280000.onClick.AddListener(() => { BazaarIAB.purchaseProduct("280000"); }); //bazaar event IABEventManager.purchaseSucceededEvent += Success => { switch (Success.ProductId) { case "CH-V-C": { inject_coin(75); BazaarIAB.consumeProduct("CH-V-C"); Instantiate(Raw_model_message_notifaction).GetComponent <Raw_model_massage_notifaction>().Change_value("Payment Successful", "75 coins have been added to your account\n" + "Thank you for your purchase", Raw_model_massage_notifaction.Type.Success, Raw_model_massage_notifaction.Theme.Night); } break; case "CH-V-C-1": { inject_coin(150); BazaarIAB.consumeProduct("CH-V-C-1"); Instantiate(Raw_model_message_notifaction).GetComponent <Raw_model_massage_notifaction>().Change_value("Payment Successful", "150 coins have been added to your account\n" + "Thank you for your purchase", Raw_model_massage_notifaction.Type.Success, Raw_model_massage_notifaction.Theme.Night); } break; case "CH-V-C-2": { inject_coin(350); BazaarIAB.consumeProduct("CH-V-C-2"); Instantiate(Raw_model_message_notifaction).GetComponent <Raw_model_massage_notifaction>().Change_value("Payment Successful", "350 coins have been added to your account\n" + "Thank you for your purchase", Raw_model_massage_notifaction.Type.Success, Raw_model_massage_notifaction.Theme.Night); } break; case "72000": { inject_coin(1500); BazaarIAB.consumeProduct("72000"); Instantiate(Raw_model_message_notifaction).GetComponent <Raw_model_massage_notifaction>().Change_value("Payment Successful", "1500 coins have been added to your account\n" + "Thank you for your purchase", Raw_model_massage_notifaction.Type.Success, Raw_model_massage_notifaction.Theme.Night); } break; case "120000": { inject_coin(1550); BazaarIAB.consumeProduct("120000"); Instantiate(Raw_model_message_notifaction).GetComponent <Raw_model_massage_notifaction>().Change_value("Payment Successful", "1550 coins have been added to your account\n" + "Thank you for your purchase", Raw_model_massage_notifaction.Type.Success, Raw_model_massage_notifaction.Theme.Night); } break; case "205000": { inject_coin(2700); BazaarIAB.consumeProduct("205000"); Instantiate(Raw_model_message_notifaction).GetComponent <Raw_model_massage_notifaction>().Change_value("Payment Successful", "2700 coins have been added to your account\n" + "Thank you for your purchase", Raw_model_massage_notifaction.Type.Success, Raw_model_massage_notifaction.Theme.Night); } break; case "23300": { inject_coin(6000); BazaarIAB.consumeProduct("23300"); Instantiate(Raw_model_message_notifaction).GetComponent <Raw_model_massage_notifaction>().Change_value("Payment Successful", "6000coins have been added to your account\n" + "Thank you for your purchase", Raw_model_massage_notifaction.Type.Success, Raw_model_massage_notifaction.Theme.Night); } break; case "280000": { inject_coin(10000); BazaarIAB.consumeProduct("280000"); Instantiate(Raw_model_message_notifaction).GetComponent <Raw_model_massage_notifaction>().Change_value("Payment Successful", "10000 coins have been added to your account\n" + "Thank you for your purchase", Raw_model_massage_notifaction.Type.Success, Raw_model_massage_notifaction.Theme.Night); } break; } Data_buy data_Buy = new Data_buy { developerid = Success.DeveloperPayload, Orderid = Success.OrderId, orginal_Json = Success.OriginalJson, Purchasses_pakage = Success.PackageName, Purchasses_productid = Success.ProductId, Purchasses_state = Success.PurchaseState.ToString(), Purchasses_time = Success.PurchaseTime.ToString(), Purchasses_token = Success.PurchaseToken, Signuture = Success.Signature, Type = Success.Type }; Chilligames_SDK.API_Client.Add_purchasses_history(new Chilligames.SDK.Model_Client.Req_add_purchasses_history { data_purchass = ChilligamesJson.SerializeObject(data_Buy), _id = _id, Name_app = "Venomic" }, () => { }, err => { });; }; IABEventManager.purchaseFailedEvent += faild => { Instantiate(Raw_model_message_notifaction).GetComponent <Raw_model_massage_notifaction>().Change_value("Payment failed", $"{faild}", Raw_model_massage_notifaction.Type.ERRoR, Raw_model_massage_notifaction.Theme.Night); }; //inject to server and game void inject_coin(int Coin_count) { PlayerPrefs.SetInt("Coin", PlayerPrefs.GetInt("Coin") + Coin_count); Chilligames_SDK.API_Client.Coin_Insert(new Chilligames.SDK.Model_Client.Req_Insert_coin { }, () => { }, err => { }); } }
private static void Consume(string itemId) { #if UNITY_ANDROID BazaarIAB.consumeProduct(itemId); #endif }