상속: IParseble
예제 #1
0
 public void UpdateDiscont(XsollaTranslations pTranslation, XsollaSummary pSummary)
 {
     // clear all gameobject
     linearLayout.objects.ForEach((obj) => Destroy(obj));
     // redraw
     InitView(pTranslation, pSummary);
 }
 public void UpdateDiscont(XsollaTranslations pTranslation, XsollaSummary pSummary)
 {
     // clear all gameobject
     linearLayout.objects.ForEach((obj) => Destroy(obj));
     // redraw
     InitView(pTranslation, pSummary);
 }
예제 #3
0
        /* * * * * * * * * * * * * * * * * * * * * * * * * * *
        * OVERRIDED METHODS
        * * * * * * * * * * * * * * * * * * * * * * * * * * */
        public IParseble Parse(JSONNode rootNode)
        {
//			textAll = new XsollaTextAll ();
//			textAll.Parse (rootNode[XsollaApiConst.R_TEXTALL]);
            JSONNode errorNode = rootNode [XsollaApiConst.ERROR_MSG];

            if (errorNode != null && errorNode.GetType() != typeof(JSONLazyCreator))
            {
                this.xsollaError = new XsollaError().Parse(errorNode) as XsollaError;
            }
            //errorNode = rootNode [XsollaApiConst.R_TEXTALL] [XsollaApiConst.ERROR_MSG][0];
            errorNode = rootNode ["errors"][0];
            if (errorNode != null)
            {
                this.xsollaError = new XsollaError().Parse(errorNode) as XsollaError;
            }
            this.SetAccount(rootNode [XsollaApiConst.R_ACCOUNT]);
            this.SetAccountXsolla(rootNode [XsollaApiConst.R_ACCOUNTXSOLLA]);
            this.SetCurrentCommand(rootNode[XsollaApiConst.R_CURRENTCOMMAND]);
            this.SetTitle(rootNode[XsollaApiConst.R_TITLE]);
            this.SetIconUrl(rootNode[XsollaApiConst.R_ICONURL]);
            this.SetCurrency(rootNode[XsollaApiConst.R_CURRENCY]);
            this.SetSum(rootNode[XsollaApiConst.R_BUYDATA]["sum"]);
            this.SetInstruction(rootNode[XsollaApiConst.R_INSTRUCTION]);
            this.SetPid(rootNode[XsollaApiConst.R_PID].AsInt);

            checkoutToken = rootNode ["checkoutToken"];
            JSONNode buyDataNode = rootNode ["buyData"];

            if (buyDataNode != null && !"null".Equals(buyDataNode))
            {
                buyData = new BuyData().Parse(buyDataNode) as BuyData;
            }

            JSONNode summaryNode = rootNode ["summary"];

            if (summaryNode != null && !"null".Equals(summaryNode))
            {
                summary = new XsollaSummary().Parse(summaryNode) as XsollaSummary;
            }

            JSONNode checkoutNode = rootNode ["checkout"];

            if (checkoutNode != null && !"null".Equals(checkoutNode))
            {
                chekout = new XsollaCheckout().Parse(checkoutNode) as XsollaCheckout;
            }

            JSONNode formNode = rootNode [XsollaApiConst.R_FORM];
            IEnumerable <JSONNode> formElements = formNode.Childs;
            IEnumerator <JSONNode> enumerator   = formElements.GetEnumerator();

            this.Clear();
            while (enumerator.MoveNext())
            {
                this.AddElement((XsollaFormElement) new XsollaFormElement().Parse(enumerator.Current));
            }
            return(this);
        }
        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 ();
        }
예제 #6
0
        /* * * * * * * * * * * * * * * * * * * * * * * * * * *
        * OVERRIDED METHODS
        * * * * * * * * * * * * * * * * * * * * * * * * * * */
        //            if (errorNode != null && errorNode.GetType() != typeof(JSONLazyCreator))
        //            {
        //                this.xsollaError = new XsollaError().Parse(errorNode) as XsollaError;
        //            }
        //            //errorNode = rootNode [XsollaApiConst.R_TEXTALL] [XsollaApiConst.ERROR_MSG][0];
        //            errorNode = rootNode ["errors"][0];
        //            if (errorNode != null)
        //            {
        //                this.xsollaError = new XsollaError().Parse(errorNode) as XsollaError;
        //            }
        public IParseble Parse(JSONNode rootNode)
        {
            JSONNode errorNode = rootNode [XsollaApiConst.R_ERRORS];
            if(errorNode.Count > 0)
                this.xsollaError = new XsollaError().ParseNew(errorNode[0]) as XsollaError;

            JSONNode messagesNode = rootNode [XsollaApiConst.R_MESSAGES];
            if (messagesNode.Count > 0)
                this.xsollaMessage = new XsollaMessage ().Parse (messagesNode[0]) as XsollaMessage;

            this.SetAccount (rootNode [XsollaApiConst.R_ACCOUNT]);
            this.SetAccountXsolla (rootNode [XsollaApiConst.R_ACCOUNTXSOLLA]);
            this.SetCurrentCommand (rootNode[XsollaApiConst.R_CURRENTCOMMAND]);
            this.SetTitle (rootNode[XsollaApiConst.R_TITLE]);
            this.SetIconUrl (rootNode[XsollaApiConst.R_ICONURL]);
            this.SetCurrency (rootNode[XsollaApiConst.R_CURRENCY]);
            this.SetSum (rootNode[XsollaApiConst.R_BUYDATA]["sum"]);
            this.SetInstruction (rootNode[XsollaApiConst.R_INSTRUCTION]);
            this.SetPid (rootNode[XsollaApiConst.R_PID].AsInt);
            this.SetSkipForm(rootNode[XsollaApiConst.R_SKIPFORM].AsBool);
            this.SetSkipCheckout(rootNode[XsollaApiConst.R_SKIPCHECKOUT].AsBool);

            checkoutToken = rootNode ["checkoutToken"];
            JSONNode buyDataNode = rootNode ["buyData"];
            if (buyDataNode != null && !"null".Equals (buyDataNode)) {
                buyData = new BuyData ().Parse (buyDataNode) as BuyData;
            }

            JSONNode summaryNode = rootNode ["summary"];
            if (summaryNode != null && !"null".Equals(summaryNode)) {
                summary = new XsollaSummary ().Parse (summaryNode) as XsollaSummary;
            }

            JSONNode checkoutNode = rootNode ["checkout"];
            if(checkoutNode != null && !"null".Equals(checkoutNode)){
                chekout = new XsollaCheckout ().Parse (checkoutNode) as XsollaCheckout;
            }

            JSONNode formNode = rootNode [XsollaApiConst.R_FORM];
            IEnumerable<JSONNode> formElements = formNode.Childs;
            IEnumerator<JSONNode> enumerator = formElements.GetEnumerator();
            this.Clear ();
            while(enumerator.MoveNext())
            {
                this.AddElement((XsollaFormElement)new XsollaFormElement().Parse(enumerator.Current));
            }
            return this;
        }
예제 #7
0
        /* * * * * * * * * * * * * * * * * * * * * * * * * * *
        * OVERRIDED METHODS
        * * * * * * * * * * * * * * * * * * * * * * * * * * */

        //			if (errorNode != null && errorNode.GetType() != typeof(JSONLazyCreator))
        //			{
        //				this.xsollaError = new XsollaError().Parse(errorNode) as XsollaError;
        //			}
        //			//errorNode = rootNode [XsollaApiConst.R_TEXTALL] [XsollaApiConst.ERROR_MSG][0];
        //			errorNode = rootNode ["errors"][0];
        //			if (errorNode != null)
        //			{
        //				this.xsollaError = new XsollaError().Parse(errorNode) as XsollaError;
        //			}
        public IParseble Parse(JSONNode rootNode)
        {
            JSONNode errorNode = rootNode [XsollaApiConst.R_ERRORS];

            if (errorNode.Count > 0)
            {
                this.xsollaError = new XsollaError().ParseNew(errorNode[0]) as XsollaError;
            }

            JSONNode messagesNode = rootNode [XsollaApiConst.R_MESSAGES];

            if (messagesNode.Count > 0)
            {
                this.xsollaMessage = new XsollaMessage().Parse(messagesNode[0]) as XsollaMessage;
            }

            this.SetAccount(rootNode [XsollaApiConst.R_ACCOUNT]);
            this.SetAccountXsolla(rootNode [XsollaApiConst.R_ACCOUNTXSOLLA]);
            this.SetCurrentCommand(rootNode[XsollaApiConst.R_CURRENTCOMMAND]);
            this.SetTitle(rootNode[XsollaApiConst.R_TITLE]);
            this.SetIconUrl(rootNode[XsollaApiConst.R_ICONURL]);
            this.SetCurrency(rootNode[XsollaApiConst.R_CURRENCY]);
            this.SetSum(rootNode[XsollaApiConst.R_BUYDATA]["sum"]);
            this.SetInstruction(rootNode[XsollaApiConst.R_INSTRUCTION]);
            this.SetPid(rootNode[XsollaApiConst.R_PID].AsInt);
            this.SetSkipForm(rootNode[XsollaApiConst.R_SKIPFORM].AsBool);
            this.SetSkipCheckout(rootNode[XsollaApiConst.R_SKIPCHECKOUT].AsBool);

            checkoutToken = rootNode ["checkoutToken"];
            JSONNode buyDataNode = rootNode ["buyData"];

            if (buyDataNode != null && !"null".Equals(buyDataNode))
            {
                buyData = new BuyData().Parse(buyDataNode) as BuyData;
            }

            JSONNode summaryNode = rootNode ["summary"];

            if (summaryNode != null && !"null".Equals(summaryNode))
            {
                summary = new XsollaSummary().Parse(summaryNode) as XsollaSummary;
            }

            JSONNode checkoutNode = rootNode ["checkout"];

            if (checkoutNode != null && !"null".Equals(checkoutNode))
            {
                chekout = new XsollaCheckout().Parse(checkoutNode) as XsollaCheckout;
            }

            JSONNode formNode = rootNode [XsollaApiConst.R_FORM];
            IEnumerable <JSONNode> formElements = formNode.Childs;
            IEnumerator <JSONNode> enumerator   = formElements.GetEnumerator();

            this.Clear();
            while (enumerator.MoveNext())
            {
                this.AddElement((XsollaFormElement) new XsollaFormElement().Parse(enumerator.Current));
            }
            return(this);
        }