Exemplo n.º 1
0
        public ActionResult Index()
        {
            var job = (Job)Session["Job"];

            var viewModel = new PaymentViewModel
            {
                Total = job.Quote.Total
            };

            return View("Index", viewModel);
        }
Exemplo n.º 2
0
        public ActionResult Make(PaymentInputModel inputModel)
        {
            var job = (Job)Session["Job"];

            // todo wrap - up in service
            var request = new AuthorizationRequest(inputModel.CardNumber.ToString(), inputModel.ExpiryDate, job.Quote.Total, job.Reference);

            var gate = new Gateway(paymentSettings.GetApiLogin(), paymentSettings.GetTransactionKey());

            var response = gate.Send(request);

            if (response.Approved)
            {
                jobService.MakePayment(job, response.Amount, response.TransactionID);
                jobService.SaveJob(job);

                Session["Job"] = job;

                var responseViewModel = new PaymentResponseViewModel
                {
                    ResponseCode = response.ResponseCode,
                    Message = response.Message,
                    TransactionId = response.TransactionID,
                    Amount = response.Amount,
                    Timestamp = job.PaymentMade.Value,
                    JobReference = job.Reference
                };

                Session["PaymentResult"] = responseViewModel;

                return RedirectToUmbracoPage(1185);
            }

            var viewModel = new PaymentViewModel
            {
                Total = job.Quote.Total
            };

            return View("Index", viewModel);
        }