private IStore InstantiateAndroid()
 {
     if (m_AppStorePlatform == AppStore.GooglePlay)
     {
         return(InstantiateGoogleStore());
     }
     else
     {
         var store = new JSONStore(m_persistentDataPath);
         return(InstantiateAndroidHelper(store));
     }
 }
Ejemplo n.º 2
0
        internal static void ProvideProductsToAds(JSONStore purchaser, IStoreCallback manager, bool shouldLog = false)
        {
            if ((purchaser == null) || (manager == null))
            {
                s_Logger.LogError("UnityIAP Promo", "Attempt to set promo products without a valid purchaser!");
                return;
            }
            s_PromoPurchaser = purchaser;
            s_Unity          = manager;

            ProvideProductsToAds(UpdatePromoProductList(), shouldLog);
        }
        /// <summary>
        /// Configures the StandardPurchasingModule.
        /// </summary>
        public override void Configure()
        {
            BindConfiguration <IGooglePlayConfiguration>(new FakeGooglePlayStoreConfiguration());
            BindExtension <IGooglePlayStoreExtensions>(new FakeGooglePlayStoreExtensions());

            BindConfiguration <IAppleConfiguration>(new FakeAppleConfiguation());
            BindExtension <IAppleExtensions>(new FakeAppleExtensions());

            BindConfiguration <IAmazonConfiguration>(new FakeAmazonExtensions());
            BindExtension <IAmazonExtensions>(new FakeAmazonExtensions());

            BindConfiguration <IMicrosoftConfiguration>(new MicrosoftConfiguration(this));
            BindExtension <IMicrosoftExtensions>(new FakeMicrosoftExtensions());

            BindConfiguration <IAndroidStoreSelection>(this);

            BindExtension <IUDPExtensions>(new FakeUDPExtension());
            BindExtension <ITransactionHistoryExtensions>(new FakeTransactionHistoryExtensions());

            // Our store implementations are singletons, we must not attempt to instantiate
            // them more than once.
            if (null == storeInstance)
            {
                storeInstance = InstantiateStore();
            }

            RegisterStore(storeInstance.storeName, storeInstance.instance);

            // Moving SetModule from reflection to an interface
            var internalStore = storeInstance.instance as IStoreInternal;

            if (internalStore != null)
            {
                // NB: as currently implemented this is also doing Init work for ManagedStore
                internalStore.SetModule(this);
            }

            // If we are using a JSONStore, bind to it to get transaction history.
            if ((this.util != null) && this.util.IsClassOrSubclass(typeof(JSONStore), storeInstance.instance.GetType()))
            {
                JSONStore jsonStore = (JSONStore)storeInstance.instance;
                BindExtension <ITransactionHistoryExtensions>(jsonStore);
            }
        }
        //stg private const string kCatalogURL = "https://ecommerce-iap-stg.ie.unityads.unity3d.com";
        //qa  private const string kCatalogURL = "http://ec2-35-172-194-34.compute-1.amazonaws.com:8000";

        /// <summary>
        /// Fetches a Product catalog for the given parameters from the given catalog service. Returns null if
        /// either current ProfileData or key input parameters are incomplete.
        /// </summary>
        /// <param name="storeName">if null or empty, returns a null catalog provider</param>
        /// <param name="baseUrl">if null or empty, returns a null catalog provider</param>
        /// <param name="webUtil"></param>
        /// <param name="logger"></param>
        /// <param name="util"></param>
        /// <returns></returns>
        public static StoreCatalogImpl CreateInstance(string storeName, string baseUrl, IAsyncWebUtil webUtil, ILogger logger, IUtil util, JSONStore baseStore = null)
        {
            if ((String.IsNullOrEmpty(storeName)) || (String.IsNullOrEmpty(baseUrl)))
            {
                return(null);
            }


            if (logger == null)
            {
                logger = UnityEngine.Debug.unityLogger;
            }
            profile = ProfileData.Instance(util);
            Dictionary <string, object> queryParams = profile.GetProfileIds();

            if ((baseStore != null) && baseStore.disableStoreCatalog)
            {
                queryParams.Add("storeDisabled", "true");
            }
            var storeCatalogURL = baseUrl + "/catalog" + queryParams.ToQueryString();
            var fileReference   = FileReference.CreateInstance(kFileName, logger, util);

            return(new StoreCatalogImpl(webUtil, logger, storeCatalogURL, storeName, fileReference));
        }
 private INativeStore GetAndroidNativeStore(JSONStore store)
 {
     return(m_NativeStoreProvider.GetAndroidStore(store, m_AppStorePlatform, m_Binder, util));
 }
 private IStore InstantiateAndroidHelper(JSONStore store)
 {
     store.SetNativeStore(GetAndroidNativeStore(store));
     return(store);
 }
        /// <summary>
        /// Configures the StandardPurchasingModule.
        /// </summary>
        public override void Configure()
        {
            BindConfiguration <IGooglePlayConfiguration>(new FakeGooglePlayStoreConfiguration());
            BindExtension <IGooglePlayStoreExtensions>(new FakeGooglePlayStoreExtensions());

            BindConfiguration <IAppleConfiguration>(new FakeAppleConfiguation());
            BindExtension <IAppleExtensions>(new FakeAppleExtensions());

            BindConfiguration <IAmazonConfiguration>(new FakeAmazonExtensions());
            BindExtension <IAmazonExtensions>(new FakeAmazonExtensions());

            BindConfiguration <ISamsungAppsConfiguration>(new FakeSamsungAppsExtensions());
            BindExtension <ISamsungAppsExtensions>(new FakeSamsungAppsExtensions());

            BindConfiguration <IMicrosoftConfiguration>(new MicrosoftConfiguration(this));
            BindExtension <IMicrosoftExtensions>(new FakeMicrosoftExtensions());

            BindConfiguration <IAndroidStoreSelection>(this);

            BindConfiguration <IManagedStoreConfig>(new FakeManagedStoreConfig());
            BindExtension <IManagedStoreExtensions>(new FakeManagedStoreExtensions());

            BindExtension <IUDPExtensions>(new FakeUDPExtension());
            BindExtension <ITransactionHistoryExtensions>(new FakeTransactionHistoryExtensions());

            // Our store implementations are singletons, we must not attempt to instantiate
            // them more than once.
            if (null == storeInstance)
            {
                storeInstance = InstantiateStore();
            }

            RegisterStore(storeInstance.storeName, storeInstance.instance);

            if (m_UseCloudCatalog)
            {
                // Use reflection to call SetCatalogProviderFunction so this implementation can remain
                // backward-compatible with older engine versions that do not contain an implementation of the method.
                var setCatalog = m_Binder.GetType().GetMethod("SetCatalogProviderFunction");
                if (setCatalog != null)
                {
                    // Create an instance of the CloudCatalogImpl
                    m_CloudCatalog = CloudCatalogImpl.CreateInstance(storeInstance.storeName);

                    // Create the function to invoke when fetching products
                    Action <Action <HashSet <ProductDefinition> > > catalogProviderFunction = (Action <HashSet <ProductDefinition> > callback) => {
                        // This call must be done through reflection because IL2CPP will choke on the call. It seems
                        // IL2CPP treats the Action<HashSet<ProductDefinition>> type in the signature of
                        // FetchProducts as a different type than the Action<HashSet<ProductDefinition>> passed as
                        // a callback here. This does work with the Mono build.
                        // Equivalent to: m_CloudCatalog.FetchProducts (callback);
                        var cloudCatalogImplFetchProducts = typeof(CloudCatalogImpl).GetMethod("FetchProducts");
                        if (cloudCatalogImplFetchProducts != null)
                        {
                            cloudCatalogImplFetchProducts.Invoke(m_CloudCatalog, new object[] { callback });
                        }
                        else
                        {
                            callback(new HashSet <ProductDefinition> ());
                        }
                    };

                    // Use reflection to set the function on the IPurchasingBinder
                    // Equivalent to: SetCatalogProviderFunction(catalogProviderFunction)
                    setCatalog.Invoke(m_Binder, new object [] { catalogProviderFunction });
                }
            }

            // Moving SetModule from reflection to an interface
            var internalStore = storeInstance.instance as IStoreInternal;

            if (internalStore != null)
            {
                // NB: as currently implemented this is also doing Init work for ManagedStore
                internalStore.SetModule(this);
            }

            var managedStore = storeInstance.instance as IManagedStoreExtensions;

            if (managedStore != null)
            {
                BindExtension <IManagedStoreExtensions>(managedStore);
            }

            // If we are using a JSONStore, bind to it to get transaction history.
            if ((this.util != null) && this.util.IsClassOrSubclass(typeof(JSONStore), storeInstance.instance.GetType()))
            {
                JSONStore jsonStore = (JSONStore)storeInstance.instance;
                BindExtension <ITransactionHistoryExtensions>(jsonStore);
            }
        }