コード例 #1
0
 public PaymentController()
 {
     OrderService = new OrderService();
     CartService  = new CartService();
     PayexService = new PayexService();
     UserService  = new UserService();
 }
コード例 #2
0
        public ActionResult PayexPurchase(int id)
        {
            var cart = CartService.GetCartById(id);

            var payexRespone = PayexService.initialize8(cart);

            if (!PayexService.Initialize8Successfull(payexRespone))
            {
                log.Debug("Initialize8 Errorcode: " + payexRespone.ErrorCode + " Description: " + payexRespone.Description);
                //TODO: visa cartsidan med en felmedelande

                TempData["Init8Error"] = "Det gick inte att slutföra köpet";
                return(RedirectToAction("Index", "Cart", new { id = cart.Id }));
            }
            else
            {
                return(Redirect(payexRespone.RedirectURL));
            }
        }
コード例 #3
0
        public ActionResult PayexComplete(string orderRef)
        {
            var completeResponse = PayexService.Complete(orderRef);

            if (PayexService.IsTrasactionSuccessfull(completeResponse))
            {
                var cart    = CartService.GetCartByCustomerId(UserService.GetCurrentCustomer().Id);
                var dbOrder = OrderService.addOrder(cart.ToOrder());
                CartService.DeleteCart(cart.Id);

                log.Debug("Transaction successfull - TransactionRef:" + completeResponse.TransactionRef + " TransactionStatus: " + completeResponse.TransactionStatus);

                return(RedirectToAction("Order", dbOrder));
            }
            else
            {
                var userId = UserService.GetCurrentCustomer().Id;
                ViewBag.PayexError = "Purchase failed please try again. Description: " + completeResponse.Description;

                log.Debug("Transaction failed - ErrorCode: " + completeResponse.ErrorCode + " Description: " + completeResponse.Description);

                return(RedirectToAction("Index", "Cart", new { id = CartService.GetCartByCustomerId(userId).Id }));
            }
        }