/// <summary>
        /// Get purchases details for all the items bought within your app.
        /// This method uses a cache of Google Play Store app without initiating a network request.
        ///
        /// Note: It's recommended for security purposes to go through purchases verification on your backend
        /// (if you have one) by calling one of the following APIs:
        /// <see>
        ///     <cref>https://developers.google.com/android-publisher/api-ref/purchases/products/get</cref>
        /// </see>
        /// <see>
        ///     <cref>https://developers.google.com/android-publisher/api-ref/purchases/subscriptions/get</cref>
        /// </see>
        /// </summary>
        /// <param name="skuType"></param>
        /// <returns></returns>
        public AN_Purchase.PurchasesResult QueryPurchases(SkuType skuType)
        {
            var resultJSON = AN_Java.Bridge.CallStatic <string>(
                k_NativeBillingClient,
                "QueryPurchases",
                HashCode,
                skuType.ToString());

            var result = JsonUtility.FromJson <AN_Purchase.PurchasesResult>(resultJSON);

            return(result);
        }
Beispiel #2
0
        private void QuerySkuDetailsForSkuType(ReadOnlyCollection <ProductDefinition> products,
                                               SkuType skuType)
        {
            var skuDetailsParamBuilder = new AndroidJavaObject(Constants.SkuDetailsParamBuilder);

            string[] skuIds = { };
            if (skuType == SkuType.InApp)
            {
                skuIds = products.Where(p => p.type == ProductType.Consumable || p.type == ProductType.NonConsumable)
                         .Select(p => p.storeSpecificId).ToArray();
            }
            else if (skuType == SkuType.Subs)
            {
                skuIds = products.Where(p => p.type == ProductType.Subscription).Select(p => p.storeSpecificId)
                         .ToArray();
            }
            else
            {
                throw new NotImplementedException(String.Format("Unsupported Google Play Store skuType {0}.", skuType));
            }

            // Set the SkuDetails request status to success state if the list is empty.
            if (!skuIds.Any())
            {
                _billingClientQuerySkuDetailsCallStatus[skuType] = AsyncRequestStatus.Succeed;
                NotifyUnityRetrieveProductsResults();
                return;
            }

            skuDetailsParamBuilder.Call <AndroidJavaObject>(Constants.SkuDetailsParamBuilderSetSkuListMethod,
                                                            JniUtils.CreateJavaArrayList(skuIds));
            skuDetailsParamBuilder.Call <AndroidJavaObject>(Constants.SkuDetailsParamBuilderSetTypeMethod,
                                                            skuType.ToString());
            var skuDetailsParam =
                skuDetailsParamBuilder.Call <AndroidJavaObject>(Constants.BuildMethod);
            var skuDetailsResponseListener = new SkuDetailsResponseListener(skuType);

            skuDetailsResponseListener.OnSkuDetailsResponse += ParseSkuDetailsResults;
            _billingClient.Call(Constants.QuerySkuDetailsMethod, skuDetailsParam,
                                skuDetailsResponseListener);
        }
        public static long GetMaxMemoryThresholdMB(SkuType sku)
        {
            long num;

            switch (sku)
            {
            case SkuType.Express:
            case SkuType.Workgroup:
                num = 4L;
                break;

            case SkuType.Standard:
            case SkuType.Web:
            case SkuType.SBS:
                num = 64L;
                break;

            default:
                throw new ArgumentException("sku", sku.ToString());
            }
            return(num * 1024);
        }
        public static void GetConcurrencyLimit(SkuType sku, out long maxPhysicalCpu, out long maxCores, out long minLogicalCpu)
        {
            minLogicalCpu = 0L;
            switch (sku)
            {
            case SkuType.Express:
                maxPhysicalCpu = 1L;
                maxCores       = 4L;
                break;

            case SkuType.Web:
                maxPhysicalCpu = 4L;
                maxCores       = 16L;
                break;

            case SkuType.Standard:
                maxPhysicalCpu = 4L;
                maxCores       = 24L;
                break;

            case SkuType.Developer:
            case SkuType.Evaluation:
            case SkuType.BusinessIntelligence:
            case SkuType.EnterpriseCore:
                maxPhysicalCpu = 0L;
                maxCores       = 0L;
                break;

            case SkuType.Enterprise:
                maxPhysicalCpu = 20L;
                maxCores       = 20L;
                break;

            default:
                throw new ArgumentException("sku", sku.ToString());
            }
        }
Beispiel #5
0
        private BillingResponseCode QueryPurchasesForSkuType(SkuType skuType)
        {
            var purchasesResult =
                _billingClient.Call <AndroidJavaObject>(Constants.QueryPurchasesMethod, skuType.ToString());

            _inventory.UpdatePurchaseInventory(_jniUtils.ParseQueryPurchasesResult(purchasesResult));
            return(_jniUtils.GetResponseCodeFromQueryPurchasesResult(purchasesResult));
        }