Exemplo n.º 1
0
        private void ObtainProductInfo(IList <string> productIdNonConsumablesList, int priceType)
        {
            if (iapAvailable != true)
            {
                OnObtainProductInfoFailure?.Invoke(IAP_NOT_AVAILABLE);
                return;
            }

            ProductInfoReq productInfoReq = new ProductInfoReq
            {
                PriceType  = priceType,
                ProductIds = productIdNonConsumablesList
            };

            iapClient.ObtainProductInfo(productInfoReq).AddOnSuccessListener((type) =>
            {
                Debug.Log("[HMSPlugin]:" + type.ErrMsg + type.ReturnCode.ToString());
                Debug.Log("[HMSPlugin]: {0=Consumable}  {1=Non-Consumable}  {2=Subscription}");
                Debug.Log("[HMSPlugin]: Found " + type.ProductInfoList.Count + " type of " + priceType + " products");
                OnObtainProductInfoSuccess?.Invoke(new List <ProductInfoResult> {
                    type
                });
            }).AddOnFailureListener((exception) =>
            {
                Debug.Log("[HMSPlugin]: ERROR non  Consumable ObtainInfo" + exception.Message);
                OnObtainProductInfoFailure?.Invoke(exception);
            });
        }
Exemplo n.º 2
0
        public void ObtainProductSubscriptionInfo(IList <string> productIdSubscriptionList)
        {
            if (iapAvailable != true)
            {
                OnObtainProductInfoFailure?.Invoke(IAP_NOT_AVAILABLE);
                return;
            }

            ProductInfoReq productInfoReq = new ProductInfoReq
            {
                PriceType  = 2,
                ProductIds = productIdSubscriptionList
            };

            iapClient.ObtainProductInfo(productInfoReq).AddOnSuccessListener((type2) =>
            {
                Debug.Log("[HMSPlugin]:" + type2.ErrMsg + type2.ReturnCode.ToString());
                Debug.Log("[HMSPlugin]: Found " + type2.ProductInfoList.Count + "consumable products");
                OnObtainProductInfoSuccess?.Invoke(new List <ProductInfoResult> {
                    type2
                });
            }).AddOnFailureListener((exception) =>
            {
                Debug.Log("[HMSPlugin]: ERROR Consumable ObtainInfo" + exception.Message);
                OnObtainProductInfoFailure?.Invoke(exception);
            });
        }
Exemplo n.º 3
0
        private void CreateProductRequest(List <string> consumablesIDs, HuaweiConstants.IAP.IapType type, System.Action onSuccess)
        {
            var productsDataRequest = new ProductInfoReq();

            productsDataRequest.PriceType  = (int)type;
            productsDataRequest.ProductIds = consumablesIDs;

            var task = iapClient.ObtainProductInfo(productsDataRequest);

            task.AddOnFailureListener(GetProductsFailure);
            task.AddOnSuccessListener((result) => { ParseProducts(result, type.ToString()); onSuccess(); });
        }
        private void QueryProducts(List <string> productIds)
        {
            Log.Info(TAG, "QueryProducts");
            ProductInfoReq req = new ProductInfoReq();

            req.PriceType  = IapClientPriceType.InAppSubscription;
            req.ProductIds = productIds;

            Task task = mClient.ObtainProductInfo(req);

            task.AddOnSuccessListener(new QueryProductListenerImp(this.view)).AddOnFailureListener(new QueryProductListenerImp(this.view));
        }
    // TODO Obtain non-consumables too!
    public void ObtainProductInfo(IList <string> productIdConsumablesList = null)
    {
        if (iapAvailable != true)
        {
            OnObtainProductInfoFailure?.Invoke(IAP_NOT_AVAILABLE);
            return;
        }

        ProductInfoReq productInfoReq = new ProductInfoReq
        {
            PriceType  = 0,
            ProductIds = productIdConsumablesList
        };

        iapClient.ObtainProductInfo(productInfoReq).AddOnSuccessListener((type0) =>
        {
            Debug.Log("[HMSPlugin]:" + type0.ErrMsg + type0.ReturnCode.ToString());
            Debug.Log("[HMSPlugin]: Found " + type0.ProductInfoList.Count + "consumable products");

            productInfoReq = new ProductInfoReq
            {
                PriceType  = 1,
                ProductIds = productIdConsumablesList
            };

            iapClient.ObtainProductInfo(productInfoReq).AddOnSuccessListener((type1) =>
            {
                Debug.Log("[HMSPlugin]:" + type1.ErrMsg + type1.ReturnCode.ToString());
                Debug.Log("[HMSPlugin]: Found " + type1.ProductInfoList.Count + "consumable products");

                productInfoReq = new ProductInfoReq
                {
                    PriceType  = 0,
                    ProductIds = productIdConsumablesList
                };

                OnObtainProductInfoSuccess?.Invoke(new List <ProductInfoResult> {
                    type0, type1
                });
            }).AddOnFailureListener((exception) =>
            {
                Debug.Log("[HMSPlugin]: ERROR Houston!!" + exception.Message);
                OnObtainProductInfoFailure?.Invoke(exception);
            });
        }).AddOnFailureListener((exception) =>
        {
            Debug.Log("[HMSPlugin]: ERROR Houston!!" + exception.Message);
            OnObtainProductInfoFailure?.Invoke(exception);
        });
    }
Exemplo n.º 6
0
    protected void InitIAP()
    {
        foreach (Product product in products)
        {
            if (product.isConsumable)
            {
                productIdConsumablesList.Add(product.productID);
            }
        }

        ProductInfoReq productInfoReq = new ProductInfoReq();



        // CONSUMABLE REQUEST
        productInfoReq.PriceType = 0;

        productInfoReq.ProductIds = productIdConsumablesList;

        ITask <ProductInfoResult> task = iapClient.ObtainProductInfo(productInfoReq);

        Debug.Log(task.Result);

        task.AddOnSuccessListener((result) =>
        {
            if (result != null)
            {
                if (result.ProductInfoList.Count != 0)
                {
                    Debug.Log("[HMSPlugin]:" + result.ErrMsg + result.ReturnCode.ToString());
                    Debug.Log("[HMSPlugin]: Found " + result.ProductInfoList.Count + "consumable products");
                    foreach (ProductInfo productInfo in result.ProductInfoList)
                    {
                        Debug.Log("[HMSPlugin]: " + productInfo.ProductName + "," + productInfo.Price);
                        productInfoList.Add(productInfo);
                    }
                }
            }
            loadedEvent.Invoke();
        }).AddOnFailureListener((exception) =>
        {
            Debug.Log("[HMSPlugin]: ERROR Houston!!" + exception.Message);
        });



        RestorePurchases();
        ObtainOwnedPurchases();
    }
Exemplo n.º 7
0
        private void QueryProducts()
        {
            Log.Info(TAG, "QueryProducts");
            List <String> productIds = new List <String>();

            productIds.Add(HIDDEN_LEVEL_PRODUCTID);
            ProductInfoReq req = new ProductInfoReq();

            req.PriceType  = IapClientPriceType.InAppNonconsumable;
            req.ProductIds = productIds;

            Task task = mClient.ObtainProductInfo(req);

            task.AddOnSuccessListener(new QueryProductListenerImp(this)).AddOnFailureListener(new QueryProductListenerImp(this));
        }
        private void QueryProducts()
        {
            Log.Info(TAG, "QueryProducts");
            List <String> productIdList = new List <String>();

            //Add the product ID that has been created in AppGallery console
            productIdList.Add("ProductCons1");

            ProductInfoReq req = new ProductInfoReq();

            req.PriceType  = IapClientPriceType.InAppConsumable;
            req.ProductIds = productIdList;

            Task task = Iap.GetIapClient(this).ObtainProductInfo(req);

            task.AddOnSuccessListener(new QueryProductListenerImp(this)).AddOnFailureListener(new QueryProductListenerImp(this));
        }
Exemplo n.º 9
0
    private void RestorePurchases()
    {
        foreach (Product product in products)
        {
            if (!product.isConsumable)
            {
                productIdConsumablesList.Add(product.productID);
            }
        }

        ProductInfoReq productInfoReq = new ProductInfoReq();


        // NON CONSUMABLE REQUEST
        productInfoReq.PriceType  = 1;
        productInfoReq.ProductIds = productIdConsumablesList;

        ITask <ProductInfoResult> task = iapClient.ObtainProductInfo(productInfoReq);

        task.AddOnSuccessListener((result) =>
        {
            Debug.Log("HMSPlugin: NON consumables result success");
            if (result != null && result.ProductInfoList.Count != 0)
            {
                Debug.Log("[HMSPlugin]:" + result.ErrMsg + result.ReturnCode.ToString());
                Debug.Log("[HMSPlugin]: Found " + result.ProductInfoList.Count + "non consumable products");
                foreach (ProductInfo productInfo in result.ProductInfoList)
                {
                    Debug.Log("[HMSPlugin]: " + productInfo.ProductName + "," + productInfo.Price);
                    productInfoList.Add(productInfo);
                }
            }
        }).AddOnFailureListener((exception) =>
        {
            Debug.Log("[HMSPlugin]: ERROR Houston!!" + exception.Message);
        });
    }
Exemplo n.º 10
0
        private void ObtainProductInfo(IList <string> productIdNonConsumablesList, PriceType priceType)
        {
            if (iapAvailable != true)
            {
                OnObtainProductInfoFailure?.Invoke(IAP_NOT_AVAILABLE);
                return;
            }

            ProductInfoReq productInfoReq = new ProductInfoReq
            {
                PriceType  = priceType,
                ProductIds = productIdNonConsumablesList
            };

            iapClient.ObtainProductInfo(productInfoReq).AddOnSuccessListener((type) =>
            {
                Debug.Log("[HMSIAPManager]:" + type.ErrMsg + type.ReturnCode.ToString());
                Debug.Log("[HMSIAPManager]: {0=Consumable}  {1=Non-Consumable}  {2=Subscription}");
                Debug.Log("[HMSIAPManager]: Found " + type.ProductInfoList.Count + " type of " + priceType.Value + " products");
                foreach (var productInfo in type.ProductInfoList)
                {
                    if (!productInfoList.Exists(c => c.ProductId == productInfo.ProductId))
                    {
                        productInfoList.Add(productInfo);
                    }
                    Debug.Log("[HMSIAPManager]: ProductId: " + productInfo.ProductId + ", ProductName: " + productInfo.ProductName + ", Price: " + productInfo.Price);
                }

                OnObtainProductInfoSuccess?.Invoke(new List <ProductInfoResult> {
                    type
                });
            }).AddOnFailureListener((exception) =>
            {
                Debug.LogError("[HMSIAPManager]: ObtainProductInfo failed. CauseMessage: " + exception.WrappedCauseMessage + ", ExceptionMessage: " + exception.WrappedExceptionMessage);
                OnObtainProductInfoFailure?.Invoke(exception);
            });
        }