public ActionResult PaymentInformation(CreditCardModel cardInfo, ChangeStepType changeStep) { if (changeStep == ChangeStepType.Previous) { return(this.RedirectToAction("PaymentMethod")); } string paymentMethod = Session["payment_method_provider"].ToString(); if (paymentMethod.Equals("Payments.SamplePaymentService", StringComparison.OrdinalIgnoreCase)) { var actionResult = this.checkoutService.GetPaymentServiceActionResult(cardInfo.ResultAccessCode); if (!actionResult.Success || !string.Equals(actionResult.AuthorizationResult, AuthorizationResult.Success.ToString(), StringComparison.OrdinalIgnoreCase)) { // authorization failed. return(PaymentInformationViewSelector(paymentMethod)); } cardInfo.CardToken = actionResult.CardToken; } if (changeStep == ChangeStepType.Next && cardInfo != null) { if (!paymentMethod.Equals("Payments.Manual") || this.ModelState.IsValid) { //session save Session["order_payment_info"] = cardInfo; return(RedirectToAction("Confirmation")); } } return(PaymentInformationViewSelector(paymentMethod)); }
public ActionResult ShippingMethod(string shippingMethod, ChangeStepType changeStep) { if (changeStep == ChangeStepType.Previous) { return(this.RedirectToAction("ShippingAddress")); } if (changeStep == ChangeStepType.Next && !string.IsNullOrEmpty(shippingMethod)) { var values = shippingMethod.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); if (values.Length == 2) { this.cartService.SetShippingMethodToCart(new ShippingInfo() { ShippingProviderID = values[0], ShippingMethodID = values[1] }); Session["shipping_method"] = values[1]; return(this.RedirectToAction("PaymentMethod")); } } return(RedirectToAction("ShippingMethod")); }
public ActionResult PaymentMethod(string paymentMethod, ChangeStepType changeStep) { if (changeStep == ChangeStepType.Previous) { return(this.RedirectToAction("ShippingMethod")); } if (changeStep == ChangeStepType.Next && !string.IsNullOrEmpty(paymentMethod)) { var values = paymentMethod.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); if (values.Length == 2) { this.cartService.SetPaymentMethodToCart(new PaymentInfo() { PaymentProviderID = values[0], PaymentMethodID = values[1] }); Session["payment_method"] = values[1]; Session["payment_method_provider"] = values[0]; return(this.RedirectToAction("PaymentInformation", new { paymentMethodProvider = values[0] })); } } return(RedirectToAction("PaymentMethod")); }
public ActionResult BillingAddress(AddressModel billingAddress, ChangeStepType changeStep) { ViewBag.Countries = Context.Database.Items["/sitecore/system/Settings/Analytics/Lookups/Countries/"]; ViewBag.Addresses = this.cartService.GetAddresses().Select(a => a.ToAddressModel()); if (changeStep != ChangeStepType.Next || !this.ModelState.IsValid) { return(View(billingAddress)); } // If address is not new if (!string.IsNullOrEmpty(billingAddress.PartyId)) { if (billingAddress.IsChanged((AddressModel)TempData["billing_address"])) { this.cartService.UpdateAddresses(new List <Party>() { billingAddress.ToParty() }); } this.cartService.SetBillingAddressToCart(new CartParty() { ExternalId = billingAddress.PartyId, PartyID = billingAddress.PartyId }); // proceed to next step return(this.RedirectToAction("ShippingAddress")); } // Add a new address to customer var party = billingAddress.ToParty(); var addresses = this.cartService.AddAddress(party); var address = addresses.FirstOrDefault(a => a.FirstName == party.FirstName && a.LastName == party.LastName && a.Email == party.Email); if (address == null) { this.ModelState.AddModelError(string.Empty, "Address could not be added to cart"); return(View(billingAddress)); } var result = this.cartService.SetBillingAddressToCart(new CartParty { ExternalId = address.ExternalId, PartyID = address.PartyId }); if (!result) { this.ModelState.AddModelError(string.Empty, "Could not update billing address"); return(View(billingAddress)); } // proceed to next step return(this.RedirectToAction("ShippingAddress")); }
public ActionResult Confirmation(ChangeStepType changeStep) { if (changeStep == ChangeStepType.Previous) { return(this.RedirectToAction("PaymentInformation", new { paymentMethodProvider = Session["payment_method_provider"].ToString() })); } if (changeStep == ChangeStepType.Confirm) { string paymentMethodProvider = Session["payment_method_provider"].ToString(); CreditCardModel cardInfo = (CreditCardModel)Session["order_payment_info"]; var paymentInformation = new PropertyCollection(); if (paymentMethodProvider.Equals("Payments.Manual", StringComparison.OrdinalIgnoreCase)) { paymentInformation = new PropertyCollection { { "CardType", cardInfo.CreditCardType }, { "CardName", cardInfo.CardholderName }, { "CardNumber", cardInfo.CardNumber }, { "CardExpirationMonth", cardInfo.ExpireMonth }, { "CardExpirationYear", cardInfo.ExpireYear }, { "CardCvv2", cardInfo.CardCode } }; } else if (paymentMethodProvider.Equals("Payments.SamplePaymentService", StringComparison.OrdinalIgnoreCase)) { paymentInformation = new PropertyCollection { { "CardType", cardInfo.CreditCardType }, { "CardPrefix", cardInfo.CreditCardPrefix }, { "ResultAccessCode", cardInfo.ResultAccessCode }, { "CardToken", cardInfo.CardToken } }; } var orderID = orderService.SetPaymentInformationAndSubmit(paymentInformation, paymentMethodProvider); return(RedirectToAction("Success", new { id = orderID })); } return(RedirectToAction("Confirmation")); }