Пример #1
0
        public ActionResult CardPay(VisaViewModel visa)
        {
            if (!ModelState.IsValid)
            {
                return(View(visa));
            }

            var order = _service.GetById(visa.OrderId);

            visa.Months = GetDate.GetAvailableMonths();
            visa.Years  = GetDate.GetAvailableYears();

            var paymentParams = Mapper.Map <PaymentParams>(visa);

            paymentParams.ToCardNumber = "11111111111111111";
            paymentParams.Amount       = order.OrderDetails.Sum(x => x.Price);
            paymentParams.Purpose      = $"Gamestore Invoice number #{order.Id}";

            _creditCardPayments = new CreditCardPayments(_paymentService);
            var payment = _creditCardPayments.Pay(visa.CardType)(paymentParams).Result;

            var paymentStatus = Mapper.Map <PaymentStatus>(payment);

            if (paymentStatus != PaymentStatus.Succesful)
            {
                ModelState.AddModelError(string.Empty,
                                         string.Format(GlobalRes.OrderTransferError, EnumDropDownListHelper.GetDisplayName(paymentStatus)));
                return(View(visa));
            }

            _service.Pay(order.CustomerId);
            return(RedirectToAction("Pay", new { payment = PaymentTypes.Bank, username = User.Identity.Name }));
        }
Пример #2
0
        public ActionResult Pay(OrderViewModel order, Func <string, object, ViewResult> viewResult)
        {
            var visa = new VisaViewModel()
            {
                OrderId = order.Id,
                Months  = GetDate.GetAvailableMonths(),
                Years   = GetDate.GetAvailableYears()
            };

            return(viewResult("~/Views/Orders/CardPay.cshtml", visa));
        }