public void initialise(IBillingServiceCallback callback) { this.callback = callback; if (null == publicKey || publicKey.Equals("[Your key]")) { callback.logError(UnibillError.GOOGLEPLAY_PUBLICKEY_NOTCONFIGURED, publicKey); callback.onSetupComplete(false); return; } var encoder = new Dictionary <string, object>(); encoder.Add("publicKey", this.publicKey); var productIds = new List <string>(); List <object> products = new List <object>(); foreach (var item in db.AllPurchasableItems) { Dictionary <string, object> product = new Dictionary <string, object>(); var id = remapper.mapItemIdToPlatformSpecificId(item); productIds.Add(id); product.Add("productId", id); product.Add("consumable", item.PurchaseType == PurchaseType.Consumable); products.Add(product); } encoder.Add("products", products); var json = encoder.toJson(); rawInterface.initialise(this, json, productIds.ToArray()); }
public void onProductListReceived(string productListString) { Dictionary <string, object> response = (Dictionary <string, object>)Unibill.Impl.MiniJSON.jsonDecode(productListString); if (response.Count == 0) { callback.logError(UnibillError.SAMSUNG_APPS_NO_PRODUCTS_RETURNED); callback.onSetupComplete(false); return; } HashSet <PurchasableItem> productsReceived = new HashSet <PurchasableItem>(); foreach (var identifier in response.Keys) { if (remapper.canMapProductSpecificId(identifier.ToString())) { var item = remapper.getPurchasableItemFromPlatformSpecificId(identifier.ToString()); Dictionary <string, object> details = (Dictionary <string, object>)response[identifier]; PurchasableItem.Writer.setAvailable(item, true); PurchasableItem.Writer.setLocalizedPrice(item, details["price"].ToString()); PurchasableItem.Writer.setLocalizedTitle(item, (string)details["localizedTitle"]); PurchasableItem.Writer.setLocalizedDescription(item, (string)details["localizedDescription"]); PurchasableItem.Writer.setISOCurrencySymbol(item, details.getString("isoCurrencyCode")); PurchasableItem.Writer.setPriceInLocalCurrency(item, decimal.Parse(details.getString("priceDecimal", "0"))); productsReceived.Add(item); } else { logger.LogError("Warning: Unknown product identifier: {0}", identifier.ToString()); } } HashSet <PurchasableItem> productsNotReceived = new HashSet <PurchasableItem> (config.AllPurchasableItems); productsNotReceived.ExceptWith(productsReceived); if (productsNotReceived.Count > 0) { foreach (PurchasableItem product in productsNotReceived) { this.unknownSamsungProducts.Add(remapper.mapItemIdToPlatformSpecificId(product)); callback.logError(UnibillError.SAMSUNG_APPS_MISSING_PRODUCT, product.Id, remapper.mapItemIdToPlatformSpecificId(product)); } } callback.onSetupComplete(true); }
public void onProductListReceived(string productListString) { Dictionary <string, object> responseHash = (Dictionary <string, object>)Unibill.Impl.MiniJSON.jsonDecode(productListString); onUserIdRetrieved(responseHash.getString("userId")); Dictionary <string, object> products = responseHash.getHash("products"); if (products.Count == 0) { callback.logError(UnibillError.AMAZONAPPSTORE_GETITEMDATAREQUEST_NO_PRODUCTS_RETURNED); callback.onSetupComplete(false); return; } HashSet <PurchasableItem> productsReceived = new HashSet <PurchasableItem>(); foreach (var identifier in products.Keys) { var item = remapper.getPurchasableItemFromPlatformSpecificId(identifier.ToString()); Dictionary <string, object> details = (Dictionary <string, object>)products[identifier]; PurchasableItem.Writer.setAvailable(item, true); PurchasableItem.Writer.setLocalizedPrice(item, details["price"].ToString()); PurchasableItem.Writer.setLocalizedTitle(item, (string)details["localizedTitle"]); PurchasableItem.Writer.setLocalizedDescription(item, (string)details["localizedDescription"]); PurchasableItem.Writer.setISOCurrencySymbol(item, details.getString("isoCurrencyCode")); PurchasableItem.Writer.setPriceInLocalCurrency(item, decimal.Parse(details.getString("priceDecimal"))); productsReceived.Add(item); } HashSet <PurchasableItem> productsNotReceived = new HashSet <PurchasableItem> (db.AllPurchasableItems); productsNotReceived.ExceptWith(productsReceived); if (productsNotReceived.Count > 0) { foreach (PurchasableItem product in productsNotReceived) { this.unknownAmazonProducts.Add(remapper.mapItemIdToPlatformSpecificId(product)); callback.logError(UnibillError.AMAZONAPPSTORE_GETITEMDATAREQUEST_MISSING_PRODUCT, product.Id, remapper.mapItemIdToPlatformSpecificId(product)); } } }
public void onProductListReceived(string productListString) { if (productListString.Length == 0) { biller.logError(UnibillError.STOREKIT_RETURNED_NO_PRODUCTS); biller.onSetupComplete(false); return; } Dictionary <string, object> response = (Dictionary <string, object>)Unibill.Impl.MiniJSON.jsonDecode(productListString); HashSet <PurchasableItem> productsReceived = new HashSet <PurchasableItem>(); foreach (var identifier in response.Keys) { var item = remapper.getPurchasableItemFromPlatformSpecificId(identifier.ToString()); Dictionary <string, object> details = (Dictionary <string, object>)response[identifier]; PurchasableItem.Writer.setLocalizedPrice(item, details["price"].ToString()); PurchasableItem.Writer.setLocalizedTitle(item, details["localizedTitle"].ToString()); PurchasableItem.Writer.setLocalizedDescription(item, details["localizedDescription"].ToString()); productsReceived.Add(item); } HashSet <PurchasableItem> productsNotReceived = new HashSet <PurchasableItem> (products); productsNotReceived.ExceptWith(productsReceived); if (productsNotReceived.Count > 0) { foreach (PurchasableItem product in productsNotReceived) { biller.logError(UnibillError.STOREKIT_REQUESTPRODUCTS_MISSING_PRODUCT, product.Id, remapper.mapItemIdToPlatformSpecificId(product)); } } this.productsNotReturnedByStorekit = new HashSet <string>(productsNotReceived.Select(x => remapper.mapItemIdToPlatformSpecificId(x))); // We should complete so long as we have at least one purchasable product. biller.onSetupComplete(true); }
public void OnProductListReceived(Product[] products) { #if UNITY_METRO UnityEngine.WSA.Application.InvokeOnAppThread(() => { if (products.Length == 0) { callback.logError(UnibillError.WIN_8_1_NO_PRODUCTS_RETURNED); callback.onSetupComplete(false); return; } HashSet <string> productsReceived = new HashSet <string>(); foreach (var product in products) { if (remapper.canMapProductSpecificId(product.Id)) { productsReceived.Add(product.Id); var item = remapper.getPurchasableItemFromPlatformSpecificId(product.Id); PurchasableItem.Writer.setAvailable(item, true); PurchasableItem.Writer.setLocalizedPrice(item, product.Price); PurchasableItem.Writer.setLocalizedTitle(item, product.Title); PurchasableItem.Writer.setLocalizedDescription(item, product.Description); PurchasableItem.Writer.setISOCurrencySymbol(item, product.IsoCurrencyCode); PurchasableItem.Writer.setPriceInLocalCurrency(item, product.PriceDecimal); } else { logger.LogError("Warning: Unknown product identifier: {0}", product.Id); } } unknownProducts = new HashSet <string>(db.AllNonSubscriptionPurchasableItems.Select(x => remapper.mapItemIdToPlatformSpecificId(x))); unknownProducts.ExceptWith(productsReceived); if (unknownProducts.Count > 0) { foreach (var id in unknownProducts) { callback.logError(UnibillError.WIN_8_1_MISSING_PRODUCT, id, remapper.getPurchasableItemFromPlatformSpecificId(id).Id); } } enumerateLicenses(); callback.onSetupComplete(true); }, false); #endif }
public void onProductListReceived(string productListString) { if (productListString.Length == 0) { biller.logError(UnibillError.STOREKIT_RETURNED_NO_PRODUCTS); biller.onSetupComplete(false); return; } Dictionary <string, object> responseObject = (Dictionary <string, object>)Unibill.Impl.MiniJSON.jsonDecode(productListString); this.appReceipt = responseObject.getString("appReceipt"); Dictionary <string, object> response = responseObject.getHash("products"); HashSet <PurchasableItem> productsReceived = new HashSet <PurchasableItem>(); foreach (var identifier in response.Keys) { if (!remapper.canMapProductSpecificId(identifier.ToString())) { biller.logError(UnibillError.UNIBILL_UNKNOWN_PRODUCTID, identifier.ToString()); continue; } var item = remapper.getPurchasableItemFromPlatformSpecificId(identifier.ToString()); Dictionary <string, object> details = (Dictionary <string, object>)response[identifier]; PurchasableItem.Writer.setAvailable(item, true); PurchasableItem.Writer.setLocalizedPrice(item, details["price"].ToString()); PurchasableItem.Writer.setLocalizedTitle(item, details["localizedTitle"].ToString()); PurchasableItem.Writer.setLocalizedDescription(item, details["localizedDescription"].ToString()); if (details.ContainsKey("isoCurrencyCode")) { PurchasableItem.Writer.setISOCurrencySymbol(item, details ["isoCurrencyCode"].ToString()); } if (details.ContainsKey("priceDecimal")) { PurchasableItem.Writer.setPriceInLocalCurrency(item, decimal.Parse(details ["priceDecimal"].ToString())); } productsReceived.Add(item); } HashSet <PurchasableItem> productsNotReceived = new HashSet <PurchasableItem> (products); productsNotReceived.ExceptWith(productsReceived); if (productsNotReceived.Count > 0) { foreach (PurchasableItem product in productsNotReceived) { biller.logError(UnibillError.STOREKIT_REQUESTPRODUCTS_MISSING_PRODUCT, product.Id, remapper.mapItemIdToPlatformSpecificId(product)); } } this.productsNotReturnedByStorekit = new HashSet <string>(productsNotReceived.Select(x => remapper.mapItemIdToPlatformSpecificId(x))); // Register our storekit transaction observer. // We must wait until we have initialised to do this. storekit.addTransactionObserver(); if (this.appReceipt != null) { biller.setAppReceipt(this.appReceipt); } // We should complete so long as we have at least one purchasable product. biller.onSetupComplete(true); }
public void OnProductListReceived(Product[] products) { if (products.Length == 0) { callback.logError(UnibillError.WP8_NO_PRODUCTS_RETURNED); callback.onSetupComplete(false); return; } HashSet <string> productsReceived = new HashSet <string>(); foreach (var product in products) { if (remapper.canMapProductSpecificId(product.Id)) { productsReceived.Add(product.Id); var item = remapper.getPurchasableItemFromPlatformSpecificId(product.Id); PurchasableItem.Writer.setLocalizedPrice(item, product.Price); PurchasableItem.Writer.setLocalizedTitle(item, product.Title); PurchasableItem.Writer.setLocalizedDescription(item, product.Description); } else { logger.LogError("Warning: Unknown product identifier: {0}", product.Id); } } unknownProducts = new HashSet <string>(db.AllNonSubscriptionPurchasableItems.Select(x => remapper.mapItemIdToPlatformSpecificId(x))); unknownProducts.ExceptWith(productsReceived); if (unknownProducts.Count > 0) { foreach (var id in unknownProducts) { callback.logError(UnibillError.WP8_MISSING_PRODUCT, id, remapper.getPurchasableItemFromPlatformSpecificId(id).Id); } } enumerateLicenses(); callback.onSetupComplete(true); }