コード例 #1
0
        /// <summary>
        /// Конструктор, использующийся для инициализации WebMoneyAccessor ключом Keeper Classic
        /// </summary>
        public WebMoneyAccessor()
        {
            var wmAccountDictionary = WebMoneyUtil.Instance.GetWmAccountSettings();

            if (wmAccountDictionary == null)
            {
                Logger.Error("WebMoneyAccessor() - не удалось прочитать необходимые для инициализировать WebMoney параметры (wmId, purseNumber и др.)");
                return;
            }

            keeperKeyValue    = wmAccountDictionary["WmKeeperKeyValue"].ToString();
            targetPurseNumber = (ulong)wmAccountDictionary["WmTargetPurseNumber"];
            wmId = (WmId)(ulong)wmAccountDictionary["WmId"];
            var targetPurseType = WebMoneyUtil.StrToCurrency(wmAccountDictionary["WmPurseCurrency"].ToString());

            purse = new Purse
            {
                Number = targetPurseNumber,
                Type   = targetPurseType
            };

            var keeperKey = new KeeperKey(keeperKeyValue);

            initializer = new Initializer(wmId, keeperKey)
            {
                StartDate = new DateTime(1983, 1, 1).ToUniversalTime()
            };
            initializer.Apply();

            wmServerTimeDifference = (WmDateTime.ServerTime2UtcTime(DateTime.Now).Hour - DateTime.Now.ToUniversalTime().Hour);
        }
コード例 #2
0
        public WmDateTime?SelectWmDateTimeIfExists(string xPath)
        {
            if (string.IsNullOrEmpty(xPath))
            {
                throw new ArgumentNullException(nameof(xPath));
            }

            var text = TrySelectNotEmptyString(xPath);

            if (null == text)
            {
                return(null);
            }

            if (text.Equals("0000-00-00 00:00:00", StringComparison.OrdinalIgnoreCase))
            {
                return(default(DateTime));
            }

            if (!WmDateTime.TryParseServerString(text, out var wmDateTime))
            {
                throw new FormatException(string.Format(CultureInfo.InvariantCulture,
                                                        "The value '{0}' of the element '{1}' is not in a correct format.", text, xPath));
            }

            return(wmDateTime);
        }
コード例 #3
0
        protected override void Fill(WmXmlPackage wmXmlPackage)
        {
            if (null == wmXmlPackage)
            {
                throw new ArgumentNullException(nameof(wmXmlPackage));
            }

            PrimaryId   = wmXmlPackage.SelectInt64("ininvoice/@id");
            SecondaryId = wmXmlPackage.SelectInt64("ininvoice/@ts");
            State       = (InvoiceState)wmXmlPackage.SelectUInt32("ininvoice/state");
            UpdateTime  = wmXmlPackage.SelectWmDateTime("ininvoice/dateupd");
        }
コード例 #4
0
        internal void Fill(WmXmlPackage wmXmlPackage)
        {
            if (null == wmXmlPackage)
            {
                throw new ArgumentNullException(nameof(wmXmlPackage));
            }

            WmId             = wmXmlPackage.SelectWmId("@wmid");
            Alias            = wmXmlPackage.SelectString("@nickname");
            Description      = wmXmlPackage.SelectString("@info");
            RegistrationDate = wmXmlPackage.SelectWmDateTime("@datereg");
        }
コード例 #5
0
        protected override void Fill(WmXmlPackage wmXmlPackage)
        {
            if (null == wmXmlPackage)
            {
                throw new ArgumentNullException(nameof(wmXmlPackage));
            }

            Id           = wmXmlPackage.SelectUInt32("operation/@id");
            Ts           = wmXmlPackage.SelectUInt32("operation/@ts");
            TransferType = (TransferType)wmXmlPackage.SelectInt32("operation/opertype");
            UpdateTime   = wmXmlPackage.SelectWmDateTime("operation/dateupd");
        }
コード例 #6
0
        protected override void Fill(WmXmlPackage wmXmlPackage)
        {
            if (null == wmXmlPackage)
            {
                throw new ArgumentNullException(nameof(wmXmlPackage));
            }

            Id         = wmXmlPackage.SelectUInt32("message/@id");
            WmId       = wmXmlPackage.SelectWmId("message/receiverwmid");
            Subject    = (Description)wmXmlPackage.SelectString("message/msgsubj");
            Content    = (Message)wmXmlPackage.SelectNotEmptyString("message/msgtext");
            CreateTime = wmXmlPackage.SelectWmDateTime("message/datecrt");
        }
コード例 #7
0
        protected override void Fill(WmXmlPackage wmXmlPackage)
        {
            if (null == wmXmlPackage)
            {
                throw new ArgumentNullException(nameof(wmXmlPackage));
            }

            Id          = wmXmlPackage.SelectUInt32("operation/@id");
            Ts          = wmXmlPackage.SelectUInt32("operation/@ts");
            OperationId = wmXmlPackage.SelectUInt32("operation/inwmtranid");
            SourcePurse = wmXmlPackage.SelectPurse("operation/pursesrc");
            TargetPurse = wmXmlPackage.SelectPurse("operation/pursedest");
            Amount      = wmXmlPackage.SelectAmount("operation/amount");
            Commission  = wmXmlPackage.SelectAmount("operation/comiss");
            Description = (Description)wmXmlPackage.SelectString("operation/desc");
            CreateTime  = wmXmlPackage.SelectWmDateTime("operation/datecrt");
            UpdateTime  = wmXmlPackage.SelectWmDateTime("operation/dateupd");
        }
コード例 #8
0
        public static DateTime GetServerTime(this WmDateTime time)
        {
            var str = time.ToServerString();

            return(DateTime.ParseExact(str, "yyyyMMdd HH:mm:ss", CultureInfo.InvariantCulture));
        }
コード例 #9
0
 public OutgoingInvoiceFilter(Purse purse, WmDateTime startTime, WmDateTime finishTime)
 {
     Purse      = purse;
     StartTime  = startTime;
     FinishTime = finishTime;
 }
コード例 #10
0
 public IncomingInvoiceFilter(WmId wmId, WmDateTime startTime, WmDateTime finishTime)
 {
     WmId       = wmId;
     StartTime  = startTime;
     FinishTime = finishTime;
 }
コード例 #11
0
 public TransferFilter(Purse purse, WmDateTime startTime, WmDateTime finishTime)
 {
     Purse      = purse;
     StartTime  = startTime;
     FinishTime = finishTime;
 }
コード例 #12
0
        protected override void Inspect(XmlPackage xmlPackage)
        {
            if (null == xmlPackage)
            {
                throw new ArgumentNullException(nameof(xmlPackage));
            }

            var wmXmlPackage = (WmXmlPackage)xmlPackage;

            int errorNumber = wmXmlPackage.SelectInt32("retval");

            if (0 != errorNumber)
            {
                MerchantOperationObtainerException.ErrorExtendedInfo errorExtendedInfo = null;

                if (wmXmlPackage.Exists("errorlog/err_code"))
                {
                    string extendedErrorNumberValue = wmXmlPackage.SelectString("errorlog/err_code");

                    if (!string.IsNullOrEmpty(extendedErrorNumberValue))
                    {
                        errorExtendedInfo = new MerchantOperationObtainerException.ErrorExtendedInfo
                        {
                            ExtendedErrorNumber = int.Parse(extendedErrorNumberValue,
                                                            CultureInfo.InvariantCulture.NumberFormat),
                            StorePurse            = wmXmlPackage.SelectPurse("errorlog/@lmi_payee_purse"),
                            OrderId               = wmXmlPackage.SelectInt32("errorlog/@lmi_payment_no"),
                            PaymentInfoCreateTime = wmXmlPackage.SelectWmDateTime("errorlog/datecrt"),
                            PaymentInfoUpdateTime = wmXmlPackage.SelectWmDateTime("errorlog/dateupd")
                        };

                        var enterTimeValue = wmXmlPackage.SelectString("errorlog/date_s");

                        if (!string.IsNullOrEmpty(enterTimeValue))
                        {
                            errorExtendedInfo.EnterTime =
                                WmDateTime.ParseServerString(enterTimeValue);
                        }

                        var authorizationTimeValue = wmXmlPackage.SelectString("errorlog/date_pc");

                        if (!string.IsNullOrEmpty(authorizationTimeValue))
                        {
                            errorExtendedInfo.AuthorizationTime =
                                WmDateTime.ParseServerString(authorizationTimeValue);
                        }

                        var confirmationTimeValue = wmXmlPackage.SelectString("errorlog/date_pd");

                        if (!string.IsNullOrEmpty(confirmationTimeValue))
                        {
                            errorExtendedInfo.ConfirmationTime =
                                WmDateTime.ParseServerString(confirmationTimeValue);
                        }

                        errorExtendedInfo.SiteId        = wmXmlPackage.SelectInt32("errorlog/siteid"); // TODO: [L] Расшифровать errorlog/siteid
                        errorExtendedInfo.PaymentMethod = wmXmlPackage.SelectString("errorlog/att");   // TODO: [L] Расшифровать errorlog/att
                    }
                }

                throw new MerchantOperationObtainerException(errorNumber, xmlPackage.SelectString("retdesc"))
                      {
                          ExtendedInfo = errorExtendedInfo
                      };
            }
        }