void onSkuDetailsResponse(AndroidJavaObject billingResult, AndroidJavaObject skuDetails)
 {
     m_Util.RunOnMainThread(() =>
     {
         var skuDetailsList = skuDetails.Enumerate <AndroidJavaObject>().ToList();
         m_OnSkuDetailsResponse(new GoogleBillingResult(billingResult), skuDetailsList);
     });
 }
        void FillPurchases(AndroidJavaObject purchaseResult, IGoogleCachedQuerySkuDetailsService cachedQuerySkuDetailsService)
        {
            AndroidJavaObject purchaseList = purchaseResult.Call <AndroidJavaObject>("getPurchasesList");

            var purchases = purchaseList.Enumerate <AndroidJavaObject>().ToList();

            for (var index = 0; index < purchases.Count; index++)
            {
                var purchase = purchases[index];
                if (purchase != null)
                {
                    m_Purchases.Add(GooglePurchaseHelper.MakeGooglePurchase(cachedQuerySkuDetailsService.GetCachedQueriedSkus().ToList(), purchase));
                }
                else
                {
                    Debug.LogWarning("Failed to retrieve Purchase from Purchase List at index " + index + " of " + purchases.Count + ". FillPurchases will skip this item");
                }
            }
        }
Exemple #3
0
        void onPurchasesUpdated(AndroidJavaObject billingResult, AndroidJavaObject javaPurchasesList)
        {
            IGoogleBillingResult result = new GoogleBillingResult(billingResult);
            var purchases = javaPurchasesList.Enumerate <AndroidJavaObject>();

            if (result.responseCode == GoogleBillingResponseCode.Ok)
            {
                HandleResultOkCases(result, purchases);
            }
            else if (result.responseCode == GoogleBillingResponseCode.UserCanceled && purchases.Any())
            {
                ApplyOnPurchases(purchases, OnPurchaseCanceled);
            }
            else if (result.responseCode == GoogleBillingResponseCode.ItemAlreadyOwned && purchases.Any())
            {
                ApplyOnPurchases(purchases, OnPurchaseAlreadyOwned);
            }
            else
            {
                HandleErrorCases(result, purchases);
            }
        }