Ejemplo n.º 1
0
        public void ItDisplaysCurrency()
        {
            decimal value = 1.56M;

            var result = value.AsCurrency("en-Gb");

            Assert.True(string.Compare("£1.56", result).Equals(0));

            result = value.AsCurrency("de-DE");
            Assert.True(string.Compare("1,56 €", result).Equals(0));
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Выполнения платежа по шаблону
        /// </summary>
        void TemplatePayment()
        {
            if (ErrCode != 0)
            {
                return;
            }

            int paySum = (int)(Amount * 100M);

            RootLog("{0} [Rapida.TplPay - start] Ext={1} TID={2} Trm={3} Amount={4}", Tid, Session, TemplateTid, PPID, Amount.AsCurrency());
            stRequest = string.Format("?function=payment&PaymExtId={0}&PPID={1}&TID={2}&Amount={3}", Session, PPID, TemplateTid, paySum);

            string Result = Get(Host + stRequest);

            if (string.IsNullOrEmpty(Result))
            {
                // Если ршибка SSL-соединения попробуем ещё раз
                if ((WebExceptionStatus)ErrCode == WebExceptionStatus.SecureChannelFailure && Attempts++ < 5)
                {
                    Wait(20);
                    TemplatePayment();
                    return;
                }

                if (ErrCode != 0) // Ошибка сервиса
                {
                    errCode = 11;
                }
                return;
            }

            string ResultStatus = XPath.GetString(Result, "/Response/Result");

            if (string.IsNullOrEmpty(ResultStatus))
            {
                ResultStatus = XPath.GetString(Result, "/Response/CheckResult");
            }

            if (ResultStatus.ToUpper() == "OK")
            {
                // Баланс агента
                Balance = XPath.GetDec(Result, "/Response/Balance").Value;
                errDesc = "Payment OK";
                Bank    = $"{XPath.GetString(Result, "/Response/B_Name").ToUpper()}; {XPath.GetString(Result, "/Response/List/par1")}; {XPath.GetString(Result, "/Response/List/par3")}; {XPath.GetString(Result, "/Response/List/par4")}";
                errCode = 3;
                state   = 6;
            }
            else
            {
                errCode = XPath.GetInt(Result, "/Response/ErrCode").Value;
                errDesc = $"({errCode}) {XPath.GetString(Result, "/Response/Description")}";
                errCode = 6;
                state   = 12;
            }

            RootLog($"{Tid} [Rapida.TplPay - finish] Ext={Session} TID={TemplateTid} Trm={PPID} Balance={Balance.AsCurrency()} err={ErrCode} {ErrDesc}");
        }