// ----------------------------------------------------------------------------------- // Init // ----------------------------------------------------------------------------------- public void Init(UCE_Tmpl_PayPalProduct myProduct) { Player player = Player.localPlayer; if (!player) { return; } product = myProduct; if (product.isActive && player.UCE_checkHasClass(product.allowedClasses) && player.UCE_PayPal_CanPurchase(product) ) { itemImage = product.image; itemName = product.name; itemDesc = product.description; itemCost = product.cost.ToString(); itemOffer = ""; if (product.hasOffer) { string offerStart = product.startMonth.ToString() + "/" + product.startDay.ToString(); string offerEnd = product.endMonth.ToString() + "/" + product.endDay.ToString(); itemOffer = validFrom + offerStart + validUntil + offerEnd; } } else { gameObject.SetActive(false); } }
// ----------------------------------------------------------------------------------- // UCE_saveCharacterPurchase // ----------------------------------------------------------------------------------- public void UCE_saveCharacterPurchase(string name, UCE_Tmpl_PayPalProduct product, string purchased) { int counter = UCE_loadCharacterPurchase(name, product.name); counter++; #if _MYSQL && _SERVER singleton.ExecuteNonQueryMySql("DELETE FROM character_purchases WHERE `character`=@name AND `product`=@product", new MySqlParameter("@name", name), new MySqlParameter("@product", product.name)); singleton.ExecuteNonQueryMySql("INSERT INTO character_purchases VALUES (@character, @product, @purchased, @counter)", new MySqlParameter("@character", name), new MySqlParameter("@product", product.name), new MySqlParameter("@purchased", purchased), new MySqlParameter("@counter", counter) ); #elif _SQLITE && _SERVER connection.Execute("DELETE FROM character_purchases WHERE character=? AND product=?", name, product.name); connection.Insert(new character_purchases { character = name, product = product.name, purchased = purchased, counter = counter }); #endif }
// ----------------------------------------------------------------------------------- // UCE_saveCharacterPurchase // ----------------------------------------------------------------------------------- public void UCE_saveCharacterPurchase(string name, UCE_Tmpl_PayPalProduct product, string purchased) { int counter = UCE_loadCharacterPurchase(name, product.name); counter++; #if _MYSQL singleton.ExecuteNonQueryMySql("DELETE FROM character_purchases WHERE `character`=@name AND `product`=@product", new MySqlParameter("@name", name), new MySqlParameter("@product", product.name)); singleton.ExecuteNonQueryMySql("INSERT INTO character_purchases VALUES (@character, @product, @purchased, @counter)", new MySqlParameter("@character", name), new MySqlParameter("@product", product.name), new MySqlParameter("@purchased", purchased), new MySqlParameter("@counter", counter) ); #elif _SQLITE singleton.ExecuteNonQuery("DELETE FROM character_purchases WHERE `character`=@name AND `product`=@product", new SqliteParameter("@name", name), new SqliteParameter("@product", product.name)); singleton.ExecuteNonQuery("INSERT INTO character_purchases VALUES (@character, @product, @purchased, @counter)", new SqliteParameter("@character", name), new SqliteParameter("@product", product.name), new SqliteParameter("@purchased", purchased), new SqliteParameter("@counter", counter) ); #endif }
// ----------------------------------------------------------------------------------- // UCE_PayPal_CanPurchase // ----------------------------------------------------------------------------------- public bool UCE_PayPal_CanPurchase(UCE_Tmpl_PayPalProduct product) { if (product.purchaseLimit <= 0) { return(true); } return(Database.singleton.UCE_loadCharacterPurchase(name, product.name) < product.purchaseLimit); }
public static void Use(UCE_Tmpl_PayPalProduct product) { Player player = Player.localPlayer; if (!player) { return; } if (product != null) { player.Cmd_UCE_PayPal_PurchaseCoins(product.name.GetDeterministicHashCode()); } }
public void OpenPurchaseItemScreen(StoreItemContent itemToPurchase) { //MenuNavigation.INSTANCE.selectPurchaseIcon (); MainStoreScreen.SetActive(false); PurchaseItemScreen.SetActive(true); product = itemToPurchase.product; PurchaseItemImageField.sprite = itemToPurchase.itemImage; PurchaseItemNameField.text = itemToPurchase.itemName; PurchaseItemCostField.text = string.Format("{0:N}", itemToPurchase.itemCost); PurchaseItemCostField.text = CurrencyCodeMapper.GetCurrencySymbol(StoreProperties.INSTANCE.currencyCode) + PurchaseItemCostField.text; PurchaseItemDescField.text = itemToPurchase.itemDesc; PurchaseItemCurrCodeField.text = StoreProperties.INSTANCE.currencyCode; changePurchaseStatus(PurchaseStatus.CREATING_PURCHASE); CreatePaymentAPI_Call existingCreatePaymentAPIcall = StoreProperties.INSTANCE.gameObject.GetComponent <CreatePaymentAPI_Call>(); if (existingCreatePaymentAPIcall != null) { Destroy(existingCreatePaymentAPIcall); } CreatePaymentAPI_Call createPaymentAPICall = StoreProperties.INSTANCE.gameObject.AddComponent <CreatePaymentAPI_Call>(); createPaymentAPICall.accessToken = StoreProperties.INSTANCE.GetComponent <GetAccessTokenAPI_Call>().API_SuccessResponse.access_token; createPaymentAPICall.transactionDescription = "purchased 1 item from x game"; createPaymentAPICall.itemCurrency = StoreProperties.INSTANCE.currencyCode; createPaymentAPICall.itemDescription = itemToPurchase.itemDesc; createPaymentAPICall.itemName = itemToPurchase.itemName; createPaymentAPICall.itemPrice = itemToPurchase.itemCost; createPaymentAPICall.JSON_CreatePaymentRequest = Resources.Load("Misc/CreatePaymentRequestBody") as TextAsset; InvokeRepeating("checkForPurchaseStatusChange", 1f, 1f); }