public ActionResult ShippingMethod(SelectShippingMethodViewModel model) { var customer = HttpContext.GetCustomer(); var storeId = AppLogic.StoreID(); if (!model.SelectedShippingMethodId.HasValue) { NoticeProvider.PushNotice("Please select a shipping method", NoticeType.Failure); return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout)); } var cart = CachedShoppingCartProvider.Get(customer, CartTypeEnum.ShoppingCart, storeId); var shippingAddress = EffectiveShippingAddressProvider.GetEffectiveShippingAddress(customer); var checkoutContext = PersistedCheckoutContextProvider.LoadCheckoutContext(customer); var shippingMethods = CachedShippingMethodCollectionProvider.Get(customer, shippingAddress, cart.CartItems, storeId); var selectedShippingMethod = shippingMethods .Where(shippingMethod => shippingMethod.Id == model.SelectedShippingMethodId) .FirstOrDefault(); if (selectedShippingMethod == null) { NoticeProvider.PushNotice("Please select a shipping method", NoticeType.Failure); return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout)); } SetShippingMethod(selectedShippingMethod, cart, customer); return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout)); }
public CartContext Apply(PreCheckoutRuleContext preCheckoutRuleContext) { var persistedCheckout = preCheckoutRuleContext .PersistedCheckoutContext; var customer = preCheckoutRuleContext .Customer; // If an offsite payment method has flagged billing or shipping as required, any changes by the customer will be reverted. if (persistedCheckout.OffsiteRequiredBillingAddressId.HasValue && customer.PrimaryBillingAddressID != persistedCheckout.OffsiteRequiredBillingAddressId) { customer.UpdateCustomer( billingAddressId: persistedCheckout.OffsiteRequiredBillingAddressId.Value); NoticeProvider.PushNotice(AppLogic.GetString("checkout.offsites.billing.reverted"), NoticeType.Warning); } if (persistedCheckout.OffsiteRequiredShippingAddressId.HasValue && customer.PrimaryShippingAddressID != persistedCheckout.OffsiteRequiredShippingAddressId) { customer.UpdateCustomer( shippingAddressId: persistedCheckout.OffsiteRequiredShippingAddressId.Value); NoticeProvider.PushNotice(AppLogic.GetString("checkout.offsites.shipping.reverted"), NoticeType.Warning); } return(new CartContext( cartContext: preCheckoutRuleContext.CartContext, cart: CachedShoppingCartProvider.Get(customer, CartTypeEnum.ShoppingCart, AppLogic.StoreID()))); }
public ActionResult TwoCheckoutReturn(string x_2checked) //This is their form field name, not mine { //http://help.2checkout.com/articles/FAQ/What-Authorize-net-parameters-does-2checkout-support/ //Y = success. K = Pending if (x_2checked != "Y" && x_2checked != "K") { NoticeProvider.PushNotice("Billing was canceled or not approved. Please retry your order.", NoticeType.Failure); return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout)); } var customer = HttpContext.GetCustomer(); var cart = CachedShoppingCartProvider.Get(customer, CartTypeEnum.ShoppingCart, AppLogic.StoreID()); var orderNumber = AppLogic.GetNextOrderNumber(); var status = Gateway.MakeOrder(string.Empty, AppLogic.ro_TXModeAuthCapture, cart, orderNumber, string.Empty, string.Empty, string.Empty, string.Empty); if (status == AppLogic.ro_OK) { var confirmationUrl = Url.Action( ActionNames.Confirmation, ControllerNames.CheckoutConfirmation, new { orderNumber = orderNumber }); return(Redirect(confirmationUrl)); } else { NoticeProvider.PushNotice(status, NoticeType.Failure); return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout)); } }
public ActionResult SagePayPiCreditCard(FormCollection collection) { var cardErrorSegments = collection["sagePayPiCardError"] .ParseAsDelimitedList('|'); if (cardErrorSegments.FirstOrDefault() == "ERROR") { var error = cardErrorSegments .Skip(1) .FirstOrDefault(); if (string.IsNullOrEmpty(error) || error.Contains("\"httpErrorCode\":401")) { NoticeProvider.PushNotice(StringResourceProvider.GetString("sagepaypi.payment.addingdetailserror"), NoticeType.Failure); return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout)); } var sagePayPi = new SagePayPi(); var errorObject = Newtonsoft.Json.Linq.JObject.Parse(error); var errorDetails = sagePayPi.GetResponseError(errorObject, "errors"); var errorMessage = string.Format("{0} {1}", StringResourceProvider.GetString("sagepaypi.payment.carderrorprompt"), errorDetails); NoticeProvider.PushNotice(errorMessage, NoticeType.Failure); return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout)); } var customer = HttpContext.GetCustomer(); var session = new CustomerSession(customer.CustomerID); session[AppLogic.SagePayPiMerchantSessionKey] = collection["sagePayPiMerchantSessionKey"]; var updatedPersistedCheckoutContext = new PersistedCheckoutContextBuilder() .From(PersistedCheckoutContextProvider.LoadCheckoutContext(customer)) .WithCreditCard(new CreditCardDetails( name: null, number: null, issueNumber: null, cardType: collection["sagePayPiCardType"], expirationDate: null, startDate: null, cvv: null)) .WithSagePayPi(new SagePayPiDetails( cardIdentifier: collection["sagePayPiCardIdentifier"], merchantSessionId: collection["sagePayPiMerchantSessionKey"], paymentMethod: Gateway.SagePayPiCreditCardKey, //This is the Sage Pay PI payment method, not ours threeDSecureApproved: false)) .WithoutOffsiteRequiredBillingAddressId() .WithoutOffsiteRequiredShippingAddressId() .Build(); PersistedCheckoutContextProvider.SaveCheckoutContext(customer, updatedPersistedCheckoutContext); customer.UpdateCustomer(requestedPaymentMethod: AppLogic.ro_PMCreditCard); return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout)); }
public ActionResult Index(ContactUsViewModel model) { var customer = HttpContext.GetCustomer(); if (CaptchaSettings.CaptchaIsConfigured() && CaptchaSettings.RequireCaptchaOnContactForm) { var captchaResult = CaptchaVerificationProvider.ValidateCaptchaResponse(Request.Form[CaptchaVerificationProvider.RecaptchaFormKey], customer.LastIPAddress); if (!captchaResult.Success) { NoticeProvider.PushNotice(captchaResult.Error.Message, NoticeType.Failure); // This error isn't actually displayed; it is just used to trigger the persisting of form data for the next page load ModelState.AddModelError( key: CaptchaVerificationProvider.RecaptchaFormKey, errorMessage: "Captcha Failed"); return(RedirectToAction(ActionNames.Index)); } } AppLogic.SendMail(subject: model.Subject, body: GetContactTopic(model), useHtml: true, fromAddress: Settings.FromAddress, fromName: Settings.FromName, toAddress: Settings.ToAddress, toName: Settings.ToName, bccAddresses: string.Empty, server: Settings.MailServer); return(RedirectToAction(ActionNames.Detail, ControllerNames.Topic, new { name = "ContactUsSuccessful" })); }
public ActionResult AmazonPayments(bool clearSession = false) { var customer = HttpContext.GetCustomer(); if (!PaymentOptionProvider.PaymentMethodSelectionIsValid(AppLogic.ro_PMAmazonPayments, customer)) { NoticeProvider.PushNotice( message: AppLogic.GetString("checkout.paymentmethodnotallowed"), type: NoticeType.Failure); return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout)); } var model = new AmazonPaymentsViewModel( residenceTypeOptions: SelectListBuilder.BuildResidenceTypeSelectList(ResidenceTypes.Residential.ToString()), clientId: AmazonPaymentsApiProvider.Configuration.ClientId, merchantId: AmazonPaymentsApiProvider.Configuration.MerchantId, scriptUrl: AmazonPaymentsApiProvider.Configuration.ScriptUrl); if (clearSession) { var updatedPersistedCheckoutContext = new PersistedCheckoutContextBuilder() .From(PersistedCheckoutContextProvider.LoadCheckoutContext(customer)) .WithoutAmazonPayments() .WithoutOffsiteRequiredBillingAddressId() .WithoutOffsiteRequiredShippingAddressId() .Build(); PersistedCheckoutContextProvider.SaveCheckoutContext(customer, updatedPersistedCheckoutContext); customer.UpdateCustomer(requestedPaymentMethod: string.Empty); return(Redirect(Url.Action(ActionNames.Index, ControllerNames.Checkout))); } return(View(model)); }
public ActionResult Detail(TopicPasswordViewModel model) { if (!ModelState.IsValid) { return(View(ViewNames.Password, new TopicPasswordViewModel { Name = model.Name })); } var customer = HttpContext.GetCustomer(); var topic = LoadTopic(model.Name); if (topic == null) { throw new HttpException(404, null); } if (model.EnteredPassword == topic.Password) { customer.ThisCustomerSession["Topic" + model.Name] = Security.MungeString(model.EnteredPassword); return(RedirectToAction(ActionNames.Detail)); } else { NoticeProvider.PushNotice("Password is incorrect", NoticeType.Failure); return(View(ViewNames.Password, model)); } }
public ActionResult ECheck() { var customer = HttpContext.GetCustomer(); if (!PaymentOptionProvider.PaymentMethodSelectionIsValid(AppLogic.ro_PMECheck, customer)) { NoticeProvider.PushNotice( message: AppLogic.GetString("checkout.paymentmethodnotallowed"), type: NoticeType.Failure); return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout)); } // AcceptJS is currently only way to use EChecks if (AppLogic.ActivePaymentGatewayCleaned() != Gateway.ro_GWACCEPTJS) { NoticeProvider.PushNotice( message: AppLogic.GetString("acceptjs.echeck.notconfigured"), type: NoticeType.Failure); return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout)); } var liveMode = AppLogic.AppConfigBool("UseLiveTransactions"); var acceptJsModel = new AcceptJsViewModel( clientKey: liveMode ? AppLogic.AppConfig("AcceptJs.Live.ClientKey") : AppLogic.AppConfig("AcceptJs.Test.ClientKey"), apiLoginId: liveMode ? AppLogic.AppConfig("AcceptJs.Live.ApiLoginId") : AppLogic.AppConfig("AcceptJs.Test.ApiLoginId"), scriptUrlHostedForm: liveMode ? AppLogic.AppConfig("AcceptJs.Form.Hosted.Live.Url") : AppLogic.AppConfig("AcceptJs.Form.Hosted.Test.Url"), scriptUrlOwnForm: liveMode ? AppLogic.AppConfig("AcceptJs.Form.Own.Live.Url") : AppLogic.AppConfig("AcceptJs.Form.Own.Test.Url")); var acceptJsECheckModel = new AcceptJsEcheckViewModel( acceptJsViewModel: acceptJsModel, eCheckViewModel: new ECheckViewModel(), checkoutECheckViewModel: new CheckoutECheckViewModel(string.Empty, string.Empty), accountTypes: ECheckAccountTypeProvider.GetECheckAccountTypesSelectList()); return(View(ViewNames.AcceptJsECheck, acceptJsECheckModel)); }
public ActionResult Index() { if (!WalletProvider.WalletsAreEnabled()) { NoticeProvider.PushNotice(AppLogic.GetString("checkout.wallet.disabled"), NoticeType.Warning); return(RedirectToAction(ActionNames.Index, ControllerNames.Account)); } var customer = HttpContext.GetCustomer(); if (!CustomerHasAvailableAddresses(customer)) { NoticeProvider.PushNotice( message: AppLogic.GetString("account.aspx.92"), type: NoticeType.Warning); return(RedirectToAction(ActionNames.Index, ControllerNames.Account)); } return(View(new WalletIndexViewModel( paymentTypes: WalletProvider .GetPaymentProfiles(customer) .Select(p => new WalletPaymentType { CardType = p.CardType, CardImage = DisplayTools.GetCardImage( imagePath: VirtualPathUtility.ToAbsolute(string.Format("~/skins/{0}/images/", SkinProvider.GetSkinNameById(customer.SkinID).ToLower())), cardName: p.CardType), CardNumber = p.CreditCardNumberMasked, ExpirationMonth = p.ExpirationMonth, ExpirationYear = p.ExpirationYear, PaymentProfileId = p.PaymentProfileId })))); }
public ActionResult Index() { if (!WalletProvider.WalletsAreEnabled()) { NoticeProvider.PushNotice("Wallets are not enabled.", NoticeType.Warning); return(RedirectToAction(ActionNames.Index, ControllerNames.Account)); } var customer = HttpContext.GetCustomer(); if (!CustomerHasAvailableAddresses(customer)) { NoticeProvider.PushNotice( message: "You must have a billing address configured before you can add a credit card to your account.", type: NoticeType.Warning); return(RedirectToAction(ActionNames.Index, ControllerNames.Account)); } return(View(new WalletIndexViewModel( paymentTypes: WalletProvider .GetPaymentProfiles(customer) .Select(p => new WalletPaymentType { CardType = p.CardType, CardImage = DisplayTools.GetCardImage( imagePath: VirtualPathUtility.ToAbsolute(string.Format("~/skins/{0}/images/", SkinProvider.GetSkinNameById(customer.SkinID).ToLower())), cardName: p.CardType), CardNumber = p.CreditCardNumberMasked, ExpirationMonth = p.ExpirationMonth, ExpirationYear = p.ExpirationYear, PaymentProfileId = p.PaymentProfileId })))); }
public ActionResult BraintreeThreeDSecureFail() { var customer = HttpContext.GetCustomer(); var context = PersistedCheckoutContextProvider.LoadCheckoutContext(customer); var updatedCheckoutContext = new PersistedCheckoutContext( creditCard: context.CreditCard, payPalExpress: context.PayPalExpress, purchaseOrder: context.PurchaseOrder, braintree: new BraintreeDetails( nonce: context.Braintree.Nonce, token: context.Braintree.Token, paymentMethod: context.Braintree.PaymentMethod, threeDSecureApproved: false), amazonPayments: context.AmazonPayments, termsAndConditionsAccepted: context.TermsAndConditionsAccepted, over13Checked: context.Over13Checked, shippingEstimateDetails: context.ShippingEstimateDetails, offsiteRequiresBillingAddressId: null, offsiteRequiresShippingAddressId: null, email: context.Email, selectedShippingMethodId: context.SelectedShippingMethodId); PersistedCheckoutContextProvider.SaveCheckoutContext(customer, updatedCheckoutContext); NoticeProvider.PushNotice("3dSecure verification failed, this order cannot be accepted.", NoticeType.Failure); return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout)); }
public ActionResult CheckoutCart([Bind(Include = "CartItems")] ShoppingCartViewModel cartViewModel) { if (!ModelState.IsValid) { return(RedirectToAction(ActionNames.CheckoutCart)); } var customer = HttpContext.GetCustomer(); var notices = new List <Notice>(); // Make request, check status var response = UpdateCartFromViewModel(cartViewModel, customer, CartTypeEnum.ShoppingCart); switch (response.Status) { case CartActionStatus.Forbidden: throw new HttpException(403, "Forbidden"); case CartActionStatus.RequiresLogin: case CartActionStatus.SessionTimeout: { foreach (var message in response.Messages) { NoticeProvider.PushNotice(message.ConvertToNotice()); } return(RedirectToAction(ActionNames.SignIn, ControllerNames.Account)); } default: break; } // Push any returned notices if (response.Messages.Any()) { foreach (var message in response.Messages) { NoticeProvider.PushNotice(message.ConvertToNotice()); } } return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout)); }
public ActionResult StartPayPalExpress(bool isPayPalCredit = false) { var customer = HttpContext.GetCustomer(); if (!PaymentOptionProvider.PaymentMethodSelectionIsValid(AppLogic.ro_PMPayPalExpress, customer)) { NoticeProvider.PushNotice( message: AppLogic.GetString("checkout.paymentmethodnotallowed"), type: NoticeType.Failure); return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout)); } var cart = CachedShoppingCartProvider.Get(customer, CartTypeEnum.ShoppingCart, AppLogic.StoreID()); Address shippingAddress = null; if (customer.IsRegistered && customer.PrimaryShippingAddressID != 0) { shippingAddress = new Address(); shippingAddress.LoadByCustomer(customer.CustomerID, customer.PrimaryShippingAddressID, AddressTypes.Shipping); } var checkoutOptions = new Dictionary <string, string>(); if (isPayPalCredit) { checkoutOptions.Add("UserSelectedFundingSource", "BML"); } var payPalExpressRedirectUrl = Gateway.StartExpressCheckout( cart: cart, boolBypassOrderReview: false, checkoutOptions: checkoutOptions); // PPE gets the redirect URL via an AJAX request, so we have to return it in the content. if (Request.IsAjaxRequest() && !isPayPalCredit) { return(Content(payPalExpressRedirectUrl)); } return(Redirect(payPalExpressRedirectUrl)); }
public ActionResult Index(int productId) { if (productId == 0) { NoticeProvider.PushNotice("Could not find the product to rate", NoticeType.Info); return(RedirectToAction(ActionNames.Index, ControllerNames.Home)); //Ended up here somehow by mistake - have to send them somewhere } return(View(BuildRatingViewModel(productId, false))); }
public ActionResult Index(int productId) { if (productId == 0) { NoticeProvider.PushNotice(AppLogic.GetString("ratings.productnotfound"), NoticeType.Info); return(RedirectToAction(ActionNames.Index, ControllerNames.Home)); //Ended up here somehow by mistake - have to send them somewhere } return(View(BuildRatingViewModel(productId, false))); }
public ActionResult ShippingMethod(SelectShippingMethodViewModel model) { var customer = HttpContext.GetCustomer(); var storeId = AppLogic.StoreID(); if (!model.SelectedShippingMethodId.HasValue) { NoticeProvider.PushNotice(StringResourceProvider.GetString("checkoutshipping.aspx.17"), NoticeType.Failure); return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout)); } var cart = CachedShoppingCartProvider.Get(customer, CartTypeEnum.ShoppingCart, storeId); var shippingAddress = EffectiveShippingAddressProvider.GetEffectiveShippingAddress(customer); var checkoutContext = PersistedCheckoutContextProvider.LoadCheckoutContext(customer); var shippingMethods = CachedShippingMethodCollectionProvider.Get(customer, shippingAddress, cart.CartItems, storeId); var selectedShippingMethod = shippingMethods .Where(shippingMethod => shippingMethod.Id == model.SelectedShippingMethodId) .FirstOrDefault(); if (selectedShippingMethod == null) { NoticeProvider.PushNotice(StringResourceProvider.GetString("checkoutshipping.aspx.17"), NoticeType.Failure); return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout)); } SetShippingMethod(selectedShippingMethod, cart, customer); if (AppConfigProvider.GetAppConfigValue <bool>("shipping.hide.options")) { return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout)); } else { return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout, new { name = SelectShippingMethodViewModel.ShippingMethodSelected })); } }
public ActionResult CreditCard() { var customer = HttpContext.GetCustomer(); if (!PaymentOptionProvider.PaymentMethodSelectionIsValid(AppLogic.ro_PMCreditCard, customer)) { NoticeProvider.PushNotice( message: "Invalid payment method! Please choose another.", type: NoticeType.Failure); return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout)); } //Decide which form to display if (AppLogic.ActivePaymentGatewayCleaned() == Gateway.ro_GWBRAINTREE) { var processor = GatewayLoader.GetProcessor(Gateway.ro_GWBRAINTREE); var clientToken = processor.ObtainBraintreeToken(); if (string.IsNullOrEmpty(clientToken)) { NoticeProvider.PushNotice("Our credit card processor is currently excperiencing difficulties. Please try another payment method or contact us for assistance.", NoticeType.Failure); return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout)); } var braintreeModel = new BraintreeViewModel(token: clientToken, scriptUrl: AppLogic.AppConfig("Braintree.ScriptUrl")); return(View(ViewNames.BraintreeCreditCard, braintreeModel)); } else { var ccModel = BuildCheckoutCreditCardViewModel(customer); return(View(ViewNames.CreditCard, ccModel)); } }
void SetCustomerVatSetting(Customer customer, string vatSetting, string vatRegistrationId) { var vatSettingRaw = (VATSettingEnum)int.Parse(vatSetting); customer.VATSettingRAW = vatSettingRaw; if (!string.IsNullOrEmpty(vatRegistrationId)) { if (AppLogic.VATRegistrationIDIsValid(customer, vatRegistrationId)) { customer.SetVATRegistrationID(vatRegistrationId); } else { NoticeProvider.PushNotice("Unable to set the VAT Registration Id. Contact the site administrator for details.", NoticeType.Warning); } } }
public CartContext Apply(PreCheckoutRuleContext preCheckoutRuleContext) { InventoryTrimmedReason inventoryTrimmedReason = CartActionProvider .ValidateCartQuantitiesAgainstInventory(preCheckoutRuleContext.Customer, preCheckoutRuleContext.CartContext.Cart.CartType); //Display inventory adjustment notice if necessary var cartTrimmedMessage = preCheckoutRuleContext.CartContext.Cart.GetInventoryTrimmedUserMessage(inventoryTrimmedReason); if (!string.IsNullOrEmpty(cartTrimmedMessage)) { NoticeProvider.PushNotice(cartTrimmedMessage, NoticeType.Info); } return(new CartContext( cartContext: preCheckoutRuleContext.CartContext, cart: CachedShoppingCartProvider.Get(preCheckoutRuleContext.Customer, CartTypeEnum.ShoppingCart, AppLogic.StoreID()))); }
void SetCustomerVatSetting(Customer customer, string vatSetting, string vatRegistrationId) { var vatSettingRaw = (VATSettingEnum)int.Parse(vatSetting); customer.VATSettingRAW = vatSettingRaw; if (!string.IsNullOrEmpty(vatRegistrationId)) { if (AppLogic.VATRegistrationIDIsValid(customer, vatRegistrationId)) { customer.SetVATRegistrationID(vatRegistrationId); } else { NoticeProvider.PushNotice(AppLogic.GetString("vat.setregistration.error"), NoticeType.Warning); } } }
public ActionResult PurchaseOrder() { var customer = HttpContext.GetCustomer(); if (!PaymentOptionProvider.PaymentMethodSelectionIsValid(AppLogic.ro_PMPurchaseOrder, customer)) { NoticeProvider.PushNotice( message: "Invalid payment method! Please choose another.", type: NoticeType.Failure); return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout)); } var checkoutContext = PersistedCheckoutContextProvider.LoadCheckoutContext(customer); var model = BuildPurchaseOrderViewModel(checkoutContext.PurchaseOrder); return(View(model)); }
public ActionResult SelectAddress(SelectAddressViewModel model) { if (!(model.SelectedAddressId > 0)) { NoticeProvider.PushNotice(AppLogic.GetString("validate.selectedaddress", HttpContext.GetCustomer().LocaleSetting), NoticeType.Failure); return(RedirectToAction( ActionNames.SelectAddress, ControllerNames.CheckoutAddress)); } return(RedirectToAction( ActionNames.MakePrimaryAddress, ControllerNames.Address, new { addressId = model.SelectedAddressId, addressType = model.AddressType, returnUrl = Url.Action(ActionNames.Index, ControllerNames.Checkout) })); }
public ActionResult SelectAddress(SelectAddressViewModel model) { if (!(model.SelectedAddressId > 0)) { NoticeProvider.PushNotice("Please select a valid address", NoticeType.Failure); return(RedirectToAction( ActionNames.SelectAddress, ControllerNames.CheckoutAddress)); } return(RedirectToAction( ActionNames.MakePrimaryAddress, ControllerNames.Address, new { addressId = model.SelectedAddressId, addressType = model.AddressType, returnUrl = Url.Action(ActionNames.Index, ControllerNames.Checkout) })); }
public ActionResult AmazonPayments(bool clearSession = false) { var customer = HttpContext.GetCustomer(); if (!PaymentOptionProvider.PaymentMethodSelectionIsValid(AppLogic.ro_PMAmazonPayments, customer)) { NoticeProvider.PushNotice( message: "Invalid payment method! Please choose another.", type: NoticeType.Failure); return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout)); } var model = new AmazonPaymentsViewModel( clientId: AmazonPaymentsApiProvider.Configuration.ClientId, merchantId: AmazonPaymentsApiProvider.Configuration.MerchantId, scriptUrl: AmazonPaymentsApiProvider.Configuration.ScriptUrl); if (clearSession) { var checkoutContext = PersistedCheckoutContextProvider.LoadCheckoutContext(customer); var updatedCheckoutContext = new PersistedCheckoutContext( creditCard: checkoutContext.CreditCard, payPalExpress: checkoutContext.PayPalExpress, purchaseOrder: checkoutContext.PurchaseOrder, braintree: checkoutContext.Braintree, amazonPayments: null, termsAndConditionsAccepted: checkoutContext.TermsAndConditionsAccepted, over13Checked: checkoutContext.Over13Checked, shippingEstimateDetails: checkoutContext.ShippingEstimateDetails, offsiteRequiresBillingAddressId: null, offsiteRequiresShippingAddressId: null, email: checkoutContext.Email, selectedShippingMethodId: checkoutContext.SelectedShippingMethodId); PersistedCheckoutContextProvider.SaveCheckoutContext(customer, updatedCheckoutContext); customer.UpdateCustomer(requestedPaymentMethod: string.Empty); return(Redirect(Url.Action(ActionNames.Index, ControllerNames.Checkout))); } return(View(model)); }
public ActionResult MicroPayDetail() { var customer = HttpContext.GetCustomer(); if (!PaymentOptionProvider.PaymentMethodSelectionIsValid(AppLogic.ro_PMMicropay, customer)) { NoticeProvider.PushNotice( message: "Invalid payment method! Please choose another.", type: NoticeType.Failure); return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout)); } var cart = CachedShoppingCartProvider.Get(customer, CartTypeEnum.ShoppingCart, AppLogic.StoreID()); var model = new MicroPayViewModel { Balance = Localization.CurrencyStringForDisplayWithExchangeRate(customer.MicroPayBalance, customer.CurrencySetting), BalanceIsSufficient = customer.MicroPayBalance >= cart.Total(true) }; return(PartialView(ViewNames.MicroPayPartial, model)); }
public ActionResult Download(int shoppingCartRecordId) { var customer = HttpContext.GetCustomer(); var customerOwnsDownload = LoadDownloadItemsForCustomer(customer.CustomerID) .Where(download => download.ShoppingCartRecordId == shoppingCartRecordId) .Any(); if (!customerOwnsDownload) { throw new HttpException(403, "Forbidden"); } var downloadItem = new DownloadItem(); downloadItem.Load(shoppingCartRecordId); var filepath = CommonLogic.SafeMapPath("~/" + downloadItem.DownloadLocation); var filename = Path.GetFileName(filepath); try { if (!System.IO.File.Exists(filepath)) { throw new FileNotFoundException("Could not download the file because it does not exist", filepath); } return(File(filepath, downloadItem.ContentType)); } catch (Exception exception) { SysLog.LogException(exception, MessageTypeEnum.GeneralException, MessageSeverityEnum.Error); NoticeProvider.PushNotice(AppLogic.GetString("download.aspx.15", customer.LocaleSetting), NoticeType.Failure); return(RedirectToAction(ActionNames.Index)); } }
public ActionResult CreditCard() { var customer = HttpContext.GetCustomer(); if (!PaymentOptionProvider.PaymentMethodSelectionIsValid(AppLogic.ro_PMCreditCard, customer)) { NoticeProvider.PushNotice( message: AppLogic.GetString("checkout.paymentmethodnotallowed"), type: NoticeType.Failure); return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout)); } //Decide which form to display if (AppLogic.ActivePaymentGatewayCleaned() == Gateway.ro_GWBRAINTREE) { var processor = GatewayLoader.GetProcessor(Gateway.ro_GWBRAINTREE); var clientToken = processor.ObtainBraintreeToken(); if (string.IsNullOrEmpty(clientToken)) { NoticeProvider.PushNotice(AppLogic.GetString("braintree.creditcardunavailable"), NoticeType.Failure); return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout)); } var braintreeModel = new BraintreeViewModel(token: clientToken, scriptUrl: AppLogic.AppConfig("Braintree.ScriptUrl")); return(View(ViewNames.BraintreeCreditCard, braintreeModel)); } else if (AppLogic.ActivePaymentGatewayCleaned() == Gateway.ro_GWACCEPTJS) { var liveMode = AppLogic.AppConfigBool("UseLiveTransactions"); var cart = CachedShoppingCartProvider.Get(customer, CartTypeEnum.ShoppingCart, AppLogic.StoreID()); var acceptJsModel = new AcceptJsViewModel( clientKey: liveMode ? AppLogic.AppConfig("AcceptJs.Live.ClientKey") : AppLogic.AppConfig("AcceptJs.Test.ClientKey"), apiLoginId: liveMode ? AppLogic.AppConfig("AcceptJs.Live.ApiLoginId") : AppLogic.AppConfig("AcceptJs.Test.ApiLoginId"), scriptUrlHostedForm: liveMode ? AppLogic.AppConfig("AcceptJs.Form.Hosted.Live.Url") : AppLogic.AppConfig("AcceptJs.Form.Hosted.Test.Url"), scriptUrlOwnForm: liveMode ? AppLogic.AppConfig("AcceptJs.Form.Own.Live.Url") : AppLogic.AppConfig("AcceptJs.Form.Own.Test.Url")); return(View(ViewNames.AcceptJsCreditCard, acceptJsModel)); } else if (AppLogic.ActivePaymentGatewayCleaned() == Gateway.ro_GWSAGEPAYPI) { var processor = (ISagePayPiGatewayProcessor)GatewayLoader.GetProcessor(Gateway.ro_GWSAGEPAYPI); var clientMerchantSessionKey = processor.ObtainSagePayPiMerchantSessionKey(); if (string.IsNullOrEmpty(clientMerchantSessionKey)) { NoticeProvider.PushNotice(AppLogic.GetString("sagepaypi.creditcardunavailable"), NoticeType.Failure); return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout)); } var sagePayPiModel = new SagePayPiViewModel(merchantSessionKey: clientMerchantSessionKey, scriptUrl: AppLogic.AppConfigBool("UseLiveTransactions") ? AppLogic.AppConfig("SagePayPi.LiveScriptUrl") : AppLogic.AppConfig("SagePayPi.TestScriptUrl"), validateCreditCardNumber: AppLogic.AppConfigBool("ValidateCreditCardNumbers")); return(View(ViewNames.SagePayPiCreditCard, sagePayPiModel)); } else { var ccModel = BuildCheckoutCreditCardViewModel(customer); return(View(ViewNames.CreditCard, ccModel)); } }
public ActionResult AddToCart(AddToCartPostModel model) { if (!ModelState.IsValid) { return(RedirectToAction(ActionNames.Index, ControllerNames.Minicart)); } var customer = HttpContext.GetCustomer(); var notices = new List <Notice>(); var cartType = model.IsWishlist ? CartTypeEnum.WishCart : CartTypeEnum.ShoppingCart; // Use the provided return URL if there is one, otherwise try to use the referrer string unverifiedReturnUrl; if (!string.IsNullOrWhiteSpace(model.ReturnUrl)) { unverifiedReturnUrl = model.ReturnUrl; } else if (Request.UrlReferrer != null) { unverifiedReturnUrl = Request.UrlReferrer.ToString(); } else { unverifiedReturnUrl = null; } // Ensure we have a safe return URL var returnUrl = UrlHelper.MakeSafeReturnUrl( returnUrl: unverifiedReturnUrl, defaultUrl: cartType == CartTypeEnum.WishCart ? Url.Action(ActionNames.Index, ControllerNames.Wishlist) : Url.Action(ActionNames.Index, ControllerNames.Checkout)); // Make request, check status var response = CartActionProvider.AddItemToCart(model.ConvertToAddToCartContext( customer, model.IsWishlist ? CartTypeEnum.WishCart : CartTypeEnum.ShoppingCart)); switch (response.Status) { case CartActionStatus.Forbidden: throw new HttpException(403, "Forbidden"); case CartActionStatus.RequiresLogin: case CartActionStatus.SessionTimeout: { foreach (var message in response.Messages) { NoticeProvider.PushNotice(message.ConvertToNotice()); } return(RedirectToAction(ActionNames.SignIn, ControllerNames.Account)); } case CartActionStatus.ValidationErrors: { foreach (var message in response.Messages) { NoticeProvider.PushNotice(message.ConvertToNotice()); } return(Redirect(returnUrl)); } default: break; } // Add any returned notices if (response.Messages.Any()) { foreach (var message in response.Messages) { NoticeProvider.PushNotice(message.ConvertToNotice()); } } else { NoticeProvider.PushNotice("Item successfully added to cart.", NoticeType.Success); } // Redirect accordingly if (AppLogic.AppConfig("AddToCartAction").Equals("STAY", StringComparison.OrdinalIgnoreCase)) { return(Redirect(returnUrl)); } return(RedirectToAction( ActionNames.Index, ControllerNames.Checkout, new { returnUrl })); }
public ActionResult Index(AccountPostViewModel model) { var customer = HttpContext.GetCustomer(); if (!ModelState.IsValid) { return(RedirectToAction(ActionNames.Index)); } if (!Customer.NewEmailPassesDuplicationRules(model.Account.Email, customer.CustomerID)) { ModelState.AddModelError("Account.Email", StringResourceProvider.GetString("createaccount_process.aspx.1")); return(RedirectToAction(ActionNames.Index)); } // The account editor only updates the password if one was specified or if the customer has not yet registered. if (!customer.IsRegistered || !string.IsNullOrEmpty(model.Account.Password)) { switch (ControllerHelper.ValidateAccountPassword(customer, model.Account.Password, model.Account.PasswordConfirmation)) { case AccountControllerHelper.PasswordValidationResult.DoesNotMatch: ModelState.AddModelError("Account.PasswordConfirmation", StringResourceProvider.GetString("account.aspx.68")); return(RedirectToAction(ActionNames.Index)); case AccountControllerHelper.PasswordValidationResult.NotStrong: ModelState.AddModelError("Account.Password", StringResourceProvider.GetString("account.aspx.69")); return(RedirectToAction(ActionNames.Index)); case AccountControllerHelper.PasswordValidationResult.SameAsCurrent: ModelState.AddModelError("Account.Password", StringResourceProvider.GetString("signin.aspx.30")); return(RedirectToAction(ActionNames.Index)); case AccountControllerHelper.PasswordValidationResult.SameAsPrevious: ModelState.AddModelError("Account.Password", string.Format(StringResourceProvider.GetString("signin.aspx.31"), Settings.NumberOfPreviouslyUsedPasswords)); return(RedirectToAction(ActionNames.Index)); default: case AccountControllerHelper.PasswordValidationResult.Ok: break; } } var vatRegistationValidationResult = ControllerHelper.ValidateVatRegistrationId(model.Account, customer); if (!vatRegistationValidationResult.Ok) { NoticeProvider.PushNotice( StringResourceProvider.GetString( vatRegistationValidationResult.Message ?? "account.aspx.91"), NoticeType.Failure); return(RedirectToAction(ActionNames.Index)); } ControllerHelper.UpdateAccount(model.Account, customer); NoticeProvider.PushNotice(StringResourceProvider.GetString("account.aspx.2"), NoticeType.Success); return(RedirectToAction(ActionNames.Index)); }
public ActionResult Confirmation(int orderNumber) { var customer = HttpContext.GetCustomer(); var checkoutContext = PersistedCheckoutContextProvider.LoadCheckoutContext(customer); var order = new Order(orderNumber, customer.LocaleSetting); //Missing info if (customer.CustomerID == 0 || orderNumber == 0) { NoticeProvider.PushNotice(AppLogic.GetString("orderconfirmation.Invalid"), NoticeType.Failure); return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout)); } //No such order if (order.IsEmpty) { NoticeProvider.PushNotice(AppLogic.GetString("orderconfirmation.aspx.19"), NoticeType.Failure); return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout)); } //Wrong customer if (customer.CustomerID != order.CustomerID) { return(RedirectToAction(ActionNames.Detail, ControllerNames.Topic, new { @name = "ordernotfound" })); } if (customer.ThisCustomerSession["3DSecure.LookupResult"].Length > 0) { var sqlParams = new SqlParameter[] { new SqlParameter("@LookupResult", customer.ThisCustomerSession["3DSecure.LookupResult"]), new SqlParameter("@OrderNumber", orderNumber) }; DB.ExecuteSQL("UPDATE Orders SET CardinalLookupResult = @LookupResult WHERE OrderNumber = @OrderNumber", sqlParams); } //Order cleanup if (!order.AlreadyConfirmed) { ViewBag.OrderAlreadyConfirmed = false; // Adding a variable to the viewbag so that xmlpackages can tell the order has not yet been confirmed var paymentMethod = AppLogic.CleanPaymentMethod(order.PaymentMethod); DB.ExecuteSQL("update Customer set OrderOptions=NULL, OrderNotes=NULL, FinalizationData=NULL where CustomerID=" + customer.CustomerID.ToString()); //New order notification AppLogic.SendOrderEMail(customer, orderNumber, false, paymentMethod, true); //Low inventory notification if (AppLogic.AppConfigBool("SendLowStockWarnings") && order.TransactionIsCaptured()) //If delayed capture, we'll check this when the order is captured { List <int> purchasedVariants = new List <int>(); foreach (CartItem ci in order.CartItems) { purchasedVariants.Add(ci.VariantID); } AppLogic.LowInventoryWarning(purchasedVariants); } //Handle impersonation var impersonationValue = customer.ThisCustomerSession[AppLogic.ImpersonationSessionKey]; if (!string.IsNullOrEmpty(impersonationValue)) { int impersonatorId = 0; if (int.TryParse(impersonationValue, out impersonatorId)) { var impersonator = new Customer(impersonatorId); var impersonationSql = "UPDATE Orders SET Notes = Notes + @ImpersonationNote WHERE OrderNumber = @OrderNumber"; var impersonationSqlParams = new SqlParameter[] { new SqlParameter("@OrderNumber", orderNumber), new SqlParameter("@ImpersonationNote", string.Format(AppLogic.GetString("admin.order.ImpersonationNote"), impersonator.EMail)) }; DB.ExecuteSQL(impersonationSql, impersonationSqlParams); customer.ThisCustomerSession.ClearVal(AppLogic.ImpersonationSessionKey); } } //Braintree cleanup if (order.PaymentGateway == Gateway.ro_GWBRAINTREE) { //Clear out some session values we don't need anymore customer.ThisCustomerSession.ClearVal(AppLogic.Braintree3dSecureKey); customer.ThisCustomerSession.ClearVal(AppLogic.BraintreeNonceKey); customer.ThisCustomerSession.ClearVal(AppLogic.BraintreePaymentMethod); } //SagePayPi cleanup if (order.PaymentGateway == Gateway.ro_GWSAGEPAYPI) { //Clear out some session values we don't need anymore customer.ThisCustomerSession.ClearVal(AppLogic.SagePayPi3dSecureKey); customer.ThisCustomerSession.ClearVal(AppLogic.SagePayPiCardIdentifier); customer.ThisCustomerSession.ClearVal(AppLogic.SagePayPiPaymentMethod); } //Make sure we don't do this again DB.ExecuteSQL("UPDATE Orders SET AlreadyConfirmed = 1 WHERE OrderNumber = @OrderNumber", new SqlParameter[] { new SqlParameter("@OrderNumber", orderNumber) }); } //Build the return model string googleTrackingCode = null; if (!order.AlreadyConfirmed && AppLogic.AppConfigBool("IncludeGoogleTrackingCode")) { googleTrackingCode = GetTrackingCodeTopicContents("GoogleTrackingCode", customer, orderNumber, order.Total()); } string generalTrackingCode = null; if (!order.AlreadyConfirmed) { generalTrackingCode = GetTrackingCodeTopicContents("ConfirmationTracking", customer, orderNumber, order.Total()); } var showGoogleCustomerReviews = AppLogic.AppConfigBool("GoogleCustomerReviewsEnabled") && !order.AlreadyConfirmed && !string.IsNullOrWhiteSpace(AppLogic.AppConfig("GoogleCustomerReviewsMerchantID")); var xmlPackage = AppLogic.AppConfig("XmlPackage.OrderConfirmationPage"); if (string.IsNullOrEmpty(xmlPackage)) { xmlPackage = "page.orderconfirmation.xml.config"; } var body = AppLogic.RunXmlPackage(xmlPackage, new Parser(), customer, customer.SkinID, string.Empty, "OrderNumber=" + orderNumber.ToString(), true, true); var model = new OrderConfirmationViewModel( orderNumber: orderNumber, body: body, googleTrackingCode: googleTrackingCode, generalTrackingCode: generalTrackingCode, showGoogleTrackingCode: !string.IsNullOrWhiteSpace(googleTrackingCode), showGeneralTrackingCode: !string.IsNullOrWhiteSpace(generalTrackingCode), showGoogleCustomerReviews: showGoogleCustomerReviews, addPayPalExpressCheckoutScript: order.PaymentMethod == AppLogic.ro_PMPayPalExpress && !order.AlreadyConfirmed, addBuySafeScript: AppLogic.GlobalConfigBool("BuySafe.Enabled") && !string.IsNullOrEmpty(AppLogic.GlobalConfig("BuySafe.Hash")) && !order.AlreadyConfirmed); //Get rid of old data - do this at the very end so we have all the info we need for order processing and building the model above ClearSensitiveOrderData(customer); if (!customer.IsRegistered || AppLogic.AppConfigBool("ForceSignoutOnOrderCompletion")) { ClearCustomerSession(customer); } return(View(model)); }