Ejemplo n.º 1
0
        //Проверка покупки подписки.
        //Subscription purchase verification.
        public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
        {
            m_GooglePlayStoreExtensions = extensions.GetExtension <IGooglePlayStoreExtensions>();
            m_StoreController           = controller;
            m_StoreExtensionProvider    = extensions;
            Dictionary <string, string> Dict = m_GooglePlayStoreExtensions.GetProductJSONDictionary();

            foreach (Product item in controller.products.all)
            {
                if (item.receipt != null)
                {
                    if (item.definition.type == ProductType.Subscription)
                    {
                        string json = (Dict == null || !Dict.ContainsKey(item.definition.storeSpecificId))
                            ? null
                            : Dict[item.definition.storeSpecificId];
                        SubscriptionManager s    = new SubscriptionManager(item, json);
                        SubscriptionInfo    info = s.getSubscriptionInfo();
                        if (info.getProductId() == "pay_noads")
                        {
                            if (info.isSubscribed() == Result.True)
                            {
                                PlayerPrefsSafe.SetInt("ADS", 1);
                            }
                            else
                            {
                                PlayerPrefsSafe.SetInt("ADS", 0);
                            }
                        }
                    }
                }
            }
        }
Ejemplo n.º 2
0
        public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
        {
            Debug.Log("In-App Purchasing successfully initialized");

            m_StoreController           = controller;
            m_GooglePlayStoreExtensions = extensions.GetExtension <IGooglePlayStoreExtensions>();

            UpdateUI();
        }
Ejemplo n.º 3
0
        public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
        {
            // Purchasing has succeeded initializing. Collect our Purchasing references.
            Debug.Log("OnInitialized: PASS");

            // Overall Purchasing system, configured with products for this application.
            m_StoreController = controller;
            // Store specific subsystem, for accessing device-specific store features.
            m_StoreExtensionProvider = extensions;
            m_AppleExtensions        = extensions.GetExtension <IAppleExtensions>();
            // On Apple platforms we need to handle deferred purchases caused by Apple's Ask to Buy feature.
            // On non-Apple platforms this will have no effect; OnDeferred will never be called.
            m_AppleExtensions.RegisterPurchaseDeferredListener(OnDeferred);
            m_GooglePlayStoreExtensions = extensions.GetExtension <IGooglePlayStoreExtensions>();
        }
Ejemplo n.º 4
0
        public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
        {
            Debug.Log("OnInitialized: PASS");

            m_StoreController        = controller;
            m_StoreExtensionProvider = extensions;
            m_AppleExtensions        = extensions.GetExtension <IAppleExtensions>();
            m_GoogleExtensions       = extensions.GetExtension <IGooglePlayStoreExtensions>();

            m_GoogleExtensions?.SetDeferredPurchaseListener(OnPurchaseDeferred);

            Dictionary <string, string> dict = m_AppleExtensions.GetIntroductoryPriceDictionary();

            foreach (Product item in controller.products.all)
            {
                if (item.receipt != null)
                {
                    string intro_json = (dict == null || !dict.ContainsKey(item.definition.storeSpecificId)) ? null : dict[item.definition.storeSpecificId];

                    if (item.definition.type == ProductType.Subscription)
                    {
                        SubscriptionManager p    = new SubscriptionManager(item, intro_json);
                        SubscriptionInfo    info = p.getSubscriptionInfo();
                        //check subscription at startup
                        if (info.isSubscribed() == Result.True || info.isFreeTrial() == Result.True)
                        {
                            //code
                        }
                        else
                        {
                            //code
                        }
                    }
                }
            }
        }
Ejemplo n.º 5
0
    /// <summary>
    /// This will be called when Unity IAP has finished initialising.
    /// </summary>
    public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
    {
        m_Controller                   = controller;
        m_AppleExtensions              = extensions.GetExtension <IAppleExtensions>();
        m_SamsungExtensions            = extensions.GetExtension <ISamsungAppsExtensions>();
        m_MicrosoftExtensions          = extensions.GetExtension <IMicrosoftExtensions>();
        m_TransactionHistoryExtensions = extensions.GetExtension <ITransactionHistoryExtensions>();
        m_GooglePlayStoreExtensions    = extensions.GetExtension <IGooglePlayStoreExtensions>();
        // Sample code for expose product sku details for google play store
        // Key is product Id (Sku), value is the skuDetails json string
        //Dictionary<string, string> google_play_store_product_SKUDetails_json = m_GooglePlayStoreExtensions.GetProductJSONDictionary();
        // Sample code for manually finish a transaction (consume a product on GooglePlay store)
        //m_GooglePlayStoreExtensions.FinishAdditionalTransaction(productId, transactionId);
        m_GooglePlayStoreExtensions.SetLogLevel(0); // 0 == debug, info, warning, error. 1 == warning, error only.

        InitUI(controller.products.all);

        // On Apple platforms we need to handle deferred purchases caused by Apple's Ask to Buy feature.
        // On non-Apple platforms this will have no effect; OnDeferred will never be called.
        m_AppleExtensions.RegisterPurchaseDeferredListener(OnDeferred);

#if SUBSCRIPTION_MANAGER
        Dictionary <string, string> introductory_info_dict = m_AppleExtensions.GetIntroductoryPriceDictionary();
#endif
        // Sample code for expose product sku details for apple store
        //Dictionary<string, string> product_details = m_AppleExtensions.GetProductDetails();


        Debug.Log("Available items:");
        foreach (Product item in controller.products.all)
        {
            if (item.availableToPurchase)
            {
                Debug.Log(string.Join(" - ", item.metadata.localizedTitle, item.metadata.localizedDescription,
                                      item.metadata.isoCurrencyCode, item.metadata.localizedPrice.ToString(),
                                      item.metadata.localizedPriceString, item.transactionID, item.receipt));
#if INTERCEPT_PROMOTIONAL_PURCHASES
                // Set all these products to be visible in the user's App Store according to Apple's Promotional IAP feature
                // https://developer.apple.com/library/content/documentation/NetworkingInternet/Conceptual/StoreKitGuide/PromotingIn-AppPurchases/PromotingIn-AppPurchases.html
                m_AppleExtensions.SetStorePromotionVisibility(item, AppleStorePromotionVisibility.Show);
#endif

#if SUBSCRIPTION_MANAGER
                // this is the usage of SubscriptionManager class
                if (item.receipt != null)
                {
                    if (item.definition.type == ProductType.Subscription)
                    {
                        if (checkIfProductIsAvailableForSubscriptionManager(item.receipt))
                        {
                            string intro_json =
                                (introductory_info_dict == null || !introductory_info_dict.ContainsKey(item.definition.storeSpecificId)) ? null : introductory_info_dict[item.definition.storeSpecificId];
                            SubscriptionManager p    = new SubscriptionManager(item, intro_json);
                            SubscriptionInfo    info = p.getSubscriptionInfo();
                            Debug.Log("product id is: " + info.getProductId());
                            Debug.Log("purchase date is: " + info.getPurchaseDate());
                            Debug.Log("subscription next billing date is: " + info.getExpireDate());
                            Debug.Log("is subscribed? " + info.isSubscribed().ToString());
                            Debug.Log("is expired? " + info.isExpired().ToString());
                            Debug.Log("is cancelled? " + info.isCancelled());
                            Debug.Log("product is in free trial peroid? " + info.isFreeTrial());
                            Debug.Log("product is auto renewing? " + info.isAutoRenewing());
                            Debug.Log("subscription remaining valid time until next billing date is: " + info.getRemainingTime());
                            Debug.Log("is this product in introductory price period? " + info.isIntroductoryPricePeriod());
                            Debug.Log("the product introductory localized price is: " + info.getIntroductoryPrice());
                            Debug.Log("the product introductory price period is: " + info.getIntroductoryPricePeriod());
                            Debug.Log("the number of product introductory price period cycles is: " + info.getIntroductoryPricePeriodCycles());
                        }
                        else
                        {
                            Debug.Log("This product is not available for SubscriptionManager class, only products that are purchase by 1.19+ SDK can use this class.");
                        }
                    }
                    else
                    {
                        Debug.Log("the product is not a subscription product");
                    }
                }
                else
                {
                    Debug.Log("the product should have a valid receipt");
                }
#endif
            }
        }

        // Populate the product menu now that we have Products
        AddProductUIs(m_Controller.products.all);

        LogProductDefinitions();
    }
Ejemplo n.º 6
0
        //
        // --- IStoreListener
        //

        public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
        {
            // Purchasing has succeeded initializing. Collect our Purchasing references.
            Debug.Log("market OnInitialized: PASS");

            // Overall Purchasing system, configured with products for this application.
            m_StoreController = controller;
            // Store specific subsystem, for accessing device-specific store features.
            m_StoreExtensionProvider = extensions;

            m_GooglePlayStoreExtensions = extensions.GetExtension <IGooglePlayStoreExtensions>();
            m_AppleExtensions           = extensions.GetExtension <IAppleExtensions>();

            int vip = 0;

            Dictionary <string, string> introductory_info_dict = m_AppleExtensions.GetIntroductoryPriceDictionary();

            //controller.products.all.First().metadata.localizedPrice
            foreach (var item in controller.products.all)
            {
                //Debug.Log(product.metadata.localizedPrice);
                //Debug.Log(product.metadata.isoCurrencyCode);
                //Debug.Log(product.metadata.localizedDescription);
                //Debug.Log(product.metadata.localizedPriceString);
                //Debug.Log(product.metadata.localizedTitle);

                // Fetch the currency Product reference from Unity Purchasing
                //Debug.Log(product.definition.id);
//#if UNITY_ANDROID
                if (item.definition.id.Length > 28)
                {
                    if (staticClass.prices.ContainsKey(item.definition.id.Substring(27)))
                    {
                        staticClass.prices[item.definition.id.Substring(27)] = item.metadata.localizedPriceString;
                    }
                }
                //#elif UNITY_IOS
                //                if (product.definition.id.Length > 23)
                //                {
                //                    if (staticClass.prices.ContainsKey(product.definition.id.Substring(22))) staticClass.prices[product.definition.id.Substring(22)] = product.metadata.localizedPriceString;
                //                }
                //#endif                         if (item.availableToPurchase)
                {
                    Debug.Log(string.Join(" - ",
                                          new[]
                    {
                        item.metadata.localizedTitle,
                        item.metadata.localizedDescription,
                        item.metadata.isoCurrencyCode,
                        item.metadata.localizedPrice.ToString(),
                        item.metadata.localizedPriceString,
                        item.transactionID,
                        item.receipt
                    }));

                    // this is the usage of SubscriptionManager class
                    if (item.receipt != null)
                    {
                        if (item.definition.type == ProductType.Subscription)
                        {
                            if (checkIfProductIsAvailableForSubscriptionManager(item.receipt))
                            {
                                string intro_json        = (introductory_info_dict == null || !introductory_info_dict.ContainsKey(item.definition.storeSpecificId)) ? null : introductory_info_dict[item.definition.storeSpecificId];
                                SubscriptionManager p    = new SubscriptionManager(item, intro_json);
                                SubscriptionInfo    info = p.getSubscriptionInfo();
                                Debug.Log("product id is: " + info.getProductId());
                                Debug.Log("purchase date is: " + info.getPurchaseDate());
                                Debug.Log("subscription next billing date is: " + info.getExpireDate());
                                Debug.Log("is subscribed? " + info.isSubscribed().ToString());

                                if (info.isSubscribed().ToString() == "True")
                                {
                                    vip = 1;
                                }

                                Debug.Log("is expired? " + info.isExpired().ToString());
                                Debug.Log("is cancelled? " + info.isCancelled());
                                Debug.Log("product is in free trial peroid? " + info.isFreeTrial());
                                Debug.Log("product is auto renewing? " + info.isAutoRenewing());
                                Debug.Log("subscription remaining valid time until next billing date is: " + info.getRemainingTime());
                                Debug.Log("is this product in introductory price period? " + info.isIntroductoryPricePeriod());
                                Debug.Log("the product introductory localized price is: " + info.getIntroductoryPrice());
                                Debug.Log("the product introductory price period is: " + info.getIntroductoryPricePeriod());
                                Debug.Log("the number of product introductory price period cycles is: " + info.getIntroductoryPricePeriodCycles());
                            }
                            else
                            {
                                Debug.Log("This product is not available for SubscriptionManager class, only products that are purchase by 1.19+ SDK can use this class.");
                            }
                        }
                        else
                        {
                            Debug.Log("the product is not a subscription product");
                        }
                    }
                    else
                    {
                        Debug.Log("the product should have a valid receipt");
                    }
                }
            }



            //extensions.GetExtension<googl>()
            if (vip == 0)
            {
                ctrProgressClass.progress["vip"] = 0;
                ctrProgressClass.saveProgress();
            }
        }
Ejemplo n.º 7
0
 public virtual void OnStoreListenerInitialized(IStoreController controller, IExtensionProvider storeExtensionProvider)
 {
     googleExtensions = storeExtensionProvider.GetExtension <IGooglePlayStoreExtensions>();
 }
Ejemplo n.º 8
0
    /// <summary>
    /// This will be called when Unity IAP has finished initialising.
    /// </summary>
    public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
    {
        // Purchasing has succeeded initializing. Collect our Purchasing references.
        Debug.Log("OnInitialized: PASS");

        // Overall Purchasing system, configured with products for this application.
        m_StoreController = controller;
        // Store specific subsystem, for accessing device-specific store features.
        m_StoreExtensionProvider = extensions;


        m_GooglePlayStoreExtensions = extensions.GetExtension <IGooglePlayStoreExtensions>();
        m_AppleExtensions           = extensions.GetExtension <IAppleExtensions>();



        Dictionary <string, string> introductory_info_dict = m_AppleExtensions.GetIntroductoryPriceDictionary();

        // This extension function returns a dictionary of the products' skuDetails from GooglePlay Store
        // Key is product Id (Sku), value is the skuDetails json string
        //Dictionary<string, string> google_play_store_product_SKUDetails_json = m_GooglePlayStoreExtensions.GetProductJSONDictionary();
        int vip = 0;

        Debug.Log("Available items:");
        foreach (var item in controller.products.all)
        {
            if (item.availableToPurchase)
            {
                Debug.Log(string.Join(" - ",
                                      new[]
                {
                    item.metadata.localizedTitle,
                    item.metadata.localizedDescription,
                    item.metadata.isoCurrencyCode,
                    item.metadata.localizedPrice.ToString(),
                    item.metadata.localizedPriceString,
                    item.transactionID,
                    item.receipt
                }));

// this is the usage of SubscriptionManager class
                if (item.receipt != null)
                {
                    if (item.definition.type == ProductType.Subscription)
                    {
                        if (checkIfProductIsAvailableForSubscriptionManager(item.receipt))
                        {
                            string intro_json        = (introductory_info_dict == null || !introductory_info_dict.ContainsKey(item.definition.storeSpecificId)) ? null : introductory_info_dict[item.definition.storeSpecificId];
                            SubscriptionManager p    = new SubscriptionManager(item, intro_json);
                            SubscriptionInfo    info = p.getSubscriptionInfo();
                            Debug.Log("product id is: " + info.getProductId());
                            Debug.Log("purchase date is: " + info.getPurchaseDate());
                            Debug.Log("subscription next billing date is: " + info.getExpireDate());
                            Debug.Log("is subscribed? " + info.isSubscribed().ToString());
                            if (info.isSubscribed().ToString() == "True")
                            {
                                vip = 1;
                            }
                            Debug.Log("is expired? " + info.isExpired().ToString());
                            Debug.Log("is cancelled? " + info.isCancelled());
                            Debug.Log("product is in free trial peroid? " + info.isFreeTrial());
                            Debug.Log("product is auto renewing? " + info.isAutoRenewing());
                            Debug.Log("subscription remaining valid time until next billing date is: " + info.getRemainingTime());
                            Debug.Log("is this product in introductory price period? " + info.isIntroductoryPricePeriod());
                            Debug.Log("the product introductory localized price is: " + info.getIntroductoryPrice());
                            Debug.Log("the product introductory price period is: " + info.getIntroductoryPricePeriod());
                            Debug.Log("the number of product introductory price period cycles is: " + info.getIntroductoryPricePeriodCycles());
                        }
                        else
                        {
                            Debug.Log("This product is not available for SubscriptionManager class, only products that are purchase by 1.19+ SDK can use this class.");
                        }
                    }
                    else
                    {
                        Debug.Log("the product is not a subscription product");
                    }
                }
                else
                {
                    Debug.Log("the product should have a valid receipt");
                }
            }
        }
        //point - comment for test Editor
        if (vip == 0)
        {
            IAPManager.setVip(vip);
        }
    }
Ejemplo n.º 9
0
        //
        // --- IStoreListener
        //


        public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
        {
            // Purchasing has succeeded initializing. Collect our Purchasing references.
            Debug.Log("[IAPManager] OnInitialized.");

            // Overall Purchasing system, configured with products for this application.
            _StoreController = controller;
            // Store specific subsystem, for accessing device-specific store features.
            _StoreExtensionProvider = extensions;

            _AppleExtensions   = extensions.GetExtension <IAppleExtensions>();
            _SamsungExtensions = extensions.GetExtension <ISamsungAppsExtensions>();
            _MoolahExtensions  = extensions.GetExtension <IMoolahExtension>();

            // On Apple platforms we need to handle deferred purchases caused by Apple's Ask to Buy feature.
            // On non-Apple platforms this will have no effect; OnDeferred will never be called.
#if UNITY_IOS
            _AppleExtensions.RegisterPurchaseDeferredListener(OnDeferred);
#endif
#if UNITY_ANDROID
            _GooglePlayStoreExtensions = extensions.GetExtension <IGooglePlayStoreExtensions>();
#endif

#if RECEIPT_VALIDATION
    #if UNITY_EDITOR
    #else
        #if UNITY_IOS
            Dictionary <string, string> introductory_info_dict = _AppleExtensions.GetIntroductoryPriceDictionary();
        #endif
        #if UNITY_ANDROID
            Dictionary <string, string> introductory_info_dict = _GooglePlayStoreExtensions.GetProductJSONDictionary();
        #endif
    #endif
#endif
            // Store products
            for (int i = 0; i < controller.products.all.Length; i++)
            {
                Product    pp = controller.products.all[i];
                IAPProduct p  = null;
                if (products.ContainsKey(pp.definition.id))
                {
                    p                     = products[pp.definition.id];
                    p.priceString         = pp.metadata.localizedPriceString;
                    p.price               = pp.metadata.localizedPrice;
                    p.title               = pp.metadata.localizedTitle;
                    p.description         = pp.metadata.localizedDescription;
                    p.isoCurrencyCode     = pp.metadata.isoCurrencyCode;
                    p.hasReceipt          = pp.hasReceipt;
                    p.availableToPurchase = pp.availableToPurchase;
                    p.receipt             = pp.receipt;
                    p.transactionID       = pp.transactionID;
                    p.rawProduct          = pp;
                    p.hasReceipt          = pp.hasReceipt;

#if RECEIPT_VALIDATION
#if UNITY_EDITOR
#else
                    _UpdateReceipt(pp, ref p, introductory_info_dict);
#endif
#endif
                }
            }
            // callback
            if (OnIAPInitialized != null)
            {
                OnIAPInitialized(products);
            }
        }