Exemple #1
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;

        // Set play store extensions.
        _playStoreExtensions =
            m_StoreExtensionProvider.GetExtension <Google.Play.Billing.IGooglePlayStoreExtensions>();
        CheckSubscriptionsAvailabilityBasedOnReceipt(controller);
        // Pass an obfuscated account id.
        _playStoreExtensions.SetObfuscatedAccountId(TrivialKartClientUtil.GetObfuscatedAccountId());
        // Set the deferred purchases callback.
        _playStoreExtensions.SetDeferredPurchaseListener(
            delegate(Product product)
        {
            ProcessDeferredPurchase(product.definition.id);
            // Do not grant the item here. Instead, record the purchase and remind
            // the user to complete the transaction in the Play Store.
        });
    }
        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;
        }