コード例 #1
0
    private void OnRetrieveProductsFinised(BillingResult result)
    {
        AndroidInAppPurchaseManager.ActionRetrieveProducsFinished -= OnRetrieveProductsFinised;

        UM_BillingConnectionResult r = new UM_BillingConnectionResult();

        r.message   = result.Message;
        r.isSuccess = result.IsSuccess;

        _IsConnected = r.isSuccess;

        if (r.isSuccess)
        {
            foreach (UM_InAppProduct product in UltimateMobileSettings.Instance.InAppProducts)
            {
                GoogleProductTemplate tpl = AndroidInAppPurchaseManager.Client.Inventory.GetProductDetails(product.AndroidId);
                if (tpl != null)
                {
                    product.SetTemplate(tpl);
                    if (product.IsConsumable && AndroidInAppPurchaseManager.Client.Inventory.IsProductPurchased(product.AndroidId))
                    {
                        AndroidInAppPurchaseManager.Client.Consume(product.AndroidId);
                    }

                    if (!product.IsConsumable && AndroidInAppPurchaseManager.Client.Inventory.IsProductPurchased(product.AndroidId))
                    {
                        UM_InAppPurchaseManager.SaveNonConsumableItemPurchaseInfo(product);
                    }
                }
            }
        }

        SendServiceConnectedEvent(r);
    }
コード例 #2
0
    //--------------------------------------
    // Private Methods
    //--------------------------------------


    private static void AddToANSettings(UM_InAppProduct prod)
    {
        if (prod.AndroidId.Equals(string.Empty))
        {
            return;
        }

        GoogleProductTemplate newTpl = new GoogleProductTemplate();

        newTpl.SKU            = prod.AndroidId;
        newTpl.Title          = prod.DisplayName;
        newTpl.Description    = prod.Description;
        newTpl.Texture        = prod.Texture;
        newTpl.LocalizedPrice = prod.LocalizedPrice;

        if (prod.Type == UM_InAppType.Consumable)
        {
            newTpl.ProductType = AN_InAppType.Consumable;
        }

        if (prod.Type == UM_InAppType.NonConsumable)
        {
            newTpl.ProductType = AN_InAppType.NonConsumable;
        }

        AndroidNativeSettings.Instance.InAppProducts.Add(newTpl);
    }
コード例 #3
0
    public void OnProducttDetailsRecive(string data)
    {
        if (data.Equals(string.Empty))
        {
            Debug.Log("InAppPurchaseManager, no products avaiable");
            return;
        }

        string[] storeData;
        storeData = data.Split(AndroidNative.DATA_SPLITTER [0]);


        for (int i = 0; i < storeData.Length; i += 7)
        {
            GoogleProductTemplate tpl = _inventory.GetProductDetails(storeData[i]);
            if (tpl == null)
            {
                tpl     = new GoogleProductTemplate();
                tpl.SKU = storeData[i];
                _inventory.Products.Add(tpl);
            }

            tpl.LocalizedPrice    = storeData[i + 1];
            tpl.Title             = storeData[i + 2];
            tpl.Description       = storeData[i + 3];
            tpl.PriceAmountMicros = System.Convert.ToInt64(storeData[i + 4]);
            tpl.PriceCurrencyCode = storeData[i + 5];
            tpl.OriginalJson      = storeData[i + 6];


            Debug.Log("Prodcut originalJson: " + tpl.OriginalJson);
        }

        Debug.Log("InAppPurchaseManager, total products loaded: " + _inventory.Products.Count);
    }
コード例 #4
0
	//--------------------------------------
	// PUBLIC METHODS
	//--------------------------------------


	public void addProduct(GoogleProductTemplate product) {
		if(_products.ContainsKey(product.SKU)) {
			_products [product.SKU] = product;
		} else {
			_products.Add (product.SKU, product);
		}
	}
コード例 #5
0
    public void OnProducttDetailsRecive(string data)
    {
        if (data.Equals(string.Empty))
        {
            Debug.Log("InAppPurchaseManager, no products avaiable");
            return;
        }

        string[] storeData;
        storeData = data.Split(AndroidNative.DATA_SPLITTER [0]);


        for (int i = 0; i < storeData.Length; i += 7)
        {
            GoogleProductTemplate tpl = new GoogleProductTemplate();
            tpl.SKU               = storeData[i];
            tpl.price             = storeData[i + 1];
            tpl.title             = storeData[i + 2];
            tpl.description       = storeData[i + 3];
            tpl.priceAmountMicros = storeData[i + 4];
            tpl.priceCurrencyCode = storeData[i + 5];
            tpl.originalJson      = storeData[i + 6];
            _inventory.addProduct(tpl);
        }

        Debug.Log("InAppPurchaseManager, tottal products loaded: " + _inventory.products.Count);
    }
            public void OnProducttDetailsRecive(string data)
            {
                if (data.Equals(string.Empty))
                {
                    return;
                }

                string[] storeData;
                storeData = data.Split(DATA_SPLITTER [0]);


                for (int i = 0; i < storeData.Length; i += 7)
                {
                    GoogleProductTemplate tpl = new GoogleProductTemplate();
                    tpl.SKU               = storeData[i];
                    tpl.LocalizedPrice    = storeData[i + 1];
                    tpl.Title             = storeData[i + 2];
                    tpl.Description       = storeData[i + 3];
                    tpl.PriceAmountMicros = System.Convert.ToInt64(storeData[i + 4]);
                    tpl.PriceCurrencyCode = storeData[i + 5];
                    tpl.OriginalJson      = storeData[i + 6];

                    androidProducts.Add(tpl.SKU, tpl);
                }

                DelegateMessage(data);
            }
            public void OnPurchaseFinishedCallback(string data)
            {
                string[] storeData;
                storeData = data.Split(DATA_SPLITTER [0]);

                int resp = System.Convert.ToInt32(storeData[0]);


                if (resp == BILLING_RESPONSE_RESULT_OK)
                {
                    string SKU = storeData[2];


                    if (androidProducts.ContainsKey(SKU))
                    {
                        GoogleProductTemplate tpl = androidProducts[SKU];
                        StansAssetsGrowIntegration.instance.OnMarketPurchaseFinished(SKU, tpl.PriceAmountMicros, tpl.PriceCurrencyCode);
                    }
                    else
                    {
                        StansAssetsGrowIntegration.instance.OnMarketPurchaseFinished(SKU, 0, "USD");
                    }
                }
                else
                {
                    StansAssetsGrowIntegration.instance.OnMarketPurchaseFailed();
                }

                DelegateMessage(data);
            }
コード例 #8
0
ファイル: UM_InAppProduct.cs プロジェクト: minh3d/TestCB
	public void SetTemplate(GoogleProductTemplate tpl) {
		_AndroidTemplate = tpl;
		_template = new UM_InAppProductTemplate();
		_template.id = tpl.SKU;
		_template.title = tpl.title;
		_template.description = tpl.description;
		_template.price = tpl.price;
	}
コード例 #9
0
    public void AddProduct(string SKU)
    {
        GoogleProductTemplate template = new GoogleProductTemplate()
        {
            SKU = SKU
        };

        AddProduct(template);
    }
コード例 #10
0
ファイル: UM_InAppProduct.cs プロジェクト: sonxoans2/TapJump
	public void SetTemplate(GoogleProductTemplate tpl) {
		_AndroidTemplate = tpl;
		_template = new UM_InAppProductTemplate();
		_template.id = tpl.SKU;
		_template.title = tpl.Title;
		_template.description = tpl.Description;
		_template.price = tpl.Price.ToString();
		_isTemplateSet = true;
	}
コード例 #11
0
ファイル: UM_InAppProduct.cs プロジェクト: hdv0112/LookandTap
 public void SetTemplate(GoogleProductTemplate tpl)
 {
     _AndroidTemplate      = tpl;
     _template             = new UM_InAppProductTemplate();
     _template.id          = tpl.SKU;
     _template.title       = tpl.title;
     _template.description = tpl.description;
     _template.price       = tpl.price;
 }
コード例 #12
0
	public GoogleProductTemplate GetProductDetails(string SKU) {
		foreach(GoogleProductTemplate p in Products) {
			if(p.SKU.Equals(SKU)) {
				return p;
			}
		}

		GoogleProductTemplate product = new GoogleProductTemplate(){SKU = SKU};
		return product;
	}
コード例 #13
0
 public void SetTemplate(GoogleProductTemplate tpl)
 {
     _AndroidTemplate      = tpl;
     _template             = new UM_InAppProductTemplate();
     _template.id          = tpl.SKU;
     _template.title       = tpl.Title;
     _template.description = tpl.Description;
     _template.price       = tpl.Price.ToString();
     _isTemplateSet        = true;
 }
コード例 #14
0
    //--------------------------------------
    // PUBLIC METHODS
    //--------------------------------------


    public void addProduct(GoogleProductTemplate product)
    {
        if (_products.ContainsKey(product.SKU))
        {
            _products [product.SKU] = product;
        }
        else
        {
            _products.Add(product.SKU, product);
        }
    }
コード例 #15
0
    public GoogleProductTemplate GetProductDetails(string SKU)
    {
        foreach (GoogleProductTemplate p in Products)
        {
            if (p.SKU.Equals(SKU))
            {
                return(p);
            }
        }

        GoogleProductTemplate product = new GoogleProductTemplate()
        {
            SKU = SKU
        };

        return(product);
    }
コード例 #16
0
	public void AddProduct(GoogleProductTemplate template) {
		
		bool IsPordcutAlreadyInList = false;
		int replaceIndex = 0;
		foreach(GoogleProductTemplate p in _inventory.Products) {
			if(p.SKU.Equals(template.SKU)) {
				IsPordcutAlreadyInList = true;
				replaceIndex = _inventory.Products.IndexOf(p);
				break;
			}
		}
		
		if(IsPordcutAlreadyInList) {
			_inventory.Products[replaceIndex] = template;
		} else {
			_inventory.Products.Add(template);
		}
	}
コード例 #17
0
    public void Purchase(string SKU, string DeveloperPayload)
    {
        _processedSKU = SKU;
        GoogleProductTemplate product = _inventory.GetProductDetails(SKU);



        string title       = SKU;
        string describtion = "???";
        string price       = "?.??$";

        _CurrentSKU = SKU;

        if (product != null)
        {
            title       = product.Title;
            describtion = product.Description;
            price       = product.LocalizedPrice;
        }

        SA_EditorInApps.ShowInAppPopup(title, describtion, price, OnPurchaseComplete);
    }
コード例 #18
0
    public static void init()
    {
        //Filling product list

        //When you will add your own proucts you can skip this code section of you already have added
        //your products ids under the editor setings menu
        AndroidInAppPurchaseManager.Client.AddProduct(ANDROID_TEST_PURCHASED);
        AndroidInAppPurchaseManager.Client.AddProduct(ANDROID_TEST_CANCELED);
        AndroidInAppPurchaseManager.Client.AddProduct(ANDROID_TEST_REFUNDED);
        AndroidInAppPurchaseManager.Client.AddProduct(ANDROID_TEST_ITEM_UNAVAILABLE);



        string MyProdcutSKU = "my.prod.id";

        AndroidInAppPurchaseManager.Client.AddProduct(MyProdcutSKU);

        //or
        GoogleProductTemplate tpl = new GoogleProductTemplate();

        tpl.SKU = MyProdcutSKU;
        AndroidInAppPurchaseManager.Client.AddProduct(tpl);


        //listening for Purchase and consume events
        AndroidInAppPurchaseManager.ActionProductPurchased += OnProductPurchased;
        AndroidInAppPurchaseManager.ActionProductConsumed  += OnProductConsumed;


        //listening for store initialising finish
        AndroidInAppPurchaseManager.ActionBillingSetupFinished += OnBillingConnected;


        //you may use loadStore function without parameter if you have filled base64EncodedPublicKey in plugin settings
        AndroidInAppPurchaseManager.Client.Connect();

        //or You can pass base64EncodedPublicKey using scirption:
        //AndroidInAppPurchaseManager.instance.loadStore(YOU_BASE_64_KEY_HERE);
    }
コード例 #19
0
    private void Android_OnRetrieveProductsFinised(CEvent e)
    {
        _IsInited = true;

        BillingResult result = e.data as BillingResult;

        AndroidInAppPurchaseManager.instance.removeEventListener(AndroidInAppPurchaseManager.ON_RETRIEVE_PRODUC_FINISHED, Android_OnRetrieveProductsFinised);

        UM_BillingConnectionResult r = new UM_BillingConnectionResult();

        r.message              = result.message;
        r.isSuccess            = result.isSuccess;
        _IsPurchasingAvailable = r.isSuccess;
        if (r.isSuccess)
        {
            foreach (UM_InAppProduct product in UltimateMobileSettings.Instance.InAppProducts)
            {
                GoogleProductTemplate tpl = AndroidInAppPurchaseManager.instance.inventory.GetProductDetails(product.AndroidId);
                if (tpl != null)
                {
                    product.SetTemplate(tpl);
                    if (product.IsConsumable && AndroidInAppPurchaseManager.instance.inventory.IsProductPurchased(product.AndroidId))
                    {
                        AndroidInAppPurchaseManager.instance.consume(product.AndroidId);
                    }

                    if (!product.IsConsumable && AndroidInAppPurchaseManager.instance.inventory.IsProductPurchased(product.AndroidId))
                    {
                        SaveNonConsumableItemPurchaseInfo(product);
                    }
                }
            }
        }


        OnBillingConnectFinishedAction(r);
        dispatch(ON_BILLING_CONNECT_FINISHED, r);
    }
コード例 #20
0
    public void AddProduct(GoogleProductTemplate template)
    {
        bool IsPordcutAlreadyInList = false;
        int  replaceIndex           = 0;

        foreach (GoogleProductTemplate p in _inventory.Products)
        {
            if (p.SKU.Equals(template.SKU))
            {
                IsPordcutAlreadyInList = true;
                replaceIndex           = _inventory.Products.IndexOf(p);
                break;
            }
        }

        if (IsPordcutAlreadyInList)
        {
            _inventory.Products[replaceIndex] = template;
        }
        else
        {
            _inventory.Products.Add(template);
        }
    }
コード例 #21
0
	public void OnProducttDetailsRecive(string data) {
		if(data.Equals(string.Empty)) {
			Debug.Log("InAppPurchaseManager, no products avaiable");
			return;
		}
		
		string[] storeData;
		storeData = data.Split(AndroidNative.DATA_SPLITTER [0]);
		
		
		for(int i = 0; i < storeData.Length; i+=7) {
			GoogleProductTemplate tpl =  _inventory.GetProductDetails(storeData[i]);
			if(tpl == null) {
				tpl =  new GoogleProductTemplate();
				tpl.SKU = storeData[i];
				_inventory.Products.Add(tpl);
			}
			
			tpl.LocalizedPrice 		  		= storeData[i + 1];
			tpl.Title 	      				= storeData[i + 2];
			tpl.Description   				= storeData[i + 3];
			tpl.PriceAmountMicros 	      	= System.Convert.ToInt64(storeData[i + 4]);
			tpl.PriceCurrencyCode   		= storeData[i + 5];
			tpl.OriginalJson   				= storeData[i + 6];
			
			
			Debug.Log("Prodcut originalJson: " + tpl.OriginalJson);
		}
		
		Debug.Log("InAppPurchaseManager, total products loaded: " + _inventory.Products.Count);
	}
コード例 #22
0
			public void OnProducttDetailsRecive(string data) {
				if(data.Equals(string.Empty)) {
					return;
				}
				
				string[] storeData;
				storeData = data.Split(DATA_SPLITTER [0]);
				
				
				for(int i = 0; i < storeData.Length; i+=7) {

					GoogleProductTemplate tpl =  new GoogleProductTemplate();
					tpl.SKU 						= storeData[i];
					tpl.LocalizedPrice 		  		= storeData[i + 1];
					tpl.Title 	      				= storeData[i + 2];
					tpl.Description   				= storeData[i + 3];
					tpl.PriceAmountMicros 	      	= System.Convert.ToInt64(storeData[i + 4]);
					tpl.PriceCurrencyCode   		= storeData[i + 5];
					tpl.OriginalJson   				= storeData[i + 6];

					androidProducts.Add(tpl.SKU, tpl);

				}

				DelegateMessage (data);
			}
コード例 #23
0
    //--------------------------------------
    // EVENTS
    //--------------------------------------



    public void OnPurchaseFinishedCallback(string data)
    {
        Debug.Log(data);
        string[] storeData;
        storeData = data.Split(AndroidNative.DATA_SPLITTER [0]);

        int resp = System.Convert.ToInt32(storeData[0]);
        GooglePurchaseTemplate purchase = new GooglePurchaseTemplate();


        if (resp == BillingResponseCodes.BILLING_RESPONSE_RESULT_OK)
        {
            purchase.SKU              = storeData[2];
            purchase.packageName      = storeData[3];
            purchase.developerPayload = storeData[4];
            purchase.orderId          = storeData[5];
            purchase.SetState(storeData[6]);
            purchase.token        = storeData[7];
            purchase.signature    = storeData[8];
            purchase.time         = System.Convert.ToInt64(storeData[9]);
            purchase.originalJson = storeData[10];

            if (_inventory != null)
            {
                _inventory.addPurchase(purchase);
            }
        }
        else
        {
            purchase.SKU = _processedSKU;
        }


        //Soomla Analytics
        if (resp == BillingResponseCodes.BILLING_RESPONSE_RESULT_OK)
        {
            GoogleProductTemplate tpl = Inventory.GetProductDetails(purchase.SKU);
            if (tpl != null)
            {
                AN_SoomlaGrow.PurchaseFinished(tpl.SKU, tpl.PriceAmountMicros, tpl.PriceCurrencyCode);
            }
            else
            {
                AN_SoomlaGrow.PurchaseFinished(purchase.SKU, 0, "USD");
            }
        }
        else
        {
            if (resp == BillingResponseCodes.BILLINGHELPERR_USER_CANCELLED)
            {
                AN_SoomlaGrow.PurchaseCanceled(purchase.SKU);
            }
            else
            {
                AN_SoomlaGrow.PurchaseError();
            }
        }

        BillingResult result = new BillingResult(resp, storeData [1], purchase);


        ActionProductPurchased(result);
    }
コード例 #24
0
	private void BillingSettings() {
		EditorGUILayout.Space();
		EditorGUILayout.HelpBox("Billing Settings", MessageType.None);


			EditorGUILayout.BeginHorizontal();
			EditorGUILayout.LabelField(Base64KeyLabel);
			settings.base64EncodedPublicKey	 	= EditorGUILayout.TextField(settings.base64EncodedPublicKey);

			if(settings.base64EncodedPublicKey.ToString().Length > 0) {
				settings.base64EncodedPublicKey 	= settings.base64EncodedPublicKey.ToString().Trim();
			}

			EditorGUILayout.EndHorizontal();

			EditorGUI.indentLevel++;
			{
				EditorGUILayout.BeginVertical (GUI.skin.box);
				
				
				EditorGUILayout.BeginHorizontal();
				AndroidNativeSettings.Instance.ShowStoreProducts = EditorGUILayout.Foldout(AndroidNativeSettings.Instance.ShowStoreProducts, "Products");
				
				EditorGUILayout.EndHorizontal();
				EditorGUILayout.Space();

				if(AndroidNativeSettings.Instance.ShowStoreProducts) {
					
					foreach(GoogleProductTemplate product in AndroidNativeSettings.Instance.InAppProducts) {
						
						EditorGUILayout.BeginVertical (GUI.skin.box);
						
						EditorGUILayout.BeginHorizontal();
						
						GUIStyle s =  new GUIStyle();
						s.padding =  new RectOffset();
						s.margin =  new RectOffset();
						s.border =  new RectOffset();
						
						if(product.Texture != null) {
							GUILayout.Box(product.Texture, s, new GUILayoutOption[]{GUILayout.Width(18), GUILayout.Height(18)});
						}
						
						product.IsOpen 	= EditorGUILayout.Foldout(product.IsOpen, product.Title);

						
						EditorGUILayout.LabelField(product.Price + "$");
						bool ItemWasRemoved = DrawSortingButtons((object) product, AndroidNativeSettings.Instance.InAppProducts);
						if(ItemWasRemoved) {
							return;
						}
						
						EditorGUILayout.EndHorizontal();
						
						if(product.IsOpen) {
							EditorGUILayout.BeginHorizontal();
							EditorGUILayout.LabelField(ProductIdDLabel);
							product.SKU	 	= EditorGUILayout.TextField(product.SKU);
							if(product.SKU.Length > 0) {
								product.SKU 		= product.SKU.Trim();
							}
							EditorGUILayout.EndHorizontal();
							
							EditorGUILayout.BeginHorizontal();
							EditorGUILayout.LabelField(DisplayNameLabel);
							product.Title	 	= EditorGUILayout.TextField(product.Title);
							EditorGUILayout.EndHorizontal();
							
							EditorGUILayout.BeginHorizontal();
							EditorGUILayout.LabelField(IsConsLabel);
							product.ProductType	 	= (AN_InAppType) EditorGUILayout.EnumPopup(product.ProductType);
							EditorGUILayout.EndHorizontal();
							
							EditorGUILayout.Space();
							EditorGUILayout.Space();

							EditorGUILayout.BeginHorizontal();
							EditorGUILayout.LabelField(DescriptionLabel);
							EditorGUILayout.EndHorizontal();
							
							EditorGUILayout.BeginHorizontal();
							product.Description	 = EditorGUILayout.TextArea(product.Description,  new GUILayoutOption[]{GUILayout.Height(60), GUILayout.Width(200)} );
							product.Texture = (Texture2D) EditorGUILayout.ObjectField("", product.Texture, typeof (Texture2D), false);
							EditorGUILayout.EndHorizontal();
						}

						
						EditorGUILayout.EndVertical();
						
					}
					
					EditorGUILayout.BeginHorizontal();
					EditorGUILayout.Space();
					if(GUILayout.Button("Add new", EditorStyles.miniButton, GUILayout.Width(250))) {
						GoogleProductTemplate product =  new GoogleProductTemplate();
						AndroidNativeSettings.Instance.InAppProducts.Add(product);
					}
					
					EditorGUILayout.Space();
					EditorGUILayout.EndHorizontal();
					EditorGUILayout.Space();
				}
				
				EditorGUILayout.EndVertical();
			}

			EditorGUI.indentLevel--;

	}
コード例 #25
0
	//--------------------------------------
	// PUBLIC METHODS
	//--------------------------------------
	

	public void AddProduct(string SKU) {
		GoogleProductTemplate template = new GoogleProductTemplate(){SKU = SKU};
		AddProduct(template);
	}