private void ChangeToNextContext(bool isSuccessful) { this.ShopModule.State = isSuccessful ? ShopActionState.Success : ShopActionState.Fail; this.ShopModule.ChangeContext(new iOSIdleContext()); StoreKitHelper.ComfirmTransaction(this.m_TransactionID); }
public void PurchaseProduct(string id) { StoreKitHelper.PurchaseProduct(id, 1); Debug.Log("PurchaseProduct!--->productID:" + id); this.ShopModule.State = ShopActionState.Operating; BuyingContext buyingContext = new BuyingContext() { ProductID = id }; if (StoreKitHelper.IsProductAvailable(id)) { this.ShopModule.ChangeContext(buyingContext); } else { RequestingContext requestingContext = new RequestingContext() { SuccessorContext = buyingContext }; this.ShopModule.ChangeContext(requestingContext); requestingContext.StartRequest(new List <string>() { id }, false); } }
public override void Execute() { if (StoreKitHelper.GetRequestState() == RequestProductState.RequestSuccess) { List <ShopItemInformation> products = this.ConstructShopItemInformation(); if (products == null) { this.OnRequestFail(); } else { if (this.SuccessorContext != null) { this.ShopModule.ChangeContext(this.SuccessorContext); } else { this.ShopModule.State = ShopActionState.Idle; IdleContext idleContext = new IdleContext(); this.ShopModule.ChangeContext(idleContext); } this.ShopModule.OnRequestSuccessed(products); } } else if (StoreKitHelper.GetRequestState() == RequestProductState.RequestFail) { this.OnRequestFail(); } }
public override void Execute() { PurchaseState purchaseState = StoreKitHelper.GetPurchaseState(); Debug.Log("the state is : " + purchaseState.ToString()); if (purchaseState == PurchaseState.PurchaseSuccess) { iOSConfirmContext confirmContext = new iOSConfirmContext(); this.ShopModule.ChangeContext(confirmContext); confirmContext.StartProductConfirm(this.m_ProductID); } else if (purchaseState == PurchaseState.PurchaseFail || purchaseState == PurchaseState.PurchaseCancel) { iOSIdleContext idleContext = new iOSIdleContext(); this.ShopModule.ChangeContext(idleContext); if (purchaseState == PurchaseState.PurchaseFail) { this.ShopModule.State = ShopActionState.Fail; PurchaseFailInformation failInformation = new PurchaseFailInformation(); failInformation.Reason = PurchaseFailedReason.Abort; failInformation.ErrorDescription = ClientStringConstants.PURCHASE_FAIL_TIPS; this.ShopModule.OnPurchaseFailed(failInformation); } else { this.ShopModule.State = ShopActionState.Cancel; PurchaseFailInformation failInformation = new PurchaseFailInformation(); failInformation.Reason = PurchaseFailedReason.Cancel; failInformation.ErrorDescription = ClientStringConstants.PURCHASE_FAIL_TIPS; this.ShopModule.OnPurchaseFailed(failInformation); } } }
public void PurchaseProduct(string productID) { StoreKitHelper.PurchaseProduct(productID, 1); Debug.Log("PurchaseProduct!--->productID:" + productID); this.ShopModule.State = ShopActionState.Operating; iOSBuyContext buyContext = new iOSBuyContext(productID); this.ShopModule.ChangeContext(buyContext); }
public void StartProductConfirm(string productID) { this.m_ProductID = productID; this.m_TransactionID = StoreKitHelper.GetTransactionID(productID, 1); if (string.IsNullOrEmpty(this.m_TransactionID)) { this.Fail(); } else { this.StartTransactionConfirm(this.m_TransactionID); } }
private List <ShopItemInformation> ConstructShopItemInformation() { string products = StoreKitHelper.GetValidProducts(); Debug.Log(products); if (products == null) { return(null); } ArrayList productList = JsonUtility.jsonDecode(products) as ArrayList; if (productList == null) { return(null); } List <ShopItemInformation> temp = new List <ShopItemInformation>(); foreach (object product in productList) { Hashtable info = product as Hashtable; if (info == null) { return(null); } ShopItemInformation itemInformation = new ShopItemInformation(); itemInformation.Initialize(info); temp.Add(itemInformation); } List <ShopItemInformation> result = new List <ShopItemInformation>(); List <ProductConfigData> productsData = ((iOSShopUtility)this.ShopModule).ProductsData; foreach (ProductConfigData p in productsData) { foreach (ShopItemInformation info in temp) { if (p.ProductID.Equals(info.ProductID)) { info.GemQuantity = p.GemQuantity; info.IconName = p.IconName; result.Add(info); break; } } } return(result); }
private void StartTransactionConfirm(string transactionID) { this.m_TransactionID = transactionID; this.m_Receipt = StoreKitHelper.GetTransactionReceipt(this.m_TransactionID); if (string.IsNullOrEmpty(this.m_Receipt)) { this.Fail(); } else { this.SubmitReceipt(); } }
private List <ShopItemInformation> ConstructShopItemInformation() { string products = StoreKitHelper.GetValidProducts(); Debug.Log(products); if (products == null) { return(null); } ArrayList productList = new ArrayList(); //= Json.jsonDecode(products) as ArrayList; if (productList == null) { return(null); } List <ShopItemInformation> results = new List <ShopItemInformation>(); foreach (object product in productList) { Hashtable info = product as Hashtable; if (info == null) { return(null); } ShopItemInformation itemInformation = new ShopItemInformation(); itemInformation.Initialize(info); results.Add(itemInformation); } /* * results.Sort((x, y) => * { * if(float.Parse(x.Price) < float.Parse(y.Price)) * { * return -1; * } * else if(float.Parse(x.Price) > float.Parse(y.Price)) * { * return 1; * } * return 0; * }); */ return(results); }
public override void Initialize() { Debug.Log("begin...!"); string unconfirmedProductID = StoreKitHelper.GetUnconfirmedProductID(); //this.m_IsRequestProducts = false; if (unconfirmedProductID != null) { iOSConfirmContext confirmContext = new iOSConfirmContext(); this.ChangeContext(confirmContext); confirmContext.StartProductConfirm(unconfirmedProductID); this.State = ShopActionState.Operating; } else { this.ChangeContext(new iOSIdleContext()); this.State = ShopActionState.Idle; } }
public override void Execute() { PurchaseState purchaseState = StoreKitHelper.GetPurchaseState(); Debug.Log("the state is : " + purchaseState.ToString()); /* * if(purchaseState == PurchaseState.PurchasePurchasing) * { * NetWorkDialog.Instance.HideConnectingWithoutManager(); * } */ if (purchaseState == PurchaseState.PurchaseSuccess) { ConfirmingContext confirmingContext = new ConfirmingContext() { ProductID = this.ProductID }; this.ShopModule.ChangeContext(confirmingContext); } else if (purchaseState == PurchaseState.PurchaseFail || purchaseState == PurchaseState.PurchaseCancel) { IdleContext idleContext = new IdleContext(); this.ShopModule.ChangeContext(idleContext); if (purchaseState == PurchaseState.PurchaseFail) { this.ShopModule.State = ShopActionState.Fail; //this.ShopModule.OnPurchaseFailed(PurchaseFailedReason.Abort); } else { this.ShopModule.State = ShopActionState.Cancel; //this.ShopModule.OnPurchaseFailed(PurchaseFailedReason.Cancel); } } }
public void StartRequest(List <string> productsId, bool isNeedRefresh) { StoreKitHelper.RequestProducts(productsId, isNeedRefresh); }