Exemplo n.º 1
0
        public ActionResult ConfirmMobile(MobilePaymentModel paymentInfo, FormCollection collcetion)
        {
            if (paymentInfo.CardAccountID == 0)
            {
                return(RedirectToAction("Index"));
            }
            if (paymentInfo.ToOwnPayments)
            {
                OwnPaymentsModule.AddMobileOwnPayment(paymentInfo, rep, WebSecurity.CurrentUserId);
            }
            MobileTransaction mt = new MobileTransaction();

            mt.Amount         = paymentInfo.Amount;
            mt.CardAccountID  = paymentInfo.CardAccountID;
            mt.CustomerID     = WebSecurity.CurrentUserId;
            mt.Date           = Time.GetTime();
            mt.MobileProvider = paymentInfo.Provider;
            mt.Phone          = paymentInfo.Phone;
            mt.Type           = PaymentType.Mobile;
            bool success = service.CreateMobileTransaction(mt);

            if (success)
            {
                return(View("Message", (object)"Платеж успешно завершен"));
            }
            else
            {
                return(View("Message", (object)"Что то пошло не так. Попробуйте еще раз"));
            }
        }
Exemplo n.º 2
0
        public ActionResult Mobile(string provider, MobilePaymentModel paymentInfo)
        {
            if (provider != null)
            {
                switch (provider)
                {
                case "MTS":
                    paymentInfo.Provider = "МТС";
                    break;

                case "Velcom":
                    paymentInfo.Provider = "Velcom";
                    break;

                case "Dialog":
                    paymentInfo.Provider = "Dialog";
                    break;

                case "Life":
                    paymentInfo.Provider = "Life :)";
                    break;

                default:
                    return(View("Message", (object)"Неправильное имя оператора мобильной связи"));
                }
            }
            if (paymentInfo.Provider == null)
            {
                return(View("Message", (object)"Неправильное имя оператора мобильной связи"));
            }

            return(View(paymentInfo));
        }
Exemplo n.º 3
0
 public ActionResult ConfirmMobile(MobilePaymentModel paymentInfo)
 {
     if (paymentInfo.CardAccountID == 0)
     {
         return(RedirectToAction("Index"));
     }
     return(View("ConfirmMobile", paymentInfo));
 }
Exemplo n.º 4
0
        public static void AddMobileOwnPayment(MobilePaymentModel model, Repositories rep, int customerId)
        {
            OwnMobilePayment p = new OwnMobilePayment();

            p.CardAccountID  = model.CardAccountID;
            p.CustomerID     = customerId;
            p.MobileProvider = model.Provider;
            p.Number         = model.Phone;
            p.Name           = model.Provider + "  " + model.Phone;
            rep.OwnMobilePayments.Add(p);
            rep.SaveChanges();
        }
Exemplo n.º 5
0
        public static MobilePaymentModel MobileOwnPaymentToModel(int paymentId, Repositories rep)
        {
            OwnMobilePayment p = rep.OwnMobilePayments.GetSingle(paymentId);

            if (p == null)
            {
                return(null);
            }
            MobilePaymentModel model = new MobilePaymentModel();

            model.CardAccountID   = p.CardAccountID;
            model.Phone           = p.Number;
            model.Provider        = p.MobileProvider;
            model.FromOwnPayments = true;
            return(model);
        }
Exemplo n.º 6
0
        public ActionResult Mobile(MobilePaymentModel paymentInfo, FormCollection collection)
        {
            int cardId;

            if (!int.TryParse(collection["item.CardAccount.CardAccountID"], out cardId))
            {
                ModelState.Clear();
                ModelState.AddModelError("CustomError", "Карта не найдена");
                return(View(paymentInfo));
            }
            else if (ModelState.IsValid)
            {
                Customer customer = rep.Customers.GetSingle(WebSecurity.CurrentUserId);
                if (customer.IsLocked)
                {
                    ModelState.Clear();
                    ModelState.AddModelError("CustomError", "Ваш аккаунт заблокирован");
                    return(View(paymentInfo));
                }
                paymentInfo.CardAccountID = cardId;
                CardAccount c = service.GetCardAccountById(cardId);
                if (c == null)
                {
                    ModelState.Clear();
                    ModelState.AddModelError("CustomError", "Карта не найдена");
                    return(View(paymentInfo));
                }
                paymentInfo.CardNumber = CardAccountModule.ConvertCardNumberString(c.CardNumber);
                if (c.IsLocked)
                {
                    ModelState.Clear();
                    ModelState.AddModelError("CustomError", "Ваша платежная карта заблокирована");
                    return(View(paymentInfo));
                }
                if (c.ExpiredDate < Time.GetTime())
                {
                    c.Status = "Истек срок действия";
                    service.UpdateCardAccount(c);
                    ModelState.Clear();
                    ModelState.AddModelError("CustomError", "Истек срок действия карты");
                    return(View(paymentInfo));
                }
                var bankAccount = service.GetBankAccountById(c.BankAccountID);
                if (bankAccount == null)
                {
                    ModelState.Clear();
                    ModelState.AddModelError("CustomError", "Ошибка базы");
                    return(View(paymentInfo));
                }
                if (bankAccount.CurrencyID != 1)
                {
                    ModelState.Clear();
                    ModelState.AddModelError("CustomError", "Оплату мобильной связи можно проводить только беларусскими рублями");
                    return(View(paymentInfo));
                }
                if (paymentInfo.Amount <= 0)
                {
                    ModelState.Clear();
                    ModelState.AddModelError("CustomError", "Сумма должна быть больше нуля");
                    return(View(paymentInfo));
                }
                if (!service.IsEnoughBalance(cardId, paymentInfo.Amount))
                {
                    ModelState.Clear();
                    ModelState.AddModelError("CustomError", "Недостаточно средств на счете");
                    return(View(paymentInfo));
                }
                return(RedirectToAction("ConfirmMobile", paymentInfo));
            }
            else
            {
                return(View(paymentInfo));
            }
        }