Esempio n. 1
0
        protected void ExtractProductIDs(List <BillingProduct> _products, out List <string> _consumableProductIDs,
                                         out List <string> _nonConsumableProductIDs)
        {
            // Initialise array
            _consumableProductIDs    = new List <string>();
            _nonConsumableProductIDs = new List <string>();

            // Total product count
            int _totalProducts = _products.Count;

            for (int _iter = 0; _iter < _totalProducts; _iter++)
            {
                BillingProduct _product      = _products[_iter];
                string         _productID    = _product.ProductIdentifier;
                bool           _isConsumable = _product.IsConsumable;

                // Add products based on flag "IsConsumable" value
                if (_isConsumable)
                {
                    _consumableProductIDs.Add(_productID);
                }
                else
                {
                    _nonConsumableProductIDs.Add(_productID);
                }
            }
        }
Esempio n. 2
0
		private void UpdateProductInfomation (List<BillingProduct> _regProductsList)
		{
			// As we were able to connect to store server, we have local description of product lets use it for presentation purpose
			int _registeredProductsCount	= _regProductsList.Count;
			int _requestedProductsCount		= RequestedProducts.Count;
			
			for (int _rIter = 0; _rIter < _registeredProductsCount; _rIter++)
			{
				BillingProduct _registedProduct	= _regProductsList[_rIter];
				string _registedProductID		= _registedProduct.ProductIdentifier;
				
				for (int _pIter	= 0; _pIter < _requestedProductsCount; _pIter++)
				{
					BillingProduct _requestedProduct	= RequestedProducts[_pIter];
					string _requestedProductID			= _requestedProduct.ProductIdentifier;
					
					// Update information
					if (_registedProductID.Equals(_requestedProductID))
					{
						_registedProduct.IsConsumable	= _requestedProduct.IsConsumable;
						break;
					}
				}
			}
		}
Esempio n. 3
0
        public static BillingProduct Create(string _name, bool _isConsumable, params PlatformID[] _platformIDs)
        {
            BillingProduct _newProduct = new BillingProduct();

            _newProduct.Name         = _name;
            _newProduct.IsConsumable = _isConsumable;

            // Set product identifiers
            if (_platformIDs != null)
            {
                foreach (PlatformID _curID in _platformIDs)
                {
                    if (_curID == null)
                    {
                        continue;
                    }

                    if (_curID.Platform == PlatformID.ePlatform.IOS)
                    {
                        _newProduct.IOSProductID = _curID.Value;
                    }
                    else if (_curID.Platform == PlatformID.ePlatform.ANDROID)
                    {
                        _newProduct.AndroidProductID = _curID.Value;
                    }
                }
            }

            return(_newProduct);
        }
Esempio n. 4
0
        /// <summary>
        /// Initiates purchase process for the specified billing product.
        /// </summary>
        /// <param name="_product">The object identifies the billing product registered in the Store.</param>
        /// <remarks>
        /// \note The payment request must have a product identifier registered with the Store.
        /// </remarks>
        public virtual void BuyProduct(BillingProduct _product)
        {
            string _productID = (_product == null) ? null : _product.ProductIdentifier;

#pragma warning disable
            BuyProduct(_productID);
#pragma warning restore
        }
		public override void RequestForBillingProducts (BillingProduct[] _billingProducts)
		{
			// Cache requested products
			RequestedProducts	= _billingProducts;

			// Request store for product information
			EditorStore.RequestForBillingProducts(_billingProducts);
		}
Esempio n. 6
0
        /// <summary>
        /// Determines whether specified billing product is already purchased.
        /// </summary>
        /// <returns><c>true</c> if specified billing product is already purchased; otherwise, <c>false</c>.</returns>
        /// <param name="_product">The object identifies the billing product registered in the Store.</param>
        /// <remarks>
        /// \note This works only for Non-Consumable (Managed) billing product. For Consumable products, this will always returns false.
        /// </remarks>
        public bool IsProductPurchased(BillingProduct _product)
        {
            string _productID = (_product == null) ? null : _product.ProductIdentifier;

#pragma warning disable
            return(IsProductPurchased(_productID));

#pragma warning restore
        }
Esempio n. 7
0
        /// <summary>
        /// Creates a new billing product with given information.
        /// </summary>
        /// <param name="_name">The name of the product.</param>
        /// <param name="_isConsumable">The type of the billing product. Is it Consumable/Non-Consumable product?</param>
        /// <param name="_platformIDs">An array of platform specific product identifiers.</param>
        /// <example>
        /// The following code example shows how to dynamically create billing product.
        /// <code>
        /// BillingProduct _newProduct	= BillingProduct.Create("name", true, Platform.Android("android-product-id"), Platform.IOS("ios-product-id"));
        /// </code>
        /// </example>
        public static BillingProduct Create(string _name, bool _isConsumable, params PlatformValue[] _productIDs)
        {
            BillingProduct _newProduct = new BillingProduct();

            _newProduct.Name                 = _name;
            _newProduct.IsConsumable         = _isConsumable;
            _newProduct.m_productIdentifiers = _productIDs;

            return(_newProduct);
        }
Esempio n. 8
0
 protected BillingProduct(BillingProduct _product)
 {
     this.Name                 = _product.Name;
     this.Description          = _product.Description;
     this.IsConsumable         = _product.IsConsumable;
     this.Price                = _product.Price;
     this.m_productIdentifiers = _product.m_productIdentifiers;
     this.LocalizedPrice       = _product.LocalizedPrice;
     this.CurrencyCode         = _product.CurrencyCode;
     this.CurrencySymbol       = _product.CurrencySymbol;
 }
Esempio n. 9
0
 public override void BuyProduct(BillingProduct _product)
 {
     if (_product != null)
     {
         BuyProduct(_product.ProductIdentifier, _product.DeveloperPayload);
     }
     else
     {
         Debug.LogError("[Billing] Product can't be null");
     }
 }
Esempio n. 10
0
 protected BillingProduct(BillingProduct _product)
 {
     this.Name             = _product.Name;
     this.Description      = _product.Description;
     this.IsConsumable     = _product.IsConsumable;
     this.Price            = _product.Price;
     this.LocalizedPrice   = _product.LocalizedPrice;
     this.CurrencyCode     = _product.CurrencyCode;
     this.CurrencySymbol   = _product.CurrencySymbol;
     this.IOSProductID     = _product.IOSProductID;
     this.AndroidProductID = _product.AndroidProductID;
 }
Esempio n. 11
0
        /// <summary>
        /// Copy this instance.
        /// </summary>
        public BillingProduct Copy()
        {
            BillingProduct _productClone = new BillingProduct();

            _productClone.Name               = this.Name;
            _productClone.Description        = this.Description;
            _productClone.IsConsumable       = this.IsConsumable;
            _productClone.Price              = this.Price;
            _productClone.LocalizedPrice     = this.LocalizedPrice;
            _productClone.m_iosProductId     = this.m_iosProductId;
            _productClone.m_androidProductId = this.m_androidProductId;

            return(_productClone);
        }
		protected void DidReceiveBillingProducts (BillingProduct[] _regProductsList, string _error)
		{
			Console.Log(Constants.kDebugTag, "[Billing] Request for billing products finished successfully.");

			// Update product information, refering to product details used for requesting
			UpdateProductInfomation(_regProductsList);

			// Backward compatibility event support
#pragma warning disable
			if (BillingProductsRequestFinishedEvent != null)
				BillingProductsRequestFinishedEvent(_regProductsList == null ? null : new List<BillingProduct>(_regProductsList), null);
#pragma warning restore

			// Event triggered
			if (DidFinishProductsRequestEvent != null)
				DidFinishProductsRequestEvent(_regProductsList, _error);
		}
Esempio n. 13
0
        public void BuyProduct(BillingProduct _product)
        {
            Debug.Log(_product.Name);
            if (NPBinding.Billing.IsProductPurchased(_product))
            {
                // Show alert message that item is already purchased
                buttonFSM.SendEvent("Zaeubri");
                Debug.Log("Bought");
                return;
            }

            // Call method to make purchase
            NPBinding.Billing.BuyProduct(_product);

            // At this point you can display an activity indicator to inform user that task is in progress
            Debug.Log("Buying...");
        }
Esempio n. 14
0
		/// <summary>
		/// Request details for given list of billing products.		
		/// </summary>
		///	<remarks> 
		/// Details of billing products needs to be fetched first with this method before purchasing any product. 
		/// </remarks>
		/// <param name="_billingProducts">List of billing products which needs details.</param>
		public virtual void RequestForBillingProducts (BillingProduct[] _billingProducts)
		{
			if (_billingProducts == null || _billingProducts.Length == 0)
			{
				Console.LogWarning(Constants.kDebugTag, "[Billing] products list is empty.");
				DidReceiveBillingProducts(null, "The operation could not be completed because product list is null or empty.");
				return;
			}

			// Cache requested products details
			RequestedProducts	= _billingProducts;

			// Get consumable and non consumable product ids
			string[] _consumableProductIDs, _nonConsumableProductIDs;

			ExtractProductIDs(_billingProducts, out _consumableProductIDs, out _nonConsumableProductIDs);

			// Request for billing products
			RequestForBillingProducts(_consumableProductIDs, _nonConsumableProductIDs);
		}
        private void OnDidFinishProductPurchase(BillingTransaction _transaction)
        {
            string _productID = _transaction.ProductIdentifier;

            // Based on receipt verification, report event
            if (_transaction.VerificationState == eBillingTransactionVerificationState.SUCCESS)
            {
                if (_transaction.TransactionState == eBillingTransactionState.PURCHASED)
                {
                    BillingProduct _productInfo = NPBinding.Billing.GetStoreProduct(_productID);

                    if (_productInfo == null)
                    {
                        DebugUtility.Logger.Log(Constants.kDebugTag, "[SoomlaGrow] The operation could not be completed because product information is not available.");
                    }
                    else
                    {
                        ReportOnBillingPurchaseFinished(_productID, (long)(_productInfo.Price * 1000000), _productInfo.CurrencyCode);
                    }
                }
                else if (_transaction.TransactionState == eBillingTransactionState.FAILED)
                {
                    if (_productID == null)
                    {
                        DebugUtility.Logger.Log(Constants.kDebugTag, "[SoomlaGrow] The operation could not be completed because product identifier information is not available.");
                    }
                    else
                    {
                        ReportOnBillingPurchaseFailed(_productID);
                    }
                }
            }
            else if (_transaction.VerificationState == eBillingTransactionVerificationState.FAILED)
            {
                ReportOnBillingPurchaseVerificationFailed();

                return;
            }
        }
Esempio n. 16
0
 protected override void ParseProductData(IDictionary _productDict, out BillingProduct _product)
 {
     _product = new AndroidBillingProduct(_productDict);
 }
		protected override void ParseProductData (IDictionary _productDict, out BillingProduct _product)
		{
			_product		= new iOSBillingProduct(_productDict);
		}
Esempio n. 18
0
		protected virtual void ParseProductData (IDictionary _productDict, out BillingProduct _product)
		{
			_product		= null;
		}
		public static BillingProduct Create (string _name, bool _isConsumable, params PlatformID[] _platformIDs)
		{
			BillingProduct	_newProduct	= new BillingProduct();
			_newProduct.Name			= _name;
			_newProduct.IsConsumable	= _isConsumable;

			// Set product identifiers
			if (_platformIDs != null)
			{
				foreach (PlatformID _curID in _platformIDs)
				{
					if (_curID == null)
						continue;

					if (_curID.Platform == PlatformID.ePlatform.IOS)
						_newProduct.IOSProductID		= _curID.Value;
					else if (_curID.Platform == PlatformID.ePlatform.ANDROID)
						_newProduct.AndroidProductID	= _curID.Value;
				}
			}

			return _newProduct;
		}
		public BillingSettings ()
		{
			Products	= new BillingProduct[0];
			iOS			= new BillingSettings.iOSSettings();
			Android		= new BillingSettings.AndroidSettings();
		}
		private void UpdateProductInfomation (BillingProduct[] _regProductsList)
		{
			if (_regProductsList == null)
				return;

			foreach (MutableBillingProduct _regProduct in _regProductsList)
			{
				int 	_productIndex	= System.Array.FindIndex(RequestedProducts, (BillingProduct _curProduct) => _curProduct.ProductIdentifier.Equals(_regProduct.ProductIdentifier));
				
				// Update product information by referring to requested products
				if (_productIndex != -1)
					_regProduct.SetIsConsumable(RequestedProducts[_productIndex].IsConsumable);
			}
		}
		protected BillingProduct (BillingProduct _product)
		{
			this.Name				= _product.Name;
			this.Description		= _product.Description;
			this.IsConsumable		= _product.IsConsumable;
			this.Price				= _product.Price;
			this.LocalizedPrice		= _product.LocalizedPrice;
			this.CurrencyCode		= _product.CurrencyCode;
			this.CurrencySymbol		= _product.CurrencySymbol;
			this.IOSProductID		= _product.IOSProductID;
			this.AndroidProductID	= _product.AndroidProductID;
		}
Esempio n. 23
0
 public BillingSettings()
 {
     Products = new BillingProduct[0];
     iOS      = new BillingSettings.iOSSettings();
     Android  = new BillingSettings.AndroidSettings();
 }
Esempio n. 24
0
		protected void ExtractProductIDs (BillingProduct[] _products, out string[] _consumableProductIDs, out string[] _nonConsumableProductIDs)
		{
			// Initialise
			List<string> _consumableProductIDList		= new List<string>();
			List<string> _nonConsumableProductIDList	= new List<string>();

			foreach (BillingProduct _curProduct in _products)
			{
				string	_curProductID	= _curProduct.ProductIdentifier;

				// Add products based on flag "IsConsumable" value
				if (_curProduct.IsConsumable)
					_consumableProductIDList.Add(_curProductID);
				else
					_nonConsumableProductIDList.Add(_curProductID);
			}

			// Set value
			_consumableProductIDs		= _consumableProductIDList.ToArray();
			_nonConsumableProductIDs	= _nonConsumableProductIDList.ToArray();
		}
		/// <summary>
		/// Copy this instance.
		/// </summary>
		public BillingProduct Copy ()
		{
			BillingProduct _productClone		= new BillingProduct();
			_productClone.Name					= this.Name;
			_productClone.Description			= this.Description;
			_productClone.IsConsumable			= this.IsConsumable;
			_productClone.Price					= this.Price;
			_productClone.LocalizedPrice		= this.LocalizedPrice;
			_productClone.m_iosProductId		= this.m_iosProductId;
			_productClone.m_androidProductId	= this.m_androidProductId;

			return _productClone;
		}