Пример #1
0
 //Shop shop) //Payment payment)
 //Сначала в этом Action Пользователь вводил WMR,
 //но теперь просто выводим данные о платеже
 public ActionResult BasketPay(W1PaymentView w1PaymentView)
 {
     return View(w1PaymentView);
 }
Пример #2
0
        //Заполнение но не добавление W1PaymentView в БД
        //W1Payment добавлять только через PaymentService!
        public W1Payment MakeW1Payment(W1Payment w1Payment)
        {
            IList<W1Payment> w1Payments;
            W1PaymentRepository w1PaymentRepository;
            DateTime expiredDate;
            W1PaymentView w1PaymentView;
            UrlGenerator urlGenerator;

            w1PaymentRepository = new W1PaymentRepository();
            urlGenerator = new UrlGenerator();

            //после дебага расскоментировать!
            //Срок истечения - 30 дней. Формат UTC(+0)
            if (w1Payment.WMI_EXPIRED_DATE == null ||
                w1Payment.WMI_EXPIRED_DATE == DateTime.MinValue)
            {
                expiredDate = DateTime.UtcNow;
                expiredDate = expiredDate.AddDays(SpecialConstants.EXPIRED_DAYS_COUNT);
                w1Payment.WMI_EXPIRED_DATE = expiredDate;
            }
            else w1Payment.WMI_EXPIRED_DATE = w1Payment.WMI_EXPIRED_DATE;
            //w1Payment.WMI_EXPIRED_DATE = new DateTime(2015, 11, 07, 12, 04, 38);

            w1Payment.WMI_SUCCESS_URL = urlGenerator.GetSuccessPaymentUrl();
            w1Payment.WMI_FAIL_URL = urlGenerator.GetFailPaymentUrl();

            w1Payment.WMI_MERCHANT_ID = SpecialConstants.WMI_MERCHANT_ID; //Id W1-кошелька
            w1Payment.WMI_CURRENCY_ID = SpecialConstants.WMI_CURRENCY_ID; //валюта - рубли

            w1Payments = w1PaymentRepository.GetAll().w1Payments;
            //Ключ. Начало отсчета нужно также синхронизировать с
            //MarketDbInitializer10.cs
            w1Payment.WMI_PAYMENT_NO =
                (w1Payments.Count > 0 ? w1Payments.Last().WMI_PAYMENT_NO + 1
                : 122); //в publish установить 1

            w1PaymentView = new W1PaymentView(w1Payment);
            w1Payment.WMI_SIGNATURE = GetSignature(w1PaymentView.dictionary);

            return w1Payment;
        }
Пример #3
0
        public ActionResult SelectShop(Shop shop)
        {
            Basket basket;
            IList<Shop> shops;
            PaymentView paymentView;
            UrlGenerator urlGenerator;
            Payment payment, dbPayment;
            W1Payment w1Payment, dbW1Payment;
            W1PaymentView w1PaymentView;
            Individual individual;
            BasketService basketService;
            IndividualRepository individualRepository;
            PaymentRepository paymentRepository;
            PaymentService paymentService;

            //Необходимо вызвать UrlGenerator в любом Post-методе контроллера,
            //иначе Request и Url поля не будут доступны.
            //В будующем нужно исправить!
            urlGenerator = new UrlGenerator(this.Request, this.Url);

            basketService = new BasketService();
            paymentRepository = new PaymentRepository();
            paymentService = new PaymentService();
            individualRepository = new IndividualRepository();
            //----
            shop = (Shop)this._shopRepository.FindById(shop.Id); //для адреса

            basket = basketService.GetBasket(User.Identity.Name);

            //Вычитаем заказанныек книги из BookVariableInfo и
            //обвновляем Basket
            basketService.ShopProcessing(basket, shop);
            shop.Address = (Address)this._addressRepository.FindById(shop.Id);
            //--
            //Создание платежной формы W1Payment
            individual = (Individual)individualRepository
                .FindIndividualByUserProfileName(User.Identity.Name);

            w1Payment = new W1Payment();
            w1Payment.WMI_PAYMENT_AMOUNT = paymentService.DecimalCounting(
                basket.TotalAmount, shop.BookDeliveryCost);
            w1Payment.WMI_DESCRIPTION = paymentService.MakeDescription(basket.Id);
            dbW1Payment = paymentService.MakeW1Payment(w1Payment);
            //добавление payment и w1Payment
            payment = new Payment()
            {
                Id = dbW1Payment.WMI_PAYMENT_NO,
                ShopId = shop.Id,
                IndividualId = individual.Id
            };
            dbPayment = paymentService.AddPayment(payment, w1Payment);
            payment.Id = dbPayment.Id;

            //Перемещение заказов из корзины в платеж и очистка корзины
            basketService.BasketToPaymentMigration(basket, payment);

            //-Создали представление для отображения w1Payment и передачи его в POST
            w1PaymentView = new W1PaymentView(dbW1Payment);//payment, basket);

            return RedirectToAction("BasketPay", w1PaymentView);//shop); //payment);
        }
Пример #4
0
        // Создает платеж W1 по его представлению
        public W1Payment MakeW1Payment(W1PaymentView w1PaymentView)
        {
            W1Payment w1Payment;
            DateTime expiredDate;

            w1Payment = new W1Payment()
            {
                WMI_PAYMENT_NO = w1PaymentView.WMI_PAYMENT_NO,
                WMI_MERCHANT_ID = w1PaymentView.WMI_MERCHANT_ID,
                WMI_CURRENCY_ID = Convert.ToInt32(w1PaymentView.WMI_CURRENCY_ID),
                //Переводить ToBase64 не нужно, это делается в методе MakeDescription
                WMI_DESCRIPTION = w1PaymentView.WMI_DESCRIPTION,
                WMI_PAYMENT_AMOUNT = Convert.ToDecimal(
                    w1PaymentView.WMI_PAYMENT_AMOUNT, CultureInfo.InvariantCulture),
                WMI_FAIL_URL = w1PaymentView.WMI_FAIL_URL,
                WMI_SUCCESS_URL = w1PaymentView.WMI_SUCCESS_URL
            };
            //после дебага расскоментировать!
            if (w1PaymentView.WMI_EXPIRED_DATE == null ||
                w1Payment.WMI_EXPIRED_DATE == DateTime.MinValue)
            {
                //Срок истечения - 30 дней. Формат UTC(+0)
                expiredDate = DateTime.UtcNow;
                expiredDate = expiredDate.AddDays(SpecialConstants.EXPIRED_DAYS_COUNT);
                w1Payment.WMI_EXPIRED_DATE = expiredDate;
            }
            else w1Payment.WMI_EXPIRED_DATE = w1Payment.WMI_EXPIRED_DATE;
            //w1Payment.WMI_EXPIRED_DATE = new DateTime(2015, 11, 07, 12, 04, 38);

            //везде сигнутура вычисляется заново. Правильно ли?
            w1Payment.WMI_SIGNATURE = GetSignature(w1PaymentView.dictionary);

            return w1Payment;
        }