Exemplo n.º 1
0
    public void InitializePurchasing()
    {
        // If we have already connected to Purchasing ...
        if (IsInitialized())
        {
            // ... we are done here.
            return;
        }

        // Create a builder, first passing in a suite of Unity provided stores.
        var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());

        // Add a product to sell / restore by way of its identifier, associating the general identifier with its store-specific identifiers.
        builder.Configure <IGooglePlayConfiguration>().SetPublicKey("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2O/9/H7jYjOsLFT/uSy3ZEk5KaNg1xx60RN7yWJaoQZ7qMeLy4hsVB3IpgMXgiYFiKELkBaUEkObiPDlCxcHnWVlhnzJBvTfeCPrYNVOOSJFZrXdotp5L0iS2NVHjnllM+HA1M0W2eSNjdYzdLmZl1bxTpXa4th+dVli9lZu7B7C2ly79i/hGTmvaClzPBNyX+Rtj7Bmo336zh2lYbRdpD5glozUq+10u91PMDPH+jqhx10eyZpiapr8dFqXl5diMiobknw9CgcjxqMTVBQHK6hS0qYKPmUDONquJn280fBs1PTeA6NMG03gb9FLESKFclcuEZtvM8ZwMMRxSLA9GwIDAQAB");


        builder.AddProduct(firstCurrencyId, ProductType.Consumable, new IDs()
        {
            { firstCurrencyIdGooglePlay, GooglePlay.Name },
        });

        UnityPurchasing.Initialize(this, builder);
    }
Exemplo n.º 2
0
        public void InitializePurchasing()
        {
            var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());

            foreach (var curPurchase in purchaseConfig.purchases)
            {
                if (curPurchase.typeBuyProduct == BuyProductType.Real)
                {
                    builder.AddProduct(curPurchase.productId, curPurchase.behavior,
                                       new IDs()
                    {
                        { curPurchase.productId, GooglePlay.Name }, { curPurchase.productIdIOS, AppleAppStore.Name }
                    });
                }
            }

            UnityPurchasing.Initialize(this, builder);

            if (GameManager.Instance.IsFakeShop)
            {
                IsInitialized = true;
            }
        }
Exemplo n.º 3
0
    public void InitializePurchasing()
    {
        // If we have already connected to Purchasing ...
        if (IsInitialized())
        {
            // ... we are done here.
            return;
        }

        // Create a builder, first passing in a suite of Unity provided stores.
        var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());

                        #if UNITY_ANDROID
        builder.Configure <IGooglePlayConfiguration>().SetPublicKey("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAkWevrJpqBtZoIQab5HwjpWwjxlvErIVpuYgZpXF0m+8uiVrclcQ8AeSNY4K07kARInHw/vy6KFmKAXozC30PbQFJ9R3ksHnVVCdrYV2UdMIMdn97vZdXuKQDginCRzInSPuTxpzcldUW1Rz501bf2dOmqof7wFC1krYNLUug8gMKvELtqqP27DZt55Fw7dlF0aa4ZKYHilT19YD+cSPrnwprVtRJZVmMvU708E5wmQGTTg2gUhja+RowBQ0VzgtVmkDGa5ujCv3yLdsBIxQsloRaWfAJZTAwr0hh8h9XapKj+nI72bLe2PXeSzgmZZgfhDeJNLYwOf7DTTL4npeHvQIDAQAB");
                        #endif
        // Add a product to sell / restore by way of its identifier, associating the general identifier
        // with its store-specific identifiers.
        builder.AddProduct(PRODUCT_TICKETS_1000, ProductType.Consumable);

        /*
         *
         * // Continue adding the non-consumable product.
         * builder.AddProduct(kProductIDNonConsumable, ProductType.NonConsumable);
         * // And finish adding the subscription product. Notice this uses store-specific IDs, illustrating
         * // if the Product ID was configured differently between Apple and Google stores. Also note that
         * // one uses the general kProductIDSubscription handle inside the game - the store-specific IDs
         * // must only be referenced here.
         * builder.AddProduct(kProductIDSubscription, ProductType.Subscription, new IDs(){
         *  { kProductNameAppleSubscription, AppleAppStore.Name },
         *  { kProductNameGooglePlaySubscription, GooglePlay.Name },
         * });
         *
         */
        // Kick off the remainder of the set-up with an asynchrounous call, passing the configuration
        // and this class' instance. Expect a response either in OnInitialized or OnInitializeFailed.
        UnityPurchasing.Initialize(this, builder);
    }
Exemplo n.º 4
0
        void Initialize()
        {
            switch (Application.platform)
            {
            case RuntimePlatform.Android:
                Store = AppStore.GooglePlay;
                break;

            case RuntimePlatform.IPhonePlayer:
                Store = AppStore.AppleAppStore;
                break;

            default:
                Store = AppStore.NotSpecified;
                break;
            }

            var module = StandardPurchasingModule.Instance(Store);

            var builder = ConfigurationBuilder.Instance(module);

            for (int i = 0; i < PlayFab.Catalog.Size; i++)
            {
                if (PlayFab.Catalog[i].VirtualCurrencyPrices == null)
                {
                    continue;
                }
                if (PlayFab.Catalog[i].VirtualCurrencyPrices.ContainsKey("RM") == false)
                {
                    continue;
                }

                builder.AddProduct(PlayFab.Catalog[i].ItemId, ProductType.Consumable);
            }

            UnityPurchasing.Initialize(Listener, builder);
        }
Exemplo n.º 5
0
    public void InitializePurchasing()
    {
#if UNITY_ANDROID
        // If we have already connected to Purchasing ...
        if (IsInitialized())
        {
            // ... we are done here.
            return;
        }


        var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());

        builder.AddProduct(PRODUCT_500COINS, ProductType.Consumable);
        builder.AddProduct(PRODUCT_1KCOINS, ProductType.Consumable);
        builder.AddProduct(PRODUCT_2KCOINS, ProductType.Consumable);
        builder.AddProduct(PRODUCT_3KCOINS, ProductType.Consumable);
        builder.AddProduct(PRODUCT_5KCOINS, ProductType.Consumable);
        builder.AddProduct(PRODUCT_10KCOINS, ProductType.Consumable);

        builder.AddProduct(PRODUCT_NOADS, ProductType.NonConsumable);

        builder.AddProduct(PRODUCT_LEVEL01STAGE05, ProductType.NonConsumable);
        builder.AddProduct(PRODUCT_LEVEL01STAGE06, ProductType.NonConsumable);
        builder.AddProduct(PRODUCT_LEVEL01STAGE07, ProductType.NonConsumable);

        builder.AddProduct(PRODUCT_LEVEL02STAGE05, ProductType.NonConsumable);
        builder.AddProduct(PRODUCT_LEVEL02STAGE06, ProductType.NonConsumable);
        builder.AddProduct(PRODUCT_LEVEL02STAGE07, ProductType.NonConsumable);

        builder.AddProduct(PRODUCT_LEVEL03STAGE05, ProductType.NonConsumable);
        builder.AddProduct(PRODUCT_LEVEL03STAGE06, ProductType.NonConsumable);
        builder.AddProduct(PRODUCT_LEVEL03STAGE07, ProductType.NonConsumable);

        UnityPurchasing.Initialize(this, builder);
#endif
    }
Exemplo n.º 6
0
    public void InitializePurchasing()
    {
        // If we have already connected to Purchasing ...
        if (IsInitialized())
        {
            // ... we are done here.
            return;
        }

        // Create a builder, first passing in a suite of Unity provided stores.
        var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());

        // Add a product to sell / restore by way of its identifier, associating the general identifier
        // with its store-specific identifiers.
        builder.AddProduct(kProductIDConsumable1, ProductType.Consumable);
        builder.AddProduct(kProductIDConsumable2, ProductType.Consumable);
        builder.AddProduct(kProductIDConsumable3, ProductType.Consumable);
        builder.AddProduct(kProductIDConsumable4, ProductType.Consumable);


        // Continue adding the non-consumable product.
        //builder.AddProduct(kProductIDNonConsumable, ProductType.NonConsumable);

        // And finish adding the subscription product. Notice this uses store-specific IDs, illustrating
        // if the Product ID was configured differently between Apple and Google stores. Also note that
        // one uses the general kProductIDSubscription handle inside the game - the store-specific IDs
        // must only be referenced here.

        /*builder.AddProduct(kProductIDSubscription, ProductType.Subscription, new IDs(){
         *  { kProductNameAppleSubscription, AppleAppStore.Name },
         *  { kProductNameGooglePlaySubscription, GooglePlay.Name },
         * });*/

        // Kick off the remainder of the set-up with an asynchrounous call, passing the configuration
        // and this class' instance. Expect a response either in OnInitialized or OnInitializeFailed.
        UnityPurchasing.Initialize(this, builder);
    }
Exemplo n.º 7
0
    private void InitializeIAP()
    {
        if (isInitialized)
        {
            return;
        }

        var purchasingModule = StandardPurchasingModule.Instance();

        purchasingModule.useFakeStoreUIMode = FakeStoreUIMode.DeveloperUser;

        var builder = ConfigurationBuilder.Instance(purchasingModule);

        builder.AddProduct(productIDConsumable_MediumPotion, ProductType.Consumable);
        builder.AddProduct(productIDNonConsumable_RareHelm, ProductType.NonConsumable, null, new PayoutDefinition(PayoutType.Item, "nothing", 1, "payout data"));

        builder.AddProduct(productIDSubscription_AutoRenew, ProductType.Subscription, new IDs
        {
            { "com.merchantmercenaries.subscription.auto", MacAppStore.Name },
            { "come.merchantmercenaries.subscription.automatic", GooglePlay.Name }
        });

        UnityPurchasing.Initialize(this, builder);
    }
Exemplo n.º 8
0
        public void InitializePurchasing()
        {
            // If we have already connected to Purchasing ...
            if (IsInitialized())
            {
                // ... we are done here.
                return;
            }

            // Create a builder, first passing in a suite of Unity provided stores.
            var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());

            // Add a product to sell / restore by way of its identifier, associating the general identifier with its store-specific identifiers.
            builder.AddProduct(Ads1Google, ProductType.NonConsumable, new IDs()
            {
                { Ads1Google, GooglePlay.Name }
            });
            builder.AddProduct(Ads2Google, ProductType.NonConsumable, new IDs()
            {
                { Ads2Google, GooglePlay.Name }
            });
            builder.AddProduct(Ads3Google, ProductType.NonConsumable, new IDs()
            {
                { Ads3Google, GooglePlay.Name }
            });
            builder.AddProduct(Ads4Google, ProductType.NonConsumable, new IDs()
            {
                { Ads4Google, GooglePlay.Name }
            });
            builder.AddProduct(Ads5Google, ProductType.NonConsumable, new IDs()
            {
                { Ads5Google, GooglePlay.Name }
            });

            UnityPurchasing.Initialize(this, builder);
        }
Exemplo n.º 9
0
        void IRefreshable.Refresh(Action onComplete, Action onFailure)
        {
            var configurationBuilder = CreateConfigurationBuilder();

            _storeListener                   = new StoreListener();
            _storeListener.Initialized      += OnInitialized;
            _storeListener.InitializeFailed += OnInitializeFailed;

            UnityPurchasing.Initialize(_storeListener, configurationBuilder);

            void OnInitialized(object sender, InitializedEventArgs eventArgs)
            {
                _storeListener.Initialized      -= OnInitialized;
                _storeListener.InitializeFailed -= OnInitializeFailed;

                ExtensionProvider = eventArgs.ExtensionProvider;
                StoreController   = eventArgs.StoreController;

                UpdateProducts();
                UpdateSubscriptions();

                onComplete();
            }

            void OnInitializeFailed(object sender, InitializeFailedEventArgs eventArgs)
            {
                _storeListener.Initialized      -= OnInitialized;
                _storeListener.InitializeFailed -= OnInitializeFailed;

                var exception = new Exception($"Initialize failed! {nameof(eventArgs.InitializationFailureReason)}: \"{eventArgs.InitializationFailureReason}\"");

                ExceptionHandler.Process(exception);

                onFailure();
            }
        }
Exemplo n.º 10
0
        /// <summary>Entry point: How the whole system starts.</summary>
        /// <param name="productIDs">Product IDs for what can be bought in the game.</param>
        /// <param name="onInitialisedAction">The action to call when this is initialised.</param>
        public AppCentralStoreListener(ProductIDs productIDs, OnInitialisedDelegate onInitialisedAction)
        {
            if (AppCentralStoreListener.IsInitialized())
            {
                return;
            }

            Debug.Log("Init Subscription " + productIDs.subscriptionProductID);
            AppCentralStoreListener.productNameAppleSubscription = productIDs.subscriptionProductID;
            AppCentralStoreListener.productIDSubscription        = productIDs.subscriptionProductID;
            this.OnInitialisedEvent += onInitialisedAction;

            // Create a builder, first passing in a suite of Unity provided stores.
            ConfigurationBuilder purchasingConfiguration = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());

            List <ProductDefinition> productDefinitions = new List <ProductDefinition>
            {
                new ProductDefinition(AppCentralStoreListener.ProductIDConsumable, UnityEngine.Purchasing.ProductType.Consumable),
                new ProductDefinition(AppCentralStoreListener.ProductIDNonConsumable, UnityEngine.Purchasing.ProductType.NonConsumable),
            };

            purchasingConfiguration.AddProducts(productDefinitions);

            // Adding the subscription product.
            // Notice this uses store-specific IDs, illustrating if the Product ID was configured differently between Apple and Google stores.
            // Also note that one uses the general ProductIDSubscription handle inside the game - the store-specific IDs must only be referenced here.
            purchasingConfiguration.AddProduct(AppCentralStoreListener.productIDSubscription, UnityEngine.Purchasing.ProductType.Subscription, new IDs
            {
                { AppCentralStoreListener.productNameAppleSubscription, AppleAppStore.Name },
                { AppCentralStoreListener.productNameGoogleSubscription, GooglePlay.Name },
            });

            // Kick off the remainder of the set-up with an asynchrounous call, passing the configuration
            // and this class' instance. Expect a response either in OnInitialized or OnInitializeFailed.
            UnityPurchasing.Initialize(this, purchasingConfiguration);
        }
Exemplo n.º 11
0
    public void InitializePurchasing()
    {
        // If we have already connected to Purchasing ...
        if (IsInitialized())
        {
            // ... we are done here.
            return;
        }


        var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());


        builder.AddProduct(PRODUCT_DIAMOND1, ProductType.Consumable);
        builder.AddProduct(PRODUCT_DIAMOND2, ProductType.Consumable);
        builder.AddProduct(PRODUCT_DIAMOND3, ProductType.Consumable);
        builder.AddProduct(PRODUCT_UNLOCK, ProductType.Consumable);
        builder.AddProduct(PRODUCT_NO_ADS, ProductType.NonConsumable);


        // Kick off the remainder of the set-up with an asynchrounous call, passing the configuration
        // and this class' instance. Expect a response either in OnInitialized or OnInitializeFailed.
        UnityPurchasing.Initialize(this, builder);
    }
Exemplo n.º 12
0
    public void InitializePurchasing()
    {
        // If we have already connected to Purchasing ...
        if (IsInitialized())
        {
            // ... we are done here.
            return;
        }

        // Create a builder, first passing in a suite of Unity provided stores.
        var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());

        InAppProductList.Instance.InitialiseProductList();

        // Add Consumable
        foreach (KeyValuePair <string, InAppProductList.ProductInfo> product in InAppProductList.Instance.ConsumableList)
        {
            AddProduct(builder, product.Value, ProductType.Consumable);
        }

        // Continue adding the non-consumable product.
        foreach (KeyValuePair <string, InAppProductList.ProductInfo> product in InAppProductList.Instance.NonConsumableList)
        {
            AddProduct(builder, product.Value, ProductType.NonConsumable);
        }

        // Adding subscription
        foreach (KeyValuePair <string, InAppProductList.ProductInfo> product in InAppProductList.Instance.SubscriptionList)
        {
            AddProduct(builder, product.Value, ProductType.Subscription);
        }

        // Kick off the remainder of the set-up with an asynchrounous call, passing the configuration
        // and this class' instance. Expect a response either in OnInitialized or OnInitializeFailed.
        UnityPurchasing.Initialize(this, builder);
    }
Exemplo n.º 13
0
    public void Initialize(IapProduct[] InProducts, string InSubscriptionId,
                           string InAppleSubscription, string InGooglePlaySubscription,
                           UnityAction <int> InInitResultAction)
    {
        Debug.Log("[IapPurchaser]    Initialize with Consumable, NonConsumable and Subscription.");

        if (IsInitialized())
        {
            Debug.Log("[IapPurchaser]    Multiple initialization.");
            if (null != InInitResultAction)
            {
                InInitResultAction.Invoke(-1);
            }
            return;
        }

        initializeResultAction = InInitResultAction;

        ConfigurationBuilder builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());
        int len = InProducts.Length;

        for (int i = 0; i < len; i++)
        {
            Debug.Log(string.Format("[IapPurchaser]    Project: Id = {0}, Type = {1};", InProducts[i].Id, InProducts[i].Type));
            builder.AddProduct(InProducts[i].Id, InProducts[i].Type);
        }

        Debug.Log(string.Format("[IapPurchaser]    Subscription: Apple = {0}, Google = {1};", InAppleSubscription, InGooglePlaySubscription));
        builder.AddProduct(InSubscriptionId, ProductType.Subscription, new IDs()
        {
            { InAppleSubscription, AppleAppStore.Name },
            { InGooglePlaySubscription, GooglePlay.Name },
        });

        UnityPurchasing.Initialize(this, builder);
    }
Exemplo n.º 14
0
    public void InitializePurchasing()
    {
        // If we have already connected to Purchasing ...
        if (IsInitialized())
        {
            // ... we are done here.
            return;
        }

        // Create a builder, first passing in a suite of Unity provided stores.
        var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());

        builder.AddProduct(PRODUCT_100_CREDITS, ProductType.Consumable);
        builder.AddProduct(PRODUCT_200_CREDITS, ProductType.Consumable);
        builder.AddProduct(PRODUCT_400_CREDITS, ProductType.Consumable);
        builder.AddProduct(PRODUCT_1000_CREDITS, ProductType.Consumable);
        builder.AddProduct(PRODUCT_2000_CREDITS, ProductType.Consumable);
        builder.AddProduct(PRODUCT_5000_CREDITS, ProductType.Consumable);
        builder.AddProduct(PRODUCT_10000_CREDITS, ProductType.Consumable);
        builder.AddProduct(PRODUCT_NO_ADS, ProductType.NonConsumable);


        UnityPurchasing.Initialize(this, builder);
    }
Exemplo n.º 15
0
    public void InitializePurchasing(MarketPurchase[] items, EventHandler <EventArgs> ready)
    {
        _onReady = ready;
        _items   = items;

        if (_storeController == null)
        {
            if (IsInitialized())
            {
                return;
            }
        }

        var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());

        foreach (MarketPurchase item in _items)
        {
            builder.AddProduct(item.Name, ProductType.Consumable, new IDs()
            {
                { item.Name, GooglePlay.Name }
            });
        }
        UnityPurchasing.Initialize(this, builder);
    }
Exemplo n.º 16
0
    public void Awake()
    {
        var module = StandardPurchasingModule.Instance();

        module.useMockBillingSystem = true; // Microsoft
        // The FakeStore supports: no-ui (always succeeding), basic ui (purchase pass/fail), and
        // developer ui (initialization, purchase, failure code setting). These correspond to
        // the FakeStoreUIMode Enum values passed into StandardPurchasingModule.useFakeStoreUIMode.
        module.useFakeStoreUIMode = FakeStoreUIMode.StandardUser;

        var builder = ConfigurationBuilder.Instance(module);

        builder.Configure <IGooglePlayConfiguration>().SetPublicKey("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2O/9/H7jYjOsLFT/uSy3ZEk5KaNg1xx60RN7yWJaoQZ7qMeLy4hsVB3IpgMXgiYFiKELkBaUEkObiPDlCxcHnWVlhnzJBvTfeCPrYNVOOSJFZrXdotp5L0iS2NVHjnllM+HA1M0W2eSNjdYzdLmZl1bxTpXa4th+dVli9lZu7B7C2ly79i/hGTmvaClzPBNyX+Rtj7Bmo336zh2lYbRdpD5glozUq+10u91PMDPH+jqhx10eyZpiapr8dFqXl5diMiobknw9CgcjxqMTVBQHK6hS0qYKPmUDONquJn280fBs1PTeA6NMG03gb9FLESKFclcuEZtvM8ZwMMRxSLA9GwIDAQAB");
        builder.AddProduct("coins", ProductType.Consumable, new IDs
        {
            { "com.unity3d.unityiap.unityiapdemo.100goldcoins.v2.c", GooglePlay.Name },
            { "com.unity3d.unityiap.unityiapdemo.100goldcoins.6", AppleAppStore.Name },
            { "com.unity3d.unityiap.unityiapdemo.100goldcoins.mac", MacAppStore.Name },
            { "com.unity3d.unityiap.unityiapdemo.100goldcoins.win8", WinRT.Name }
        });

        builder.AddProduct("sword", ProductType.NonConsumable, new IDs
        {
            { "com.unity3d.unityiap.unityiapdemo.sword.c", GooglePlay.Name },
            { "com.unity3d.unityiap.unityiapdemo.sword.6", AppleAppStore.Name },
            { "com.unity3d.unityiap.unityiapdemo.sword.mac", MacAppStore.Name },
            { "com.unity3d.unityiap.unityiapdemo.sword", WindowsPhone8.Name }
        });
        builder.AddProduct("subscription", ProductType.Subscription, new IDs
        {
            { "com.unity3d.unityiap.unityiapdemo.subscription", GooglePlay.Name, AppleAppStore.Name }
        });

        // Now we're ready to initialize Unity IAP.
        UnityPurchasing.Initialize(this, builder);
    }
Exemplo n.º 17
0
    // ========================================================================== //

    /* public - [Do] Function
     * 외부 객체가 호출                         */
    public static void DoInit(Action <TENUM, bool> onPurchased)
    {
        if (_bInit)
        {
            return;
        }

        int iLen = PrimitiveHelper.GetEnumMax <TENUM>();

        if (iLen == 0)
        {
            Debug.LogWarning("Unity IAP : 상품을 등록해주세요!"); return;
        }

        StandardPurchasingModule pModule  = StandardPurchasingModule.Instance();
        ConfigurationBuilder     pBuilder = ConfigurationBuilder.Instance(pModule);

        TENUM[] eEnum = PrimitiveHelper.DoGetEnumType <TENUM>();

        for (int i = 0; i < iLen; i++)
        {
            string strProductID = eEnum[i].ToString();

            Debug.Log(strProductID);

            pBuilder.AddProduct(strProductID, ProductType.Consumable, new IDs {
                { strProductID, AppleAppStore.Name },
                { strProductID, GooglePlay.Name }
            });
        }

        IStoreListener pStoreListener = new SCUnityIAPService <TENUM>();

        UnityPurchasing.Initialize(pStoreListener, pBuilder);
        _EVENT_OnPurchased = onPurchased;
    }
Exemplo n.º 18
0
    public void InitializePurchasing()
    {
        if (IsInitialized())
        {
            return;
        }

        var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());

        //Our products, with their consumable types
        builder.AddProduct(PURCHASE_GETCURRENCY_SMALL, ProductType.Consumable);       // Consumable purchase = something you can purchase over and over
        builder.AddProduct(PURCHASE_GETCURRENCY_MEDIUM, ProductType.Consumable);
        builder.AddProduct(PURCHASE_GETCURRENCY_BIG, ProductType.Consumable);

        builder.AddProduct(PURCHASE_GETNOADS, ProductType.NonConsumable);     // Non-consumable purchase = something you can purchase only once

        //Below is a builder for a subscription product, which we aren't planning to use atm. I'll leave it here for refence or if we need for some reason.

        /*builder.AddProduct(kProductIDSubscription, ProductType.Subscription, new IDs(){
         *  { kProductNameGooglePlaySubscription, GooglePlay.Name },
         * });*/

        UnityPurchasing.Initialize(this, builder);
    }
Exemplo n.º 19
0
        /// <summary>
        /// Fetch Apprien variant IAP ids and re-initialize UnityPurchasing
        /// </summary>
        private void FetchPrices()
        {
            // Update the products with Apprien IAP ids
            StartCoroutine(
                _apprienManager.FetchApprienPrices(
                    _apprienProducts,
                    () =>
            {
                // The products will now contain updated IAP ids. Add them to the product builder
                // If the connection failed or the variants were not fetched for some reason
                // this will add duplicates to the builder, which will ignore them safely.
                foreach (var product in _apprienProducts)
                {
                    // Apprien variant IAP id. If connection failed, the variant IAP id
                    // defaults to the base IAP id
                    _builder.AddProduct(product.ApprienVariantIAPId, product.ProductType);
                }

                // Initialize UnityPurchasing with the fetched IAP ids
                UnityPurchasing.Initialize(this, _builder);
            }
                    )
                );
        }
Exemplo n.º 20
0
    public void InitializePurchasing()
    {
        Debug.Log("InAppBilling: InitializePurchasing()");
        initialized = true;

        // If we have already connected to Purchasing ...
        if (IsInitialized())
        {
            // ... we are done here.
            Debug.Log("InAppBilling: Trying to initialize, but it's already initialized.");
            return;
        }

        // Create a builder, first passing in a suite of Unity provided stores.
        var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());

        // Add a product to sell / restore by way of its identifier, associating the general identifier with its store-specific identifiers.
        builder.AddProduct(kItem, ProductType.NonConsumable, new IDs()
        {
            { kGooglePlayItem, GooglePlay.Name }
        });                                                                                                      // Continue adding the non-consumable product.

        UnityPurchasing.Initialize(this, builder);
    }
Exemplo n.º 21
0
    public void InitializePurchasing()
    {
        // If we have already connected to Purchasing ...
        if (IsInitialized())
        {
            // ... we are done here.
            return;
        }
        var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());

        builder.Configure <IGooglePlayConfiguration>().SetPublicKey(AndroidKey);
        //KHOI TAO CAC TEN MAT HANG TREN CAC STORE
        foreach (var item in productIAP)
        {
            builder.AddProduct(item.ID, item.productType, new IDs()
            {
                { item.IdIOS, AppleAppStore.Name },//dinh nghia them cho ro rang cac store, cung khong can thiet + IOS
                { item.IdAndroid, GooglePlay.Name },
                { item.ID, WindowsStore.Name },
                { item.ID, FacebookStore.Name },
            });
        }
        UnityPurchasing.Initialize(this, builder);
    }
Exemplo n.º 22
0
        public void InitializePurchasing()
        {
            if (IsInitialized())
            {
                return;
            }

            var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());

            builder.AddProduct(NO_ADS, ProductType.NonConsumable);
            builder.AddProduct(BUY_1000_DOLLARS_ID, ProductType.Consumable);
            builder.AddProduct(BUY_5000_DOLLARS_ID, ProductType.Consumable);
            builder.AddProduct(BUY_30000_DOLLARS_ID, ProductType.Consumable);
            builder.AddProduct(BUY_30000_DOLLARS_FIRST_ID, ProductType.Consumable);
            builder.AddProduct(BUY_20000_DOLLARS_ID, ProductType.Consumable);
            builder.AddProduct(STARTER_PACK, ProductType.Consumable);
            builder.AddProduct(WEAPON_PACK, ProductType.Consumable);
            builder.AddProduct(STARTER_PACK_OLD, ProductType.Consumable);
            builder.AddProduct(FIGHTER_KIT, ProductType.Consumable);
            builder.AddProduct(BUILDER_KIT, ProductType.Consumable);
            builder.AddProduct(SURVIVAL_KIT, ProductType.Consumable);

            UnityPurchasing.Initialize(this, builder);
        }
Exemplo n.º 23
0
    public void InitializePurchasing()
    {
        // If we have already connected to Purchasing ...
        if (IsInitialized())
        {
            // ... we are done here.
            return;
        }

        // Create a builder, first passing in a suite of Unity provided stores.
        var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());

        // Add a product to sell / restore by way of its identifier, associating the general identifier
        // with its store-specific identifiers.
        builder.AddProduct(PRODUCT_GOLD_50, ProductType.Consumable);
        builder.AddProduct(PRODUCT_GOLD_500, ProductType.Consumable);
        builder.AddProduct(PRODUCT_TOKENS_5, ProductType.Consumable);
        // Continue adding the non-consumable product.
        builder.AddProduct(PRODUCT_REMOVE_ADDS, ProductType.NonConsumable);

        // Kick off the remainder of the set-up with an asynchrounous call, passing the configuration
        // and this class' instance. Expect a response either in OnInitialized or OnInitializeFailed.
        UnityPurchasing.Initialize(this, builder);
    }
Exemplo n.º 24
0
    public void InitializePurchasing()
    {
        // If we have already connected to Purchasing ...
        if (IsInitialized())
        {
            // ... we are done here.
            return;
        }

        // Create a builder, first passing in a suite of Unity provided stores.
        var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());

        // Add a product to sell / restore by way of its identifier, associating the general identifier
        // with its store-specific identifiers.
        builder.AddProduct(forestProjectilePackID, ProductType.NonConsumable);
        builder.AddProduct(thousandCoins, ProductType.Consumable);
        builder.AddProduct(fiveThousandCoins, ProductType.Consumable);
        builder.AddProduct(tenThousandCoins, ProductType.Consumable);
        builder.AddProduct(removeAds, ProductType.NonConsumable);

        // Kick off the remainder of the set-up with an asynchrounous call, passing the configuration
        // and this class' instance. Expect a response either in OnInitialized or OnInitializeFailed.
        UnityPurchasing.Initialize(this, builder);
    }
Exemplo n.º 25
0
    /// Called when the available items have been pulled from ChilliConnect.
    /// Builds the Unity purchasing system using the available items
    ///
    /// @param request
    ///     Information about the request, including the URL endpoint.
    /// @param response
    ///     Response from the request. Holds the information on all purchaseable items
    ///
    private void OnAvailableItemsFetched(GetRealMoneyPurchaseDefinitionsRequest request, GetRealMoneyPurchaseDefinitionsResponse response)
    {
        var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());

        Debug.Log("Available items fetched:");

        //Initialise Unity purchasing with the product ids available on ChilliConnect
        foreach (var item in response.Items)
        {
            Debug.Log(string.Format("Product: {0}", item.Key));
            builder.AddProduct(item.Key, ProductType.Consumable, new IDs
            {
                { item.GoogleId, GooglePlay.Name },
                { item.IosId, AppleAppStore.Name }
            });

            m_availableItems.Add(new Item(GetPlatformProductId(item), item.Key));
        }

        builder.Configure <IGooglePlayConfiguration>().SetPublicKey("ADD YOUR GOOGLE PUBLIC KEY");

        // Expect a response either in OnInitialized or OnInitializeFailed.
        UnityPurchasing.Initialize(this, builder);
    }
Exemplo n.º 26
0
    public void InitializePurchasing()
    {
        // If we have already connected to Purchasing ...
        if (IsInitialized())
        {
            // ... we are done here.
            return;
        }

        // Create a builder, first passing in a suite of Unity provided stores.
        var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());

        builder.AddProduct(PRODUCT_100_BISCUITS, ProductType.Consumable);

        builder.AddProduct(PRODUCT_250_BISCUITS, ProductType.Consumable);

        builder.AddProduct(PRODUCT_400_BISCUITS, ProductType.Consumable);

        builder.AddProduct(PRODUCT_STARTER_PACK, ProductType.NonConsumable);

        // Kick off the remainder of the set-up with an asynchrounous call, passing the configuration
        // and this class' instance. Expect a response either in OnInitialized or OnInitializeFailed.
        UnityPurchasing.Initialize(this, builder);
    }
Exemplo n.º 27
0
    public void InitializePurchasing()
    {
        if (IsInitialized())
        {
            return;
        }

        var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());

        //builder.AddProduct(kProductIDConsumable, ProductType.Consumable);
        builder.AddProduct(IDNonConsumableNoAds, ProductType.NonConsumable);
        builder.AddProduct(IDConsumableCoins1000, ProductType.Consumable);
        builder.AddProduct(IDConsumableCoins2000, ProductType.Consumable);
        builder.AddProduct(IDConsumableCoins4000noads, ProductType.NonConsumable);
        //builder.AddProduct(IDConsumableCoins1000, ProductType.Consumable);
        //builder.AddProduct(IDConsumableCoins10000, ProductType.Consumable);

        //builder.AddProduct(kProductIDSubscription, ProductType.Subscription, new IDs(){
        //    { kProductNameAppleSubscription, AppleAppStore.Name },
        //    { kProductNameGooglePlaySubscription, GooglePlay.Name },
        //});

        UnityPurchasing.Initialize(this, builder);
    }
Exemplo n.º 28
0
    public void Awake()
    {
        var module = StandardPurchasingModule.Instance();

        // The FakeStore supports: no-ui (always succeeding), basic ui (purchase pass/fail), and
        // developer ui (initialization, purchase, failure code setting). These correspond to
        // the FakeStoreUIMode Enum values passed into StandardPurchasingModule.useFakeStoreUIMode.
        module.useFakeStoreUIMode = FakeStoreUIMode.StandardUser;

        var builder = ConfigurationBuilder.Instance(module);

        // This enables the Microsoft IAP simulator for local testing.
        // You would remove this before building your release package.
        builder.Configure <IMicrosoftConfiguration>().useMockBillingSystem = true;
        builder.Configure <IGooglePlayConfiguration>().SetPublicKey("MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEA2O/9/H7jYjOsLFT/uSy3ZEk5KaNg1xx60RN7yWJaoQZ7qMeLy4hsVB3IpgMXgiYFiKELkBaUEkObiPDlCxcHnWVlhnzJBvTfeCPrYNVOOSJFZrXdotp5L0iS2NVHjnllM+HA1M0W2eSNjdYzdLmZl1bxTpXa4th+dVli9lZu7B7C2ly79i/hGTmvaClzPBNyX+Rtj7Bmo336zh2lYbRdpD5glozUq+10u91PMDPH+jqhx10eyZpiapr8dFqXl5diMiobknw9CgcjxqMTVBQHK6hS0qYKPmUDONquJn280fBs1PTeA6NMG03gb9FLESKFclcuEZtvM8ZwMMRxSLA9GwIDAQAB");
        m_IsGooglePlayStoreSelected = Application.platform == RuntimePlatform.Android && module.androidStore == AndroidStore.GooglePlay;

        // CloudMoolah Configuration setings
        // All games must set the configuration. the configuration need to apply on the CloudMoolah Portal.
        // CloudMoolah APP Key
        builder.Configure <IMoolahConfiguration>().appKey = "d93f4564c41d463ed3d3cd207594ee1b";
        // CloudMoolah Hash Key
        builder.Configure <IMoolahConfiguration>().hashKey = "cc";
        // This enables the CloudMoolah test mode for local testing.
        // You would remove this, or set to CloudMoolahMode.Production, before building your release package.
        builder.Configure <IMoolahConfiguration>().SetMode(CloudMoolahMode.AlwaysSucceed);
        // This records whether we are using Cloud Moolah IAP.
        // Cloud Moolah requires logging in to access your Digital Wallet, so:
        // A) IAPDemo (this) displays the Cloud Moolah GUI button for Cloud Moolah
        m_IsCloudMoolahStoreSelected = Application.platform == RuntimePlatform.Android && module.androidStore == AndroidStore.CloudMoolah;

        // Define our products.
        // In this case our products have the same identifier across all the App stores,
        // except on the Mac App store where product IDs cannot be reused across both Mac and
        // iOS stores.
        // So on the Mac App store our products have different identifiers,
        // and we tell Unity IAP this by using the IDs class.
        builder.AddProduct("100.gold.coins", ProductType.Consumable, new IDs
        {
            { "100.gold.coins.mac", MacAppStore.Name },
            { "000000596586", TizenStore.Name },
            { "com.ff", MoolahAppStore.Name },
        });

        builder.AddProduct("500.gold.coins", ProductType.Consumable, new IDs
        {
            { "500.gold.coins.mac", MacAppStore.Name },
            { "000000596581", TizenStore.Name },
            { "com.ee", MoolahAppStore.Name },
        });

        builder.AddProduct("sword", ProductType.NonConsumable, new IDs
        {
            { "sword.mac", MacAppStore.Name },
            { "000000596583", TizenStore.Name },
        });

        builder.AddProduct("subscription", ProductType.Subscription, new IDs
        {
            { "subscription.mac", MacAppStore.Name }
        });

        // Write Amazon's JSON description of our products to storage when using Amazon's local sandbox.
        // This should be removed from a production build.
        builder.Configure <IAmazonConfiguration>().WriteSandboxJSON(builder.products);

        // This enables simulated purchase success for Samsung IAP.
        // You would remove this, or set to SamsungAppsMode.Production, before building your release package.
        builder.Configure <ISamsungAppsConfiguration>().SetMode(SamsungAppsMode.AlwaysSucceed);
        // This records whether we are using Samsung IAP. Currently ISamsungAppsExtensions.RestoreTransactions
        // displays a blocking Android Activity, so:
        // A) Unity IAP does not automatically restore purchases on Samsung Galaxy Apps
        // B) IAPDemo (this) displays the "Restore" GUI button for Samsung Galaxy Apps
        m_IsSamsungAppsStoreSelected = Application.platform == RuntimePlatform.Android && module.androidStore == AndroidStore.SamsungApps;


        // This selects the GroupId that was created in the Tizen Store for this set of products
        // An empty or non-matching GroupId here will result in no products available for purchase
        builder.Configure <ITizenStoreConfiguration>().SetGroupId("100000085616");


                #if RECEIPT_VALIDATION
        validator = new CrossPlatformValidator(GooglePlayTangle.Data(), AppleTangle.Data(), Application.bundleIdentifier);
                #endif

        // Now we're ready to initialize Unity IAP.
        UnityPurchasing.Initialize(this, builder);
    }
Exemplo n.º 29
0
    public void Awake()
    {
        StandardPurchasingModule module = StandardPurchasingModule.Instance();

        // The FakeStore supports: no-ui (always succeeding), basic ui (purchase pass/fail), and
        // developer ui (initialization, purchase, failure code setting). These correspond to
        // the FakeStoreUIMode Enum values passed into StandardPurchasingModule.useFakeStoreUIMode.
        module.useFakeStoreUIMode = FakeStoreUIMode.StandardUser;

        ConfigurationBuilder builder = ConfigurationBuilder.Instance(module);

        // Set this to true to enable the Microsoft IAP simulator for local testing.
        builder.Configure <IMicrosoftConfiguration>().useMockBillingSystem = false;

        m_IsGooglePlayStoreSelected =
            Application.platform == RuntimePlatform.Android && module.appStore == AppStore.GooglePlay;

#if AGGRESSIVE_INTERRUPT_RECOVERY_GOOGLEPLAY
        // For GooglePlay, if we have access to a backend server to deduplicate purchases, query purchase history
        // when attempting to recover from a network-interruption encountered during purchasing. Strongly recommend
        // deduplicating transactions across app reinstallations because this relies upon the on-device, deletable
        // TransactionLog database.
        builder.Configure <IGooglePlayConfiguration>().aggressivelyRecoverLostPurchases = true;
        // Use purchaseToken instead of orderId for all transactions to avoid non-unique transactionIDs for a
        // single purchase; two ProcessPurchase calls for one purchase, differing only by which field of the receipt
        // is used for the Product.transactionID. Automatically true if aggressivelyRecoverLostPurchases is enabled
        // and this API is not called at all.
        builder.Configure <IGooglePlayConfiguration>().UsePurchaseTokenForTransactionId(true);
#endif

        // Define our products.
        // Either use the Unity IAP Catalog, or manually use the ConfigurationBuilder.AddProduct API.
        // Use IDs from both the Unity IAP Catalog and hardcoded IDs via the ConfigurationBuilder.AddProduct API.

        // Use the products defined in the IAP Catalog GUI.
        // E.g. Menu: "Window" > "Unity IAP" > "IAP Catalog", then add products, then click "App Store Export".
        ProductCatalog catalog = ProductCatalog.LoadDefaultCatalog();

        foreach (ProductCatalogItem product in catalog.allValidProducts)
        {
            if (product.allStoreIDs.Count > 0)
            {
                IDs ids = new IDs();
                foreach (StoreID storeID in product.allStoreIDs)
                {
                    ids.Add(storeID.id, storeID.store);
                }
                builder.AddProduct(product.id, product.type, ids);
            }
            else
            {
                builder.AddProduct(product.id, product.type);
            }
        }

        // In this case our products have the same identifier across all the App stores,
        // except on the Mac App store where product IDs cannot be reused across both Mac and
        // iOS stores.
        // So on the Mac App store our products have different identifiers,
        // and we tell Unity IAP this by using the IDs class.

        builder.AddProduct("100.gold.coins", ProductType.Consumable, new IDs
        {
            { "com.unity3d.unityiap.unityiapdemo.100goldcoins.7", MacAppStore.Name },
            { "100.gold.coins", AmazonApps.Name },
            { "100.gold.coins", AppleAppStore.Name }
        }
#if USE_PAYOUTS
                           , new List <PayoutDefinition> {
            new PayoutDefinition(PayoutType.Item, "", 1, "item_id:76543"),
            new PayoutDefinition(PayoutType.Currency, "gold", 50)
        }
#endif //USE_PAYOUTS
                           );

        builder.AddProduct("500.gold.coins", ProductType.Consumable, new IDs
        {
            { "com.unity3d.unityiap.unityiapdemo.500goldcoins.7", MacAppStore.Name },
            { "500.gold.coins", AmazonApps.Name },
        }
#if USE_PAYOUTS
                           , new PayoutDefinition(PayoutType.Currency, "gold", 500)
#endif //USE_PAYOUTS
                           );

        builder.AddProduct("300.gold.coins", ProductType.Consumable, new IDs()
#if USE_PAYOUTS
                           , new List <PayoutDefinition> {
            new PayoutDefinition(PayoutType.Item, "", 1, "item_id:76543"),
            new PayoutDefinition(PayoutType.Currency, "gold", 50)
        }
#endif //USE_PAYOUTS
                           );

        builder.AddProduct("sub1", ProductType.Subscription, new IDs());

        builder.AddProduct("sub2", ProductType.Subscription, new IDs());


        // Write Amazon's JSON description of our products to storage when using Amazon's local sandbox.
        // This should be removed from a production build.
        //builder.Configure<IAmazonConfiguration>().WriteSandboxJSON(builder.products);

        // This enables simulated purchase success for Samsung IAP.
        // You would remove this, or set to SamsungAppsMode.Production, before building your release package.
        builder.Configure <ISamsungAppsConfiguration>().SetMode(SamsungAppsMode.AlwaysSucceed);
        // This records whether we are using Samsung IAP. Currently ISamsungAppsExtensions.RestoreTransactions
        // displays a blocking Android Activity, so:
        // A) Unity IAP does not automatically restore purchases on Samsung Galaxy Apps
        // B) IAPDemo (this) displays the "Restore" GUI button for Samsung Galaxy Apps
        m_IsSamsungAppsStoreSelected =
            Application.platform == RuntimePlatform.Android && module.appStore == AppStore.SamsungApps;

#if INTERCEPT_PROMOTIONAL_PURCHASES
        // On iOS and tvOS we can intercept promotional purchases that come directly from the App Store.
        // On other platforms this will have no effect; OnPromotionalPurchase will never be called.
        builder.Configure <IAppleConfiguration>().SetApplePromotionalPurchaseInterceptorCallback(OnPromotionalPurchase);
        Debug.Log("Setting Apple promotional purchase interceptor callback");
#endif

#if RECEIPT_VALIDATION
        string appIdentifier;
        #if UNITY_5_6_OR_NEWER
        appIdentifier = Application.identifier;
        #else
        appIdentifier = Application.bundleIdentifier;
        #endif
        validator = new CrossPlatformValidator(GooglePlayTangle.Data(), AppleTangle.Data(), appIdentifier);
#endif

        // Now we're ready to initialize Unity IAP.
        UnityPurchasing.Initialize(this, builder);
    }
Exemplo n.º 30
0
        /// <summary>
        /// Callback for succesful ProductService.GetSalesInventory
        /// </summary>
        /// <param name="in_jsonString"></param>
        /// <param name="in_object"></param>
        public void OnReadInventory(string in_jsonString, object in_object)
        {
            //Build IAPProducts based on all platform responses
            // ios and google play store now supported [smrj]

            m_productInventory.Clear(); // Clearing to fill with fresh data

            Dictionary <string, object> jsonMessage = (Dictionary <string, object>)JsonReader.Deserialize(in_jsonString);
            Dictionary <string, object> jsonData    = (Dictionary <string, object>)jsonMessage[BrainCloudConsts.JSON_DATA];
            var jsonArray = jsonData[JSON_PRODUCT_INVENTORY] as Array;
            Dictionary <string, object> product;
            Dictionary <string, object> priceData;

#if UNITY_IOS
            Dictionary <string, object> idsObject; //itunes may have an array of ids for iphone, ipad and appletv
#endif
            Dictionary <string, object> currencyRewards;

            IAPProduct iapProduct = null;

#if BUY_CURRENCY_ENABLED && !STEAMWORKS_ENABLED
            var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());
#endif
            for (int index = 0; index < jsonArray.Length; index++)
            {
                product   = ((Dictionary <string, object>)jsonArray.GetValue(index));
                priceData = ((Dictionary <string, object>)product[KEY_PRICEDATA]);

#if UNITY_ANDROID
                var storeId = (string)priceData[KEY_ANDROIDID];
#elif UNITY_WEBGL
                var storeId = (string)product[KEY_PRODUCT_FBURL];
#elif UNITY_IOS
                var idsArray = priceData[KEY_IDS] as Array;
                idsObject = ((Dictionary <string, object>)idsArray.GetValue(0));
                var storeId = (string)idsObject[KEY_ITUNESID];
#elif STEAMWORKS_ENABLED
                var storeId = ((int)priceData[KEY_PRODUCTID]).ToString();
#else
                var storeId = "";
                try
                {
                    // TODO add more store integration here [SMRJ]
                    storeId = (string)priceData[KEY_ANDROIDID];
                }
                catch (Exception)
                {
                    continue;
                }
#endif
                var braincloudID   = (string)product[KEY_PRODUCTID];
                var category       = (string)product[KEY_CATEGORY];
                var title          = (string)product[KEY_TITLE];
                var description    = (string)product[KEY_DESCRIPTION];
                var imageUrl       = (string)product[KEY_IMAGEURL];
                var referencePrice = Convert.ToDecimal(priceData[KEY_REFERENCEPRICE]);
                var price          = referencePrice / 100;
                var isPromotion    = (bool)priceData[KEY_ISPROMOTION];

                //get the value of the currency with the same name as the category
                currencyRewards = (Dictionary <string, object>)product[KEY_CURRENCY];

                // merge the peer / parent currencies within this dictionary as well
                if (product.ContainsKey(KEY_PARENT_CURRENCY))
                {
                    foreach (var item in product[KEY_PARENT_CURRENCY] as Dictionary <string, object> )
                    {
                        foreach (var currencyReward in item.Value as Dictionary <string, object> )
                        {
                            currencyRewards.Add(currencyReward.Key, currencyReward.Value);
                        }
                    }
                }

                if (product.ContainsKey(KEY_PEER_CURRENCY))
                {
                    foreach (var item in product[KEY_PEER_CURRENCY] as Dictionary <string, object> )
                    {
                        foreach (var currencyReward in item.Value as Dictionary <string, object> )
                        {
                            currencyRewards.Add(currencyReward.Key, currencyReward.Value);
                        }
                    }
                }

                object currencyVal;
                currencyRewards.TryGetValue(category, out currencyVal);

                var currencyValue = Convert.ToInt32(currencyVal);
                var type          = (string)product[KEY_TYPE];

#if BUY_CURRENCY_ENABLED
                var productType = ProductType.Consumable;

                switch (type.ToLower())
                {
                case PRODUCT_TYPE_SUBSCRIPTION:
                    productType = ProductType.Subscription;
                    break;

                case PRODUCT_TYPE_NON_CONSUMABLE:
                    productType = ProductType.NonConsumable;
                    break;

                case PRODUCT_TYPE_CONSUMABLE:
                default:
                    //productType = ProductType.Consumable; -> Already set as default value
                    break;
                }
#endif

                Dictionary <string, object> packRewards = (Dictionary <string, object>)product[BrainCloudConsts.JSON_DATA];

#if BUY_CURRENCY_ENABLED
                iapProduct = new IAPProduct(braincloudID, storeId, productType, category, title, description, imageUrl, referencePrice, price, isPromotion, currencyValue, currencyRewards, packRewards);
#else
                iapProduct = new IAPProduct(braincloudID, storeId, category, title, description, imageUrl, referencePrice, price, isPromotion, currencyValue, currencyRewards, packRewards);
#endif

                iapProduct.PriceString = String.Format("{0:c}", referencePrice / 100);

                //update the regular price on sale items
                if (isPromotion && product.ContainsKey(KEY_DEFAULTPRICEDATA))
                {
                    var defaultPriceData = ((Dictionary <string, object>)product[KEY_DEFAULTPRICEDATA]);
                    var refPrice         = Convert.ToDecimal(defaultPriceData[KEY_REFERENCEPRICE]);
#if UNITY_ANDROID
                    var regularId = (string)defaultPriceData[KEY_ANDROIDID];
#elif UNITY_WEBGL
                    var regularId = (string)product[KEY_PRODUCT_FBURL];
#elif STEAMWORKS_ENABLED
                    var regularId = ((int)defaultPriceData[KEY_PRODUCTID]).ToString();
#else
                    var ids       = defaultPriceData[KEY_IDS] as Array;
                    var regIdVal  = ((Dictionary <string, object>)ids.GetValue(0));
                    var regularId = (string)regIdVal[KEY_ITUNESID];
#endif

                    iapProduct.RegularPriceID     = regularId;
                    iapProduct.RegularPrice       = refPrice / 100;
                    iapProduct.RegularPriceString = String.Format("{0:c}", refPrice / 100);
#if BUY_CURRENCY_ENABLED && !STEAMWORKS_ENABLED                 // unity does not support steam works iap
                    builder.AddProduct(regularId, productType); //add this as a reference to the regular priced item
#endif
                }
#if BUY_CURRENCY_ENABLED && !STEAMWORKS_ENABLED                             // unity does not support steam works iap
                builder.AddProduct(iapProduct.StoreProductId, productType); //add to ConfigurationBuilder
#endif
                m_productInventory.Add(iapProduct);                         //add to List of products
            }
#if BUY_CURRENCY_ENABLED && !STEAMWORKS_ENABLED                             // unity does not support steam works iap
            UnityPurchasing.Initialize(this, builder);
#else
            GEventManager.TriggerEvent(GEventManager.ON_IAP_PRODUCTS_UPDATED);
#endif
        }