public ExtensionProviderExtensionsTest()
        {
            this.provider = A.Fake<IExtensionProvider<IExtension>>();
            this.extension = A.Fake<IExtension>();

            this.exception = new Exception();
        }
        public GlimpseServerMiddleware(RequestDelegate next, IApplicationBuilder app, IExtensionProvider<IAllowClientAccess> authorizeClientProvider, IExtensionProvider<IAllowAgentAccess> authorizeAgentProvider, IExtensionProvider<IResourceStartup> resourceStartupsProvider, IExtensionProvider<IResource> resourceProvider, IResourceManager resourceManager, IOptions<GlimpseServerOptions> serverOptions)
        {
            _authorizeClients = authorizeClientProvider.Instances;
            _authorizeAgents = authorizeAgentProvider.Instances;
            _serverOptions = serverOptions.Value;

            _next = next;
            _branch = BuildBranch(app, resourceStartupsProvider.Instances, resourceProvider.Instances, resourceManager);
        }
		public MockServiceProviderService(IExtensionProvider extensionProvider, Type serializableObjectType)
		{
			list.Add(extensionProvider);
			if (serializableObjectType != null)
			{
				typeList = new List<Type>();
				typeList.Add(serializableObjectType);
			}
		}
Esempio n. 4
0
        //
        // --- IStoreListener
        //
        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;
        }
Esempio 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_MoolahExtensions = extensions.GetExtension<IMoolahExtension> ();

		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);

		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
					}));
			}
		}

		// Prepare model for purchasing
		if (m_Controller.products.all.Length > 0) 
		{
			m_SelectedItemIndex = 0;
		}

		// Populate the product menu now that we have Products
		for (int t = 0; t < m_Controller.products.all.Length; t++)
		{
			var item = m_Controller.products.all[t];
			var description = string.Format("{0} - {1}", item.metadata.localizedTitle, item.metadata.localizedPriceString);

			// NOTE: my options list is created in InitUI
			GetDropdown().options[t] = new Dropdown.OptionData(description);
		}

		// Ensure I render the selected list element
		GetDropdown().RefreshShownValue();

		// Now that I have real products, begin showing product purchase history
		UpdateHistoryUI();
	}
Esempio n. 6
0
        public VsixExtension(IExtensionProvider provider, NuSpec nuSpec, FileSystemPath location, 
      ExtensionLocations extensionLocations)
        {
            var source = GetType().Name;

              this.nuSpec = nuSpec;
              this.location = location;
              this.extensionLocations = extensionLocations;

              Version = new Version(nuSpec.Version);
              Metadata = new VsixExtensionMetadata(nuSpec);
              Supported = true; // TODO
              Enabled = new Property<bool?>(string.Format("{0}::Enabled", source), null);
              RuntimeInfoRecords = new ListEvents<ExtensionRecord>(string.Format("{0}::RuntimeInfoRecords", source));
              Source = provider;
        }
    private Selectable m_InteractableSelectable; // Optimization used for UI state management

    /// <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> ();

		InitUI(controller.products.all);

        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
                    }));
            }
        }

        // Prepare model for purchasing
        if (m_Controller.products.all.Length > 0) 
        {
            m_SelectedItemIndex = 0;
        }

        // Populate the product menu now that we have Products
        for (int t = 0; t < m_Controller.products.all.Length; t++)
        {
            var item = m_Controller.products.all[t];
            var description = string.Format("{0} - {1}", item.metadata.localizedTitle, item.metadata.localizedPriceString);

            // NOTE: my options list is created in InitUI
            GetDropdown().options[t] = new Dropdown.OptionData(description);
        }

        // Ensure I render the selected list element
        GetDropdown().RefreshShownValue();

        // Now that I have real products, begin showing product purchase history
        UpdateHistoryUI();
    }
Esempio n. 8
0
 public StoreListenerProxy(IStoreListener forwardTo, AnalyticsReporter analytics, IExtensionProvider extensions)
 {
     this.m_ForwardTo  = forwardTo;
     this.m_Analytics  = analytics;
     this.m_Extensions = extensions;
 }
Esempio n. 9
0
    public void OnInitializeFailed(InitializationFailureReason error)
    {
   
        m_StoreController = null;
        // Store specific subsystem, for accessing device-specific store features.
        m_StoreExtensionProvider = null;

        init = false;
    }
Esempio n. 10
0
 /// <summary>
 /// Surrounds the specified action expression with extension methods following a certain convention.
 /// </summary>
 /// <typeparam name="TExtension">The type of the extension.</typeparam>
 /// <param name="provider">The provider.</param>
 /// <param name="action">The action expression.</param>
 /// <param name="args">The arguments.</param>
 public static void SurroundWithExtension <TExtension>(this IExtensionProvider <TExtension> provider, Expression <Action> action, params object[] args)
     where TExtension : class
 {
     SurroundWithExtensionInternal <TExtension, Missing>(provider, action, args);
 }
Esempio n. 11
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();
    }
        private static void ProvideObjectExtender(ModelElement mel, IExtensibleObject extensibleObject, IExtensionProvider extensionProvider)
        {
            ExtensionProviderHelper extensionProviderHelper = new ExtensionProviderHelper(extensibleObject);

            if (extensibleObject.ObjectExtenderContainer == null)
            {
                extensionProviderHelper.CreateObjectExtenderContainer();
                object extender = extensionProviderHelper.CreateObjectExtender(extensionProvider, mel);
                extensionProviderHelper.SetObjectExtender(extender);
            }
            else
            {
                if (extensionProviderHelper.GetObjectExtender(extensionProvider) == null)
                {
                    object extender = extensionProviderHelper.CreateObjectExtender(extensionProvider, mel);
                    extensionProviderHelper.SetObjectExtender(extender);
                }
                else
                {
                    //Redirect object extender
                    extensionProviderHelper.SetObjectExtender(extensionProviderHelper.GetObjectExtender(extensionProvider));
                }
            }
        }
Esempio n. 13
0
    /* ===================================================
     *
     * IStoreListener
     *
     * =================================================== */

    public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
    {
        Debug.Log("IAP::OnInitialized Succeed!");
        _storeController   = controller;
        _extensionProvider = extensions;
    }
Esempio n. 14
0
    public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
    {
        m_StoreController = controller;

        m_StoreExtensionProvider = extensions;
    }
 public StoreListenerProxy(IStoreListener forwardTo, AnalyticsReporter analytics, IExtensionProvider extensions)
 {
     this.m_ForwardTo = forwardTo;
     this.m_Analytics = analytics;
     this.m_Extensions = extensions;
 }
Esempio n. 16
0
 public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
 {
     this.controller = controller;
     this.extensions = extensions;
 }
Esempio n. 17
0
    public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
    {
        m_StoreController = controller;
        // Store specific subsystem, for accessing device-specific store features.
        m_StoreExtensionProvider = extensions;

        init = true;
    }
 public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
 {
     //Debug.Log("IAPMgr initialized");
     mStoreController = controller;
     mStoreExtensionProvider = extensions;
 }
Esempio n. 19
0
 /// <summary>
 /// Raises the initialized event.
 /// 初期化イベント
 /// </summary>
 /// <param name="controller">Controller.</param>
 /// <param name="extentions">Extentions.</param>
 public void OnInitialized(IStoreController controller, IExtensionProvider extentions)
 {
     Debug.Log("IAP ===>>> Initialize Successful ....");
     m_Controller = controller;             //コントローラーは購入時に使うので保持しておく
     m_Extentions = extentions;
 }
Esempio n. 20
0
  //  
  // --- IStoreListener
  //

  public void OnInitialized(IStoreController controller, IExtensionProvider extensions) {
    // Purchasing has succeeded initializing. Collect our Purchasing references.
    Debug.Log("OnInitialized: PASS");
    // Update m_products_map that would be used by UICharacters
    m_products_map = new Dictionary<string, Product>();
    foreach (Product product in controller.products.all) {
      m_products_map.Add(product.definition.id, product);
    }

    // Overall Purchasing system, configured with products for this application.
    m_StoreController = controller;
    // Store specific subsystem, for accessing device-specific store features.
    m_StoreExtensionProvider = extensions;
  }
Esempio n. 21
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();
            }
        }
 public InspectorsInspectorFunction(IExtensionProvider<IInspector> inspectorProvider)
 {
     _inspectors = inspectorProvider.Instances;
 }
Esempio n. 23
0
 public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
 {
     Debug.Log("OnInitialized: " + controller + ", " + extensions);
     this.controller = controller;
 }
Esempio n. 24
0
    public void OnInitialized(IStoreController sc, IExtensionProvider ep)
    {
        Debug.Log("OnInitialized : PASS");

        storeController = sc;
        extensionProvider = ep;
    }
Esempio n. 25
0
 // This is automatically invoked automatically when IAP service is initialized
 public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
 {
     m_StoreController  = controller;
     debugReporter.text = debugReporter.text + "\n" + "OnInitialized()";
     loadingAnimation.SetActive(false);
 }
		/// <summary>
		/// Gets the type of the domain model associated with the IExtensionProvider.
		/// </summary>
		/// <param name="extensionProvider">The extension provider.</param>
		/// <returns></returns>
		public static Type GetDomainModelType(IExtensionProvider extensionProvider)
		{
			Guard.ArgumentNotNull(extensionProvider, "extensionProvider");

			ExtensionProviderAttribute att = ReflectionHelper.GetAttribute<ExtensionProviderAttribute>(extensionProvider.GetType());

			if(att != null)
			{
				return att.ModelToExtend;
			}

			return null;
		}
		private static void ProvideObjectExtender(ModelElement mel, IExtensibleObject extensibleObject, IExtensionProvider extensionProvider)
		{
			ExtensionProviderHelper extensionProviderHelper = new ExtensionProviderHelper(extensibleObject);

			if (extensibleObject.ObjectExtenderContainer == null)
			{
				extensionProviderHelper.CreateObjectExtenderContainer();
				object extender = extensionProviderHelper.CreateObjectExtender(extensionProvider, mel);
				extensionProviderHelper.SetObjectExtender(extender);
			}
			else
			{
				if (extensionProviderHelper.GetObjectExtender(extensionProvider) == null)
				{
					object extender = extensionProviderHelper.CreateObjectExtender(extensionProvider, mel);
					extensionProviderHelper.SetObjectExtender(extender);
				}
				else
				{
					//Redirect object extender
					extensionProviderHelper.SetObjectExtender(extensionProviderHelper.GetObjectExtender(extensionProvider));
				}
			}
		}
Esempio n. 28
0
 public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
 {
     storeController = controller;
     storeExtensions = extensions;
     //Debug.Log("store initialize success");
 }
Esempio n. 29
0
 void IStoreListener.OnInitialized(IStoreController controller, IExtensionProvider extensions)
 {
     storeController = controller;
     Debug.Log("결제기능 초기화");
 }
 public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
 {
     Debug.Log("OnInitialized: PASS");
     m_StoreController = controller;
     m_StoreExtensionProvider = extensions;
 }
Esempio n. 31
0
 public void RegisterExtensionProvider(IExtensionProvider extensionProvider)
 {
     _extensionProviders.Add(extensionProvider);
 }
 public DefaultAgentStartupManager(IExtensionProvider<IAgentStartup> startupProvider)
 {
     Startups = startupProvider.Instances;
 }
Esempio n. 33
0
 /// <summary>
 /// 
 /// </summary>
 /// <param name="db"></param>
 /// <param name="settings"></param>
 public ReportsService(IExtensionProvider extensions, IKcsarContext db, IAppSettings settings)
 {
     this.extensions = extensions;
       this.db = db;
       this.settings = settings;
 }
 public DefaultRequestIgnorerManager(IExtensionProvider<IRequestIgnorer> requestIgnorerProvider, IHttpContextAccessor httpContextAccessor)
 {
     RequestIgnorers = requestIgnorerProvider.Instances;
     HttpContextAccessor = httpContextAccessor;
 }
Esempio n. 35
0
 public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
 {
     _client._controller = controller;
     _client._status     = Status.Initialized;
 }
Esempio n. 36
0
using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.Purchasing;

public class IAPManager : MonoBehaviour, IStoreListener
{

    // Placing the Purchaser class in the CompleteProject namespace allows it to interact with ScoreManager, 
    // one of the existing Survival Shooter scripts.
    // Deriving the Purchaser class from IStoreListener enables it to receive messages from Unity Purchasing.

    private static IStoreController m_StoreController;          // The Unity Purchasing system.
    private static IExtensionProvider m_StoreExtensionProvider; // The store-specific Purchasing subsystems.

    // Product identifiers for all products capable of being purchased: 
    // "convenience" general identifiers for use with Purchasing, and their store-specific identifier 
    // counterparts for use with and outside of Unity Purchasing. Define store-specific identifiers 
    // also on each platform's publisher dashboard (iTunes Connect, Google Play Developer Console, etc.)

    // General product identifiers for the consumable, non-consumable, and subscription products.
    // Use these handles in the code to reference which product to purchase. Also use these values 
    // when defining the Product Identifiers on the store. Except, for illustration purposes, the 
    // kProductIDSubscription - it has custom Apple and Google identifiers. We declare their store-
    // specific mapping to Unity Purchasing's AddProduct, below.
    //public static string kProductIDConsumable =    "consumable";
    public static string kProductIDNonConsumable = "noads";
    //public static string kProductIDSubscription =  "subscription";

    // Apple App Store-specific product identifier for the subscription product.
    //private static string kProductNameAppleSubscription =  "com.unity3d.subscription.new";

    // Google Play Store-specific product identifier subscription product.
    //private static string kProductNameGooglePlaySubscription =  "com.SushrutS.TowerTrouble.noads";

    void Start()
    {
        // If we haven't set up the Unity Purchasing reference
        if (m_StoreController == null)
        {
            // Begin to configure our connection to Purchasing
            InitializePurchasing();
        }
    }

    public void InitializePurchasing()
    {
        // If we have already connected to Purchasing ...
        if (IsInitialized())
        {
            // ... we are done here.
            return;
        }

        // Create a builder, first passing in a suite of Unity provided stores.
        var builder = ConfigurationBuilder.Instance(StandardPurchasingModule.Instance());

        // Add a product to sell / restore by way of its identifier, associating the general identifier
        // with its store-specific identifiers.
        //builder.AddProduct( kProductIDConsumable, ProductType.Consumable );
        // Continue adding the non-consumable product.
        builder.AddProduct( kProductIDNonConsumable, ProductType.NonConsumable );
        // And finish adding the subscription product. Notice this uses store-specific IDs, illustrating
        // if the Product ID was configured differently between Apple and Google stores. Also note that
        // one uses the general kProductIDSubscription handle inside the game - the store-specific IDs 
        // must only be referenced here. 
        //builder.AddProduct( kProductIDSubscription, ProductType.Subscription, new IDs(){
        //        { kProductNameAppleSubscription, AppleAppStore.Name },
        //        { kProductNameGooglePlaySubscription, GooglePlay.Name },
        //    } );

        // Kick off the remainder of the set-up with an asynchrounous call, passing the configuration 
        // and this class' instance. Expect a response either in OnInitialized or OnInitializeFailed.
        UnityPurchasing.Initialize( this, builder );
    }


    private bool IsInitialized()
    {
        // Only say we are initialized if both the Purchasing references are set.
        return m_StoreController != null && m_StoreExtensionProvider != null;
    }


    public void BuyConsumable()
    {
        // Buy the consumable product using its general identifier. Expect a response either 
        // through ProcessPurchase or OnPurchaseFailed asynchronously.
        //BuyProductID( kProductIDConsumable );
    }


    public void BuyNonConsumable()
    {
        // Buy the non-consumable product using its general identifier. Expect a response either 
        // through ProcessPurchase or OnPurchaseFailed asynchronously.
        BuyProductID( kProductIDNonConsumable );
    }


    public void BuySubscription()
    {
        // Buy the subscription product using its the general identifier. Expect a response either 
        // through ProcessPurchase or OnPurchaseFailed asynchronously.
        // Notice how we use the general product identifier in spite of this ID being mapped to
        // custom store-specific identifiers above.
        //BuyProductID( kProductIDSubscription );
    }


    void BuyProductID(string productId)
    {
        // If Purchasing has been initialized ...
        if (IsInitialized())
        {
            // ... look up the Product reference with the general product identifier and the Purchasing 
            // system's products collection.
            Product product = m_StoreController.products.WithID(productId);

            // If the look up found a product for this device's store and that product is ready to be sold ... 
            if (product != null && product.availableToPurchase)
            {
                Debug.Log( string.Format( "Purchasing product asychronously: '{0}'", product.definition.id ) );
                // ... buy the product. Expect a response either through ProcessPurchase or OnPurchaseFailed 
                // asynchronously.
                m_StoreController.InitiatePurchase( product );
            }
            // Otherwise ...
            else
            {
                // ... report the product look-up failure situation  
                Debug.Log( "BuyProductID: FAIL. Not purchasing product, either is not found or is not available for purchase" );
            }
        }
        // Otherwise ...
        else
        {
            // ... report the fact Purchasing has not succeeded initializing yet. Consider waiting longer or 
            // retrying initiailization.
            Debug.Log( "BuyProductID FAIL. Not initialized." );
        }
    }


    // Restore purchases previously made by this customer. Some platforms automatically restore purchases, like Google. 
    // Apple currently requires explicit purchase restoration for IAP, conditionally displaying a password prompt.
    public void RestorePurchases()
    {
        // If Purchasing has not yet been set up ...
        if (!IsInitialized())
        {
            // ... report the situation and stop restoring. Consider either waiting longer, or retrying initialization.
            Debug.Log( "RestorePurchases FAIL. Not initialized." );
            return;
        }

        // If we are running on an Apple device ... 
        if (Application.platform == RuntimePlatform.IPhonePlayer ||
            Application.platform == RuntimePlatform.OSXPlayer)
        {
            // ... begin restoring purchases
            Debug.Log( "RestorePurchases started ..." );

            // Fetch the Apple store-specific subsystem.
            var apple = m_StoreExtensionProvider.GetExtension<IAppleExtensions>();
            // Begin the asynchronous process of restoring purchases. Expect a confirmation response in 
            // the Action<bool> below, and ProcessPurchase if there are previously purchased products to restore.
            apple.RestoreTransactions( (result) =>
            {
                // The first phase of restoration. If no more responses are received on ProcessPurchase then 
                // no purchases are available to be restored.
                Debug.Log( "RestorePurchases continuing: " + result + ". If no further messages, no purchases available to restore." );
            } );
        }
        // Otherwise ...
        else
        {
            // We are not running on an Apple device. No work is necessary to restore purchases.
            Debug.Log( "RestorePurchases FAIL. Not supported on this platform. Current = " + Application.platform );
        }
    }


    //  
    // --- IStoreListener
    //

    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;
    }


    public void OnInitializeFailed(InitializationFailureReason error)
    {
        // Purchasing set-up has not succeeded. Check error for reason. Consider sharing this reason with the user.
        Debug.Log( "OnInitializeFailed InitializationFailureReason:" + error );
    }


    public PurchaseProcessingResult ProcessPurchase(PurchaseEventArgs args)
    {
        // A consumable product has been purchased by this user.
        //if (String.Equals( args.purchasedProduct.definition.id, kProductIDConsumable, StringComparison.Ordinal ))
        //{
        //    Debug.Log( string.Format( "ProcessPurchase: PASS. Product: '{0}'", args.purchasedProduct.definition.id ) );
        //    // The consumable item has been successfully purchased, add 100 coins to the player's in-game score.
        //    //ScoreManager.score += 100;

        //}
        //// Or ... a non-consumable product has been purchased by this user.
        //else
        if (String.Equals( args.purchasedProduct.definition.id, kProductIDNonConsumable, StringComparison.Ordinal ))
        {
            Debug.Log( string.Format( "ProcessPurchase: PASS. Product: '{0}'", args.purchasedProduct.definition.id ) );

            PurchaseComplete();


            // TODO: The non-consumable item has been successfully purchased, grant this item to the player.
        }
        // Or ... a subscription product has been purchased by this user.
        //else if (String.Equals( args.purchasedProduct.definition.id, kProductIDSubscription, StringComparison.Ordinal ))
        //{
        //    Debug.Log( string.Format( "ProcessPurchase: PASS. Product: '{0}'", args.purchasedProduct.definition.id ) );
        //    // TODO: The subscription item has been successfully purchased, grant this to the player.
        //}
        // Or ... an unknown product has been purchased by this user. Fill in additional products here....
        else
        {
            Debug.Log( string.Format( "ProcessPurchase: FAIL. Unrecognized product: '{0}'", args.purchasedProduct.definition.id ) );
            UIScript.instance.SetPurchaseState( "UnKnown Product" );
        }

        // Return a flag indicating whether this product has completely been received, or if the application needs 
        // to be reminded of this purchase at next app launch. Use PurchaseProcessingResult.Pending when still 
        // saving purchased products to the cloud, and when that save is delayed. 
        return PurchaseProcessingResult.Complete;
    }


    public void OnPurchaseFailed(Product product, PurchaseFailureReason failureReason)
    {
        // A product purchase attempt did not succeed. Check failureReason for more detail. Consider sharing 
        // this reason with the user to guide their troubleshooting actions.
        Debug.Log( string.Format( "OnPurchaseFailed: FAIL. Product: '{0}', PurchaseFailureReason: {1}", product.definition.storeSpecificId, failureReason ) );

        UIScript.instance.SetPurchaseState( "PUrchase Failed" + failureReason );

        if(failureReason == PurchaseFailureReason.DuplicateTransaction)
Esempio n. 37
0
 void IStoreListener.OnInitialized(IStoreController controller, IExtensionProvider extensions)
 {
     _list.ForEach(l => l.OnInitialized(controller, extensions));
 }
Esempio n. 38
0
 public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
 {
     throw new System.NotImplementedException();
 }
Esempio n. 39
0
 public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
 {
     m_StoreController        = controller;
     m_StoreExtensionProvider = extensions;
 }
Esempio n. 40
0
        // Optionally: verify old purchases online.
        // Once we've received the product list, we overwrite
        // the existing shop item values with this online data
        public void OnInitialized(IStoreController ctrl, IExtensionProvider ext)
        {
            controller = ctrl;
            extensions = ext;

            if (validator && validator.shouldValidate(VerificationType.onStart))
                validator.Validate();

            if (ShopManager.GetInstance())
                ShopManager.OverwriteWithFetch(controller.products.all);
        }
Esempio n. 41
0
 public AggregateExtensionConfigureOptions(string sectionName, IExtensionProvider extensions)
 {
     _sectionName = sectionName;
     _extensions  = extensions.Instances;
     _mapper      = new Lazy <Mapper>(() => GetMapper());
 }
Esempio n. 42
0
 public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
 {
     OnStoreInit?.Invoke(this, controller);
 }
Esempio n. 43
0
 public ExtensionProviderTests()
 {
     _options           = new NtradaOptions();
     _extensionProvider = new ExtensionProvider(_options);
 }
            void IStoreListener.OnInitialized(IStoreController controller, IExtensionProvider provider)
            {
                var eventArgs = new InitializedEventArgs(controller, provider);

                Initialized(this, eventArgs);
            }
Esempio n. 45
0
 public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
 {
     Debug.Log("OnInitialized: PASS");
     m_StoreController        = controller;
     m_StoreExtensionProvider = extensions;
 }
 public InitializedEventArgs(IStoreController controller, IExtensionProvider provider)
 {
     AppleExtensions = provider.GetExtension <IAppleExtensions>();
     StoreController = controller;
 }
Esempio n. 47
0
 public override void RestoreReciepts(IExtensionProvider sentProvider)
 {
     throw new NotImplementedException();
 }
Esempio n. 48
0
 void IStoreListener.OnInitialized(IStoreController controller, IExtensionProvider extensions)
 {
     storeController = controller;
 }
 public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
 {
     Debug.Log("In-App Purchasing successfully initialized");
     m_StoreController = controller;
 }
Esempio n. 50
0
 public void OnInitialized(IStoreController sc, IExtensionProvider ep)
 {
     storeController   = sc;
     extensionProvider = ep;
 }
Esempio n. 51
0
 /// <summary>
 /// Surrounds the specified function expression with extension methods following a certain convention.
 /// </summary>
 /// <typeparam name="TExtension">The type of the extension.</typeparam>
 /// <typeparam name="TResult">The type of the result.</typeparam>
 /// <param name="provider">The provider.</param>
 /// <param name="function">The function expression.</param>
 /// <param name="args">The arguments.</param>
 /// <returns>The result of the function expression.</returns>
 public static TResult SurroundWithExtension <TExtension, TResult>(this IExtensionProvider <TExtension> provider, Expression <Func <TResult> > function, params object[] args)
     where TExtension : class
 {
     return(SurroundWithExtensionInternal <TExtension, TResult>(provider, function, args));
 }
 public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
 {
     Debug.Log("Store initialized");
     _storeController        = controller;
     _storeExtensionProvider = extensions;
 }
Esempio n. 53
0
 public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
 {
     this.controller = controller;
     this.extensions = extensions;
 }
 public DefaultInspectorFunctionManager(IExtensionProvider<IInspectorFunction> inspectorStartupProvider)
 {
     InspectorStartups = inspectorStartupProvider.Instances;
 }