Ejemplo n.º 1
0
        /// <summary>
        /// Получить список транзакций кошелька, за указанный период времени. Период времени должен быть не больше трёх месяцев.
        /// </summary>
        public List <Transfer> GetTransfers(DateTime startTime, DateTime finishTime)
        {
            var transferFilter = new TransferFilter(purse, startTime.AddHours(wmServerTimeDifference), finishTime.AddHours(wmServerTimeDifference));

            try
            {
                var transferRegister = transferFilter.Submit();
                return(transferRegister.TransferList);
            }
            catch (Exception ex)
            {
                Logger.Error(
                    string.Format("GetTransfers() - Не удалось получить список транзакций с сервера WebMoney кошелька {0} за период времени {1} от до {2}",
                                  purse.ToString(), startTime, finishTime), ex);
                return(null);
            }
        }
Ejemplo n.º 2
0
        public IEnumerable <ITransfer> SelectTransfers(string purse, DateTime fromTime, DateTime toTime)
        {
            if (null == purse)
            {
                throw new ArgumentNullException(nameof(purse));
            }

            var request = new TransferFilter(Purse.Parse(purse), fromTime, toTime)
            {
                Initializer = Session.AuthenticationService.ObtainInitializer()
            };

            TransferRegister response;

            try
            {
                response = request.Submit();
            }
            catch (WmException exception)
            {
                throw new ExternalServiceException(exception.Message, exception);
            }

            return(response.TransferList.Select(t =>
            {
                var transfer = new BusinessObjects.Transfer(Session.CurrentIdentifier, t.PrimaryId, t.SecondaryId,
                                                            t.SourcePurse.ToString(), t.TargetPurse.ToString(), t.Amount,
                                                            t.Commission, ConvertFrom.ApiTypeToContractType(t.TransferType), t.Description, t.Partner,
                                                            t.Rest,
                                                            t.CreateTime.ToUniversalTime(), t.UpdateTime.ToUniversalTime())
                {
                    InvoiceId = t.InvoiceId,
                    OrderId = t.OrderId,
                    PaymentId = t.PaymentId,
                    ProtectionPeriod = t.Period,
                    Locked = t.IsLocked,
                    Description = !string.IsNullOrEmpty(t.Description) ? t.Description : "[empty]"
                };


                return transfer;
            }));
        }
Ejemplo n.º 3
0
        /// <summary>
        /// Reads the specified start.
        /// </summary>
        /// <param name="range">The range.</param>
        public void Read(DateRange range)
        {
            TransferFilter transferFilter = new TransferFilter(_purse, range.From, range.To);
            var            transactions   = transferFilter.Submit();

            if (transactions == null || transactions.Length == 0)
            {
                return;
            }
            //Incomment transfers
            transactions = transactions.Where(e => e.TargetPurse == _purse).OrderBy(e => e.CreateTime).ToArray();

            var last = _manager.GetLast();

            if (last.Count > 0)
            {
                transactions = transactions.Where(e => e.CreateTime > last[0].Date).ToArray();
            }

            foreach (var transfer in transactions)
            {
                Store(transfer);
            }
        }
Ejemplo n.º 4
0
        public static void UpdateTransferStatus(DateTime startDate, List<Transfer> transfers)
        {
            startDate = (DateTime.Now - startDate).Days > 88 ? DateTime.Now.AddMonths(-3) : startDate;

            TransferFilter tf = new TransferFilter(Purse.Parse(Configuration.Purse),
                                                                  WmDateTime.Parse(startDate.ToString("dd.MM.yyyy HH:mm:ss")),
                                                                  WmDateTime.Parse(DateTime.Now.ToString("dd.MM.yyyy HH:mm:ss")));

            ExistentTransfer[] eoi = tf.Submit();
            if (eoi != null)
            {
                foreach (ExistentTransfer inv in eoi)
                {
                    Transfer t = transfers.Where(p => p.TransferId == (int)inv.TransferId).SingleOrDefault();
                    if (t != null)
                    {
                        GT.BO.Implementation.BillingSystem.WebMoneyTransfer wm = new GT.BO.Implementation.BillingSystem.WebMoneyTransfer();
                        wm.TransferId = t.TransferId;
                        wm.Description = inv.Description;
                        wm.TargetPurse = inv.TargetPurse.ToString();
                        wm.SourcePurse = inv.SourcePurse != null ? inv.SourcePurse.Number.ToString() : null;
                        wm.WmInvoiceId = (int)inv.Id;
                        wm.WmTransferId = (int)inv.TransferId;
                        wm.TransDate = ((DateTime)inv.UpdateTime).ToUniversalTime();
                        wm.RetCode = 0;
                        WebMoneyTransferFacade.Add(wm);
                        BillingSystemFacade.CompleteTransfer(t.TransferId);
                        transfers.Remove(t);

                        if (t.Commission != t.Commission)
                        {
                            MailMessage m = new MailMessage(SmtpManager.Instance.Config.SupportEmail,
                                                            SmtpManager.Instance.Config.Email4Errors,
                                                            "WEB MONEY ERROR COMMISSION",
                                                            String.Format("TransferId = {0}; WebMoneyId = {1}", t.TransferId, wm.Id));
                            SmtpManager.Instance.Send(m);
                        }
                    }
                }
            }
        }