Пример #1
0
        public PaymentResult ProcessPayment(ViewModels.CheckoutViewModel model)
        {
            var request = new TransactionRequest()
            {
                Amount     = model.Total,
                CreditCard = new TransactionCreditCardRequest()
                {
                    Number          = model.CardNumber,
                    CVV             = model.Cvv,
                    ExpirationMonth = model.Month,
                    ExpirationYear  = model.Year
                },
                Options = new TransactionOptionsRequest()
                {
                    SubmitForSettlement = true
                }
            };

            var result = _gateway.Transaction.Sale(request);

            if (result.IsSuccess())
            {
                return(new PaymentResult(result.Target.Id, true, null));
            }

            return(new PaymentResult(null, false, result.Message));
        }
Пример #2
0
        //
        // GET: /Checkout/
        public ActionResult Index()
        {
            CheckoutViewModel checkoutObj = this.Session[CHECKOUT_SESSION_KEY] as CheckoutViewModel;
            if (checkoutObj == null)
            {
                checkoutObj = new ViewModels.CheckoutViewModel();
                if (!Request.IsAuthenticated)
                {
                    checkoutObj.CurrentStep = ViewModels.CheckoutStep.Authentication;
                }
                else
                {
                    checkoutObj.CurrentStep = ViewModels.CheckoutStep.BillingInfo;
                    checkoutObj.IsPassword = true;
                    checkoutObj.UserName = User.Identity.Name;

                    this.Session[CHECKOUT_SESSION_KEY] = checkoutObj;

                }

            }
            return View("Index", checkoutObj);
        }