// This is invoked manually to update the premium currency void UpdatePremiumCurrency() { PlayFabClientAPI.GetUserInventory(new GetUserInventoryRequest(), result => { PremiumMoneyTracker.SetMoney(result.VirtualCurrency["PM"]); }, error => Debug.LogError(error.GenerateErrorReport())); }
public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args) { // A consumable product has been purchased by this user. if (String.Equals(args.purchasedProduct.definition.id, kProductIDConsumable, StringComparison.Ordinal)) { Debug.Log(string.Format("ProcessPurchase: PASS. Product: '{0}'", args.purchasedProduct.definition.id)); PremiumMoneyTracker.ChangeMoneyCount(100); } // This user has purchased 10 premium else if (String.Equals(args.purchasedProduct.definition.id, kProductIDConsumable_10Premium, StringComparison.Ordinal)) { Debug.Log(string.Format("ProcessPurchase: PASS. Product: '{0}'", args.purchasedProduct.definition.id)); PremiumMoneyTracker.ChangeMoneyCount(10); } // This user has purchased 100 premium else if (String.Equals(args.purchasedProduct.definition.id, kProductIDConsumable_100Premium, StringComparison.Ordinal)) { Debug.Log(string.Format("ProcessPurchase: PASS. Product: '{0}'", args.purchasedProduct.definition.id)); PremiumMoneyTracker.ChangeMoneyCount(100); } // This user has purchased 600 premium else if (String.Equals(args.purchasedProduct.definition.id, kProductIDConsumable_600Premium, StringComparison.Ordinal)) { Debug.Log(string.Format("ProcessPurchase: PASS. Product: '{0}'", args.purchasedProduct.definition.id)); PremiumMoneyTracker.ChangeMoneyCount(600); } // This user has purchased 2000 premium else if (String.Equals(args.purchasedProduct.definition.id, kProductIDConsumable_2000Premium, StringComparison.Ordinal)) { Debug.Log(string.Format("ProcessPurchase: PASS. Product: '{0}'", args.purchasedProduct.definition.id)); PremiumMoneyTracker.ChangeMoneyCount(2000); } // Or ... a non-consumable product has been purchased by this user. else if (String.Equals(args.purchasedProduct.definition.id, kProductIDNonConsumable, StringComparison.Ordinal)) { Debug.Log(string.Format("ProcessPurchase: PASS. Product: '{0}'", args.purchasedProduct.definition.id)); // TODO: The non-consumable item has been successfully purchased, grant this item to the player. } // Or ... a subscription product has been purchased by this user. else if (String.Equals(args.purchasedProduct.definition.id, kProductIDSubscription, StringComparison.Ordinal)) { Debug.Log(string.Format("ProcessPurchase: PASS. Product: '{0}'", args.purchasedProduct.definition.id)); // TODO: The subscription item has been successfully purchased, grant this to the player. } // Or ... an unknown product has been purchased by this user. Fill in additional products here.... else { Debug.Log(string.Format("ProcessPurchase: FAIL. Unrecognized product: '{0}'", args.purchasedProduct.definition.id)); } // Return a flag indicating whether this product has completely been received, or if the application needs // to be reminded of this purchase at next app launch. Use PurchaseProcessingResult.Pending when still // saving purchased products to the cloud, and when that save is delayed. return(PurchaseProcessingResult.Complete); }
private void OnLoginSuccess(LoginResult result) { //for testing the customdata of items //Dictionary<string, string> i = new Dictionary<string, string>(); //i.Add("outfit", "{\"hat\":\"wow\",\"glasses\":\"sunglasses\"}"); //SetItemCutsomData(i, "891C2D292A879E29", "5055A279219519E2"); Debug.Log("Logged in!"); playerId = result.PlayFabId; CatInventory.catInv.GetPlayFabDecor(); PremiumMoneyTracker.SetMoney(result.InfoResultPayload.UserVirtualCurrency["PM"]); MoneyTracker.SetMoneyText(result.InfoResultPayload.UserVirtualCurrency["NM"]); iap.RefreshIAPItems(); }