示例#1
0
        private async Task <PurchaseResult> GetPurchaseResult(BillingResult billingResult, IList <Purchase> purchases)
        {
            var purchaseResult = new PurchaseResult();

            if (billingResult.ResponseCode == BillingResponseCode.Ok && purchases != null)
            {
                purchaseResult.PurchaseState = Plugin.XFInAppBilling.PurchaseState.Purchased;
                if (purchases?.Count > 0)
                {
                    var purchaseResults = await GetPurchasesAsync(purchases);

                    purchaseResult = purchaseResults?.OrderByDescending(p => p.ExpirationDate).Last();
                }
            }
            else if (billingResult.ResponseCode == BillingResponseCode.UserCancelled)
            {
                purchaseResult.PurchaseState = Plugin.XFInAppBilling.PurchaseState.Cancelled;
            }
            else if (billingResult.ResponseCode == BillingResponseCode.ItemAlreadyOwned)
            {
                purchaseResult.PurchaseState = Plugin.XFInAppBilling.PurchaseState.AlreadyOwned;
            }
            else
            {
                purchaseResult.PurchaseState = Plugin.XFInAppBilling.PurchaseState.Failed;
            }

            return(purchaseResult);
        }
示例#2
0
    //--------------------------------------
    // Android Listners
    //--------------------------------------



    void Android_ActionProductPurchased(BillingResult result)
    {
        UM_InAppProduct p = UltimateMobileSettings.Instance.GetProductByAndroidId(result.purchase.SKU);

        if (p != null)
        {
            if (p.IsConsumable)
            {
                AndroidInAppPurchaseManager.instance.consume(result.purchase.SKU);
            }
            else
            {
                UM_PurchaseResult r = new UM_PurchaseResult();
                r.isSuccess           = result.isSuccess;
                r.product             = p;
                r.Google_PurchaseInfo = result.purchase;

                SendPurchaseEvent(r);
            }
        }
        else
        {
            SendNoTemplateEvent();
        }
    }
示例#3
0
    private static void OnRetrieveProductsFinised(BillingResult result)
    {
        AndroidInAppPurchaseManager.ActionRetrieveProducsFinished -= OnRetrieveProductsFinised;


        if (result.isSuccess)
        {
            foreach (GoogleProductTemplate tpl in AndroidInAppPurchaseManager.instance.inventory.products)
            {
                for (int i = 0; i < GUI_Shop.GetInstance().containerShopCoins.transform.childCount; i++)
                {
                    ShopContent content = GUI_Shop.GetInstance().containerShopCoins.transform.GetChild(i).gameObject.GetComponent <ShopContent>();
                    if (tpl.SKU.Equals(content.uniqueID))
                    {
                        GameManager.SetNGUILabel(content.transform.Find("Label Price"), tpl.price);
                        Transform trButtonBuy = content.transform.Find("ButtonBuy");
                        if (trButtonBuy)
                        {
                            trButtonBuy.gameObject.SetActive(true);
                        }
                        break;
                    }
                }
            }
        }
        else
        {
            //AndroidMessage.Create("Connection Responce", result.response.ToString() + " " + result.message);
        }

        Debug.Log("Connection Response: " + result.response.ToString() + " " + result.message);
    }
示例#4
0
    private static void OnProductPurchased(CEvent e)
    {
        BillingResult result = e.data as BillingResult;

        //this flag will tell you if purchase is avaliable
        //result.isSuccess


        //infomation about purchase stored here
        //result.purchase

        //here is how for example you can get product SKU
        //result.purchase.SKU


        if (result.isSuccess)
        {
            OnProcessingPurchasedProduct(result.purchase);
        }
        else
        {
            AndroidMessage.Create("Product Purchase Failed", result.response.ToString() + " " + result.message);
        }

        Debug.Log("Purchased Responce: " + result.response.ToString() + " " + result.message);
    }
    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);
    }
示例#6
0
 public void OnPurchasesUpdated(BillingResult result, IList <Purchase> purchases)
 {
     Log.Debug(TAG, "OnPurchasesUpdated()");
     if (result.ResponseCode == BillingResponseCode.Ok && purchases != null)
     {
         foreach (var purchase in purchases)
         {
             // It's a donation that grants nothing, so we're safe to consume this right away
             ConsumePurchase(purchase);
             string sku = purchase.Skus[0];
             foreach (var item in skuDetails)
             {
                 if (item.Sku == sku)
                 {
                     ShowThankYouMessage(item);
                     break;
                 }
             }
         }
     }
     else if (result.ResponseCode != BillingResponseCode.UserCancelled)
     {
         var toast = Toast.MakeText(parent_activity, "Something went wrong, try again maybe?", ToastLength.Long);
         toast.Show();
     }
 }
示例#7
0
 private static void OnProductPurchased(BillingResult result)
 {
     if(result.isSuccess)
     {
         OnProcessingPurchasedProduct (result.purchase);
     }
 }
示例#8
0
    private static void OnRetrieveProductsFinised(BillingResult result)
    {
        AndroidInAppPurchaseManager.ActionRetrieveProducsFinished -= OnRetrieveProductsFinised;

        if(result.isSuccess)
        {
            _isInited = true;

            foreach(GooglePurchaseTemplate tpl in AndroidInAppPurchaseManager.instance.inventory.purchases)
            {
                //AndroidMessage.Create(tpl.title, tpl.SKU);
                switch(tpl.SKU)
                {
                case "panda":
                    SingletonSaveData.instance.pandaLocked = false;
                    break;

                case "lugg":
                    SingletonSaveData.instance.juggLocked = false;
                    break;

                case "demon":
                    SingletonSaveData.instance.demonLocked = false;
                    break;
                }
            }
        }
        else
        {

        }
    }
示例#9
0
    private static void OnProductPurchased(BillingResult result)
    {
        //this flag will tell you if purchase is available
        //result.isSuccess


        //infomation about purchase stored here
        //result.purchase

        //here is how for example you can get product SKU
        //result.purchase.SKU


        if (result.isSuccess)
        {
            OnProcessingPurchasedProduct(result.purchase);
        }
        else
        {
            if (FailedPurchase != null)
            {
                FailedPurchase();
            }
            else
            {
                Debug.LogWarning("NOTHING IS SUBSCRIBED TO FailedPurchase DELEGATE");
            }

            AndroidMessage.Create("Product Purchase Failed", result.response.ToString() + " " + result.message);
        }
        Debug.Log("Purchased Responce: " + result.response.ToString() + " " + result.message);
    }
    public void OnConsumeFinishedCallBack(string data)
    {
        string[] storeData;
        storeData = data.Split(AndroidNative.DATA_SPLITTER [0]);

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


        if (resp == BillingResponseCodes.BILLING_RESPONSE_RESULT_OK)
        {
            purchase                  = new GooglePurchaseTemplate();
            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.originalJson = storeData[9];

            if (_inventory != null)
            {
                _inventory.removePurchase(purchase);
            }
        }

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

        ActionProductConsumed(result);
        dispatch(ON_PRODUCT_CONSUMED, result);
    }
示例#11
0
    private static void OnRetrieveProductsFinished(BillingResult result)
    {
        AndroidInAppPurchaseManager.ActionRetrieveProducsFinished -= OnRetrieveProductsFinished;

        if (result.IsSuccess)
        {
            if (AndroidInAppPurchaseManager.Client.Inventory.IsProductPurchased(SKU_MoneyPack_1))
            {
                AndroidInAppPurchaseManager.Client.Consume(SKU_MoneyPack_1);
            }
            else if (AndroidInAppPurchaseManager.Client.Inventory.IsProductPurchased(SKU_MoneyPack_2))
            {
                AndroidInAppPurchaseManager.Client.Consume(SKU_MoneyPack_2);
            }
            else if (AndroidInAppPurchaseManager.Client.Inventory.IsProductPurchased(SKU_MoneyPack_3))
            {
                AndroidInAppPurchaseManager.Client.Consume(SKU_MoneyPack_3);
            }
            else if (AndroidInAppPurchaseManager.Client.Inventory.IsProductPurchased(SKU_NoAds))
            {
                PlayerPrefs.SetInt("NoAds", 1);
            }
            else if (AndroidInAppPurchaseManager.Client.Inventory.IsProductPurchased(SKU_UnlimFreeze))
            {
                PlayerPrefs.SetInt("UnlimFreeze", 1);
            }
        }
    }
    //--------------------------------------
    // Event Handlers
    //--------------------------------------


    private void OnProductPurchased(BillingResult result)
    {
        UM_InAppProduct p = UltimateMobileSettings.Instance.GetProductByAndroidId(result.Purchase.SKU);

        if (p != null)
        {
            if (p.IsConsumable && result.IsSuccess)
            {
                AndroidInAppPurchaseManager.Client.Consume(result.Purchase.SKU);
            }
            else
            {
                UM_PurchaseResult r = new UM_PurchaseResult();
                r.isSuccess = result.IsSuccess;
                r.product   = p;
                r.SetResponceCode(result.Response);
                r.Google_PurchaseInfo = result.Purchase;

                SendPurchaseFinishedEvent(r);
            }
        }
        else
        {
            SendNoTemplateEvent();
        }
    }
示例#13
0
        private async Task ConsumePurchaseAsync(string token)
        {
            ConsumeParams consumeParams =
                ConsumeParams.NewBuilder()
                .SetPurchaseToken(token)
                .Build();

            // Consume the Consumable Product
            ConsumeResult consumeResult = await _billingClient.ConsumeAsync(consumeParams);

            BillingResult result = consumeResult?.BillingResult;

            if (result == null)
            {
                // Failed to get result back.
                throw new InAppPurchaseException(PurchaseError.Unknown, "BillingResult is null");
            }

            if (result.ResponseCode != BillingResponseCode.Ok)
            {
                throw new InAppPurchaseException(
                          result.ResponseCode.ToPurchaseError(),
                          result.DebugMessage);
            }

            // Otherwise, the ConsumeAsync succeeded.
        }
示例#14
0
        private async Task AcklowledgePurchaseAsync(string token)
        {
            AcknowledgePurchaseParams acknowledgePurchaseParams =
                AcknowledgePurchaseParams.NewBuilder()
                .SetPurchaseToken(token)
                .Build();

            // Consume the Non-Consumable Product
            BillingResult result = await _billingClient.AcknowledgePurchaseAsync(acknowledgePurchaseParams);

            if (result == null)
            {
                // Failed to get result back.
                throw new InAppPurchaseException(PurchaseError.Unknown, "BillingResult is null");
            }

            if (result.ResponseCode != BillingResponseCode.Ok)
            {
                throw new InAppPurchaseException(
                          result.ResponseCode.ToPurchaseError(),
                          result.DebugMessage);
            }

            // Otherwise, the Acknowledgement succeeded.
        }
示例#15
0
 private static void OnProductConsumed(BillingResult result)
 {
     if (result.IsSuccess)
     {
         OnProcessingConsumeProduct(result.Purchase);
         Debug.Log("Successfull consume!");
     }
 }
示例#16
0
    public void OnQueryInventoryFinishedCallBack()
    {
        BillingResult result = new BillingResult(BillingResponseCodes.BILLING_RESPONSE_RESULT_OK, "BILLING_RESPONSE_RESULT_OK");

        _IsInventoryLoaded            = true;
        _IsProductRetrievingInProcess = false;

        ActionRetrieveProducsFinished(result);
    }
示例#17
0
	private static void OnRetrieveProductsFinised(BillingResult result) {
		AndroidInAppPurchaseManager.ActionRetrieveProducsFinished -= OnRetrieveProductsFinised;
		if(result.isSuccess) {
			UpdateStoreData();
			_isInited = true;
		} else {
			AndroidMessage.Create("Connection Responce", result.response.ToString() + " " + result.message);
		}
	}
示例#18
0
        /// <summary>
        /// Returns product info for the specified Ids
        /// </summary>
        /// <param name="productIds">Product Ids</param>
        /// <param name="productType">Product Type (either BillingClient.SkuType.Inapp or BillingClient.SkuType.Subs)</param>
        /// <returns></returns>
        public async Task <IEnumerable <Product> > LoadProductsAsync(string[] productIds, ProductType productType)
        {
            string skuType = GetBillingSkuType(productType);

            // Build the Sku Params
            SkuDetailsParams skuParams = SkuDetailsParams.NewBuilder()
                                         .SetSkusList(productIds)
                                         .SetType(skuType)
                                         .Build();

            // Query the Play store
            QuerySkuDetailsResult queryResult = await _billingClient.QuerySkuDetailsAsync(skuParams);

            BillingResult result = queryResult?.Result;

            if (result == null)
            {
                // Failed to get products. Set the Exception to the Task, so the caller can react to the issue
                throw new InAppPurchaseException(PurchaseError.Unknown, "BillingResult is null");
            }

            if (result.ResponseCode != BillingResponseCode.Ok)
            {
                PurchaseError purchaseError = result.ResponseCode.ToPurchaseError();
                // Failed to get products. Set the Exception to the Task, so the caller can react to the issue
                throw new InAppPurchaseException(purchaseError, result.DebugMessage);
            }

            // Wait till the products are received in the callback
            IList <SkuDetails> skuDetails = queryResult?.SkuDetails;

            if (skuDetails == null)
            {
                skuDetails = new List <SkuDetails>();
            }

            // Add more Skus to the Dictionary of SkuDetails
            // We need SkuDetails to initiate the Purchase
            foreach (SkuDetails sku in skuDetails)
            {
                _retrievedProducts.TryAdd(sku.Sku, sku);
            }

            // Return products
            return(skuDetails.Select(p => new Product
            {
                Name = p.Title,
                Description = p.Description,
                CurrencyCode = p.PriceCurrencyCode,
                FormattedPrice = p.Price,
                ProductId = p.Sku,
                MicrosPrice = p.PriceAmountMicros,
                LocalizedIntroductoryPrice = p.IntroductoryPrice,
                MicrosIntroductoryPrice = p.IntroductoryPriceAmountMicros
            }));
        }
示例#19
0
	private static void OnProductConsumed(BillingResult result) {
		
		if(result.isSuccess) {
			OnProcessingConsumeProduct (result.purchase);
		} else {
			AndroidMessage.Create("Product Cousume Failed", result.response.ToString() + " " + result.message);
		}
		
		Debug.Log ("Cousume Responce: " + result.response.ToString() + " " + result.message);
	}
示例#20
0
    public void Consume(string SKU)
    {
        GooglePurchaseTemplate purchase = null;

        purchase     = new GooglePurchaseTemplate();
        purchase.SKU = SKU;
        BillingResult result = new BillingResult(BillingResponseCodes.BILLING_RESPONSE_RESULT_OK, "BILLING_RESPONSE_RESULT_OK", purchase);

        ActionProductConsumed(result);
    }
示例#21
0
 public void OnBillingSetupFinished(BillingResult result)
 {
     Log.Debug(TAG, "OnBillingSetupFinished()");
     if (result.ResponseCode != BillingResponseCode.Ok)
     {
         Log.Debug(TAG, "Billing setup failed with code " + result.ResponseCode.ToString());
     }
     SkuDetailsParams.Builder details_builder = SkuDetailsParams.NewBuilder();
     details_builder.SetSkusList(skuList).SetType(BillingClient.SkuType.Inapp);
     billingClient.QuerySkuDetails(details_builder.Build(), this);
 }
示例#22
0
    private static void OnBillingConnected(BillingResult result)
    {
        AndroidInAppPurchaseManager.ActionBillingSetupFinished -= OnBillingConnected;

        if(result.isSuccess)
        {
            //Store connection is Successful. Next we loading product and customer purchasing details
            AndroidInAppPurchaseManager.instance.retrieveProducDetails();
            AndroidInAppPurchaseManager.ActionRetrieveProducsFinished += OnRetrieveProductsFinised;
        }
    }
示例#23
0
        /// <summary>
        /// Sku/Product details Handler
        /// </summary>
        /// <param name="billingResult"></param>
        /// <param name="skuDetails"></param>
        public void OnSkuDetailsResponse(BillingResult billingResult, IList <SkuDetails> skuDetails)
        {
            try
            {
                InAppBillingProducts = new List <InAppBillingProduct>();
                if (billingResult.ResponseCode == BillingResponseCode.Ok)
                {
                    // List<string> unavailableSkus = args.UnavailableSkus;
                    if (skuDetails?.Count > 0)
                    {
                        foreach (var product in skuDetails)
                        {
                            InAppBillingProducts.Add(new InAppBillingProduct
                            {
                                Description                = product.Description,
                                LocalizedPrice             = product.Price,
                                LocalizedIntroductoryPrice = product.IntroductoryPrice,
                                CurrencyCode               = product.PriceCurrencyCode,
                                MicrosIntroductoryPrice    = product.IntroductoryPriceAmountMicros,
                                MicrosPrice                = product.PriceAmountMicros,
                                ProductId                 = product.Sku,
                                Name                      = product.Title,
                                Type                      = product.Type,
                                IconUrl                   = product.IconUrl,
                                IsRewarded                = product.IsRewarded,
                                IntroductoryPrice         = product.IntroductoryPrice,
                                IntroductoryPriceCycles   = product.IntroductoryPriceCycles,
                                IntroductoryPricePeriod   = product.IntroductoryPricePeriod,
                                SubscriptionPeriod        = product.SubscriptionPeriod,
                                FreeTrialPeriod           = product.FreeTrialPeriod,
                                OriginalPrice             = product.OriginalPrice,
                                OriginalPriceAmountMicros = product.OriginalPriceAmountMicros
                            });
                        }

                        ProductToPurcase = skuDetails[0];
                    }
                }

                var errorCode = GetErrorCode(billingResult.ResponseCode);
                if (errorCode != null) //No error
                {
                    _tcsProducts?.TrySetException(errorCode);
                }
                else
                {
                    _tcsProducts?.TrySetResult(InAppBillingProducts);
                }
            }
            catch (Exception ex)
            {
                _tcsProducts?.TrySetException(ex);
            }
        }
示例#24
0
 private static void OnProductConsumed(BillingResult result)
 {
     if (result.isSuccess)
     {
         GUI_Shop.GetInstance().OnSuccessfulPurchase(result.purchase.SKU);
     }
     else
     {
     }
     Debug.LogError("OnProductConsumed " + result.response.ToString());
 }
	public void Connect() {
		if(AndroidNativeSettings.Instance.IsBase64KeyWasReplaced) {
			_IsConnectingToServiceInProcess = true;
			Connect(AndroidNativeSettings.Instance.base64EncodedPublicKey);
		} else {
			SA_EditorNotifications.ShowNotification("Billing Connection Failed", "Wrong Public Key", SA_EditorNotificationType.Error);

			BillingResult result = new BillingResult(BillingResponseCodes.BILLINGHELPER_MISSING_TOKEN, "Connection Failed");
			ActionBillingSetupFinished(result);
		}
	}
    private static void OnGooglePlayStoreBillingConnected(BillingResult result)
    {
        AndroidInAppPurchaseManager.ActionBillingSetupFinished -= OnGooglePlayStoreBillingConnected;


        if (result.isSuccess)
        {
        }

        Debug.Log("[IAPPurchaseController] Connection Response: " + result.response.ToString() + " " + result.message);
    }
示例#27
0
    public void OnBillingSetupFinishedCallback(string data)
    {
        string[] storeData;
        storeData = data.Split(AndroidNative.DATA_SPLITTER [0]);

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

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

        dispatch(ON_BILLING_SETUP_FINISHED, result);
    }
示例#28
0
    public void OnQueryInventoryFinishedCallBack(string data)
    {
        string[] storeData;
        storeData = data.Split(AndroidNative.DATA_SPLITTER [0]);

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

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

        dispatch(ON_RETRIEVE_PRODUC_FINISHED, result);
    }
    private static void OnGooglePlayStoreRetrieveProductsFinised(BillingResult result)
    {
        if (result.isSuccess)
        {
        }
        else
        {
            //AndroidMessage.Create("Connection Responce", result.response.ToString() + " " + result.message);
        }

        Debug.Log("[IAPPurchaseController] Connection Response: " + result.response.ToString() + " " + result.message);
    }
示例#30
0
 public void OnSkuDetailsResponse(BillingResult result, IList <SkuDetails> sku_list)
 {
     Log.Debug(TAG, "OnSkuDetailsResponse()");
     if (result.ResponseCode != BillingResponseCode.Ok)
     {
         Log.Debug(TAG, "SKU Detail setup failed with code " + result.ResponseCode.ToString());
         return;
     }
     skuDetails.AddRange(sku_list);
     skuDetails.Sort((p, q) => p.PriceAmountMicros.CompareTo(q.PriceAmountMicros));
     dispatcher.Post(new SwSystem.Messages.DonationUpdateMessage(SwSystem.Messages.DonationUpdateMessage.UpdateType.SetupComplete));
 }
	private static void OnProductPurchased(CEvent e) {
		BillingResult result = e.data as BillingResult;
		
		
		if(result.isSuccess) {
			OnProcessingPurchasedProduct (result.purchase);
		} else {
			AndroidMessage.Create("Product Purchase Failed", result.response.ToString() + " " + result.message);
		}
		
		Debug.Log ("Purchased Responce: " + result.response.ToString() + " " + result.message);
	}
示例#32
0
    private static void OnProductPurchased(BillingResult result)
    {
        if (result.IsSuccess)
        {
            OnProcessingPurchasedProduct(result.Purchase);

            AndroidMessage.Create(
                "Purchase",
                "Successfull purchase!",
                AndroidDialogTheme.ThemeHoloLight);
        }
    }
示例#33
0
        private void OnInitialized(BillingResult result)
        {
            this.products = new Dictionary <string, ProductDescription>();

            if (!result.IsSuccess)
            {
                OnSetupFailed(result.Response + ", " + result.Message);
                return;
            }

            AndroidInAppPurchaseManager.Client.RetrieveProducDetails();
        }
示例#34
0
    //purchasing events
    private void OnProductPurchased(BillingResult result)
    {
        if (result.IsSuccess)
        {
            OnProcessingPurchasedProduct(result.Purchase);
        }

        else
        {
            AndroidMessage.Create("Product Purchase Failed", result.Response.ToString() + " " + result.Message);
        }
    }
	private void OnRetrieveProductsFinised(BillingResult result) {
		Debug.Log("OnRetrieveProductsFinised");

		AndroidInAppPurchaseManager.ActionRetrieveProducsFinished -= OnRetrieveProductsFinised;
		
		if(result.isSuccess) {
			Debug.Log("OnRetrieveProductsFinised COMPLETE");
			ActionComplete();
		} else {
			Debug.Log("OnRetrieveProductsFinised FAILED");
			ActionFailed();
		}
	}
	private void OnBillingConnected(BillingResult result) {
		Debug.Log("OnBillingConnected");
		if(result == null) {
			OnBillingConnectFinished();
			return;
		}


		AndroidInAppPurchaseManager.ActionBillingSetupFinished -= OnBillingConnected;
		
		
		if(result.isSuccess) {
			OnBillingConnectFinished();
		}  else {
			Debug.Log("OnBillingConnected Failed");
			ActionFailed();
		}

	}
示例#37
0
	public static void OnProductConsumed(BillingResult result) {
		
		if(result.isSuccess) {
			try {
				ConsoleManager.getInstance ().addToExternalString ( "Consume succeeded: " + result.response.ToString() + " " + result.message );
			} catch {}
			OnProcessingConsumeProduct (result.purchase);
		} else {
			try {
				ConsoleManager.getInstance ().addToExternalString ( "Consume product failed: " + result.response.ToString() + " " + result.message );
			} catch {}
			
			_transactionInProgress = false;	
			
			Application.OpenURL ( "market://" );
			
			GoogleAnalytics.instance.LogScreen ( "Trasaction failed - product " + result.purchase.SKU );
		}
		
		Debug.Log ("Consume Response: " + result.response.ToString() + " " + result.message);
	}
示例#38
0
	public static void OnBillingConnected(BillingResult result) {
		
		ConsoleManager.getInstance ().addToExternalString ("Billing connection result");

//		AndroidInAppPurchaseManager.instance.removeEventListener (AndroidInAppPurchaseManager.ON_BILLING_SETUP_FINISHED, OnBillingConnected);
		
		
		if (result.isSuccess) {
			//Store connection is Successful. Next we loading product and customer purchasing details
			//AndroidInAppPurchaseManager.instance.addEventListener (AndroidInAppPurchaseManager.ON_RETRIEVE_PRODUC_FINISHED, OnRetriveProductsFinised);
			AndroidInAppPurchaseManager.instance.retrieveProducDetails ();

			billingSupported = true;
			try {
				ConsoleManager.getInstance ().addToExternalString ( "Billing supported." );
			} catch {}

	
		} else {
			billingSupported = false;
			
			try {
				ConsoleManager.getInstance ().addToExternalString ( "Billing not supported: " + result.response.ToString() + " " + result.message );
			} catch {}
			
			_transactionInProgress = false;
			
			if ( (result.response.ToString() + " " + result.message).Contains ( "3:Billing" ))
			{
				GameObject loginToGoogleAccountPopupScreen = ( GameObject ) Resources.Load ( "UI/Laboratory/noAccountUIScreen" );
				
				if ( FLUIControl.currentBlackOutUI )
				{
					FLUIControl.currentBlackOutUI.AddComponent < AlphaDisapearAndDestory > ();
					Destroy ( FLUIControl.currentBlackOutUI.GetComponent < BoxCollider > ());
					FLUIControl.getInstance ().putHeigherOrLowerCurrencyPanel ( false );
				}
				
				FLGlobalVariables.POPUP_UI_SCREEN = false;
				
				FLUIControl.getInstance ().createPopup ( loginToGoogleAccountPopupScreen, true );
				
				Application.OpenURL ( "market://" );
			}
			
			GoogleAnalytics.instance.LogScreen ( "Transaction failed");

		}
	}
	public void OnConsumeFinishedCallBack(string data) {
		string[] storeData;
		storeData = data.Split(AndroidNative.DATA_SPLITTER [0]);
		
		int resp = System.Convert.ToInt32 (storeData[0]);
		GooglePurchaseTemplate purchase = null;
		
		
		if(resp == BillingResponseCodes.BILLING_RESPONSE_RESULT_OK) {
			purchase = new GooglePurchaseTemplate ();
			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.removePurchase (purchase);
			}
			
		}
		
		BillingResult result = new BillingResult (resp, storeData [1], purchase);
		
		ActionProductConsumed(result);
	}
示例#40
0
	public static void OnProductPurchased(BillingResult result) {
		
		//this flag will tell you if purchase is avaliable
		//result.isSuccess
		
		
		//infomation about purchase stored here
		//result.purchase
		
		//here is how for example you can get product SKU
		//result.purchase.SKU
		
		
		if(result.isSuccess) {
			_transactionInProgress = false;
			try {
				ConsoleManager.getInstance ().addToExternalString ( "Purchase suceeded: " + result.response.ToString() + " " + result.message );
			} catch {}
			OnProcessingPurchasedProduct (result.purchase);
		} else {
			try {
				ConsoleManager.getInstance ().addToExternalString ( "Purchase failed: " + result.response.ToString() + " " + result.message );
			} catch {}
			
			_transactionInProgress = false;
			
			Application.OpenURL ( "market://" );
			
			GoogleAnalytics.instance.LogScreen ( "Trasaction failed - product " + result.purchase.SKU );
		}
	}
	//--------------------------------------
	// 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);
	}
	public void OnBillingSetupFinishedCallback(string data) {
		string[] storeData;
		storeData = data.Split(AndroidNative.DATA_SPLITTER [0]);
		
		int resp = System.Convert.ToInt32 (storeData[0]);
		
		

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

		if(result.isSuccess) {
			_IsConnected = true;
		}
		_IsConnectingToServiceInProcess = false;
		
		AN_SoomlaGrow.SetPurhsesSupportedState(result.isSuccess);
		
		ActionBillingSetupFinished(result);
	}
	private static void OnProductConsumed(BillingResult result) {
		
		if(result.IsSuccess) {
			OnProcessingConsumeProduct (result.Purchase);
		} else {
			AndroidMessage.Create("Product Cousume Failed", result.Response.ToString() + " " + result.Message);
		}
		
		Debug.Log ("Cousume Responce: " + result.Response.ToString() + " " + result.Message);
	}
	public void Consume(string SKU) {

		GooglePurchaseTemplate purchase = null;
		purchase = new GooglePurchaseTemplate ();
		purchase.SKU = _CurrentSKU;
		BillingResult result = new BillingResult(BillingResponseCodes.BILLING_RESPONSE_RESULT_OK, "BILLING_RESPONSE_RESULT_OK", purchase);

		ActionProductConsumed(result);
	}
	static void HandleActionRetrieveProducsFinished (BillingResult res) {
		ActionRetrieveProducsFinished(res);
	}
	public void OnQueryInventoryFinishedCallBack(string data) {
		string[] storeData;
		storeData = data.Split(AndroidNative.DATA_SPLITTER [0]);
		
		int resp = System.Convert.ToInt32 (storeData[0]);
		
		BillingResult result = new BillingResult (resp, storeData [1]);
		
		_IsInventoryLoaded = true;
		_IsProductRetrievingInProcess = false;
		
		ActionRetrieveProducsFinished(result);
	}
	static void HandleActionProductPurchased (BillingResult res) {
		ActionProductPurchased(res);
	}
	static void HandleActionProductConsumed (BillingResult res) {
		ActionProductConsumed(res);
	}
	static void HandleActionBillingSetupFinished (BillingResult res) {
		ActionBillingSetupFinished(res);
	}
示例#50
0
	public static void OnRetriveProductsFinised(BillingResult result) {
//		AndroidInAppPurchaseManager.instance.removeEventListener (AndroidInAppPurchaseManager.ON_RETRIEVE_PRODUC_FINISHED, OnRetriveProductsFinised);
		
		if(result.isSuccess) {
			
			UpdateStoreData();
			
			try {
				ConsoleManager.getInstance ().addToExternalString ( "Product list received successfully:" + result.response.ToString() + " " + result.message);
			} catch {}
			
			
		} else {
			try {
				ConsoleManager.getInstance ().addToExternalString ( "Product list retrieval failed: " + result.response.ToString() + " " + result.message );
			} catch {}
		}
		
	}
	private static void OnRetrieveProductsFinised(BillingResult result) {
		AndroidInAppPurchaseManager.ActionRetrieveProducsFinished -= OnRetrieveProductsFinised;
		if(result.IsSuccess) {
			UpdateStoreData();
			_isInited = true;
		} else {
			AndroidMessage.Create("Connection Responce", result.Response.ToString() + " " + result.Message);
		}
	}
	private void OnPurchaseComplete(bool IsSucceeded) {

		GooglePurchaseTemplate purchase = null;
		
		BillingResult result;

		if(IsSucceeded) {
			purchase = new GooglePurchaseTemplate ();
			purchase.SKU = _CurrentSKU;

			result = new BillingResult(BillingResponseCodes.BILLING_RESPONSE_RESULT_OK, "BILLING_RESPONSE_RESULT_OK", purchase);
		} else {
			result = new BillingResult(BillingResponseCodes.BILLINGHELPERR_USER_CANCELLED, "BILLINGHELPERR_USER_CANCELLED");
		}

		ActionProductPurchased(result);
	}
	private void GenerateConnectionResult() {

		bool IsSucceeded = SA_EditorTesting.HasFill(_RequestsSuccessRate);

		BillingResult result;
		if(IsSucceeded) {
			_IsConnected = true;
			result = new BillingResult(BillingResponseCodes.BILLING_RESPONSE_RESULT_OK, "Connection Successful");
			SA_EditorNotifications.ShowNotification("Billing Connected", "Connection successful", SA_EditorNotificationType.Message);
		} else {
			result = new BillingResult(BillingResponseCodes.BILLINGHELPER_UNKNOWN_ERROR, "Connection Failed");
			SA_EditorNotifications.ShowNotification("Billing Connection Failed", "Connection Failed", SA_EditorNotificationType.Error);
		}

		_IsConnectingToServiceInProcess = false;
		ActionBillingSetupFinished(result);
	}
	private static void OnProductPurchased(BillingResult result) {

		//this flag will tell you if purchase is available
		//result.isSuccess


		//infomation about purchase stored here
		//result.purchase

		//here is how for example you can get product SKU
		//result.purchase.SKU

		
		if(result.IsSuccess) {
			OnProcessingPurchasedProduct (result.Purchase);
		} else {
			AndroidMessage.Create("Product Purchase Failed", result.Response.ToString() + " " + result.Message);
		}
		
		Debug.Log ("Purchased Responce: " + result.Response.ToString() + " " + result.Message);
	}
示例#55
0
    private static void OnProductPurchased(BillingResult result)
    {
        if(result.isSuccess) {
            AndroidMessage.Create ("Product Purchased", result.purchase.SKU+ "\n Full Response: " + result.purchase.originalJson);
            OnProcessingPurchasedProduct (result.purchase);
        } else {
            AndroidMessage.Create("Product Purchase Failed", result.response.ToString() + " " + result.message);
        }

        Debug.Log ("Purchased Responce: " + result.response.ToString() + " " + result.message);
        Debug.Log (result.purchase.originalJson);
    }
	private static void OnBillingConnected(BillingResult result) {

		AndroidInAppPurchaseManager.ActionBillingSetupFinished -= OnBillingConnected;
		
		
		if(result.IsSuccess) {
			//Store connection is Successful. Next we loading product and customer purchasing details
			AndroidInAppPurchaseManager.ActionRetrieveProducsFinished += OnRetrieveProductsFinised;
			AndroidInAppPurchaseManager.Client.RetrieveProducDetails();

		} 
		
		AndroidMessage.Create("Connection Responce", result.Response.ToString() + " " + result.Message);
		Debug.Log ("Connection Responce: " + result.Response.ToString() + " " + result.Message);
	}
示例#57
0
    private static void OnRetrieveProductsFinised(BillingResult result)
    {
        AndroidInAppPurchaseManager.ActionRetrieveProducsFinished -= OnRetrieveProductsFinised;

        if(result.isSuccess) {
            _isInited = true;
            AndroidMessage.Create("Success", "Billing init complete inventory contains: " + AndroidInAppPurchaseManager.instance.inventory.purchases.Count + " products");

            Debug.Log("Loaded products names");
            foreach(GoogleProductTemplate tpl in AndroidInAppPurchaseManager.instance.inventory.products) {
                Debug.Log(tpl.title);
                Debug.Log(tpl.originalJson);
            }
        } else {
             AndroidMessage.Create("Connection Responce", result.response.ToString() + " " + result.message);
        }

        Debug.Log ("Connection Responce: " + result.response.ToString() + " " + result.message);
    }
	public void OnQueryInventoryFinishedCallBack() {

		BillingResult result = new BillingResult(BillingResponseCodes.BILLING_RESPONSE_RESULT_OK, "BILLING_RESPONSE_RESULT_OK");
		_IsInventoryLoaded = true;
		_IsProductRetrievingInProcess = false;
		
		ActionRetrieveProducsFinished(result);
	}
示例#59
0
 public Recency FromBillingResult(BillingResult billingResult)
 {
     return billingResult.Paid ? Recency.UpToDate() : IncreaseRecency();
 }