//-------------------------------------- // WP8 Listners //-------------------------------------- private void WP8_OnInitComplete() { _IsInited = true; _IsPurchasingAvailable = true; UM_BillingConnectionResult r = new UM_BillingConnectionResult(); r.message = "Inited"; r.isSuccess = true; foreach (UM_InAppProduct product in UltimateMobileSettings.Instance.InAppProducts) { WP8ProductTemplate tpl = WP8InAppPurchasesManager.instance.GetProductById(product.WP8Id); if (tpl != null) { product.SetTemplate(tpl); if (product.WP8Template.isPurchased && !product.IsConsumable) { SaveNonConsumableItemPurchaseInfo(product); } } } OnBillingConnectFinishedAction(r); dispatch(ON_BILLING_CONNECT_FINISHED, r); }
//-------------------------------------- // Event Handlers //-------------------------------------- private void OnInitComplete(WP8_InAppsInitResult result) { _IsConnected = true; UM_BillingConnectionResult r = new UM_BillingConnectionResult(); r.message = "Inited"; r.isSuccess = true; foreach (UM_InAppProduct product in UltimateMobileSettings.Instance.InAppProducts) { WP8ProductTemplate tpl = WP8InAppPurchasesManager.Instance.GetProductById(product.WP8Id); if (tpl != null) { product.SetTemplate(tpl); if (product.WP8Template.IsPurchased && !product.IsConsumable) { UM_InAppPurchaseManager.SaveNonConsumableItemPurchaseInfo(product); } } } SendServiceConnectedEvent(r); }
public void SetTemplate(WP8ProductTemplate tpl) { _WP8Template = tpl; _template = new UM_InAppProductTemplate(); _template.id = tpl.ProductId; _template.title = tpl.Name; _template.description = tpl.Description; _template.price = tpl.Price; }
//-------------------------------------- // INITIALIZE //-------------------------------------- //-------------------------------------- // PUBLIC METHODS //-------------------------------------- void OnGUI() { UpdateToStartPos(); GUI.Label(new Rect(10.0f, 200.0f, Screen.width, Screen.height), WPN_BillingManagerExample._status); GUI.Label(new Rect(StartX, StartY, Screen.width, 40), "Market Example", style); StartY += YLableStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Init")) { WPN_BillingManagerExample.Init(); } if (!WPN_BillingManagerExample.IsInited) { return; } StartX += XButtonStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Buy Consumable")) { WPN_BillingManagerExample.Purchase(WPN_BillingManagerExample.YOUR_CONSUMABLE_PRODUCT_ID_CONSTANT); } StartX += XButtonStep; if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Buy Durable")) { WPN_BillingManagerExample.Purchase(WPN_BillingManagerExample.YOUR_DURABLE_PRODUCT_ID_CONSTANT); } #if UNITY_WSA StartY += YLableStep; StartX -= XButtonStep; WP8ProductTemplate consumable = WP8InAppPurchasesManager.Instance.GetProductById(WPN_BillingManagerExample.YOUR_CONSUMABLE_PRODUCT_ID_CONSTANT); if (consumable != null) { if (consumable.IsPurchased) { if (GUI.Button(new Rect(StartX, StartY, buttonWidth, buttonHeight), "Consume Product")) { WPN_BillingManagerExample.Consume(WPN_BillingManagerExample.YOUR_CONSUMABLE_PRODUCT_ID_CONSTANT); } } } #endif }
private void ProductsDetailsDelegate(string data) { WP8_InAppsInitResult result; if (data.Equals(string.Empty)) { Debug.Log("InAppPurchaseManager, you have no avaiable products"); result = new WP8_InAppsInitResult(); OnInitComplete(result); return; } string[] storeData; storeData = data.Split("|" [0]); for (int i = 0; i < storeData.Length; i += 7) { WP8ProductTemplate tpl = new WP8ProductTemplate(); tpl.ImgURL = storeData[i]; tpl.Name = storeData[i + 1]; tpl.ProductId = storeData[i + 2]; tpl.Price = storeData[i + 3]; if (storeData[i + 4].Trim().Length > 0) { tpl.Type = (WP8PurchaseProductType)Enum.Parse(typeof(WP8PurchaseProductType), storeData[i + 4]); } tpl.Description = storeData[i + 5]; tpl.isPurchased = (Boolean)Boolean.Parse(storeData[i + 6]); _products.Add(tpl); } _IsInitialized = true; result = new WP8_InAppsInitResult(); OnInitComplete(result); //Deffered purchases event dispatch foreach (WP8PurchseResponce defferedPurchase in _defferedPurchases) { OnPurchaseFinished(defferedPurchase); } _defferedPurchases.Clear(); }
private void InitCallback(string res) { string[] data = res.Split(new string[] { SPLITTER2 }, StringSplitOptions.None); int status = Int32.Parse(data[0]); WP8_InAppsInitResult result = new WP8_InAppsInitResult(status); if (result.IsSucceeded) { for (int i = 1; i < data.Length; i++) { System.Diagnostics.Debug.WriteLine("Product RAW Data: {0}", data[i]); string[] productInfo = data[i].Split(new string[] { SPLITTER1 }, StringSplitOptions.None); WP8ProductTemplate product = new WP8ProductTemplate(); product.ImgURI = productInfo[0]; product.Name = productInfo[1]; product.ProductId = productInfo[2]; product.Price = productInfo[3]; product.Type = (WP8PurchaseProductType)Enum.Parse(typeof(WP8PurchaseProductType), productInfo[4]); product.Description = productInfo[5]; product.IsPurchased = bool.Parse(productInfo[6]); product.TransactionID = productInfo[7]; _products.Add(product); } _IsInitialized = true; } OnInitComplete(result); #if UNITY_WP8 //Deffered purchases event dispatch foreach (WP8PurchseResponce defferedPurchase in _defferedPurchases) { OnPurchaseFinished(defferedPurchase); } _defferedPurchases.Clear(); #endif }
private void ProductsDetailsDelegate(string data) { WP8_InAppsInitResult result; if(data.Equals(string.Empty)) { Debug.Log("InAppPurchaseManager, you have no avaiable products"); result = new WP8_InAppsInitResult(); OnInitComplete(result); return; } string[] storeData; storeData = data.Split("|" [0]); for ( int i = 0; i < storeData.Length; i += 7 ) { WP8ProductTemplate tpl = new WP8ProductTemplate(); tpl.ImgURL = storeData[i]; tpl.Name = storeData[i + 1]; tpl.ProductId = storeData[i + 2]; tpl.Price = storeData[i + 3]; if (storeData[i+4].Trim().Length > 0) tpl.Type = (WP8PurchaseProductType)Enum.Parse(typeof(WP8PurchaseProductType), storeData[i + 4]); tpl.Description = storeData[i + 5]; tpl.isPurchased = (Boolean)Boolean.Parse(storeData[i + 6]); _products.Add(tpl); } _IsInitialized = true; result = new WP8_InAppsInitResult(); OnInitComplete(result); //Deffered purchases event dispatch foreach (WP8PurchseResponce defferedPurchase in _defferedPurchases) { OnPurchaseFinished(defferedPurchase); } _defferedPurchases.Clear(); }
private void ProductsDetailsDelegate(string data) { WP8_InAppsInitResult result; if (data.Equals(string.Empty)) { Debug.Log("InAppPurchaseManager, you have no avaiable products"); result = new WP8_InAppsInitResult(); dispatch(INITIALIZED, result); OnInitComplete(result); return; } string[] storeData; storeData = data.Split("|" [0]); for (int i = 0; i < storeData.Length; i += 7) { WP8ProductTemplate tpl = new WP8ProductTemplate(); tpl.ImgURL = storeData[i]; tpl.Name = storeData[i + 1]; tpl.ProductId = storeData[i + 2]; tpl.Price = storeData[i + 3]; tpl.Type = (WP8PurchaseProductType)Enum.Parse(typeof(WP8PurchaseProductType), storeData[i + 4]); tpl.Description = storeData[i + 5]; tpl.isPurchased = (Boolean)Boolean.Parse(storeData[i + 6]); _products.Add(tpl); } _IsInitialized = true; result = new WP8_InAppsInitResult(); dispatch(INITIALIZED, result); OnInitComplete(result); }
private void ProductsDetailsDelegate(string data) { if(data.Equals(string.Empty)) { Debug.Log("InAppPurchaseManager, you have no avaiable products"); dispatch(INITIALIZED, _products); return; } string[] storeData; storeData = data.Split("|" [0]); for ( int i = 0; i < storeData.Length; i += 7 ) { WP8ProductTemplate tpl = new WP8ProductTemplate(); tpl.ImgURL = storeData[i]; tpl.Name = storeData[i + 1]; tpl.ProductId = storeData[i + 2]; tpl.Price = storeData[i + 3]; tpl.Type = (WP8PurchaseProductType)Enum.Parse(typeof(WP8PurchaseProductType), storeData[i + 4]); tpl.Description = storeData[i + 5]; tpl.isPurchased = (Boolean)Boolean.Parse(storeData[i + 6]); _products.Add(tpl); } dispatch(INITIALIZED, _products); }