Example #1
0
        public void HandleReceiptVerificationResponse(string uid, string transactionId, string currencyCode, double price, double bonusMultiplier, bool isPromo, string offerUid, CrateData crateData)
        {
            CurrentPlayer        currentPlayer        = Service.CurrentPlayer;
            StaticDataController staticDataController = Service.StaticDataController;
            InAppPurchaseTypeVO  inAppPurchaseTypeVO  = staticDataController.Get <InAppPurchaseTypeVO>(uid);

            if (inAppPurchaseTypeVO.IsPromo)
            {
                isPromo = true;
            }
            bool   flag = !string.IsNullOrEmpty(offerUid);
            string text = inAppPurchaseTypeVO.RewardEmpire;

            if (currentPlayer.Faction == FactionType.Rebel)
            {
                text = inAppPurchaseTypeVO.RewardRebel;
            }
            if (string.IsNullOrEmpty(text) && !flag)
            {
                Service.Logger.Error("MoneyReceiptVerifyResponse:" + inAppPurchaseTypeVO.Uid + " faction specific reward uids do not exist");
                return;
            }
            bool             flag2            = false;
            TargetedBundleVO targetedBundleVO = null;

            if (flag)
            {
                targetedBundleVO = staticDataController.GetOptional <TargetedBundleVO>(offerUid);
                if (targetedBundleVO != null)
                {
                    Service.TargetedBundleController.GrantTargetedBundleRewards(targetedBundleVO);
                    flag2 = true;
                }
                else
                {
                    Service.Logger.Error("MoneyReceiptVerifyResponse: targeted offer " + offerUid + " does not exist");
                }
            }
            else
            {
                RewardVO optional = staticDataController.GetOptional <RewardVO>(text);
                if (optional == null)
                {
                    Service.Logger.Error("MoneyReceiptVerifyResponse:" + text + " does not exist");
                }
                else if (inAppPurchaseTypeVO.CurrencyType.Equals("hard"))
                {
                    RewardUtils.GrantReward(currentPlayer, optional, bonusMultiplier);
                }
                else
                {
                    RewardUtils.GrantInAppPurchaseRewardToHQInventory(optional);
                }
            }
            if (inAppPurchaseTypeVO.ProductId.Contains("promo"))
            {
                isPromo = true;
            }
            int amount;

            if (inAppPurchaseTypeVO.CurrencyType.Equals("hard"))
            {
                amount = (int)Math.Floor(bonusMultiplier * (double)inAppPurchaseTypeVO.Amount);
            }
            else
            {
                amount = inAppPurchaseTypeVO.Amount;
            }
            this.Consume(inAppPurchaseTypeVO.ProductId);
            string     text2             = uid;
            bool       flag3             = false;
            SaleTypeVO currentActiveSale = SaleUtils.GetCurrentActiveSale();

            if (currentActiveSale != null && !isPromo)
            {
                text2 = text2 + "_" + currentActiveSale.Uid;
            }
            if (isPromo)
            {
                text2 += "_promo";
                flag3  = true;
            }
            if (GameConstants.IAP_FORCE_POPUP_ENABLED)
            {
                flag3 = true;
            }
            if (flag2)
            {
                Service.TargetedBundleController.HandleTargetedOfferSuccess(crateData, targetedBundleVO);
            }
            else if (flag3)
            {
                this.ShowRedemptionScreen(amount, uid);
                Service.EventManager.SendEvent(EventId.InAppPurchaseMade, null);
            }
            Service.DMOAnalyticsController.LogPaymentAction(currencyCode, price, inAppPurchaseTypeVO.ProductId, 1, text2);
        }