예제 #1
0
 public void OnProductListReceived(ProductDescription[] products)
 {
     util.RunOnMainThread(() => {
         // Extract transaction IDs from receipts where available.
         foreach (var product in products)
         {
             if (!string.IsNullOrEmpty(product.Receipt))
             {
                 product.TransactionID = readTransactionIdFromReceipt(product.Receipt);
             }
         }
         callback.onSetupComplete(new List <ProductDescription>(products));
     });
 }
예제 #2
0
        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);
        }
예제 #3
0
        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
        }
예제 #4
0
 public void initialise (IBillingServiceCallback biller) {
     this.biller = biller;
     if (reportError) {
         biller.logError(UnibillError.AMAZONAPPSTORE_GETITEMDATAREQUEST_FAILED);
     }
     biller.onSetupComplete(!reportCriticalError);
 }
예제 #5
0
        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 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());
        }
예제 #7
0
 public void initialise(IBillingServiceCallback biller)
 {
     this.biller = biller;
     if (reportError)
     {
         biller.logError(UnibillError.AMAZONAPPSTORE_GETITEMDATAREQUEST_FAILED);
     }
     biller.onSetupComplete(!reportCriticalError);
 }
예제 #8
0
 public void initialise (IBillingServiceCallback biller) {
     this.biller = biller;
     bool available = storekit.storeKitPaymentsAvailable ();
     if (available) {
         string[] platformSpecificProductIds = remapper.getAllPlatformSpecificProductIds();
         storekit.storeKitRequestProductData (string.Join (",", platformSpecificProductIds), platformSpecificProductIds);
     } else {
         biller.logError(UnibillError.STOREKIT_BILLING_UNAVAILABLE);
         biller.onSetupComplete(false);
     }
 }
예제 #9
0
        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);
        }
예제 #10
0
        public void initialise(IBillingServiceCallback biller)
        {
            this.biller = biller;

            var products = new List <ProductDescription>();

            foreach (var id in remapper.getAllPlatformSpecificProductIds())
            {
                products.Add(new ProductDescription(id, "$123.45", "Fake title", "Fake description", "USD", 123.45m));
            }

            biller.onSetupComplete(products);
        }
예제 #11
0
        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(string productListString)
        {
            if (productListString.Length == 0)
            {
                biller.logError(UnibillError.STOREKIT_RETURNED_NO_PRODUCTS);
                biller.onSetupComplete(false);
                return;
            }

            var responseObject = (Dictionary <string, object>)Unibill.Impl.MiniJSON.jsonDecode(productListString);
            var productHash    = responseObject.getHash("products");

            var products = Util.DeserialiseProductList(productHash);

            // Register our storekit transaction observer.
            // We must wait until we have initialised to do this.
            storekit.addTransactionObserver();

            var appReceipt = responseObject.getString("appReceipt");

            onAppReceiptRetrieved(appReceipt);

            biller.onSetupComplete(products);
        }
        public void initialise(IBillingServiceCallback biller)
        {
            this.biller = biller;
            bool available = storekit.unibillPaymentsAvailable();

            if (available)
            {
                storekit.unibillRequestProductData(remapper.getAllPlatformSpecificProductIds().toJson());
            }
            else
            {
                biller.logError(UnibillError.STOREKIT_BILLING_UNAVAILABLE);
                biller.onSetupComplete(false);
            }
        }
예제 #14
0
 // Callbacks
 public void onBillingNotSupported()
 {
     callback.logError(UnibillError.GOOGLEPLAY_BILLING_UNAVAILABLE);
     callback.onSetupComplete(false);
 }
예제 #15
0
 public void onGetItemDataFailed()
 {
     this.callback.logError(UnibillError.AMAZONAPPSTORE_GETITEMDATAREQUEST_FAILED);
     callback.onSetupComplete(true);
 }
예제 #16
0
 public void onProductListReceived(string productListString)
 {
     callback.onSetupComplete(Util.DeserialiseProductList(productListString));
 }
 public void OnProductListReceived(ProductDescription[] products)
 {
     UnityEngine.WSA.Application.InvokeOnAppThread(() => {
         callback.onSetupComplete(new List <ProductDescription>(products));
     }, false);
 }
예제 #18
0
        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);
        }