public void InitializeStore() { Debug.Log("Initializing Store"); var catalogJson = LocalDataManager.Instance.GetConfigJson(typeof(ProductCatalog).Name); _productCatalog = ProductCatalog.Deserialize(catalogJson); if (IsInitialized()) { OnInitSuccess.SafeInvoke(); return; } if (_isInitializing) { return; } _isInitializing = true; var module = StandardPurchasingModule.Instance(); var builder = ConfigurationBuilder.Instance(module); /* var settings = new JsonSerializerSettings * { * NullValueHandling = NullValueHandling.Ignore, * MissingMemberHandling = MissingMemberHandling.Ignore * }; * * _productCatalog = JsonConvert.DeserializeObject<ProductCatalog>(catalogJson, settings);*/ #if UNITY_IOS appleConfig = builder.Configure <IAppleConfiguration> (); #endif foreach (var product in _productCatalog.allProducts) { Debug.Log("Product: " + product.id + ", type: " + product.type); if (product.allStoreIDs.Count > 0) { var ids = new IDs(); foreach (var storeId in product.allStoreIDs) { ids.Add(storeId.id, storeId.store); } builder.AddProduct(product.id, product.type, ids); } else { builder.AddProduct(product.id, product.type); } } UnityPurchasing.Initialize(this, builder); }
//----- property ----- //----- method ----- public void Initialize() { var purchasingModule = StandardPurchasingModule.Instance(); var configurationBuilder = ConfigurationBuilder.Instance(purchasingModule); if (configurationBuilder != null) { appleConfiguration = configurationBuilder.Configure <IAppleConfiguration>(); } }
/// <summary> /// Initialize Hermes IAP. /// </summary> /// <param name="iapBuilder">Builder data used to create instance.</param> /// <param name="onDone">Callback when initialization is done.</param> public void Init(IAPBuilder iapBuilder, Action <InitStatus> onDone) { if (IsInit) { onDone(initStatus); return; } if (onInitDone != null) { Debug.LogWarning("Hermes is already in the process of initializing."); onDone(InitStatus.Initializing); return; } appleTangleData = iapBuilder.AppleTangleData ?? null; var module = iapBuilder.PurchasingModule ?? StandardPurchasingModule.Instance(); var builder = ConfigurationBuilder.Instance(module); appleConfig = builder.Configure <IAppleConfiguration>(); // Verify if purchases are possible on this iOS device. if (!appleConfig.canMakePayments) { initStatus = InitStatus.PurchasingDisabled; onDone(InitStatus.PurchasingDisabled); return; } // Add Products to store. foreach (var key in iapBuilder.Products.Keys) { builder.AddProduct(key, iapBuilder.Products[key]); } deferPurchaseCompatible = iapBuilder.DeferredPurchaseCompatible; promotionalPurchaseCompatible = iapBuilder.PromotionalPurchaseCompatible; if (promotionalPurchaseCompatible) { appleConfig.SetApplePromotionalPurchaseInterceptorCallback(OnPromotionalPurchase); onPromotionalPurchase = iapBuilder.OnPromotionalPurchase; } onInitDone = onDone; UnityPurchasing.Initialize(this, builder); }