Ejemplo n.º 1
0
 internal StoreService(string name, IPurchasingModule purchasingModule, IStoreDelegate storeDelegate)
 {
     _serviceName      = string.IsNullOrEmpty(name) ? "Purchasing" : "Purchasing." + name;
     _console          = new TraceSource(_serviceName, SourceLevels.All);
     _delegate         = storeDelegate;
     _purchasingModule = purchasingModule;
 }
Ejemplo n.º 2
0
        /// <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.");
                return;
            }

            googleTangleData = iapBuilder.GoogleTangleData ?? null;
            IPurchasingModule    module  = Google.Play.Billing.GooglePlayStoreModule.Instance();
            ConfigurationBuilder builder = ConfigurationBuilder.Instance(module);

            // Add Products to store.
            foreach (var key in iapBuilder.Products.Keys)
            {
                builder.AddProduct(key, iapBuilder.Products[key]);
            }

            deferPurchaseCompatible = iapBuilder.DeferredPurchaseCompatible;

            onInitDone = onDone;
            UnityPurchasing.Initialize(this, builder);
        }
Ejemplo n.º 3
0
        void IStoreListener.OnInitialized(IStoreController controller, IExtensionProvider extensions)
        {
            DebugLog("IAP Manager successfully initialized");

            storeController = controller;
            googlePlay      = extensions.GetExtension <Google.Play.Billing.IGooglePlayStoreExtensions>();

            if (deferPurchaseCompatible)
            {
                // enable deferred purchases
                IPurchasingModule googlePlayModule = Google.Play.Billing.GooglePlayStoreModule.Instance();
                var configurationBuilder           = ConfigurationBuilder.Instance(googlePlayModule);
                configurationBuilder.Configure <Google.Play.Billing.IGooglePlayConfiguration>().EnableDeferredPurchase();

                // Notify callback for when purchases are deferred to a parent.
                googlePlay.SetDeferredPurchaseListener(product => {
                    DebugLog("Purchase request deferred to parent.");
                    OnPurchaseDeferred?.Invoke(product);
                });
            }

            initStatus = InitStatus.Ok;

            onInitDone?.Invoke(initStatus);
            onInitDone = null;
        }
Ejemplo n.º 4
0
 public PurchasingFactory(IPurchasingModule first, params IPurchasingModule[] remainingModules)
 {
     first.Configure(this);
     foreach (var module in remainingModules)
     {
         module.Configure(this);
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Creates a new <see cref="IStoreService"/> instance.
        /// </summary>
        /// <exception cref="ArgumentNullException">Thrown if <paramref name="purchasingModule"/> or <paramref name="storeDelegate"/> is <c>null</c>.</exception>
        /// <exception cref="InvalidOperationException">Thrown if an instance of <see cref="IStoreService"/> already exists.</exception>
        public static IStoreService CreateStore(IPurchasingModule purchasingModule, IStoreDelegate storeDelegate)
        {
            if (purchasingModule == null)
            {
                throw new ArgumentNullException(nameof(purchasingModule));
            }

            if (storeDelegate == null)
            {
                throw new ArgumentNullException(nameof(storeDelegate));
            }

            return(new StoreService(string.Empty, purchasingModule, storeDelegate));
        }
        public static ConfigurationBuilder Instance(IPurchasingModule first, params IPurchasingModule[] rest)
        {
            PurchasingFactory factory = new PurchasingFactory(first, rest);

            return(new ConfigurationBuilder(factory));
        }
Ejemplo n.º 7
0
 /// <summary>
 /// Add Purchasing module.
 /// </summary>
 public static IAPBuilder WithPurchasingModule(this IAPBuilder builder, IPurchasingModule module)
 {
     builder.PurchasingModule = module;
     return(builder);
 }