Ejemplo n.º 1
0
 public static WebMoneyTransfer CreateWM()
 {
     Transfer t = BillingSystemFacadeHelper.AddTransferFromUserToRealSource((RealMoneySourceType?)RealMoneySourceType.WebMoney, null, null);
     WebMoneyTransfer wm = new WebMoneyTransfer();
     wm.TransferId = t.TransferId;
     wm.WmInvoiceId = new Random((int)DateTime.Now.Ticks).Next(10, 20);
     wm.WmTransferId = new Random((int)DateTime.Now.Ticks).Next(10, 20);
     wm.TargetPurse = WebMoneyManager.Configuration.Purse;
     return wm;
 }
Ejemplo n.º 2
0
 public static WebMoneyTransfer Add(WebMoneyTransfer wm)
 {
     return new WebMoneyTransfer().Load<WebMoneyTransfer>(WebMoneyDataAdapter.Add(wm));
 }
Ejemplo n.º 3
0
        public void ProcessRequest(HttpContext context)
        {
            if (null == context)
                throw new ArgumentNullException("context");

            if (null == context.Request.Form)
                return;

            string LMI_PREREQUEST = context.Request.Form["LMI_PREREQUEST"];
            string LMI_PAYMENT_NO = context.Request.Form["LMI_PAYMENT_NO"];
            string LMI_PAYMENT_AMOUNT = context.Request.Form["LMI_PAYMENT_AMOUNT"];
            string LMI_PAYEE_PURSE = context.Request.Form["LMI_PAYEE_PURSE"];

            int tId;

            AssistLogger.WriteInformation(String.Format("TransferId = {0} | PAYEE PURSE = {1} | AMOUNT = {2} | PAYER PURSE = {3} | PAYER WMID = {4} ",
                                                        LMI_PAYMENT_NO, LMI_PAYEE_PURSE, LMI_PAYMENT_AMOUNT,
                                                        context.Request.Form["LMI_PAYER_PURSE"],
                                                        context.Request.Form["LMI_PAYER_WM"]),
                                         AssistLogger.Category.WebMoney);

            if (string.Compare(LMI_PAYEE_PURSE, WebMoneyManager.Configuration.Purse, true) != 0)
            {
                throw new ArgumentException(
                    string.Format(CultureInfo.InvariantCulture, "Подмена кошелька (LMI_PAYEE_PURSE == {0})!",
                                  LMI_PAYEE_PURSE), "LMI_PAYEE_PURSE");
            }

            if (string.IsNullOrEmpty(LMI_PAYMENT_NO) || !int.TryParse(LMI_PAYMENT_NO, out tId))
                    throw new ArgumentException("Не задан или задан неверно номер платежа!", "LMI_PAYMENT_NO");

            Transfer transfer = BillingSystemFacade.GetTransferById(tId);
            if (transfer == null || transfer.FromTransferParticipant.ActualEntityType != GT.Global.Entities.EntityType.RealMoneySource ||
                    transfer.FromTransferParticipant.RealMoneySourceId != (int)RealMoneySourceType.WebMoney || transfer.Status != TransferStatus.Pending)
            {
                throw new ArgumentException("Неверно задан номер платежа", "LMI_PAYMENT_NO");
            }

            if (String.IsNullOrEmpty(LMI_PAYMENT_AMOUNT))
            {
                throw new ArgumentException("Не задана сумма платежа!", "LMI_PAYMENT_AMOUNT");
            }

            decimal amount = TypeConverter.ToDecimal(LMI_PAYMENT_AMOUNT.Replace('.', ',')).ToMoney();

            if (amount <= 0)
                    throw new ArgumentException("Не задана или задана неверно сумма платежа!", "LMI_PAYMENT_AMOUNT");

            if (string.Compare("1", LMI_PREREQUEST) == 0)
            {
                context.Response.Write("YES");
                return;
            }

            string LMI_MODE = context.Request.Form["LMI_MODE"];
            string LMI_PAYER_WM = context.Request.Form["LMI_PAYER_WM"];
            string LMI_SYS_INVS_NO = context.Request.Form["LMI_SYS_INVS_NO"];
            string LMI_SYS_TRANS_NO = context.Request.Form["LMI_SYS_TRANS_NO"];
            string LMI_SYS_TRANS_DATE = context.Request.Form["LMI_SYS_TRANS_DATE"];
            string LMI_PAYER_PURSE = context.Request.Form["LMI_PAYER_PURSE"];
            string LMI_HASH = context.Request.Form["LMI_HASH"];

            if (string.Compare("0", LMI_MODE) != 0)
                throw new ArgumentException("Попытка провести платеж в тестовом режиме!", "LMI_MODE");

            StringBuilder stringBuilder = new StringBuilder();

            stringBuilder.Append(LMI_PAYEE_PURSE);
            stringBuilder.Append(LMI_PAYMENT_AMOUNT);
            stringBuilder.Append(LMI_PAYMENT_NO);
            stringBuilder.Append(LMI_MODE);
            stringBuilder.Append(LMI_SYS_INVS_NO);
            stringBuilder.Append(LMI_SYS_TRANS_NO);
            stringBuilder.Append(LMI_SYS_TRANS_DATE);
            stringBuilder.Append(WebMoneyManager.Configuration.Key); // Секретный ключ
            stringBuilder.Append(LMI_PAYER_PURSE);
            stringBuilder.Append(LMI_PAYER_WM);

            string value = stringBuilder.ToString();

            string etaloneHash = GetMD5HashString(value);

            if (string.Compare(etaloneHash, LMI_HASH, true) != 0)
                throw new ArgumentException(
                    string.Format(CultureInfo.InvariantCulture, "Неверная подпись запроса (form == {0})!",
                                  context.Request.Form), "LMI_HASH");

            WebMoneyTransfer wm = new WebMoneyTransfer();
            wm.TransferId = transfer.TransferId;
            wm.WmInvoiceId = TypeConverter.ToInt32(LMI_SYS_INVS_NO);
            wm.WmTransferId = TypeConverter.ToInt32(LMI_SYS_TRANS_NO);
            wm.TargetPurse = WebMoneyManager.Configuration.Purse;
            wm.SourcePurse = LMI_PAYER_PURSE;

            int? msgId = Dictionaries.Instance.GetWebMoneyMessageIdByRetcodeAndType(0, (int)WebMoneyMessagesTypes.Merchant);
            if (msgId.HasValue)
            {
                wm.RetCode = msgId.Value;
            }

            wm.PayerWmid = LMI_PAYER_WM;
            wm.ATMWmTransId = TypeConverter.ToInt32(context.Request.Form["LMI_ATM_WMTRANSID"]);
            wm.CapitallerWmid = TypeConverter.ToInt32(context.Request.Form["LMI_CAPITALLER_WMID"]);
            wm.Description = context.Request.Form["LMI_PAYMENT_DESC"];
            wm.EuronoteEmail = context.Request.Form["LMI_EURONOTE_EMAIL"];
            wm.EuronoteNumber = TypeConverter.ToDecimal(context.Request.Form["LMI_EURONOTE_NUMBER"]);
            wm.PaymerEmail = context.Request.Form["LMI_PAYMER_EMAIL"];
            wm.PaymerNumber = TypeConverter.ToInt64(context.Request.Form["LMI_PAYMER_NUMBER"]);
            wm.TelepatOrderId = TypeConverter.ToInt32(context.Request.Form["LMI_TELEPAT_ORDERID"]);
            wm.TelepatPhone = context.Request.Form["LMI_TELEPAT_PHONENUMBER"];

            WebMoneyTransferFacade.Add(wm);

            BillingSystemFacade.CompleteTransfer(transfer.TransferId);
        }
Ejemplo n.º 4
0
        public override GT.BO.Implementation.BillingSystem.Transfer TopUp(decimal amount)
        {
            if (m_TargetWmId == null)
            {
                return null;
            }

            Transfer t = null;

            amount = amount.ToMoney();

            if (amount > 0)
            {
                t = base.TopUp(amount);
                if (t != null)
                {
                    OriginalInvoice oi = new OriginalInvoice((ulong)t.TransferId,
                                                             m_TargetWmId,
                                                             Purse.Parse(Configuration.Purse),
                                                             Amount.Parse(amount.ToString()),
                                                             new Info(TOPUP, false),
                                                             new Info(ADDRESS, false));

                    GT.BO.Implementation.BillingSystem.WebMoneyTransfer wm = new GT.BO.Implementation.BillingSystem.WebMoneyTransfer();
                    wm.TransferId = t.TransferId;
                    wm.TargetPurse = Configuration.Purse;

                    try
                    {
                        RecentInvoice ri = oi.Submit();
                        if (ri != null)
                        {
                            int? msgId = Dictionaries.Instance.GetWebMoneyMessageIdByRetcodeAndType(0, (int)WebMoneyMessagesTypes.X1);
                            if (msgId.HasValue)
                            {
                                wm.RetCode = msgId.Value;
                            }
                            wm.WmInvoiceId = (int)ri.Id;
                            wm.PayerWmid = ri.SourceWmId.ToString();
                            wm.Description = ri.Description;
                            wm.TransDate = ((DateTime)ri.CreateTime).ToUniversalTime();
                            WebMoneyTransferFacade.Add(wm);
                        }
                    }
                    catch (WmException ex)
                    {
                        string note = null;
                        int? messageId = Dictionaries.Instance.GetWebMoneyMessageIdByRetcodeAndType(ex.Number, (int)WebMoneyMessagesTypes.X1);
                        if (messageId != null)
                        {
                            wm.RetCode = messageId.Value;
                            wm.Description = ex.Message;
                            note = Dictionaries.Instance.GetWebMoneyMessageById(messageId.Value);
                        }
                        else
                        {
                            wm.Description = String.Format("retcode = {0}; {1}", ex.Number, ex.Message);
                            note = Dictionaries.Instance.GetWebMoneyDefaultSystemErrorMessage();
                        }

                        WebMoneyTransferFacade.Add(wm);
                        BillingSystemFacade.RefuseTransfer(t.TransferId, note);
                    }
                }
            }

            return t;
        }
Ejemplo n.º 5
0
        public override GT.BO.Implementation.BillingSystem.Transfer DrawOut(decimal amount)
        {
            if (m_TargePurse == null)
            {
                return null;
            }

            Transfer t = base.DrawOut(amount);
            if (t != null)
            {
                decimal newAmount = (t.Amount - t.Commission - t.OurCommission).ToMoney();

                OriginalTransfer ot = new OriginalTransfer((ulong)t.TransferId,
                                                            Purse.Parse(Configuration.Purse),
                                                            m_TargePurse,
                                                            Amount.Parse(newAmount.ToString()),
                                                            new Info(DRAWOUT, false),
                                                            0);

                GT.BO.Implementation.BillingSystem.WebMoneyTransfer wm = new GT.BO.Implementation.BillingSystem.WebMoneyTransfer();
                wm.TransferId = t.TransferId;
                wm.SourcePurse = Configuration.Purse;
                wm.TargetPurse = m_TargePurse.ToString();

                try
                {
                    RecentTransfer tr = ot.Submit();
                    if (tr != null)
                    {
                        int? msgId = Dictionaries.Instance.GetWebMoneyMessageIdByRetcodeAndType(0, (int)WebMoneyMessagesTypes.X2);
                        if (msgId.HasValue)
                        {
                            wm.RetCode = msgId.Value;
                        }

                        wm.WmTransferId = (int)tr.Id;
                        wm.WmInvoiceId = (int)tr.InvoiceId;
                        wm.Description = tr.Description != null ? tr.Description.ToString() : null;
                        wm.TransDate = ((DateTime)tr.CreateTime).ToUniversalTime();
                        wm.Commission = (decimal)tr.Commission;
                        wm = WebMoneyTransferFacade.Add(wm);
                        BillingSystemFacade.CompleteTransfer(t.TransferId);

                        if (wm.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);
                        }
                    }
                }
                catch (WmException ex)
                {
                    string note = null;
                    int? messageId = Dictionaries.Instance.GetWebMoneyMessageIdByRetcodeAndType(ex.Number, (int)WebMoneyMessagesTypes.X2);
                    if (messageId != null)
                    {
                        wm.RetCode = messageId.Value;
                        wm.Description = ex.Message;
                        note = Dictionaries.Instance.GetWebMoneyMessageById(messageId.Value);
                    }
                    else
                    {
                        wm.Description = String.Format("retcode = {0}; {1}", ex.Number, ex.Message);
                        note = Dictionaries.Instance.GetWebMoneyDefaultSystemErrorMessage();
                    }

                    WebMoneyTransferFacade.Add(wm);
                    t = BillingSystemFacade.RefuseTransfer(t.TransferId, note);
                }
            }

            return t;
        }
Ejemplo n.º 6
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);
                        }
                    }
                }
            }
        }
Ejemplo n.º 7
0
        public static void UpdateOutgoingInvoices(DateTime startDate, List<Transfer> transfers)
        {
            startDate = (DateTime.Now - startDate).Days > 88 ? DateTime.Now.AddMonths(-3) : startDate;

            OutgoingInvoiceFilter oif = new OutgoingInvoiceFilter(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")));

            ExistentOutgoingInvoice[] eoi = oif.Submit();
            if (eoi != null)
            {
                foreach (ExistentOutgoingInvoice inv in eoi)
                {
                    if (inv.State == InvoiceState.Paid && inv.OrderId != 0)
                    {
                        Transfer t = transfers.Where(p => p.TransferId == (int)inv.OrderId).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.Value.ToString() : null;
                            wm.WmInvoiceId = (int)inv.Id;
                            wm.WmTransferId = (int)inv.OperationId;
                            wm.TransDate = ((DateTime)inv.UpdateTime).ToUniversalTime();
                            wm.RetCode = 0;
                            WebMoneyTransferFacade.Add(wm);
                            BillingSystemFacade.CompleteTransfer(t.TransferId);
                            transfers.Remove(t);
                        }
                    }
                }
            }
        }
Ejemplo n.º 8
0
        public static bool UpdateMerchantTransferStatus(int transferId)
        {
            MerchantOperationFilter mof = new MerchantOperationFilter(Purse.Parse(Configuration.Purse), (ulong)transferId);
            try
            {
                ExistentMerchantOperation emo = mof.Submit();

                if (emo != null)
                {
                    GT.BO.Implementation.BillingSystem.WebMoneyTransfer wm = new GT.BO.Implementation.BillingSystem.WebMoneyTransfer();
                    wm.TransferId = transferId;
                    wm.Description = emo.Description;
                    wm.WmInvoiceId = (int)emo.InvoiceId;
                    wm.WmTransferId = (int)emo.OperationId;
                    wm.SourcePurse = emo.SourcePurse.ToString();
                    wm.TargetPurse = WebMoneyManager.Configuration.Purse;
                    wm.TelepatPhone = emo.TelepatPhone.ToString();
                    long l;
                    if (long.TryParse(emo.PaymerNumber, out l))
                    {
                        wm.PaymerNumber = l;
                    }

                    wm.PaymerEmail = emo.PaymerEmail.ToString();
                    int casher;
                    if (int.TryParse(emo.CashierNumber.ToString(), out casher))
                    {
                        wm.ATMWmTransId = casher;
                    }

                    wm.RetCode = 0;

                    WebMoneyTransferFacade.Add(wm);

                    BillingSystemFacade.CompleteTransfer(transferId);
                    return true;
                }
            }
            catch (WmException wm)
            {
                if (wm.Number != -8)
                {
                    throw wm;
                }
            }

            return false;
        }