Exemplo n.º 1
0
            public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args)
            {
                IAP.LogMessage("IAPManager.ProcessPurchase");

                DoOnIAPComplete(new IAPSuccess(args.purchasedProduct), null);
                return(PurchaseProcessingResult.Complete);
            }
Exemplo n.º 2
0
            public void OnInitializeFailed(InitializationFailureReason error)
            {
                IAP.LogMessage("IAPManager.OnInitializeFailed - Reason: " + error);

                IAPFail.Reason reason = GetInitFailReason(error);
                DoOnInitComplete(false, new IAPFail(reason));
            }
Exemplo n.º 3
0
            public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
            {
                IAP.LogMessage("IAPManager.OnInitialized");

                storeController        = controller;
                storeExtensionProvider = extensions;
                DoOnInitComplete(true, null);
            }
Exemplo n.º 4
0
            public void OnPurchaseFailed(Product product, PurchaseFailureReason failureReason)
            {
                IAP.LogMessage(string.Format(
                                   "IAPManager.OnPurchaseFailed - Unity Product id: {0}, Store-Specific id: {1}, Failure reason: {2}",
                                   product.definition.id,
                                   product.definition.storeSpecificId,
                                   failureReason
                                   ));

                DoOnIAPComplete(null, new IAPFail(failureReason));
            }
Exemplo n.º 5
0
            /// <summary>
            /// Starts the the restoration process.
            /// </summary>
            public void Start()
            {
                var apple = storeExtensionProvider.GetExtension <IAppleExtensions>();

                timer.Start();
                apple.RestoreTransactions((bool result) => {
                    IAP.LogMessage("IAPManager.Restorer.RestorePurchases - Item result: " + result);

                    if (timer.IsValid)
                    {
                        timer.Stop();
                        timer.Start();
                    }
                });
            }
Exemplo n.º 6
0
        /// <summary>
        /// Restores non-consumable / subscription purchases.
        /// </summary>
        public static void RestorePurchases(IAP.OnRestoredHandler callback)
        {
            onRestoreComplete = callback;

            if (!IsInitialized)
            {
                DoOnRestoreComplete(false, new IAPFail(IAPFail.Reason.NotInitialized));
                return;
            }
            if (!IAP.IsRestoreSupported)
            {
                DoOnRestoreComplete(false, new IAPFail(IAPFail.Reason.PlatformNotSupported));
                return;
            }

            ProductRestorer = new Restorer(() => {
                IAP.LogMessage("IAPManager.OnTimerFinished - Restore completed.");
                DoOnRestoreComplete(true, null);
            });
            ProductRestorer.Start();
        }
Exemplo n.º 7
0
        /// <summary>
        /// Use this method for initialization.
        /// For the products, use IAPProduct.Initialize method to create a new product.
        /// </summary>
        public static void Initialize(IAP.OnInitializedHandler callback, bool isTestMode, List <IAPProduct> products)
        {
            onInitComplete = callback;
            IAP.IsTestMode = isTestMode;

            SetupInstance();

            if (products == null || products.Count == 0)
            {
                IAP.LogMessage("IAPManager.Initialize - Product list can't be null or empty!");
                return;
            }

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

            for (int i = 0; i < products.Count; i++)
            {
                builder.AddProduct(products[i]);
            }

            UnityPurchasing.Initialize(new Listener(), builder);
        }