Get() public méthode

public Get ( string key ) : string
key string
Résultat string
        public void init(XsollaManagerSubscription pSub, XsollaTranslations pTranslation)
        {
            mSub          = pSub;
            mSubName.text = mSub.GetName();
            String nextChargeFormat = pTranslation.Get("next_charge");             // next_charge:"Next invoice: {{amount}}, {{date}}↵"

            int indx = 0;

            while (nextChargeFormat.Contains("{{"))
            {
                String replacedPart = nextChargeFormat.Substring(nextChargeFormat.IndexOf("{{", 0) + 1, nextChargeFormat.IndexOf("}}", 0) - nextChargeFormat.IndexOf("{{", 0));
                nextChargeFormat = nextChargeFormat.Replace(replacedPart, indx.ToString());
                indx++;
            }

            if (pSub.mStatus == "active")
            {
                mNextInvoice.text = String.Format(nextChargeFormat, mSub.mCharge.ToString(), StringHelper.DateFormat(pSub.mDateNextCharge));
            }
            else
            {
                mNextInvoice.gameObject.SetActive(false);
            }

            if (pSub.mPaymentMethod != "null")
            {
                mPaymentMethodName.text = pSub.mPaymentMethod + " " + pSub.mPaymentVisibleName;
            }
            else
            {
                switch (pSub.mStatus)
                {
                case "freeze":
                {
                    mPaymentMethodName.text = String.Format(StringHelper.PrepareFormatString(pTranslation.Get("user_subscription_hold_to")), StringHelper.DateFormat(pSub.mHoldDates.dateTo));
                    break;
                }

                case "non_renewing":
                {
                    mPaymentMethodName.text = String.Format(StringHelper.PrepareFormatString(pTranslation.Get("user_subscription_non_renewing")), StringHelper.DateFormat(pSub.mDateNextCharge));
                    break;
                }

                default:
                {
                    mPaymentMethodName.gameObject.SetActive(false);
                    break;
                }
                }
            }

            mDetailText.text = pTranslation.Get("user_subscription_to_details");
        }
Exemple #2
0
        public List <LabelValue> getImportDetails()
        {
            List <LabelValue>  list        = new List <LabelValue>();
            XsollaTranslations translation = mUtils.GetTranslations();

            // ПОЛЯ ДЕТАЛИЗАЦИИ
            // имя
            list.Add(new LabelValue(translation.Get("user_subscription_name"), mSubDetail.mName));
            // статус
            list.Add(new LabelValue(translation.Get("user_subscription_status"), translation.Get("user_subscription_status_" + mSubDetail.mStatus)));
            // ценa
            list.Add(new LabelValue(translation.Get("user_subscription_charge"), mSubDetail.mCharge.ToString()));
            // цикл платежа
            list.Add(new LabelValue(translation.Get("user_subscription_period"), formattedPeriod(mSubDetail.mPeriod.mValue.ToString(), mSubDetail.mPeriod.mUnit)));

            if (mSubDetail.mStatus == "non_renewing")
            {
                list.Add(new LabelValue(translation.Get("user_subscription_end_bill_date"), StringHelper.DateFormat(mSubDetail.mDateNextCharge)));
            }

            if (mSubDetail.mNextPeriodPlanChange != null)
            {
                list.Add(new LabelValue(translation.Get("user_subscription_new_plan"), string.Format(StringHelper.PrepareFormatString(translation.Get("user_subscription_next_period_plan_change")), mSubDetail.mNextPeriodPlanChange.name, StringHelper.DateFormat(mSubDetail.mNextPeriodPlanChange.date))));
            }

            if (mSubDetail.mIsSheduledHoldExist && (mSubDetail.mSheduledHoldDates != null) || (mSubDetail.mStatus == "freeze") && (mSubDetail.mHoldDates != null))
            {
                String lDateFrom = "", lDateTo = "";
                if (mSubDetail.mStatus == "freeze")
                {
                    if (mSubDetail.mHoldDates != null)
                    {
                        lDateFrom = StringHelper.DateFormat(mSubDetail.mHoldDates.dateFrom);
                        lDateTo   = StringHelper.DateFormat(mSubDetail.mHoldDates.dateTo);
                    }
                }
                else
                {
                    if (mSubDetail.mSheduledHoldDates != null)
                    {
                        lDateFrom = StringHelper.DateFormat(mSubDetail.mSheduledHoldDates.dateFrom);
                        lDateTo   = StringHelper.DateFormat(mSubDetail.mSheduledHoldDates.dateTo);
                    }
                }

                if (mSubDetail.mIsSheduledHoldExist)
                {
                    list.Add(new LabelValue(translation.Get("user_subscription_hold_dates"), lDateFrom + " - " + lDateTo, translation.Get(mSubDetail.mStatus == "freeze"?"user_subscription_unhold":"cancel"), cancelHoldDates));
                }
                else
                {
                    list.Add(new LabelValue(translation.Get("user_subscription_hold_dates"), lDateFrom + " - " + lDateTo));
                }
            }

            return(list);
        }
 private void InitFooter(XsollaUtils utils)
 {
     if (utils != null)
     {
         Text[]             texts         = mainScreen.GetComponentsInChildren <Text> ();
         XsollaTranslations translatrions = utils.GetTranslations();
         texts [4].text = translatrions.Get(XsollaTranslations.SUPPORT_CUSTOMER_SUPPORT);
         texts [5].text = translatrions.Get(XsollaTranslations.SUPPORT_CONTACT_US);
         texts [6].text = translatrions.Get(XsollaTranslations.XSOLLA_COPYRIGHT);
         texts [7].text = translatrions.Get(XsollaTranslations.FOOTER_SECURED_CONNECTION);
         texts [8].text = translatrions.Get(XsollaTranslations.FOOTER_AGREEMENT);
     }
 }
 protected GameObject GetHelp(XsollaTranslations translations)
 {
     if (translations != null)
     {
         GameObject helpObj = GetObject("Prefabs/SimpleView/Help");
         Text[]     texsts  = helpObj.GetComponentsInChildren <Text>();
         texsts[0].text = translations.Get(XsollaTranslations.SUPPORT_PHONE);
         texsts[1].text = translations.Get(XsollaTranslations.SUPPORT_NEED_HELP);
         texsts[2].text = "*****@*****.**";
         texsts[3].text = translations.Get(XsollaTranslations.SUPPORT_CUSTOMER_SUPPORT);
         return(helpObj);
     }
     return(null);
 }
Exemple #5
0
		protected GameObject GetHelp(XsollaTranslations translations)
		{
			if (translations != null)
			{ 
				GameObject helpObj = Instantiate (Resources.Load ("Prefabs/SimpleView/Help")) as GameObject;
				Text[] texsts = helpObj.GetComponentsInChildren<Text>();
				texsts[0].text = translations.Get(XsollaTranslations.SUPPORT_PHONE);
				texsts[1].text = translations.Get(XsollaTranslations.SUPPORT_NEED_HELP);
				texsts[2].text = "*****@*****.**";
				texsts[3].text = translations.Get(XsollaTranslations.SUPPORT_CUSTOMER_SUPPORT);
				return helpObj;
			}
			return null;
		}
Exemple #6
0
 private void DrawScreen(XsollaTranslations translations, XsollaError error)
 {
     linerLayout.AddObject(GetError(error));
     linerLayout.AddObject(GetButton(translations.Get(XsollaTranslations.FORM_CONTINUE), delegate { OnClickButton(error); }));
     linerLayout.AddObject(GetHelp(translations));
     linerLayout.Invalidate();
 }
Exemple #7
0
        public List <LabelValue> getImportDetails()
        {
            List <LabelValue>  list        = new List <LabelValue>();
            XsollaTranslations translation = mUtils.GetTranslations();

            // ПОЛЯ ДЕТАЛИЗАЦИИ
            // имя
            if (mSubDetail.mPaymentMethodName != "null")
            {
                list.Add(new LabelValue(translation.Get("user_subscription_payment_method"), mSubDetail.mPaymentMethodName + " (" + mSubDetail.mPaymentMethodVisName + ")"));
            }
            // сумма след списание
            list.Add(new LabelValue(translation.Get("user_subscription_next_bill_sum"), mSubDetail.mNextCharge.ToString()));
            // дата след списание
            list.Add(new LabelValue(translation.Get("user_subscription_next_bill_date"), StringHelper.DateFormat(mSubDetail.mDateNextCharge)));
            return(list);
        }
Exemple #8
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);
                });
            }
        }
        public void InitScreen(XsollaTranslations pTranslation, XsollaFormElement pForm)
        {
            _promoBtn.GetComponent<Text>().text = pTranslation.Get("coupon_control_header");
            _promoDesc.text = pTranslation.Get("coupon_control_hint");
            _promoCodeApply.gameObject.GetComponentInChildren<Text>().text = pTranslation.Get("coupon_control_apply");
            _acceptLable.text = pTranslation.Get("coupon_control_accepted");

            _inputField.onValueChanged.AddListener(delegate
                {
                    if (_panelError.activeSelf)
                        _panelError.SetActive(false);
                });

            if (pForm.IsReadOnly() && !pForm.GetValue().Equals(""))
            {
                _inputField.text = pForm.GetValue();
                ApplySuccessful();
            }
        }
        public void InitScreen(XsollaTranslations pTranslation, XsollaFormElement pForm)
        {
            _promoBtn.GetComponent <Text>().text = pTranslation.Get("coupon_control_header");
            _promoDesc.text = pTranslation.Get("coupon_control_hint");
            _promoCodeApply.gameObject.GetComponentInChildren <Text>().text = pTranslation.Get("coupon_control_apply");
            _acceptLable.text = pTranslation.Get("coupon_control_accepted");

            _inputField.onValueChanged.AddListener(delegate
            {
                if (_panelError.activeSelf)
                {
                    _panelError.SetActive(false);
                }
            });

            if (pForm.IsReadOnly() && !pForm.GetValue().Equals(""))
            {
                _inputField.text = pForm.GetValue();
                ApplySuccessful();
            }
        }
        public void InitScreen(XsollaTranslations pTranslation, XsollaHistoryList pList, String pVirtualCurrName)
        {
            mVirtCurrName = pVirtualCurrName;
            Logger.Log("Init history screen");
            mTitle.text = pTranslation.Get("balance_history_page_title");

            mBtnContinue.GetComponent <Text>().text = pTranslation.Get("balance_back_button") + " >";
            mBtnContinue.GetComponent <Button>().onClick.AddListener(delegate
            {
                Logger.Log("Destroy history");
                Destroy(this.gameObject);
            });

            AddHistoryRow(pTranslation, null, false, true);

            foreach (XsollaHistoryItem item in pList.GetItemsList())
            {
                AddHistoryRow(pTranslation, item, mLimit % 2 != 0, false);
                mLimit++;
            }

            isRefresh = false;
        }
        public void InitScreen(XsollaTranslations pTranslation, XsollaHistoryList pList, String pVirtualCurrName)
        {
            mVirtCurrName = pVirtualCurrName;
            Logger.Log("Init history screen");
            mTitle.text = pTranslation.Get("balance_history_page_title");

            mBtnContinue.GetComponent<Text>().text = pTranslation.Get("balance_back_button") + " >";
            mBtnContinue.GetComponent<Button>().onClick.AddListener(delegate
                {
                    Logger.Log("Destroy history");
                    Destroy(this.gameObject);
                });

            AddHistoryRow(pTranslation, null, false, true);

            foreach (XsollaHistoryItem item in pList.GetItemsList())
            {
                AddHistoryRow(pTranslation, item, mLimit%2 != 0, false);
                mLimit ++;
            }

            isRefresh = false;
        }
        public void InitBtn(XsollaSubscription pSub, XsollaTranslations pTranslation)
        {
            _sub          = pSub;
            _subName.text = _sub.GetName();

            if (_sub.description != null)
            {
                _desc.GetComponent <Text>().text = _sub.description;
                _desc.SetActive(true);
            }
            else
            {
                _desc.SetActive(false);
            }

            if (!_sub.IsSpecial())
            {
                _newPrice.text = CurrencyFormatter.Instance.FormatPrice(_sub.chargeCurrency, _sub.chargeAmount);
                _oldPrice.gameObject.SetActive(false);
            }
            else
            {
                _oldPrice.text = CurrencyFormatter.Instance.FormatPrice(_sub.chargeCurrency, _sub.chargeAmountWithoutDiscount);
                _newPrice.text = CurrencyFormatter.Instance.FormatPrice(_sub.chargeCurrency, _sub.chargeAmount);
                _offerText.GetComponent <Text>().text = pTranslation.Get("option_offer");
            }
            _offerText.SetActive(_sub.IsSpecial()?true:false);
            _offerImagePanel.enabled = _sub.IsSpecial()?true:false;

            _period.text = _sub.GetPeriodString("Every");

            _btnSub.onClick.AddListener(() => {
                Dictionary <string, object> purchase = new Dictionary <string, object>();
                purchase.Add("id_package", _sub.id);

                gameObject.GetComponentInParent <XsollaPaystationController> ().ChooseItem(purchase, false);
            });
        }
        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());
            });
        }
        public void InitView(XsollaTranslations translations, XsollaSummary summary)
        {
            _translations = translations;
            _summary      = summary;

            if (this.gameObject.GetComponent <VerticalLayoutGroup>() == null)
            {
                this.gameObject.AddComponent <VerticalLayoutGroup>();
                VerticalLayoutGroup obj = this.GetComponent <VerticalLayoutGroup>();
                obj.childForceExpandHeight = false;
            }
            GameObject header = Instantiate(orderSummaryPrefab);

            header.GetComponentsInChildren <Text> () [0].text = translations.Get(XsollaTranslations.PAYMENT_SUMMARY_HEADER);
            linearLayout.AddObject(header);
            foreach (IXsollaSummaryItem purchase in _summary.GetPurchases())
            {
                linearLayout.AddObject(GetSummaryItem(purchase));
            }
            XsollaFinance finance = _summary.GetFinance();

            linearLayout.AddObject(GetItem(subTotalPrefab, translations.Get(XsollaTranslations.PAYMENT_SUMMARY_SUBTOTAL), PriceFormatter.Format(finance.subTotal.amount, finance.subTotal.currency)));
            if (finance.discount != null && finance.discount.amount > 0)
            {
                linearLayout.AddObject(GetItem(financeItemPrefab, translations.Get(XsollaTranslations.PAYMENT_SUMMARY_DISCOUNT), "- " + PriceFormatter.Format(finance.discount.amount, finance.discount.currency)));
            }
            if (finance.fee != null)
            {
                linearLayout.AddObject(GetItem(financeItemPrefab, translations.Get(XsollaTranslations.PAYMENT_SUMMARY_FEE), PriceFormatter.Format(finance.fee.amount, finance.fee.currency)));
            }
            if (finance.xsollaCredits != null && finance.xsollaCredits.amount > 0)
            {
                linearLayout.AddObject(GetItem(financeItemPrefab, translations.Get(XsollaTranslations.PAYMENT_SUMMARY_XSOLLA_CREDITS), PriceFormatter.Format(finance.xsollaCredits.amount, finance.xsollaCredits.currency)));
            }
            linearLayout.AddObject(GetItem(totalPrefab, translations.Get(XsollaTranslations.PAYMENT_SUMMARY_TOTAL), PriceFormatter.Format(finance.total.amount, finance.total.currency)));
            if (finance.vat != null && finance.vat.amount > 0)
            {
                linearLayout.AddObject(GetItem(financeItemPrefab, "VAT", PriceFormatter.Format(finance.vat.amount, finance.vat.currency)));
            }
            linearLayout.Invalidate();
        }
        public void InitView(XsollaTranslations translations, XsollaSummary summary)
        {
            _translations = translations;
            _summary = summary;

            if (this.gameObject.GetComponent<VerticalLayoutGroup>() == null)
            {
                this.gameObject.AddComponent<VerticalLayoutGroup>();
                VerticalLayoutGroup obj = this.GetComponent<VerticalLayoutGroup>();
                obj.childForceExpandHeight = false;
            }
            GameObject header = Instantiate (orderSummaryPrefab);
            header.GetComponentsInChildren<Text> () [0].text = translations.Get (XsollaTranslations.PAYMENT_SUMMARY_HEADER);
            linearLayout.AddObject(header);
            foreach(IXsollaSummaryItem purchase in _summary.GetPurchases ())
            {
                linearLayout.AddObject(GetSummaryItem(purchase));
            }
            XsollaFinance finance = _summary.GetFinance ();
            linearLayout.AddObject(GetItem(subTotalPrefab, translations.Get(XsollaTranslations.PAYMENT_SUMMARY_SUBTOTAL), PriceFormatter.Format(finance.subTotal.amount, finance.subTotal.currency)));
            if (finance.discount != null && finance.discount.amount > 0)
            {
                linearLayout.AddObject(GetItem(financeItemPrefab, translations.Get(XsollaTranslations.PAYMENT_SUMMARY_DISCOUNT), "- " + PriceFormatter.Format(finance.discount.amount, finance.discount.currency)));
            }
            if (finance.fee != null)
            {
                linearLayout.AddObject (GetItem (financeItemPrefab, translations.Get(XsollaTranslations.PAYMENT_SUMMARY_FEE), PriceFormatter.Format (finance.fee.amount, finance.fee.currency)));
            }
            if (finance.xsollaCredits != null && finance.xsollaCredits.amount > 0)
            {
                linearLayout.AddObject(GetItem(financeItemPrefab, translations.Get(XsollaTranslations.PAYMENT_SUMMARY_XSOLLA_CREDITS), PriceFormatter.Format(finance.xsollaCredits.amount, finance.xsollaCredits.currency)));
            }
            linearLayout.AddObject(GetItem(totalPrefab, translations.Get(XsollaTranslations.PAYMENT_SUMMARY_TOTAL), PriceFormatter.Format(finance.total.amount, finance.total.currency)));
            if (finance.vat != null && finance.vat.amount > 0)
            {
                    linearLayout.AddObject(GetItem(financeItemPrefab, "VAT", PriceFormatter.Format(finance.vat.amount, finance.vat.currency)));
            }
            linearLayout.Invalidate ();
        }
Exemple #17
0
        public void InitView(XsollaTranslations pTranslations, XsollaForm form)
        {
            _form = form;
            // if have skipCheckout and this checkout form
            if ((form.GetCurrentCommand() == XsollaForm.CurrentCommand.CHECKOUT) && form.GetSkipChekout())
            {
                string checkoutToken  = _form.GetCheckoutToken();
                bool   isLinkRequired = checkoutToken != null &&
                                        !"".Equals(checkoutToken) &&
                                        !"null".Equals(checkoutToken) &&
                                        !"false".Equals(checkoutToken);
                if (isLinkRequired)
                {
                    OnClickPay(isLinkRequired);
                    return;
                }
            }

            string pattern = "{{.*?}}";
            Regex  regex   = new Regex(pattern);
            string title   = regex.Replace(pTranslations.Get(XsollaTranslations.PAYMENT_PAGE_TITLE_VIA), form.GetTitle(), 1);

            layout.AddObject(GetTitle(title));
            layout.AddObject(GetError(form.GetError()));
            layout.AddObject(GetInfo(form.GetMessage()));
            if (form.GetVisible().Count > 0)
            {
                GameObject formView = GetFormView(form, pTranslations);
                layout.AddObject(formView);
            }
            if (form.GetAccountXsolla() != null && !"".Equals(form.GetAccountXsolla()) && !"null".Equals(form.GetAccountXsolla()))
            {
                layout.AddObject(GetTwoTextPlate("Xsolla number", form.GetAccountXsolla()));
            }
            if (form.GetAccount() != null && !"".Equals(form.GetAccount()) && !"null".Equals(form.GetAccount()))
            {
                layout.AddObject(GetTwoTextPlate("2pay number", form.GetAccount()));
            }
            if (form.IsValidPaymentSystem())
            {
                layout.AddObject(GetTextPlate(pTranslations.Get(XsollaTranslations.FORM_CC_EULA)));
            }
            GameObject footerInstance = Instantiate(footer);

            Text[] footerTexts = footerInstance.GetComponentsInChildren <Text> ();
//			footerTexts [0].text = "back";//back
            string nextStep = form.GetNextStepString();

            footerTexts [2].text = nextStep;            //translations.Get (XsollaTranslations.FORM_CONTINUE);//pay now
            Button[] footerButtons = footerInstance.GetComponentsInChildren <Button> ();
            if (OnClickBack != null)
            {
                footerButtons [0].onClick.AddListener(() => {
                    OnBack();
                });
            }
            else
            {
                footerButtons [0].gameObject.SetActive(false);
            }

            if (form.GetCurrentCommand() == XsollaForm.CurrentCommand.ACCOUNT ||
                form.GetCurrentCommand() == XsollaForm.CurrentCommand.CREATE ||
                form.GetCurrentCommand() == XsollaForm.CurrentCommand.CHECKOUT) //
            {
                footerTexts [1].text = "";                                      //total
                RectTransform buttonRect = footerButtons [1].GetComponent <RectTransform>();
                Vector2       vecMin     = buttonRect.anchorMin;
                vecMin.x             = vecMin.x - (buttonRect.anchorMax.x - vecMin.x) / 2;
                buttonRect.anchorMin = vecMin;
            }
            else
            {
                footerTexts [1].text = pTranslations.Get(XsollaTranslations.TOTAL) + " " + form.GetSumTotal();                  //total
            }

            layout.AddObject(footerInstance);
            layout.Invalidate();

            if (!"".Equals(nextStep) && form.GetCurrentCommand() != XsollaForm.CurrentCommand.ACCOUNT)
            {
                string checkoutToken  = _form.GetCheckoutToken();
                bool   isLinkRequired = checkoutToken != null &&
                                        !"".Equals(checkoutToken) &&
                                        !"null".Equals(checkoutToken) &&
                                        !"false".Equals(checkoutToken);
                string link = "https://secure.xsolla.com/pages/checkout/?token=" + _form.GetCheckoutToken();
                if (isLinkRequired && Application.platform == RuntimePlatform.WebGLPlayer)
                {
                    RectTransform buttonRect = footerButtons [1].GetComponent <RectTransform>();
                    int           width      = (int)(buttonRect.rect.xMax - buttonRect.rect.xMin);
                    int           height     = (int)(buttonRect.rect.yMax - buttonRect.rect.yMin);
                    height = height * 8;
                    Vector3[] vec = new Vector3[4];
                    buttonRect.GetWorldCorners(vec);
                    int xPos = (int)vec[0].x;
                    int yPos = (int)vec[0].y;
                    yPos = yPos / 2;
                    CreateLinkButtonWebGl(xPos, yPos, width, height, link, "CardPaymeentForm", "Next");
                    footerButtons [1].onClick.AddListener(() => {
                        OnClickPay(false);
                    });
                }
                else
                {
                    footerButtons [1].onClick.AddListener(() => {
                        OnClickPay(isLinkRequired);
                    });
                }
            }
            else
            {
                footerButtons [1].gameObject.SetActive(false);
            }
        }
Exemple #18
0
        public GameObject GetCardViewWeb(XsollaForm xsollaForm, XsollaTranslations translations)
        {
            GameObject cardViewObj = Instantiate(Resources.Load("Prefabs/SimpleView/_ScreenCheckout/CardViewLayoutWeb")) as GameObject;

            InputField[] inputs = cardViewObj.GetComponentsInChildren <InputField>();
            validators = new List <ValidatorInputField> ();
            for (int i = inputs.Length - 1; i >= 0; i--)
            {
                XsollaFormElement   element     = null;
                string              newErrorMsg = "Invalid";
                InputField          input       = inputs[i];
                ValidatorInputField validator   = input.GetComponentInChildren <ValidatorInputField>();
                // CVV > *HOLDER* > *ZIP* > YEAR > MONTH > NUMBER
                switch (i)               //input.tag)
                {
                case 5:                  //"CardNumber":
                    element     = xsollaForm.GetItem(XsollaApiConst.CARD_NUMBER);
                    newErrorMsg = translations.Get(XsollaTranslations.VALIDATION_MESSAGE_CARDNUMBER);
                    CCEditText ccEditText = input.GetComponent <CCEditText>();
                    isMaestro = ccEditText.IsMaestro();
                    validator.AddValidator(new ValidatorEmpty(newErrorMsg));
                    validator.AddValidator(new ValidatorCreditCard(newErrorMsg));
                    break;

                case 4:                        //"Month":
                    element     = xsollaForm.GetItem(XsollaApiConst.CARD_EXP_MONTH);
                    newErrorMsg = translations.Get(XsollaTranslations.VALIDATION_MESSAGE_CARD_MONTH);
                    validator.AddValidator(new ValidatorEmpty(newErrorMsg));
                    validator.AddValidator(new ValidatorMonth(newErrorMsg));
                    break;

                case 3:                        //"Year":
                    element     = xsollaForm.GetItem(XsollaApiConst.CARD_EXP_YEAR);
                    newErrorMsg = translations.Get(XsollaTranslations.VALIDATION_MESSAGE_CARD_YEAR);
                    validator.AddValidator(new ValidatorEmpty(newErrorMsg));
                    validator.AddValidator(new ValidatorYear(newErrorMsg));
                    break;

                case 2:                        //"Zip":
                    element     = xsollaForm.GetItem(XsollaApiConst.CARD_ZIP);
                    newErrorMsg = translations.Get(XsollaTranslations.VALIDATION_MESSAGE_REQUIRED);
                    validator.AddValidator(new ValidatorEmpty(newErrorMsg));
                    break;

                case 1:                        //"CardHolder":
                    element     = xsollaForm.GetItem(XsollaApiConst.CARD_HOLDER);
                    newErrorMsg = translations.Get(XsollaTranslations.VALIDATION_MESSAGE_REQUIRED);
                    validator.AddValidator(new ValidatorEmpty(newErrorMsg));
                    break;

                case 0:                        //"Cvv":
                    element     = xsollaForm.GetItem(XsollaApiConst.CARD_CVV);
                    newErrorMsg = translations.Get(XsollaTranslations.VALIDATION_MESSAGE_CVV);
                    validator.AddValidator(new ValidatorEmpty(newErrorMsg));
                    validator.AddValidator(new ValidatorCvv(newErrorMsg, isMaestro));
                    break;

                default:
                    break;
                }

                if (element != null)
                {
                    //		input.text = element.GetTitle();
                    //						input.GetComponentInChildren<MainValidator>().setErrorMsg(newErrorMsg);
                    if (element.GetName() != XsollaApiConst.CARD_CVV)
                    {
                        input.GetComponentInChildren <Text>().text = element.GetExample();
                    }
                    // FIX update with unity 5.2
                    input.onValueChanged.AddListener(delegate { OnValueChange(input, element.GetName()); });
                }
                else
                {
                    DestroyImmediate(input.transform.parent.gameObject);
                }

                if (validator != null)
                {
                    validators.Add(validator);
                }
            }
            // Toggle allowSubscription
            // get toggle object
            Toggle toggle = cardViewObj.GetComponentInChildren <Toggle> ();

            if (xsollaForm.Contains(XsollaApiConst.ALLOW_SUBSCRIPTION))
            {
                XsollaFormElement ToggleElement = null;
                ToggleElement = xsollaForm.GetItem(XsollaApiConst.ALLOW_SUBSCRIPTION);
                // set label name
                Text lable = toggle.transform.GetComponentInChildren <Text>();
                lable.text = ToggleElement.GetTitle();
                OnValueChange(ToggleElement.GetName(), toggle.isOn?"1":"0");
                toggle.onValueChanged.AddListener((b) => {
                    OnValueChange(ToggleElement.GetName(), b?"1":"0");
                });
            }
            else
            {
                GameObject.Find(toggle.transform.parent.name).SetActive(false);
            }

            if (xsollaForm.Contains("couponCode") && xsollaForm.GetItem("couponCode").IsVisible())
            {
                GameObject          promoController = Instantiate(Resources.Load("Prefabs/SimpleView/_PaymentFormElements/ContainerPromoCode")) as GameObject;
                PromoCodeController controller      = promoController.GetComponent <PromoCodeController>();
                controller.InitScreen(translations, xsollaForm.GetItem("couponCode"));
                controller._inputField.onValueChanged.AddListener((s) => {
                    OnValueChange("couponCode", s.Trim());
                });
                controller._promoCodeApply.onClick.AddListener(() =>
                {
                    bool isLinkRequired = false;
                    if ((_form.GetCurrentCommand() == XsollaForm.CurrentCommand.CHECKOUT) && _form.GetSkipChekout())
                    {
                        string checkoutToken = _form.GetCheckoutToken();
                        isLinkRequired       = checkoutToken != null &&
                                               !"".Equals(checkoutToken) &&
                                               !"null".Equals(checkoutToken) &&
                                               !"false".Equals(checkoutToken);
                    }
                    if (isLinkRequired)
                    {
                        string link = "https://secure.xsolla.com/pages/checkout/?token=" + _form.GetCheckoutToken();
                        if (Application.platform == RuntimePlatform.WebGLPlayer ||
                            Application.platform == RuntimePlatform.OSXWebPlayer ||
                            Application.platform == RuntimePlatform.WindowsWebPlayer)
                        {
                            Application.ExternalEval("window.open('" + link + "','Window title')");
                        }
                        else
                        {
                            Application.OpenURL(link);
                        }
                    }
                    gameObject.GetComponentInParent <XsollaPaystationController> ().ApplyPromoCoupone(_form.GetXpsMap());
                });
                promoController.transform.SetParent(cardViewObj.transform);
            }
            return(cardViewObj);
        }
        public override void InitScreen(XsollaTranslations translations, XsollaStatus xsollaStatus)
        {
            ResizeToParent();

            GameObject.FindObjectOfType <MainHeaderController>().setStateUserMenu(false);

            string           input      = translations.Get(XsollaTranslations.STATUS_PURCHASED_DESCRIPTION);
            XsollaStatusText statusText = xsollaStatus.GetStatusText();

            XsollaStatus.Group currentStatus = xsollaStatus.GetGroup();
            if (input != null)
            {
                string pattern = "{{.*?}}";
                Regex  regex   = new Regex(pattern);

                if ((statusText.GetPurchsaeValue() != "") && (statusText.Get("sum").GetValue() != ""))
                {
                    input = regex.Replace(input, statusText.GetPurchsaeValue(), 1);
                    input = regex.Replace(input, statusText.Get("sum").GetValue(), 1);
                }
                else
                {
                    input = "";
                }
            }
            else
            {
                input = "";
            }
            PrepareStatus(currentStatus, xsollaStatus.GetStatusText().GetState(), input, xsollaStatus.GetInvoice(), xsollaStatus);
            AddTitle(statusText.GetProjectString());
            if (currentStatus == XsollaStatus.Group.DONE)
            {
                AddStatus(translations.Get(XsollaTranslations.VIRTUALSTATUS_DONE_DESCRIPTIONS));
            }

            if (statusText.GetPurchsaeValue() != "")
            {
                AddElement(statusText.GetPurchsaeValue(), statusText.Get("sum").GetValue());
            }

            XsollaStatusText.StatusTextElement element = statusText.Get("out");
            if (element != null)
            {
                AddElement(statusText.Get("out").GetPref(), statusText.Get("out").GetValue());
            }
            element = statusText.Get("invoice");
            if (element != null)
            {
                AddElement(statusText.Get("invoice").GetPref(), statusText.Get("invoice").GetValue());
            }
            element = statusText.Get("details");
            if (element != null)
            {
                AddElement(statusText.Get("details").GetPref(), statusText.Get("details").GetValue());
            }
            element = statusText.Get("time");
            if (element != null)
            {
                AddElement(statusText.Get("time").GetPref(), statusText.Get("time").GetValue());
            }
            element = statusText.Get("merchant");
            if (element != null)
            {
                AddElement(statusText.Get("merchant").GetPref(), statusText.Get("merchant").GetValue());
            }
            element = statusText.Get("userWallet");
            if (element != null)
            {
                AddElement(statusText.Get("userWallet").GetPref(), statusText.Get("userWallet").GetValue());
            }
            AddLine();
            AddBigElement(statusText.Get("sum").GetPref(), statusText.Get("sum").GetValue());

            statusViewExitButton.gameObject.GetComponent <Text> ().text = translations.Get(XsollaTranslations.BACK_TO_STORE);
            statusViewExitButton.onClick.AddListener(delegate
            {
                //OnClickExit(currentStatus, xsollaStatus.GetStatusData().GetInvoice(), xsollaStatus.GetStatusData().GetStatus(), null);
                OnClickBack(currentStatus, xsollaStatus.GetStatusData().GetInvoice(), xsollaStatus.GetStatusData().GetStatus(), null);
            });
        }
        public void Init(XsollaTranslations pTranslation, XsollaHistoryItem pItem, String pVirtCurrName, Boolean pEven, Action pSortAction, Boolean pHeader = false, Boolean pDesc = true)
        {
            Image imgComp = this.GetComponent <Image>();

            imgComp.enabled = pEven;

            if (pHeader)
            {
                mDate.text = pTranslation.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 = pTranslation.Get("balance_history_date") + " ↓";
                });

                mType.text       = pTranslation.Get("balance_history_purpose");
                mItem.text       = pTranslation.Get("balance_history_item");
                mBalance.text    = pTranslation.Get("balance_history_vc_amount");
                mPrice.text      = pTranslation.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.ToShortDateString();
            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(pTranslation.Get("balance_history_payment_info")), pItem.paymentName, pItem.invoiceId);
                break;
            }

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

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

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

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

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

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

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

            case "subscriptionCancellation":
            {
                mType.text = String.Format(prepareTypeStr(pTranslation.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)
            {
                mBalance.text = ((pItem.vcAmount > 0)?"+":"") + pItem.vcAmount + " " + pVirtCurrName + "\n" + "(=" + pItem.userBalance + " " + pVirtCurrName + ")";
            }
            else
            {
                mBalance.text = "";
            }

            if (pItem.paymentAmount != 0)
            {
                mPrice.text = CurrencyFormatter.FormatPrice(pItem.paymentCurrency, pItem.paymentAmount.ToString("0.00"));
                if (pItem.paymentCurrency == "RUB")
                {
                    mSymbolRub.SetActive(true);
                }
                else
                {
                    mSymbolRub.SetActive(false);
                    mPrice.alignment = TextAnchor.LowerLeft;
                }
            }
            else
            {
                mPrice.text = "";
            }
        }
        public override void InitScreen(XsollaTranslations translations, XsollaStatus xsollaStatus)
        {
            ResizeToParent();
            string           input      = translations.Get(XsollaTranslations.STATUS_PURCHASED_DESCRIPTION);
            XsollaStatusText statusText = xsollaStatus.GetStatusText();

            XsollaStatus.Group currentStatus = xsollaStatus.GetGroup();
            if (input != null)
            {
                string pattern = "{{.*?}}";
                Regex  regex   = new Regex(pattern);
                input = regex.Replace(input, statusText.GetPurchsaeValue(), 1);
                input = regex.Replace(input, statusText.Get("sum").GetValue(), 1);
            }
            else
            {
                input = "";
            }
            PrepareStatus(currentStatus, xsollaStatus.GetStatusText().GetState(), input, xsollaStatus.GetInvoice());
            AddTitle(statusText.GetProjectString());
            if (currentStatus == XsollaStatus.Group.DONE)
            {
                AddStatus(translations.Get(XsollaTranslations.VIRTUALSTATUS_DONE_DESCRIPTIONS));
            }

            AddElement(statusText.GetPurchsaeValue(), statusText.Get("sum").GetValue());

            XsollaStatusText.StatusTextElement element = statusText.Get("out");
            if (element != null)
            {
                AddElement(statusText.Get("out").GetPref(), statusText.Get("out").GetValue());
            }
            element = statusText.Get("invoice");
            if (element != null)
            {
                AddElement(statusText.Get("invoice").GetPref(), statusText.Get("invoice").GetValue());
            }
            element = statusText.Get("details");
            if (element != null)
            {
                AddElement(statusText.Get("details").GetPref(), statusText.Get("details").GetValue());
            }
            element = statusText.Get("time");
            if (element != null)
            {
                AddElement(statusText.Get("time").GetPref(), statusText.Get("time").GetValue());
            }
            element = statusText.Get("merchant");
            if (element != null)
            {
                AddElement(statusText.Get("merchant").GetPref(), statusText.Get("merchant").GetValue());
            }
            element = statusText.Get("userWallet");
            if (element != null)
            {
                AddElement(statusText.Get("userWallet").GetPref(), statusText.Get("userWallet").GetValue());
            }
            AddLine();
            AddBigElement(statusText.Get("sum").GetPref(), statusText.Get("sum").GetValue());
//			Debug.Log ("statusText.backUrlCaption " + statusText.backUrlCaption);

            if (statusText.backUrlCaption != null && !"".Equals(statusText.backUrlCaption))
            {
                statusViewExitButton.gameObject.GetComponent <Text> ().text = statusText.backUrlCaption;
            }
            else
            {
                statusViewExitButton.gameObject.GetComponent <Text> ().text = translations.Get(XsollaTranslations.BACK_TO_STORE);
            }
            statusViewExitButton.onClick.AddListener(delegate { OnClickExit(currentStatus, xsollaStatus.GetStatusData().GetInvoice(), xsollaStatus.GetStatusData().GetStatus(), null); });
        }