@@ -793,7 +793,6 @@ public ActionResult ConfirmOrder(FormCollection form)
793793 if ( ( _workContext . CurrentCustomer . IsGuest ( ) && ! _orderSettings . AnonymousCheckoutAllowed ) )
794794 return new HttpUnauthorizedResult ( ) ;
795795
796-
797796 //model
798797 var model = new CheckoutConfirmModel ( ) ;
799798 try
@@ -827,35 +826,30 @@ public ActionResult ConfirmOrder(FormCollection form)
827826
828827 if ( placeOrderResult . Success )
829828 {
829+ var postProcessPaymentRequest = new PostProcessPaymentRequest
830+ {
831+ Order = placeOrderResult . PlacedOrder
832+ } ;
833+
830834 if ( isPaymentPaymentWorkflowRequired )
831835 {
832- var postProcessPaymentRequest = new PostProcessPaymentRequest ( )
833- {
834- Order = placeOrderResult . PlacedOrder
835- } ;
836836 _paymentService . PostProcessPayment ( postProcessPaymentRequest ) ;
837837 }
838838
839839 _httpContext . Session [ "PaymentData" ] = null ;
840840 _httpContext . Session [ "OrderPaymentInfo" ] = null ;
841841 _httpContext . RemoveCheckoutState ( ) ;
842842
843- if ( _webHelper . IsRequestBeingRedirected || _webHelper . IsPostBeingDone )
844- {
845- //redirection or POST has been done in PostProcessPayment
846- return Content ( "Redirected" ) ;
847- }
848- else
849- {
850- //if no redirection has been done (to a third-party payment page)
851- //theoretically it's not possible
852- return RedirectToAction ( "Completed" ) ;
853- }
843+ if ( postProcessPaymentRequest . RedirectUrl . HasValue ( ) )
844+ {
845+ return Redirect ( postProcessPaymentRequest . RedirectUrl ) ;
846+ }
847+
848+ return RedirectToAction ( "Completed" ) ;
854849 }
855850 else
856851 {
857- foreach ( var error in placeOrderResult . Errors )
858- model . Warnings . Add ( error ) ;
852+ model . Warnings . AddRange ( placeOrderResult . Errors ) ;
859853 }
860854 }
861855 catch ( Exception exc )
@@ -864,12 +858,6 @@ public ActionResult ConfirmOrder(FormCollection form)
864858 model . Warnings . Add ( exc . Message ) ;
865859 }
866860
867- //If we got this far, something failed, redisplay form
868-
869- //if (model.Warnings.Count > 0)
870- // TempData["ConfirmOrderWarnings"] = model.Warnings;
871-
872- //return RedirectToRoute("CheckoutConfirm");
873861 return View ( model ) ;
874862 }
875863
0 commit comments