Format() public static method

public static Format ( float amountFloat, string currency ) : string
amountFloat float
currency string
return string
        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();
        }
Exemplo n.º 2
0
 public string GetSumTotal()
 {
     if (buyData != null && buyData.sum != null && buyData.currency != null)
     {
         return(PriceFormatter.Format(buyData.sum, buyData.currency));
     }
     else if (summary != null)
     {
         return(PriceFormatter.Format(summary.GetFinance().total.amount, summary.GetFinance().total.currency));
     }
     else
     {
         if (sum != null && currency != null)
         {
             return(PriceFormatter.Format(sum, currency));
         }
         else
         {
             return("");
         }
     }
 }
Exemplo n.º 3
0
 public string GetPrice()
 {
     return(PriceFormatter.Format(amount, currency));
 }