public bool FindAvailableIAP(TargetedBundleVO offerVO, out string currentIapId, out string offerCost)
        {
            bool            result         = false;
            IDataController dataController = Service.Get <IDataController>();

            currentIapId = string.Empty;
            offerCost    = string.Empty;
            InAppPurchaseController inAppPurchaseController = Service.Get <InAppPurchaseController>();
            int i     = 0;
            int count = offerVO.LinkedIAPs.Count;

            while (i < count)
            {
                string uid = offerVO.LinkedIAPs[i];
                InAppPurchaseTypeVO optional = dataController.GetOptional <InAppPurchaseTypeVO>(uid);
                if (optional != null)
                {
                    InAppPurchaseProductInfo iAPProduct = inAppPurchaseController.GetIAPProduct(optional.ProductId);
                    if (iAPProduct != null)
                    {
                        currentIapId = optional.ProductId;
                        offerCost    = iAPProduct.FormattedRealCost;
                        result       = true;
                        break;
                    }
                }
                i++;
            }
            return(result);
        }
Пример #2
0
    public void OnInitialized(IStoreController controller, IExtensionProvider extensions)
    {
        this.m_StoreController        = controller;
        this.m_StoreExtensionProvider = extensions;
        List <InAppPurchaseProductInfo> list = new List <InAppPurchaseProductInfo>();

        Product[] all = controller.products.all;
        for (int i = 0; i < all.Length; i++)
        {
            Product product = all[i];
            InAppPurchaseProductInfo inAppPurchaseProductInfo = new InAppPurchaseProductInfo();
            inAppPurchaseProductInfo.AppStoreId        = product.definition.storeSpecificId;
            inAppPurchaseProductInfo.Name              = product.metadata.localizedTitle;
            inAppPurchaseProductInfo.FormattedRealCost = product.metadata.localizedPriceString;
            inAppPurchaseProductInfo.RealCost          = Regex.Replace(inAppPurchaseProductInfo.FormattedRealCost, "[^\\s,.0-9]", "");
            list.Add(inAppPurchaseProductInfo);
        }
        Debug.Log("Billing initialized");
        Service.Get <InAppPurchaseController>().OnGetInfoForProducts(list);
    }