public ActionResult RemoveSimplePayment() { var shopName = "CommerceEngineDefaultStorefront"; // Better use a configured store, not CommerceEngineDefaultStorefront as it's not really configured var cartName = "Default"; var userId = "CommerceUsers\\[email protected]"; var domain = Context.User.Domain; // Get a cart var loadCartRequest = new LoadCartByNameRequest(shopName, cartName, userId); var cartResult = _cartServiceProvider.LoadCart(loadCartRequest); Assert.IsTrue(cartResult.Success, String.Join("|", cartResult.SystemMessages.Select(e => e.Message))); var cart = cartResult.Cart; var removePaymentInfoRequest = new RemovePaymentInfoRequest(cart, cart.Payment); var removePaymentInfoResult = _cartServiceProvider.RemovePaymentInfo(removePaymentInfoRequest); Assert.IsTrue(removePaymentInfoResult.Success, String.Join("|", removePaymentInfoResult.SystemMessages.Select(e => e.Message))); return(View(removePaymentInfoResult)); }
public ActionResult CreatePayment(PaymentPickerViewModel createPaymentViewModel) { var cartService = new CartServiceProvider(); var cart = GetCart(); // First remove all the existing payment info's associated with the cart. var removeRequest = new RemovePaymentInfoRequest(cart, cart.Payment.ToList()); cartService.RemovePaymentInfo(removeRequest); var paymentList = new List <PaymentInfo> { new PaymentInfo() { PaymentMethodID = createPaymentViewModel.SelectedPaymentMethodId.ToString(), } }; var addRequest = new AddPaymentInfoRequest(cart, paymentList); cartService.AddPaymentInfo(addRequest); return(Redirect("/preview")); }