Esempio n. 1
0
        public IConfigData Clone()
        {
            IAPConfigData c = new IAPConfigData();

            c.id             = id;
            c.name           = name;
            c.description    = description;
            c.iapData        = iapData.Clone() as List <IAPData>;
            c.consumable     = consumable;
            c.noAdsIap       = noAdsIap;
            c.isSubscription = isSubscription;

            return(c);
        }
        public override void Execute()
        {
            _iapId = purchaseResult.purchasedItem.id;

            logger.Log(Tag, "IAP id: " + _iapId);

            if (purchaseResult.result == PurchaseIAPResultCode.Success)
            {
                IAPConfigData iapConfig = iapConfigModel.GetIAPByPurchaseId(_iapId);
                _purchasedItem = itemConfigModel.GetItemByIapConfigId(iapConfig.id);

                if (_purchasedItem == null)
                {
                    logger.LogError(Tag, "Could not find item config id for iap + " + _iapId);
                    Fail();
                    return;
                }

                CollectPurchasedItem();

                if (DidPurchasedNoAds())
                {
                    logger.Log(Tag, "PurchaseNoAdsCommand of " + _purchasedItem);

                    settingsStateModel.SetNoAds();
                    bannerAds.Hide();
                }

                EnablePromotionEligibility();
            }
            else
            {
                logger.Log(Tag, "Purchase failed");
                Fail();
            }

            iapPurchaseDoneSignal.Dispatch(purchaseResult);
        }
Esempio n. 3
0
        private void BuyItemByIAP(string itemId, Promise <BuyItemResult> promise)
        {
            ItemConfigData itemData = itemConfigModel.GetItem(itemId);

            IAPConfigData iapData = iapConfigModel.GetIAP(itemData.iapConfigId);

            if (iapData == null)
            {
                logger.LogError(Tag, ".PurchaseItemByIAP - Could not find iap data for item : " + itemData.id);
                promise.Resolve(new BuyItemResult(BuyItemResultCode.Error));
            }

            if (IsPurchaseInProgress)
            {
                logger.Log(Tag, ".PurchaseItemByIAP - Purchase is in progress - ignoring new purchase request for item : " + itemData.id);
                promise.Resolve(new BuyItemResult(BuyItemResultCode.Error));
            }
            else
            {
                iapPurchaseDoneSignal.AddOnce(iapResult => HandleIapResult(iapResult, promise));

                requestPurchaseInAppItemSignal.Dispatch(iapData);
            }
        }