GetProject() public method

public GetProject ( ) : XsollaProject
return XsollaProject
Ejemplo n.º 1
0
        public void InitScreen(XsollaUtils pUtils)
        {
            // set title
            _titleProj.text = pUtils.GetProject().name;

            // user name
            _userName.text = pUtils.GetUser().GetName();

            if (pUtils.GetUser().virtualCurrencyBalance != null)
            {
                AddUserMenuBtn(pUtils.GetTranslations().Get("user_menu_balance"), ShowHistory);
                _pMenuBtnComponent.enabled = true;
            }

            if (!pUtils.IsServerLess())
            {
                AddUserMenuBtn(pUtils.GetTranslations().Get("user_menu_payment_accounts"), ShowPaymentManager);
            }

            if (pUtils.GetProject().components.ContainsKey("subscriptions"))
            {
                AddUserMenuBtn(pUtils.GetTranslations().Get("user_menu_user_subscription"), ShowSubscriptionManager);
            }

            if (pUtils.IsServerLess())
            {
                _userName.color            = StyleManager.Instance.GetColor(StyleManager.BaseColor.disable_user_menu);
                _pMenuBtnComponent.enabled = false;
                mDropIcon.gameObject.SetActive(false);
            }
        }
Ejemplo n.º 2
0
        public void init(XsollaPricepoint pItem, XsollaUtils pUtils)
        {
            mItem  = pItem;
            mUtils = pUtils;

            // Загружаем картинку
            if (pItem.image != "null")
            {
                mImgLoader.LoadImage(mItemImg, pItem.GetImageUrl());
            }
            else
            if (pUtils.GetProject().virtualCurrencyIconUrl != "null")
            {
                mImgLoader.LoadImage(mItemImg, pUtils.GetProject().virtualCurrencyIconUrl);
            }
            else
            {
                mItemImg.color = new Color(255, 255, 255, 0);
            }

            // Задаем короткое описание
            mShortDesc.text = pItem.GetDescription();

            // Задаем название
            mItemName.text = pUtils.GetProject().isDiscrete ? pItem.outAmount.ToString("N2") : pItem.outAmount.ToString("##.00");
            mVcCurr.text   = mUtils.GetProject().virtualCurrencyName;

            // Рекламный блок
            SetAdBlock(pItem);
            // Ценовой блок
            SetAmountBlock(pItem.sum, pItem.sumWithoutDiscount, pItem.currency);
        }
        public void initScreen(XsollaUtils pUtils, string pCustomCurrency, Action<Dictionary<string, object>> pActionCalc, Action<float> pTryPay)
        {
            if (pUtils.GetProject().isDiscrete)
                virtCurrAmount.contentType = InputField.ContentType.IntegerNumber;
            else
                virtCurrAmount.contentType = InputField.ContentType.DecimalNumber;

            // Set btn Name
            btnPay.gameObject.GetComponentInChildren<Text>().text = pUtils.GetTranslations().Get("form_continue");
            mTotalTitle = pUtils.GetTranslations().Get("payment_summary_total");
            mCustomCurrency = pCustomCurrency;
            ImageLoader imageLoader = FindObjectOfType<ImageLoader>();
            Logger.Log("VirtIcon " + pUtils.GetProject().virtualCurrencyIconUrl);
            imageLoader.LoadImage(iconVirtCurr, "http:" + pUtils.GetProject().virtualCurrencyIconUrl);

            virtCurrAmount.onEndEdit.AddListener(delegate
                {
                    if (!mSetValues)
                        pActionCalc(GetParamsForCalc(true));
                });

            realCurrAmount.onEndEdit.AddListener(delegate
                {
                    if (!mSetValues)
                        pActionCalc(GetParamsForCalc(false));
                });

            btnPay.onClick.AddListener(delegate
                {
                    pTryPay(GetOutAmount());
                });
        }
Ejemplo n.º 4
0
 public void init(XsollaUtils pUtils)
 {
     mUtils          = pUtils;
     _titlePage.text = (pUtils.GetProject().components ["subscriptions"].Name != "") ? pUtils.GetProject().components["subscriptions"].Name : pUtils.GetTranslations().Get(XsollaTranslations.SUBSCRIPTION_PAGE_TITLE);
     mProgressBar.SetLoading(false);
     GetSubsRequest();
 }
        //  новая инициализация
        public void init(XsollaUtils pUtils, XsollaPricepoint pDefPackage)
        {
            mUtils = pUtils;
            if (pUtils.GetProject().isDiscrete)
            {
                virtCurrAmount.contentType = InputField.ContentType.IntegerNumber;
            }
            else
            {
                virtCurrAmount.contentType = InputField.ContentType.DecimalNumber;
            }

            btnPay.gameObject.GetComponentInChildren <Text>().text = pUtils.GetTranslations().Get("form_continue");
            FindObjectOfType <ImageLoader>().LoadImage(iconVirtCurr, pUtils.GetProject().virtualCurrencyIconUrl);

            // Задаем дефолтное значение для обсчета
            totalAmountTitle.text = mUtils.GetTranslations().Get("form_subtotal");
            virtCurrAmount.text   = pDefPackage.outAmount.ToString();
            realCurrAmount.text   = pDefPackage.sum.ToString();
            mTotalAmount.text     = CurrencyFormatter.Instance.FormatPrice(pDefPackage.currency, pDefPackage.sum);;

            virtCurrAmount.onValueChanged.AddListener(delegate
            {
                if (!mSetValues)
                {
                    CancelInvoke();
                    Invoke("RecalcVcAmount", 1);
                }
            });
            virtCurrAmount.onEndEdit.AddListener(delegate { mErrorPanel.gameObject.SetActive(false); });
            realCurrAmount.onValueChanged.AddListener(delegate
            {
                if (!mSetValues)
                {
                    CancelInvoke();
                    Invoke("RecalcAmount", 1);
                }
            });
            realCurrAmount.onEndEdit.AddListener(delegate { mErrorPanel.gameObject.SetActive(false); });

            btnPay.onClick.AddListener(delegate
            {
                BuyBtn();
            });
        }
Ejemplo n.º 6
0
        public void Init(XsollaUtils pUtils)
        {
            if (pUtils != null)
            {
                XsollaTranslations lTranslatrions = pUtils.GetTranslations();
                mCustomerSupport.text   = lTranslatrions.Get(XsollaTranslations.SUPPORT_CUSTOMER_SUPPORT);
                mContactUs.text         = lTranslatrions.Get(XsollaTranslations.SUPPORT_CONTACT_US);
                mCopyRight.text         = lTranslatrions.Get(XsollaTranslations.XSOLLA_COPYRIGHT);
                mSecuredConnection.text = lTranslatrions.Get(XsollaTranslations.FOOTER_SECURED_CONNECTION);

                mAgreement.text = pUtils.GetProject().eula != "null" ? pUtils.GetProject().eula : lTranslatrions.Get(XsollaTranslations.FOOTER_AGREEMENT);

                mAgreement.gameObject.GetComponent <Button>().onClick.AddListener(delegate
                {
                    new OpenUrlHelper().OpenUrl(pUtils.GetProject().eulaUrl != "null" ? pUtils.GetProject().eulaUrl : mUrl);
                });
            }
        }
Ejemplo n.º 7
0
        public void initScreen(XsollaUtils pUtils, string pCustomCurrency, Action <Dictionary <string, object> > pActionCalc, Action <float> pTryPay)
        {
            if (pUtils.GetProject().isDiscrete)
            {
                virtCurrAmount.contentType = InputField.ContentType.IntegerNumber;
            }
            else
            {
                virtCurrAmount.contentType = InputField.ContentType.DecimalNumber;
            }

            // Set btn Name
            btnPay.gameObject.GetComponentInChildren <Text>().text = pUtils.GetTranslations().Get("form_continue");
            mTotalTitle     = pUtils.GetTranslations().Get("payment_summary_total");
            mCustomCurrency = pCustomCurrency;
            ImageLoader imageLoader = FindObjectOfType <ImageLoader>();

            Logger.Log("VirtIcon " + pUtils.GetProject().virtualCurrencyIconUrl);
            imageLoader.LoadImage(iconVirtCurr, "http:" + pUtils.GetProject().virtualCurrencyIconUrl);

            virtCurrAmount.onEndEdit.AddListener(delegate
            {
                if (!mSetValues)
                {
                    pActionCalc(GetParamsForCalc(true));
                }
            });

            realCurrAmount.onEndEdit.AddListener(delegate
            {
                if (!mSetValues)
                {
                    pActionCalc(GetParamsForCalc(false));
                }
            });

            btnPay.onClick.AddListener(delegate
            {
                pTryPay(GetOutAmount());
            });
        }
        public void OpenPricepoints(XsollaUtils utils, XsollaPricepointsManager pricepoints)
        {
            DrawShopScreen ();
            string title = utils.GetTranslations ().Get (XsollaTranslations.PRICEPOINT_PAGE_TITLE);
            string vcName = utils.GetProject ().virtualCurrencyName;
            string buyText = utils.GetTranslations ().Get (XsollaTranslations.VIRTUAL_ITEM_OPTION_BUTTON);

            if (utils.GetSettings().components.virtualCurreny.customAmount)
                _shopViewController.OpenPricepoints(title, pricepoints, vcName, buyText, true, utils);
            else
                _shopViewController.OpenPricepoints(title, pricepoints, vcName, buyText);
        }
        public void InitScreen(XsollaUtils pUtils)
        {
            // set title
            _titleProj.text = pUtils.GetProject().name;

            // user name
            _userName.text = pUtils.GetUser().GetName();

            if (pUtils.GetUser().virtualCurrencyBalance != null)
            {
                GameObject obj = Instantiate(Resources.Load(PREFAB_VIEW_MENU_ITEM_EMPTY)) as GameObject;
                UserProfileBtnController controller = obj.GetComponentInChildren <UserProfileBtnController>();
                controller.InitScreen("History", ShowHistory);
                obj.transform.SetParent(_btnDropDownObj.transform);
            }
        }
        public void OpenPricepoints(XsollaUtils utils, XsollaPricepointsManager pricepoints)
        {
            DrawShopScreen();
            string title   = utils.GetTranslations().Get(XsollaTranslations.PRICEPOINT_PAGE_TITLE);
            string vcName  = utils.GetProject().virtualCurrencyName;
            string buyText = utils.GetTranslations().Get(XsollaTranslations.VIRTUAL_ITEM_OPTION_BUTTON);

            if (utils.GetSettings().components.virtualCurreny.customAmount)
            {
                _shopViewController.OpenPricepoints(title, pricepoints, vcName, buyText, true, utils);
            }
            else
            {
                _shopViewController.OpenPricepoints(title, pricepoints, vcName, buyText);
            }
        }
Ejemplo n.º 11
0
        public void InitScreen(XsollaUtils pUtils)
        {
            // set title
            _titleProj.text = pUtils.GetProject().name;

            // user name
            _userName.text = pUtils.GetUser().GetName();

            if (pUtils.GetUser().virtualCurrencyBalance != null)
            {
                GameObject obj = Instantiate(Resources.Load(PREFAB_VIEW_MENU_ITEM_EMPTY)) as GameObject;
                UserProfileBtnController controller = obj.GetComponentInChildren<UserProfileBtnController>();
                controller.InitScreen("History", ShowHistory);
                obj.transform.SetParent(_btnDropDownObj.transform);
            }
        }
        public void DrawVpStatus(XsollaUtils utils, XVPStatus status)
        {
            XsollaTranslations translations = utils.GetTranslations();
            string             input;

            if (status.Status.HeaderDescription == null)
            {
                input = translations.Get(XsollaTranslations.STATUS_PURCHASED_DESCRIPTION);
            }
            else
            {
                input = status.Status.HeaderDescription;
            }
            XsollaStatus.Group currentStatus = status.GetGroup();

            PrepareStatus(currentStatus, status.Status.Header, input, "");
            AddTitle(utils.GetProject().name);
            AddStatus(status.Status.Description);
            AddElement(translations.Get("virtualstatus_check_operation"), status.OperationId);
            AddElement(translations.Get("virtualstatus_check_time"), string.Format("{0:dd/MM/yyyy HH:mm}", DateTime.Parse(status.OperationCreated)));
            if (status.Items.Count > 0)
            {
                AddElement(translations.Get("virtualstatus_check_virtual_items"), status.GetPurchase(0));
            }
            if (status.vCurr.Count > 0)
            {
                AddElement(translations.Get("virtualstatus_check_virtual_currency"), status.GetVCPurchase(0) + " " + utils.GetProject().virtualCurrencyName);
            }

            if (status.OperationType != "coupon")
            {
                AddLine();
                AddBigElement(translations.Get("virtualstatus_check_vc_amount"), status.VcAmount + " " + utils.GetProject().virtualCurrencyName);
            }
            statusViewExitButton.gameObject.GetComponent <Text> ().text = translations.Get(XsollaTranslations.BACK_TO_STORE);
            statusViewExitButton.onClick.AddListener(delegate
            {
                OnClickBack(currentStatus, status.OperationId, Xsolla.XsollaStatusData.Status.DONE, status.GetPurchaseList());
            });
        }
Ejemplo n.º 13
0
        private void InitMenu(XsollaUtils pUtils)
        {
            mRadioGroupController = mNavMenuPanel.gameObject.AddComponent <RadioGroupController> ();
            GameObject menuItemEmptyPrefab             = Resources.Load(PREFAB_VIEW_MENU_ITEM_EMPTY) as GameObject;
            Dictionary <string, XComponent> components = pUtils.GetProject().components;

            if (components.ContainsKey("items") && components ["items"].IsEnabled)
            {
                string lName = (components ["items"].Name != "") ? components ["items"].Name : pUtils.GetTranslations().Get(XsollaTranslations.VIRTUALITEM_PAGE_TITLE);
                addMenuBtn("", lName, RadioButton.RadioType.SCREEN_GOODS);
            }

            if (components.ContainsKey("virtual_currency") && components ["virtual_currency"].IsEnabled)
            {
                string lName = (components ["virtual_currency"].Name != "") ? components["virtual_currency"].Name : pUtils.GetTranslations().Get(XsollaTranslations.PRICEPOINT_PAGE_TITLE);
                addMenuBtn("", lName, RadioButton.RadioType.SCREEN_PRICEPOINT);
            }

            if (components.ContainsKey("subscriptions") && components["subscriptions"].IsEnabled)
            {
                string lName = (components["subscriptions"].Name != "") ? components["subscriptions"].Name : pUtils.GetTranslations().Get("state_name_subscription");
                addMenuBtn("", lName, RadioButton.RadioType.SCREEN_SUBSCRIPTION);
            }

            if (components.ContainsKey("coupons") && components["coupons"].IsEnabled)
            {
                string lName = (components["coupons"].Name != "") ? components["coupons"].Name : pUtils.GetTranslations().Get(XsollaTranslations.COUPON_PAGE_TITLE);
                addMenuBtn("", lName, RadioButton.RadioType.SCREEN_REDEEMCOUPON);
            }

            GameObject menuItemEmpty = Instantiate(menuItemEmptyPrefab);

            menuItemEmpty.transform.SetParent(mNavMenuPanel.transform);

            if (!pUtils.IsServerLess())
            {
                addMenuBtn("", "", RadioButton.RadioType.SCREEN_FAVOURITE, true);
            }
        }
Ejemplo n.º 14
0
        public void init(XsollaUtils pUtils)
        {
            mUtils     = pUtils;
            mListItems = new List <PricePointItemController>();

            mStartProgressBar();

            mShopTitle.text = (pUtils.GetProject().components ["virtual_currency"].Name != "") ? pUtils.GetProject().components["virtual_currency"].Name : pUtils.GetTranslations().Get(XsollaTranslations.PRICEPOINT_PAGE_TITLE);

            // Задаем перевод на отсутствие товаров
            mEmptyLabel.text = mUtils.GetTranslations().Get("virtualitem_no_data");
            mEmptyLabel.gameObject.SetActive(false);

            // Возможность произвольной покупки
            if (mUtils.GetSettings().components.virtualCurreny.customAmount)
            {
                mCustomAmountLink.SetActive(true);
                mCustomController = mCustomAmountScreen.GetComponent <CustomVirtCurrAmountController>();
                mCustomAmountLink.GetComponent <Button>().onClick.AddListener(ChangeStateCusomAmount);
                StateCustomAmount = false;
            }
            else
            {
                mCustomAmountLink.SetActive(false);
                StateCustomAmount = false;
            }

            // получить список пакетов
            Dictionary <String, object> lParams = new Dictionary <string, object>();

            lParams.Add(XsollaApiConst.ACCESS_TOKEN, mUtils.GetAcceessToken());
            if (mUtils.GetUser().userBalance != null)
            {
                lParams.Add(XsollaApiConst.USER_INITIAL_CURRENCY, mUtils.GetUser().userBalance.currency);
            }
            ApiRequest.Instance.getApiRequest(new XsollaRequestPckg(mPricePointsUrl, lParams), PricePointsRecived, ErrorRecived);
        }
Ejemplo n.º 15
0
        private void ProcessingRequestResult(int pType, RequestClass pRequestResult, Dictionary<string, object> pDataArgs)
        {
            if (!pRequestResult.HasError)
            {
                // Start Processing
                Debug.Log("Type -> " + pType);
                Debug.Log("WWW_request -> " + pRequestResult.TextRequest);

                JSONNode rootNode = JSON.Parse(pRequestResult.TextRequest);
                if(rootNode != null && rootNode.Count > 2 || rootNode["error"] == null) {
                    switch(pType)
                    {
                    case TRANSLATIONS:
                        {
                            if(rootNode.Count > 2){
                                XsollaUtils utils = new XsollaUtils().Parse(rootNode) as XsollaUtils;
                                projectId = utils.GetProject().id.ToString();

                                OnUtilsRecieved(utils);
                                // if base param not containKey access token, then add token from util
                                if (!baseParams.ContainsKey(XsollaApiConst.ACCESS_TOKEN))
                                    _accessToken = utils.GetAcceessToken();
                                OnTranslationRecieved(utils.GetTranslations());
                            } else {
                                XsollaError error = new XsollaError();
                                error.Parse(rootNode);
                                OnErrorReceived(error);
                            }
                        }
                        break;
                    case DIRECTPAYMENT_FORM:
                        {
                            if(rootNode.Count > 8) {
                                XsollaForm form = new XsollaForm();
                                form.Parse(rootNode);
                                switch (form.GetCurrentCommand()) {
                                case XsollaForm.CurrentCommand.STATUS:
                                    GetStatus(form.GetXpsMap());
                                    break;
                                case XsollaForm.CurrentCommand.CHECKOUT:
                                case XsollaForm.CurrentCommand.CHECK:
                                case XsollaForm.CurrentCommand.FORM:
                                case XsollaForm.CurrentCommand.CREATE:
                                case XsollaForm.CurrentCommand.ACCOUNT:
                                    OnFormReceived(form);
                                    break;
                                case XsollaForm.CurrentCommand.UNKNOWN:
                                    if(rootNode.Count > 10)
                                    {
                                        OnFormReceived(form);
                                    } else {
                                        XsollaError error = new XsollaError();
                                        error.Parse(rootNode);
                                        OnErrorReceived(error);
                                    }
                                    break;
                                default:
                                    break;
                                }
                            } else {
                                XsollaStatusPing statusPing = new XsollaStatusPing();
                                statusPing.Parse(rootNode);
                                OnStatusChecked(statusPing);
                            }
                        }
                        break;
                    case DIRECTPAYMENT_STATUS:
                        {
                            XsollaForm form = new XsollaForm();
                            form.Parse(rootNode);
                            XsollaStatus status = new XsollaStatus();
                            status.Parse(rootNode);
                            OnStatusReceived(status, form);
                        }
                        break;
                    case PRICEPOINTS:
                        {
                            XsollaPricepointsManager pricepoints = new XsollaPricepointsManager();
                            pricepoints.Parse(rootNode);
                            OnPricepointsRecieved(pricepoints);
                        }
                        break;
                    case GOODS:
                        {
                            XsollaGoodsManager goods = new XsollaGoodsManager();
                            goods.Parse(rootNode);
                            OnGoodsRecieved(goods);
                        }
                        break;
                    case GOODS_GROUPS:
                        {
                            XsollaGroupsManager groups = new XsollaGroupsManager();
                            groups.Parse(rootNode);
                            OnGoodsGroupsRecieved(groups);
                        }
                        break;
                    case GOODS_ITEMS:
                        {
                            XsollaGoodsManager goods = new XsollaGoodsManager();
                            goods.Parse(rootNode);
                            OnGoodsRecieved(goods);
                        }
                        break;
                    case PAYMENT_LIST:
                        {
                            XsollaPaymentMethods paymentMethods = new XsollaPaymentMethods();
                            paymentMethods.Parse(rootNode);
                            OnPaymentMethodsRecieved(paymentMethods);
                        }
                        break;
                    case SAVED_PAYMENT_LIST:
                        {
                            XsollaSavedPaymentMethods savedPaymentsMethods = new XsollaSavedPaymentMethods();
                            savedPaymentsMethods.Parse(rootNode);
                            OnSavedPaymentMethodsRecieved(savedPaymentsMethods);
                        }
                        break;
                    case QUICK_PAYMENT_LIST:
                        {
                            XsollaQuickPayments quickPayments = new XsollaQuickPayments();
                            quickPayments.Parse(rootNode);
                            OnQuickPaymentMethodsRecieved(quickPayments);
                        }
                        break;
                    case COUNTRIES:
                        {
                            XsollaCountries countries = new XsollaCountries();
                            countries.Parse(rootNode);
                            OnCountriesRecieved(countries);
                        }
                        break;
                    case VIRTUAL_PAYMENT_SUMMARY:
                        {
                            XVirtualPaymentSummary summary = new XVirtualPaymentSummary();
                            summary.Parse(rootNode);
                            Logger.Log("VIRTUAL_PAYMENT_SUMMARY " + summary.ToString());
                            if(summary.IsSkipConfirmation) {
                                Logger.Log("IsSkipConfirmation true");
                                pDataArgs.Add("dont_ask_again", 0);
                                ProceedVPayment(pDataArgs);
                            } else {
                                Logger.Log("IsSkipConfirmation false");
                                OnVPSummaryRecieved(summary);
                            }
                        }
                        break;
                    case VIRTUAL_PROCEED:
                        {
                            XProceed proceed = new XProceed();
                            proceed.Parse(rootNode);
                            Logger.Log ("VIRTUAL_PROCEED " + proceed.ToString());
                            if(proceed.IsInvoiceCreated) {
                                Logger.Log ("VIRTUAL_PROCEED 1");
                                long operationId = proceed.OperationId;
                                pDataArgs.Add("operation_id", operationId);
                                VPaymentStatus(pDataArgs);
                            } else {
                                Logger.Log ("VIRTUAL_PROCEED 0 ");
                                OnVPProceedError(proceed.Error);
                            }
                        }
                        break;
                    case VIRTUAL_STATUS:
                        {
                            XVPStatus vpStatus = new XVPStatus();
                            vpStatus.Parse(rootNode);
                            //{"errors":[ {"message":"Insufficient balance to complete operation"} ], "api":{"ver":"1.0.1"}, "invoice_created":"false", "operation_id":"0", "code":"0"}
                            Logger.Log ("VIRTUAL_STATUS" + vpStatus.ToString());
                            OnVPStatusRecieved(vpStatus);
                        }
                        break;

                    case APPLY_PROMO_COUPONE:
                        {
                            XsollaForm form = new XsollaForm();
                            form.Parse(rootNode);
                            OnApplyCouponeReceived(form);
                        }
                        break;
                    case COUPON_PROCEED:
                        {
                            XsollaCouponProceedResult couponProceed = new XsollaCouponProceedResult();
                            couponProceed.Parse(rootNode);
                            if (couponProceed._error != null)
                            {
                                Logger.Log("COUPON_PROCEED ERROR: " + couponProceed._error);
                                OnCouponProceedErrorRecived(couponProceed);
                            }
                            else
                            {
                                long operationId = couponProceed._operationId;
                                if (pDataArgs.ContainsKey("coupon_code"))
                                    pDataArgs.Remove("coupon_code");
                                pDataArgs.Add("operation_id", operationId);
                                VPaymentStatus(pDataArgs);
                            }
                        }
                        break;

                    case HISTORY:
                        {
                            XsollaHistoryList history = new XsollaHistoryList().Parse(rootNode["operations"]) as XsollaHistoryList;
                            OnHistoryRecieved(history);

                        }
                        break;
                    case CALCULATE_CUSTOM_AMOUNT:
                        {
                            //TODO: fill method
                            CustomVirtCurrAmountController.CustomAmountCalcRes res = new CustomVirtCurrAmountController.CustomAmountCalcRes().Parse(rootNode["calculation"]) as CustomVirtCurrAmountController.CustomAmountCalcRes;
                            OnCustomAmountResRecieved(res);
                        }
                        break;
                    default:
                        break;
                    }
                } else {
                    XsollaError error = new XsollaError();
                    error.Parse(rootNode);
                    OnErrorReceived(error);
                }
            }
            else
            {
                JSONNode errorNode = JSON.Parse(pRequestResult.TextRequest);
                string errorMsg = errorNode["errors"].AsArray[0]["message"].Value
                    + ". Support code " + errorNode["errors"].AsArray[0]["support_code"].Value;
                int errorCode = 0;
                if(pRequestResult.ErrorText.Length > 3)
                    errorCode = int.Parse(pRequestResult.ErrorText.Substring(0, 3));
                else
                    errorCode = int.Parse(pRequestResult.ErrorText);
                OnErrorReceived(new XsollaError(errorCode, errorMsg));
            }
            if(projectId != null && !"".Equals(projectId))
                LogEvent ("UNITY " + SDK_VERSION + " REQUEST", projectId, pRequestResult.Url);
            else
                LogEvent ("UNITY " + SDK_VERSION + " REQUEST", "undefined", pRequestResult.Url);
        }
        public void DrawScreen(XsollaUtils utils, XVirtualPaymentSummary summary)
        {
            ResizeToParent();
            Title.text        = utils.GetTranslations().Get("cart_page_title");
            Confirmation.text = utils.GetTranslations().Get("cart_confirm_your_purchase");
            ImageLoader.UploadImageToCurrentView(summary.Items [0].GetImage());
            ItemName.text = summary.Items [0].Name;

            BackTo.GetComponent <Text>().text = "< " + utils.GetTranslations().Get("back_to_virtualitem");
            BackTo.GetComponent <Button>().onClick.AddListener(delegate
            {
                onClickBack();
            });
            ToggleText.text        = utils.GetTranslations().Get("cart_dont_ask_again");
            Total.text             = utils.GetTranslations().Get("total") + " " + summary.Total + " " + utils.GetProject().virtualCurrencyName;
            ProceedButtonText.text = utils.GetTranslations().Get("cart_submit");
            ProceedButton.onClick.AddListener(() => OnClickProceed());
        }
        public void Init(XsollaUtils pUtils, XsollaHistoryItem pItem, Boolean pEven, Action pSortAction, Boolean pHeader = false, Boolean pDesc = true)
        {
            mUtils = pUtils;
            Image imgComp = this.GetComponent <Image>();

            imgComp.enabled = pEven;

            if (pHeader)
            {
                mDate.text = mUtils.GetTranslations().Get("balance_history_date") + (pDesc == true?" ▼":" ▲");
                Button sortBtn = mDate.gameObject.AddComponent <Button>();
                sortBtn.onClick.AddListener(delegate
                {
                    Logger.Log("On sort btn click");
                    pSortAction();
                    mDate.text = mUtils.GetTranslations().Get("balance_history_date") + " ↓";
                });

                mType.text       = mUtils.GetTranslations().Get("balance_history_purpose");
                mItem.text       = mUtils.GetTranslations().Get("balance_history_item");
                mBalance.text    = mUtils.GetTranslations().Get("balance_history_vc_amount");
                mPrice.text      = mUtils.GetTranslations().Get("balance_history_payment_amount");
                mPrice.alignment = TextAnchor.LowerLeft;

                // Activate devider
                mDevider.SetActive(true);
                LayoutElement layout = this.transform.GetComponent <LayoutElement>();
                layout.minHeight = 30;
                return;
            }

            mDate.text = pItem.date.ToString("MMM d, yyyy hh:mm tt");
            // balance_history_payment_info:"Payment via {{paymentName}}, transaction ID {{transactionId}}"
            // balance_history_payment_info_cancellation:"Refund. Payment via {{paymentName}}, transaction ID {{transactionId}}"
            // balance_history_subscription_change:"Subscription change. Payment via {{paymentName}}, transaction ID: {{transactionId}} "
            // balance_history_subscription_create:"Subscription create. Payment via {{paymentName}}, transaction ID {{transactionId}}"
            // balance_history_subscription_renew:"Subscription renewal. Payment via {{paymentName}}, transaction ID: {{transactionId}} "
            // balance_history_ingame_info:"In-Game Purchase"
            // balance_history_internal_info:"{{comment}}"
            // balance_history_coupon_info:"Coupon, code {{code}}"
            // subscription_cancellation:"Subscription cancellation"

            switch (pItem.operationType)
            {
            case "payment":
            {
                mType.text = String.Format(prepareTypeStr(mUtils.GetTranslations().Get("balance_history_payment_info")), pItem.paymentName, pItem.invoiceId);
                break;
            }

            case "cancellation":
            {
                mType.text = String.Format(prepareTypeStr(mUtils.GetTranslations().Get("balance_history_payment_info_cancellation")), pItem.paymentName, pItem.invoiceId);
                break;
            }

            case "inGamePurchase":
            {
                mType.text = String.Format(prepareTypeStr(mUtils.GetTranslations().Get("balance_history_ingame_info")));
                break;
            }

            case "internal":
            {
                mType.text = String.Format(prepareTypeStr(mUtils.GetTranslations().Get("balance_history_internal_info")), pItem.comment);
                break;
            }

            case "coupon":
            {
                mType.text = String.Format(prepareTypeStr(mUtils.GetTranslations().Get("balance_history_coupon_info")), pItem.couponeCode);
                break;
            }

            case "subscriptionRenew":
            {
                mType.text = String.Format(prepareTypeStr(mUtils.GetTranslations().Get("balance_history_subscription_renew")), pItem.paymentName, pItem.invoiceId);
                break;
            }

            case "subscriptionCreate":
            {
                mType.text = String.Format(prepareTypeStr(mUtils.GetTranslations().Get("balance_history_subscription_create")), pItem.paymentName, pItem.invoiceId);
                break;
            }

            case "subscriptionChange":
            {
                mType.text = String.Format(prepareTypeStr(mUtils.GetTranslations().Get("balance_history_subscription_change")), pItem.paymentName, pItem.invoiceId);
                break;
            }

            case "subscriptionCancellation":
            {
                mType.text = String.Format(prepareTypeStr(mUtils.GetTranslations().Get("subscription_cancellation")), pItem.paymentName, pItem.invoiceId);
                break;
            }

            default:
            {
                mType.text = "";
                break;
            }
            }

            if (pItem.virtualItems.items.GetCount() != 0)
            {
                mItem.text = pItem.virtualItems.items.GetItemByPosition(0).GetName();
            }

            if (pItem.vcAmount != 0)
            {
                if (mUtils.GetUser().userBalance != null)
                {
                    mBalance.text = ((pItem.vcAmount > 0)?"+":"") + pItem.vcAmount + " " + mUtils.GetProject().virtualCurrencyName + "\n" + "(=" + pItem.userBalance + " " + mUtils.GetProject().virtualCurrencyName + ")";
                }
            }
            else
            {
                mBalance.text = "";
            }

            if (pItem.paymentAmount != 0)
            {
                mPrice.text = CurrencyFormatter.Instance.FormatPrice(pItem.paymentCurrency, pItem.paymentAmount);
            }
            else
            {
                mPrice.text = "";
            }
        }
Ejemplo n.º 18
0
        private void ProcessingRequestResult(int pType, RequestClass pRequestResult, Dictionary <string, object> pDataArgs)
        {
            if (!pRequestResult.HasError)
            {
                // Start Processing
                Debug.Log("Type -> " + pType);
                Debug.Log("WWW_request -> " + pRequestResult.TextRequest);

                JSONNode rootNode = JSON.Parse(pRequestResult.TextRequest);
                if (rootNode != null && rootNode.Count > 2 || rootNode["error"] == null)
                {
                    switch (pType)
                    {
                    case TRANSLATIONS:
                    {
                        if (rootNode.Count > 2)
                        {
                            XsollaUtils utils = new XsollaUtils().Parse(rootNode) as XsollaUtils;
                            projectId = utils.GetProject().id.ToString();

                            OnUtilsRecieved(utils);
                            // if base param not containKey access token, then add token from util
                            if (!baseParams.ContainsKey(XsollaApiConst.ACCESS_TOKEN))
                            {
                                _accessToken = utils.GetAcceessToken();
                            }
                            OnTranslationRecieved(utils.GetTranslations());
                        }
                        else
                        {
                            XsollaError error = new XsollaError();
                            error.Parse(rootNode);
                            OnErrorReceived(error);
                        }
                    }
                    break;

                    case DIRECTPAYMENT_FORM:
                    {
                        if (rootNode.Count > 8)
                        {
                            XsollaForm form = new XsollaForm();
                            form.Parse(rootNode);
                            switch (form.GetCurrentCommand())
                            {
                            case XsollaForm.CurrentCommand.STATUS:
                                GetStatus(form.GetXpsMap());
                                break;

                            case XsollaForm.CurrentCommand.CHECKOUT:
                            case XsollaForm.CurrentCommand.CHECK:
                            case XsollaForm.CurrentCommand.FORM:
                            case XsollaForm.CurrentCommand.CREATE:
                            case XsollaForm.CurrentCommand.ACCOUNT:
                                OnFormReceived(form);
                                break;

                            case XsollaForm.CurrentCommand.UNKNOWN:
                                if (rootNode.Count > 10)
                                {
                                    OnFormReceived(form);
                                }
                                else
                                {
                                    XsollaError error = new XsollaError();
                                    error.Parse(rootNode);
                                    OnErrorReceived(error);
                                }
                                break;

                            default:
                                break;
                            }
                        }
                        else
                        {
                            XsollaStatusPing statusPing = new XsollaStatusPing();
                            statusPing.Parse(rootNode);
                            OnStatusChecked(statusPing);
                        }
                    }
                    break;

                    case DIRECTPAYMENT_STATUS:
                    {
                        XsollaForm form = new XsollaForm();
                        form.Parse(rootNode);
                        XsollaStatus status = new XsollaStatus();
                        status.Parse(rootNode);
                        OnStatusReceived(status, form);
                    }
                    break;

                    case PRICEPOINTS:
                    {
                        XsollaPricepointsManager pricepoints = new XsollaPricepointsManager();
                        pricepoints.Parse(rootNode);
                        OnPricepointsRecieved(pricepoints);
                    }
                    break;

                    case GOODS:
                    {
                        XsollaGoodsManager goods = new XsollaGoodsManager();
                        goods.Parse(rootNode);
                        OnGoodsRecieved(goods);
                    }
                    break;

                    case GOODS_GROUPS:
                    {
                        XsollaGroupsManager groups = new XsollaGroupsManager();
                        groups.Parse(rootNode);
                        OnGoodsGroupsRecieved(groups);
                    }
                    break;

                    case GOODS_ITEMS:
                    {
                        XsollaGoodsManager goods = new XsollaGoodsManager();
                        goods.Parse(rootNode);
                        OnGoodsRecieved(goods);
                    }
                    break;

                    case PAYMENT_LIST:
                    {
                        XsollaPaymentMethods paymentMethods = new XsollaPaymentMethods();
                        paymentMethods.Parse(rootNode);
                        OnPaymentMethodsRecieved(paymentMethods);
                    }
                    break;

                    case SAVED_PAYMENT_LIST:
                    {
                        XsollaSavedPaymentMethods savedPaymentsMethods = new XsollaSavedPaymentMethods();
                        savedPaymentsMethods.Parse(rootNode);
                        OnSavedPaymentMethodsRecieved(savedPaymentsMethods);
                    }
                    break;

                    case QUICK_PAYMENT_LIST:
                    {
                        XsollaQuickPayments quickPayments = new XsollaQuickPayments();
                        quickPayments.Parse(rootNode);
                        OnQuickPaymentMethodsRecieved(quickPayments);
                    }
                    break;

                    case COUNTRIES:
                    {
                        XsollaCountries countries = new XsollaCountries();
                        countries.Parse(rootNode);
                        OnCountriesRecieved(countries);
                    }
                    break;

                    case VIRTUAL_PAYMENT_SUMMARY:
                    {
                        XVirtualPaymentSummary summary = new XVirtualPaymentSummary();
                        summary.Parse(rootNode);
                        Logger.Log("VIRTUAL_PAYMENT_SUMMARY " + summary.ToString());
                        if (summary.IsSkipConfirmation)
                        {
                            Logger.Log("IsSkipConfirmation true");
                            pDataArgs.Add("dont_ask_again", 0);
                            ProceedVPayment(pDataArgs);
                        }
                        else
                        {
                            Logger.Log("IsSkipConfirmation false");
                            OnVPSummaryRecieved(summary);
                        }
                    }
                    break;

                    case VIRTUAL_PROCEED:
                    {
                        XProceed proceed = new XProceed();
                        proceed.Parse(rootNode);
                        Logger.Log("VIRTUAL_PROCEED " + proceed.ToString());
                        if (proceed.IsInvoiceCreated)
                        {
                            Logger.Log("VIRTUAL_PROCEED 1");
                            long operationId = proceed.OperationId;
                            pDataArgs.Add("operation_id", operationId);
                            VPaymentStatus(pDataArgs);
                        }
                        else
                        {
                            Logger.Log("VIRTUAL_PROCEED 0 ");
                            OnVPProceedError(proceed.Error);
                        }
                    }
                    break;

                    case VIRTUAL_STATUS:
                    {
                        XVPStatus vpStatus = new XVPStatus();
                        vpStatus.Parse(rootNode);
                        //{"errors":[ {"message":"Insufficient balance to complete operation"} ], "api":{"ver":"1.0.1"}, "invoice_created":"false", "operation_id":"0", "code":"0"}
                        Logger.Log("VIRTUAL_STATUS" + vpStatus.ToString());
                        OnVPStatusRecieved(vpStatus);
                    }
                    break;

                    case APPLY_PROMO_COUPONE:
                    {
                        XsollaForm form = new XsollaForm();
                        form.Parse(rootNode);
                        OnApplyCouponeReceived(form);
                    }
                    break;

                    case COUPON_PROCEED:
                    {
                        XsollaCouponProceedResult couponProceed = new XsollaCouponProceedResult();
                        couponProceed.Parse(rootNode);
                        if (couponProceed._error != null)
                        {
                            Logger.Log("COUPON_PROCEED ERROR: " + couponProceed._error);
                            OnCouponProceedErrorRecived(couponProceed);
                        }
                        else
                        {
                            long operationId = couponProceed._operationId;
                            if (pDataArgs.ContainsKey("coupon_code"))
                            {
                                pDataArgs.Remove("coupon_code");
                            }
                            pDataArgs.Add("operation_id", operationId);
                            VPaymentStatus(pDataArgs);
                        }
                    }
                    break;

                    case HISTORY:
                    {
                        XsollaHistoryList history = new XsollaHistoryList().Parse(rootNode["operations"]) as XsollaHistoryList;
                        OnHistoryRecieved(history);
                    }
                    break;

                    case CALCULATE_CUSTOM_AMOUNT:
                    {
                        //TODO: fill method
                        CustomVirtCurrAmountController.CustomAmountCalcRes res = new CustomVirtCurrAmountController.CustomAmountCalcRes().Parse(rootNode["calculation"]) as CustomVirtCurrAmountController.CustomAmountCalcRes;
                        OnCustomAmountResRecieved(res);
                    }
                    break;

                    default:
                        break;
                    }
                }
                else
                {
                    XsollaError error = new XsollaError();
                    error.Parse(rootNode);
                    OnErrorReceived(error);
                }
            }
            else
            {
                JSONNode errorNode = JSON.Parse(pRequestResult.TextRequest);
                string   errorMsg  = errorNode["errors"].AsArray[0]["message"].Value
                                     + ". Support code " + errorNode["errors"].AsArray[0]["support_code"].Value;
                int errorCode = 0;
                if (pRequestResult.ErrorText.Length > 3)
                {
                    errorCode = int.Parse(pRequestResult.ErrorText.Substring(0, 3));
                }
                else
                {
                    errorCode = int.Parse(pRequestResult.ErrorText);
                }
                OnErrorReceived(new XsollaError(errorCode, errorMsg));
            }
            if (projectId != null && !"".Equals(projectId))
            {
                LogEvent("UNITY " + SDK_VERSION + " REQUEST", projectId, pRequestResult.Url);
            }
            else
            {
                LogEvent("UNITY " + SDK_VERSION + " REQUEST", "undefined", pRequestResult.Url);
            }
        }
        //TODO minimize
        private void InitMenu(XsollaUtils utils)
        {
            _radioController = menuTransform.gameObject.AddComponent<RadioGroupController> ();
            GameObject menuItemPrefab 		= Resources.Load (PREFAB_VIEW_MENU_ITEM) as GameObject;
            GameObject menuItemIconPrefab 	= Resources.Load (PREFAB_VIEW_MENU_ITEM_ICON) as GameObject;
            GameObject menuItemEmptyPrefab 	= Resources.Load (PREFAB_VIEW_MENU_ITEM_EMPTY) as GameObject;
            //			menuTransform = mainScreen.GetComponentInChildren<HorizontalLayoutGroup> ().gameObject.transform;
            Dictionary<string, XComponent> components = utils.GetProject().components;
            XsollaPaystation2 paystation2 			  = utils.GetSettings ().paystation2;
            bool isGoodsRequred = components.ContainsKey("items") && components ["items"].IsEnabled;
            if(isGoodsRequred)
            {
                GameObject menuItemGoods = Instantiate(menuItemPrefab) as GameObject;
                Text[] texts = menuItemGoods.GetComponentsInChildren<Text>();
                texts[0].text = "";
                texts[1].text = utils.GetTranslations().Get(XsollaTranslations.VIRTUALITEM_PAGE_TITLE);
                menuItemGoods.GetComponent<Button>().onClick.AddListener(delegate {
                    LoadGoodsGroups();
                    _radioController.SelectItem(0);
                });
                menuItemGoods.transform.SetParent(menuTransform);
                _radioController.AddButton(menuItemGoods.GetComponent<RadioButton>());
            }
            //HACK with Unity 5.3
            //bool isPricepointsRequired = components.ContainsKey("virtual_currency") && components ["virtual_currency"].IsEnabled;
            if (paystation2.pricepointsAtFirst != null && paystation2.pricepointsAtFirst.Equals("1"))
            {
                GameObject menuItemPricepoints = Instantiate(menuItemPrefab) as GameObject;
                Text[] texts = menuItemPricepoints.GetComponentsInChildren<Text>();
                texts[0].text = "";
                texts[1].text = utils.GetTranslations().Get(XsollaTranslations.PRICEPOINT_PAGE_TITLE);
                menuItemPricepoints.GetComponent<Button>().onClick.AddListener(delegate {
                    LoadShopPricepoints();
                    _radioController.SelectItem(1);
                });
                menuItemPricepoints.transform.SetParent(menuTransform);
                _radioController.AddButton(menuItemPricepoints.GetComponent<RadioButton>());
            }

            if (components.ContainsKey("coupons") && components["coupons"].IsEnabled)
            {
                GameObject menuItemCoupons = Instantiate(menuItemPrefab) as GameObject;
                Text[] texts = menuItemCoupons.GetComponentsInChildren<Text>();
                texts[0].text = "";
                texts[1].text = utils.GetTranslations().Get(XsollaTranslations.COUPON_PAGE_TITLE);
                menuItemCoupons.GetComponent<Button>().onClick.AddListener(delegate {
                    ShowRedeemCoupon();
                    _radioController.SelectItem(2);
                });
                menuItemCoupons.transform.SetParent(menuTransform);
                _radioController.AddButton(menuItemCoupons.GetComponent<RadioButton>());
            }

            GameObject menuItemEmpty = Instantiate (menuItemEmptyPrefab);
            menuItemEmpty.transform.SetParent (menuTransform);

            GameObject menuItemFavorite = Instantiate (menuItemIconPrefab);
            menuItemFavorite.GetComponentInChildren<Text> ().text = "";
            menuItemFavorite.GetComponent<Button>().onClick.AddListener(delegate {
                _shopViewController.SetTitle(utils.GetTranslations().Get(XsollaTranslations.VIRTUALITEMS_TITLE_FAVORITE));
                LoadFavorites();
                _radioController.SelectItem(3);
            });
            menuItemFavorite.transform.SetParent (menuTransform);
            _radioController.AddButton(menuItemFavorite.GetComponent<RadioButton>());
        }
        private IEnumerator WaitForRequest(int pType, WWW www, Dictionary <string, object> post)
        {
            Logger.Log("Start get www");
            yield return(www);

            // check for errors
            if (www.error == null)
            {
                Debug.Log("Type -> " + pType);
                Debug.Log("WWW_request -> " + www.text);
                string data = www.text;

                JSONNode rootNode = JSON.Parse(www.text);
                if (rootNode != null && rootNode.Count > 2 || rootNode["error"] == null)
                {
                    switch (pType)
                    {
                    case TRANSLATIONS:
                    {
                        if (rootNode.Count > 2)
                        {
                            XsollaUtils utils = new XsollaUtils().Parse(rootNode) as XsollaUtils;
                            projectId = utils.GetProject().id.ToString();
                            if (baseParams.ContainsKey(XsollaApiConst.ACCESS_TOKEN))
                            {
                                utils.SetAccessToken(baseParams[XsollaApiConst.ACCESS_TOKEN].ToString());
                            }

                            OnUtilsRecieved(utils);
//								// if base param not containKey access token, then add token from util
//								if (!baseParams.ContainsKey(XsollaApiConst.ACCESS_TOKEN))
//									_accessToken = utils.GetAcceessToken();
                            OnTranslationRecieved(utils.GetTranslations());
                        }
                        else
                        {
                            XsollaError error = new XsollaError();
                            error.Parse(rootNode);
                            OnErrorReceived(error);
                        }
                        break;
                    }

                    case DIRECTPAYMENT_FORM:
                    {
                        if (rootNode.Count > 8)
                        {
                            XsollaForm form = new XsollaForm();
                            form.Parse(rootNode);
                            switch (form.GetCurrentCommand())
                            {
                            case XsollaForm.CurrentCommand.STATUS:
                                // if we replaced or add saved account, we must start loop on get list saved account
                                if (post.ContainsKey("save_payment_account_only") || (post.ContainsKey("replace_payment_account")))
                                {
                                    if (!form.IsCardPayment() && !(post.ContainsKey("replace_payment_account")))
                                    {
                                        OnWaitPaymentChange();
                                        break;
                                    }
                                    else
                                    {
                                        OnPaymentManagerMethod(null, post.ContainsKey("replace_payment_account")?false:true);
                                        break;
                                    }
                                }
                                GetStatus(form.GetXpsMap());
                                break;

                            case XsollaForm.CurrentCommand.CHECKOUT:
                            case XsollaForm.CurrentCommand.CHECK:
                            case XsollaForm.CurrentCommand.FORM:
                            case XsollaForm.CurrentCommand.CREATE:
                            case XsollaForm.CurrentCommand.ACCOUNT:
                                OnFormReceived(form);
                                break;

                            case XsollaForm.CurrentCommand.UNKNOWN:
                                if (rootNode.Count > 10)
                                {
                                    OnFormReceived(form);
                                }
                                else
                                {
                                    XsollaError error = new XsollaError();
                                    error.Parse(rootNode);
                                    OnErrorReceived(error);
                                }
                                break;

                            default:
                                break;
                            }
                        }
                        else
                        {
                            XsollaStatusPing statusPing = new XsollaStatusPing();
                            statusPing.Parse(rootNode);
                            OnStatusChecked(statusPing);
                        }
                        break;
                    }

                    case DIRECTPAYMENT_STATUS:
                    {
                        XsollaForm form = new XsollaForm();
                        form.Parse(rootNode);
                        XsollaStatus status = new XsollaStatus();
                        status.Parse(rootNode);
                        OnStatusReceived(status, form);
                        break;
                    }

                    case PRICEPOINTS:
                    {
                        XsollaPricepointsManager pricepoints = new XsollaPricepointsManager();
                        pricepoints.Parse(rootNode);
                        OnPricepointsRecieved(pricepoints);
                        break;
                    }

                    case GOODS:
                    {
                        XsollaGoodsManager goods = new XsollaGoodsManager();
                        goods.Parse(rootNode);
                        OnGoodsRecieved(goods);
                        break;
                    }

                    case GOODS_GROUPS:
                    {
                        XsollaGroupsManager groups = new XsollaGroupsManager();
                        groups.Parse(rootNode);
                        OnGoodsGroupsRecieved(groups);
                        break;
                    }

                    case GOODS_ITEMS:
                    {
                        XsollaGoodsManager goods = new XsollaGoodsManager();
                        goods.Parse(rootNode);
                        OnGoodsRecieved(goods);
                        break;
                    }

                    case PAYMENT_LIST:
                    {
                        XsollaPaymentMethods paymentMethods = new XsollaPaymentMethods();
                        paymentMethods.Parse(rootNode);
                        OnPaymentMethodsRecieved(paymentMethods);
                        break;
                    }

                    case SAVED_PAYMENT_LIST:
                    {
                        XsollaSavedPaymentMethods savedPaymentsMethods = new XsollaSavedPaymentMethods();
                        savedPaymentsMethods.Parse(rootNode);
                        OnSavedPaymentMethodsRecieved(savedPaymentsMethods);
                        break;
                    }

                    case QUICK_PAYMENT_LIST:
                    {
                        XsollaQuickPayments quickPayments = new XsollaQuickPayments();
                        quickPayments.Parse(rootNode);
                        OnQuickPaymentMethodsRecieved(quickPayments);
                        break;
                    }

                    case COUNTRIES:
                    {
                        XsollaCountries countries = new XsollaCountries();
                        countries.Parse(rootNode);
                        OnCountriesRecieved(countries);
                        break;
                    }

                    case VIRTUAL_PAYMENT_SUMMARY:
                    {
                        XVirtualPaymentSummary summary = new XVirtualPaymentSummary();
                        summary.Parse(rootNode);
                        Logger.Log("VIRTUAL_PAYMENT_SUMMARY " + summary.ToString());
                        if (summary.IsSkipConfirmation)
                        {
                            Logger.Log("IsSkipConfirmation true");
                            post.Add("dont_ask_again", 0);
                            ProceedVPayment(post);
                        }
                        else
                        {
                            Logger.Log("IsSkipConfirmation false");
                            OnVPSummaryRecieved(summary);
                        }
                        break;
                    }

                    case VIRTUAL_PROCEED:
                    {
                        XProceed proceed = new XProceed();
                        proceed.Parse(rootNode);
                        Logger.Log("VIRTUAL_PROCEED " + proceed.ToString());
                        if (proceed.IsInvoiceCreated)
                        {
                            Logger.Log("VIRTUAL_PROCEED 1");
                            long operationId = proceed.OperationId;
                            post.Add("operation_id", operationId);
                            VPaymentStatus(post);
                        }
                        else
                        {
                            Logger.Log("VIRTUAL_PROCEED 0 ");
                            OnVPProceedError(proceed.Error);
                        }
                        break;
                    }

                    case VIRTUAL_STATUS:
                    {
                        XVPStatus vpStatus = new XVPStatus();
                        vpStatus.Parse(rootNode);
                        Logger.Log("VIRTUAL_STATUS" + vpStatus.ToString());
                        OnVPStatusRecieved(vpStatus);
                        break;
                    }

                    case APPLY_PROMO_COUPONE:
                    {
                        XsollaForm form = new XsollaForm();
                        form.Parse(rootNode);
                        OnApplyCouponeReceived(form);
                        break;
                    }

                    case COUPON_PROCEED:
                    {
                        XsollaCouponProceedResult couponProceed = new XsollaCouponProceedResult();
                        couponProceed.Parse(rootNode);
                        if (couponProceed._error != null)
                        {
                            Logger.Log("COUPON_PROCEED ERROR: " + couponProceed._error);
                            OnCouponProceedErrorRecived(couponProceed);
                        }
                        else
                        {
                            long operationId = couponProceed._operationId;
                            if (post.ContainsKey("coupon_code"))
                            {
                                post.Remove("coupon_code");
                            }
                            post.Add("operation_id", operationId);

                            VPaymentStatus(post);
                        }
                        break;
                    }

                    case CALCULATE_CUSTOM_AMOUNT:
                    {
                        CustomVirtCurrAmountController.CustomAmountCalcRes res = new CustomVirtCurrAmountController.CustomAmountCalcRes().Parse(rootNode["calculation"]) as CustomVirtCurrAmountController.CustomAmountCalcRes;
                        OnCustomAmountResRecieved(res);
                        break;
                    }

                    case PAYMENT_MANAGER_LIST:
                    {
                        XsollaSavedPaymentMethods res = new XsollaSavedPaymentMethods().Parse(rootNode) as XsollaSavedPaymentMethods;
                        OnPaymentManagerMethod(res, false);
                        break;
                    }

                    case DELETE_SAVED_METHOD:
                    {
                        OnDeleteSavedPaymentMethod();
                        break;
                    }

                    case SUBSCRIPTIONS_MANAGER_LIST:
                    {
                        XsollaManagerSubscriptions lSubsList = new XsollaManagerSubscriptions().Parse(rootNode["subscriptions"]) as XsollaManagerSubscriptions;
                        OnManageSubsListrecived(lSubsList);
                        break;
                    }

                    default:
                        break;
                    }
                }
                else
                {
                    XsollaError error = new XsollaError();
                    error.Parse(rootNode);
                    OnErrorReceived(error);
                }
            }
            else
            {
                JSONNode errorNode = JSON.Parse(www.text);
                string   errorMsg  = errorNode["errors"].AsArray[0]["message"].Value
                                     + ". Support code " + errorNode["errors"].AsArray[0]["support_code"].Value;
                int errorCode = 0;
                if (www.error.Length > 3)
                {
                    errorCode = int.Parse(www.error.Substring(0, 3));
                }
                else
                {
                    errorCode = int.Parse(www.error);
                }
                OnErrorReceived(new XsollaError(errorCode, errorMsg));
            }
            if (projectId != null && !"".Equals(projectId))
            {
                LogEvent("UNITY " + SDK_VERSION + " REQUEST", projectId, www.url);
            }
            else
            {
                LogEvent("UNITY " + SDK_VERSION + " REQUEST", "undefined", www.url);
            }
        }
        //TODO minimize
        private void InitMenu(XsollaUtils utils)
        {
            _radioController = menuTransform.gameObject.AddComponent <RadioGroupController> ();
            GameObject menuItemPrefab      = Resources.Load(PREFAB_VIEW_MENU_ITEM) as GameObject;
            GameObject menuItemIconPrefab  = Resources.Load(PREFAB_VIEW_MENU_ITEM_ICON) as GameObject;
            GameObject menuItemEmptyPrefab = Resources.Load(PREFAB_VIEW_MENU_ITEM_EMPTY) as GameObject;
//			menuTransform = mainScreen.GetComponentInChildren<HorizontalLayoutGroup> ().gameObject.transform;
            Dictionary <string, XComponent> components = utils.GetProject().components;
            XsollaPaystation2 paystation2 = utils.GetSettings().paystation2;
            bool isGoodsRequred           = components.ContainsKey("items") && components ["items"].IsEnabled;

            if (isGoodsRequred)
            {
                GameObject menuItemGoods = Instantiate(menuItemPrefab) as GameObject;
                Text[]     texts         = menuItemGoods.GetComponentsInChildren <Text>();
                texts[0].text = "";
                texts[1].text = utils.GetTranslations().Get(XsollaTranslations.VIRTUALITEM_PAGE_TITLE);
                menuItemGoods.GetComponent <Button>().onClick.AddListener(delegate {
                    LoadGoodsGroups();
                    _radioController.SelectItem(0);
                });
                menuItemGoods.transform.SetParent(menuTransform);
                _radioController.AddButton(menuItemGoods.GetComponent <RadioButton>());
            }
            //HACK with Unity 5.3
            //bool isPricepointsRequired = components.ContainsKey("virtual_currency") && components ["virtual_currency"].IsEnabled;
            if (paystation2.pricepointsAtFirst != null && paystation2.pricepointsAtFirst.Equals("1"))
            {
                GameObject menuItemPricepoints = Instantiate(menuItemPrefab) as GameObject;
                Text[]     texts = menuItemPricepoints.GetComponentsInChildren <Text>();
                texts[0].text = "";
                texts[1].text = utils.GetTranslations().Get(XsollaTranslations.PRICEPOINT_PAGE_TITLE);
                menuItemPricepoints.GetComponent <Button>().onClick.AddListener(delegate {
                    LoadShopPricepoints();
                    _radioController.SelectItem(1);
                });
                menuItemPricepoints.transform.SetParent(menuTransform);
                _radioController.AddButton(menuItemPricepoints.GetComponent <RadioButton>());
            }

            if (components.ContainsKey("coupons") && components["coupons"].IsEnabled)
            {
                GameObject menuItemCoupons = Instantiate(menuItemPrefab) as GameObject;
                Text[]     texts           = menuItemCoupons.GetComponentsInChildren <Text>();
                texts[0].text = "";
                texts[1].text = utils.GetTranslations().Get(XsollaTranslations.COUPON_PAGE_TITLE);
                menuItemCoupons.GetComponent <Button>().onClick.AddListener(delegate {
                    ShowRedeemCoupon();
                    _radioController.SelectItem(2);
                });
                menuItemCoupons.transform.SetParent(menuTransform);
                _radioController.AddButton(menuItemCoupons.GetComponent <RadioButton>());
            }

            GameObject menuItemEmpty = Instantiate(menuItemEmptyPrefab);

            menuItemEmpty.transform.SetParent(menuTransform);


            GameObject menuItemFavorite = Instantiate(menuItemIconPrefab);

            menuItemFavorite.GetComponentInChildren <Text> ().text = "";
            menuItemFavorite.GetComponent <Button>().onClick.AddListener(delegate {
                _shopViewController.SetTitle(utils.GetTranslations().Get(XsollaTranslations.VIRTUALITEMS_TITLE_FAVORITE));
                LoadFavorites();
                _radioController.SelectItem(3);
            });
            menuItemFavorite.transform.SetParent(menuTransform);
            _radioController.AddButton(menuItemFavorite.GetComponent <RadioButton>());
        }
        /// <summary>
        /// Sets the amount block.
        /// </summary>
        /// <param name="pVcAmount">P vc amount.</param>
        /// <param name="pVcAmountWithoutDiscount">P vc amount without discount.</param>
        /// <param name="pAmount">P amount.</param>
        /// <param name="pAmountWithoutDiscount">P amount without discount.</param>
        /// <param name="pCurrency">P currency.</param>
        private void SetAmountBlock(Decimal pVcAmount, Decimal pVcAmountWithoutDiscount, Decimal pAmount, Decimal pAmountWithoutDiscount, String pCurrency)
        {
            // Виртуальная покупка или нет
            if (mItem.IsVirtualPayment())
            {
                if (pVcAmount == pVcAmountWithoutDiscount)
                {
                    mAmount.text = pVcAmount.ToString("N2");
                }
                else
                {
                    mAmount.text = pVcAmountWithoutDiscount.ToString("N2") + " " + pVcAmount.ToString("N2");
                }

                if (mUtils.GetProject().virtualCurrencyIconUrl != "null")
                {
                    // если тут придется ошибка с загрузкой, нужно залить альфа канал
                    mImgLoader.LoadImage(mVcIcon, mUtils.GetProject().virtualCurrencyIconUrl);
                }
                else
                {
                    mAmount.text = mAmount.text + " " + mUtils.GetProject().virtualCurrencyName;
                    mVcIcon.gameObject.SetActive(false);
                }
                mCurrency.gameObject.SetActive(false);
            }
            else
            {
                mVcIcon.gameObject.SetActive(false);
                if (pAmount == pAmountWithoutDiscount)
                {
                    mAmount.text = CurrencyFormatter.Instance.FormatPrice(pCurrency, pAmount);
                }
                else
                {
                    mOldAmount.enabled = true;
                    mOldAmount.text    = CurrencyFormatter.Instance.FormatPrice(pCurrency, pAmountWithoutDiscount);
                    mAmount.text       = CurrencyFormatter.Instance.FormatPrice(pCurrency, pAmount);
                }
            }

            // Название для кнопки покупки
            mBtnBuyText.text = mUtils.GetTranslations().Get("virtual_item_option_button");

            // Если цена должна быть в кнопке
            if (mUtils.GetSettings().mDesktop.pVirtItems.mButtonWithPrice)
            {
                // Скрываем текст самой кнопки
                mBuyBtn.GetComponentInChildren <Text>().gameObject.SetActive(false);
                // Переносим ценовой блок в кнопку
                mAmountPanel.transform.SetParent(mBuyBtn.transform);
                // Растягиваем
                Resizer.ResizeToParrentRe(mAmountPanel);
                // Меняем цвет текстов
                IEnumerator lEnum = mAmountPanel.transform.GetComponentsInChildren <ColorController>().GetEnumerator();
                while (lEnum.MoveNext())
                {
                    (lEnum.Current as ColorController).itemsToColor[0].color = StyleManager.BaseColor.txt_white;
                }
            }

            mBuyBtn.GetComponent <Button>().onClick.AddListener(delegate
            {
                BuyClick(mItem);
            });
        }
 private void callbackDeleteSubMethod(JSONNode pNode)
 {
     if (pNode["status"].Value == "saved")
     {
         // перестроить детализацию и показать статус подписка отменена
         OnClickBackSubsListAction();
         showStatus(String.Format(StringHelper.PrepareFormatString(mUtils.GetTranslations().Get("user_subscription_message_canceled")), mLocalSubDetail.mName, mUtils.GetProject().name));
     }
 }