public ActionResult Ok() { var customer = HttpContext.GetCustomer(); var formString = Request.Form.ToString(); var postData = string.IsNullOrEmpty(formString) ? Request.QueryString.ToString() : formString; //Successful order callback - make the order and send to confirmation if (!string.IsNullOrEmpty(postData)) { var parameterDictionary = PayFlowProController.GetParameterStringAsDictionary(postData, true); var processor = new PayPalEmbeddedCheckoutCallBackProcessor(parameterDictionary, customer); var redirectRoute = processor.ProcessCallBack(); return(new RedirectResult(redirectRoute)); } //Customer ended up here after the order was created - send them to confirmation var orderNumber = DB.GetSqlN( "select MAX(OrderNumber) N from dbo.orders where CustomerID = @customerId", new SqlParameter("customerId", customer.CustomerID)); var confirmationUrl = Url.Action( ActionNames.Confirmation, ControllerNames.CheckoutConfirmation, new { orderNumber = orderNumber }); return(Redirect(confirmationUrl)); }
protected void Page_Load(object sender, System.EventArgs e) { Customer thisCustomer; int customerId = 0; String postData = String.IsNullOrEmpty(Request.Form.ToString()) ? Request.QueryString.ToString() : Request.Form.ToString(); if (Request.Form["USER1"] != null && Request.Form["USER1"] != "" && int.TryParse(Request.Form["USER1"], out customerId)) //silent post { thisCustomer = new Customer(customerId, true); PayPalEmbeddedCheckoutCallBackProcessor processor = new PayPalEmbeddedCheckoutCallBackProcessor(PayFlowProController.GetParameterStringAsDictionary(postData, true), thisCustomer); string redirectPage = processor.ProcessCallBack(); } else if (!String.IsNullOrEmpty(Request.Form.ToString())) //notification (ipn) { } else // customer returning to site { if (QSResultCode == 0) { int OrderNumber = DB.GetSqlN("select MAX(OrderNumber) N from dbo.orders where CustomerID = " + ThisCustomer.CustomerID.ToString()); Response.Redirect("orderconfirmation.aspx?ordernumber=" + OrderNumber.ToString() + "&paymentmethod=PayPalEmbeddedCheckout", true); return; } ErrorMessage er = new ErrorMessage(QSResponseMessage); ShoppingCart cart = new ShoppingCart(SkinID, ThisCustomer, CartTypeEnum.ShoppingCart, 0, false); var checkoutController = CheckOutPageControllerFactory.CreateCheckOutPageController(ThisCustomer, cart); Response.Redirect(checkoutController.GetCheckoutPaymentPage() + "?ErrorMsg=" + er.MessageId, true); } }