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 OnPurchaseSucceeded(string productId, string receipt, string tranId) { util.RunOnMainThread(() => { // Our implementations don't currently set the transaction Id, // so we extract it from the receipt. tranId = readTransactionIdFromReceipt(receipt); if (!remapper.canMapProductSpecificId(productId)) { logger.LogError("Purchased unknown product: {0}. Ignoring!", productId); return; } var details = remapper.getPurchasableItemFromPlatformSpecificId(productId); switch (details.PurchaseType) { case PurchaseType.Consumable: callback.onPurchaseSucceeded(productId, receipt, tranId); break; case PurchaseType.NonConsumable: case PurchaseType.Subscription: var item = remapper.getPurchasableItemFromPlatformSpecificId(productId); // We should only provision non consumables if they're not owned. if (0 == tDb.getPurchaseHistory(item)) { callback.onPurchaseSucceeded(productId, receipt, tranId); } break; } }); }
public void onPurchaseSucceeded(string data, string receipt) { Dictionary <string, object> response = (Dictionary <string, object>)Unibill.Impl.MiniJSON.jsonDecode(data); var productId = (string)response ["productId"]; var transactionId = response.getString("transactionIdentifier"); // If we're restoring, make sure it isn't a consumable. if (restoreInProgress) { if (remapper.canMapProductSpecificId(productId)) { if (remapper.getPurchasableItemFromPlatformSpecificId(productId).PurchaseType == PurchaseType.Consumable) { // Silently ignore this consumable. logger.Log("Ignoring restore of consumable: " + productId); // We must close the transaction or storekit will keep sending it to us. storekit.finishTransaction(transactionId); return; } } } biller.onPurchaseSucceeded(productId, receipt, transactionId); }
public void OnPurchaseSucceeded(string productId, string receipt, string tranId) { UnityEngine.WSA.Application.InvokeOnAppThread(() => { logger.LogError("PURCHASE SUCCEEDED!:{0}", count++); if (!remapper.canMapProductSpecificId(productId)) { logger.LogError("Purchased unknown product: {0}. Ignoring!", productId); return; } var details = remapper.getPurchasableItemFromPlatformSpecificId(productId); switch (details.PurchaseType) { case PurchaseType.Consumable: callback.onPurchaseSucceeded(productId, receipt, tranId); break; case PurchaseType.NonConsumable: case PurchaseType.Subscription: var item = remapper.getPurchasableItemFromPlatformSpecificId(productId); // We should only provision non consumables if they're not owned. if (0 == tDb.getPurchaseHistory(item)) { callback.onPurchaseSucceeded(productId, receipt, tranId); } break; } }, false); }
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); }
public void onProductListReceived(string productListString) { Dictionary <string, object> response = (Dictionary <string, object>)Unibill.Impl.MiniJSON.jsonDecode(productListString); if (response.Count == 0) { callback.logError(UnibillError.GOOGLEPLAY_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")); long priceInMicros = details.getLong("priceInMicros"); decimal price = new decimal(priceInMicros) / 1000000m; PurchasableItem.Writer.setPriceInLocalCurrency(item, price); productsReceived.Add(item); } else { logger.LogError("Warning: Unknown product identifier: {0}", identifier.ToString()); } } 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.GOOGLEPLAY_MISSING_PRODUCT, product.Id, remapper.mapItemIdToPlatformSpecificId(product)); } } logger.Log("Received product list, polling for consumables..."); rawInterface.pollForConsumables(); }
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) { 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); }