示例#1
0
        public void _CreatingProductsFromCatalogShouldWork()
        {
            var products   = ApprienProduct.FromIAPCatalog(_catalog);
            var productIds = products.Select(item => item.BaseIAPId).ToList();

            Assert.AreEqual(6, products.Length);
            Assert.Contains(_defaultIAPid, productIds);
            foreach (var id in _testIAPids)
            {
                Assert.Contains(id, productIds);
            }
        }
示例#2
0
        private void InitializeProducts()
        {
            // Create ApprienProducts from the IAP or subscription Catalog
            var catalogFile = Resources.Load <TextAsset>(_currentTab == TabType.IAPs ? "ApprienIAPProductCatalog" : "ApprienSubscriptionProductCatalog");
            var catalog     = ProductCatalog.FromTextAsset(catalogFile);

            _apprienProducts = ApprienProduct.FromIAPCatalog(catalog);

            // Initialize Unity IAP configuration builder
            _builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());

            // Platform specific integration type for the manager.
            ApprienIntegrationType integrationType;

#if UNITY_IOS
            integrationType = ApprienIntegrationType.AppleAppStore;
#else
            integrationType = ApprienIntegrationType.GooglePlayStore;
#endif

            // Package name. Usually Application.identifier
            var packageName = Application.identifier;

            _apprienManager = new ApprienManager(
                Application.identifier,
                integrationType,
                ApprienConnection.Token
                );

            // Add standard IAP ids, so that there is always a fallback if Apprien variants cannot be fetched
            foreach (var product in _apprienProducts)
            {
                _builder.AddProduct(product.BaseIAPId, product.ProductType);
            }

            FetchPrices();
        }