Esempio n. 1
0
        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));
        }
Esempio n. 2
0
        public override IEnumerable <ModelValidationResult> Validate(object container)
        {
            var results = InnerValidator.Validate(container);

            foreach (var result in results)
            {
                result.Message = StringResourceProvider.GetString(result.Message);
            }

            return(results);
        }
Esempio n. 3
0
        public ActionResult PopUp(string imagePath, string altText = null)
        {
            if (!imagePath.StartsWith("/"))
            {
                imagePath = string.Format("/{0}", imagePath);
            }

            // Validate the imagePath parameter
            Uri imageUri;

            if (!Uri.TryCreate(imagePath, UriKind.Relative, out imageUri))
            {
                throw new HttpException(404, null);
            }

            var decodedAltText = Encoding.UTF8.GetString(HttpServerUtility.UrlTokenDecode(altText));

            if (string.IsNullOrWhiteSpace(decodedAltText))
            {
                decodedAltText = StringResourceProvider.GetString("popup.aspx.1");
            }

            return(View(new PopUpImageViewModel(
                            imageUrl: imageUri.ToString(),
                            altText: decodedAltText)));
        }
        public ActionResult Index()
        {
            ViewBag.MetaTitle = Settings.PageTitle;

            var model = new ContactUsRenderModel(
                pageHeader: StringResourceProvider.GetString("ContactUs.Page.Header"),
                useCaptcha: CaptchaSettings.CaptchaIsConfigured() && CaptchaSettings.RequireCaptchaOnContactForm);

            return(View(model));
        }
Esempio n. 5
0
        protected override void OnLoad(EventArgs e)
        {
            if (!AppLogic.AppConfigBool("DataRetentionPolicies.Enabled"))
            {
                AlertMessageDisplay.PushAlertMessage(StringResourceProvider.GetString("admin.customerremoval.dataretention.notenabled.message"),
                                                     AlertMessage.AlertType.Error);

                Response.Redirect("default.aspx");
            }
            base.OnLoad(e);
        }
        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 }));
            }
        }
Esempio n. 7
0
 string GetReplacementText()
 {
     return(StringResourceProvider.GetString("dataretentionpolicies.replacementtext"));
 }
Esempio n. 8
0
        public override string CaptureOrder(Order order)
        {
            var result        = AppLogic.ro_OK;
            var transactionId = LookupSagePayPiTransactionId(order.OrderNumber);

            if (string.IsNullOrEmpty(transactionId))
            {
                return(StringResourceProvider.GetString("admin.sagepaypi.notransactionid"));
            }

            var jsonObject = new JObject(
                new JProperty("instructionType", "release"),
                new JProperty("amount", GetSmallestCurrencyUnit(order.OrderBalance, Localization.StoreCurrency()))
                );

            var transactionUrl = string.Format(
                "{0}transactions/{1}",
                AppConfigProvider.GetAppConfigValue <bool>("UseLiveTransactions")
                                        ? AppConfigProvider.GetAppConfigValue("SagePayPi.LiveUrl")
                                        : AppConfigProvider.GetAppConfigValue("SagePayPi.TestUrl"),
                transactionId);

            var instructionsTransactionUrl = $"{transactionUrl}/instructions";
            var apiResponse = SagePayPiApiCall(jsonObject.ToString(), instructionsTransactionUrl, "POST");
            var formattedTransactionResponse = JObject.Parse(apiResponse);
            var responseHasError             = ResponseHasError(formattedTransactionResponse, "instructionType", "release");

            DB.ExecuteSQL("update orders set CaptureTXCommand = @CaptureTXCommand where OrderNumber = @OrderNumber",
                          new SqlParameter("@CaptureTXCommand", $"{order.CaptureTXCommand}" +
                                           $"{Environment.NewLine}" +
                                           $"{Environment.NewLine}" +
                                           $"POST Method - URL: {instructionsTransactionUrl}, " +
                                           $"Request: {jsonObject}"),
                          new SqlParameter("@OrderNumber", order.OrderNumber));

            DB.ExecuteSQL("update orders set CaptureTXResult = @CaptureTXResult where OrderNumber = @OrderNumber",
                          new SqlParameter("@CaptureTXResult", $"{order.CaptureTXResult}" +
                                           $"{Environment.NewLine}" +
                                           $"{Environment.NewLine}" +
                                           $"{formattedTransactionResponse}"),
                          new SqlParameter("@OrderNumber", order.OrderNumber));

            if (responseHasError)
            {
                var error = GetResponseError(formattedTransactionResponse, "description");

                if (error.EqualsIgnoreCase(StringResourceProvider.GetString("sagepaypi.error.unknownresponseerror")))
                {
                    error = GetResponseError(formattedTransactionResponse, "errors");
                }

                if (error.EqualsIgnoreCase("Transaction status not applicable"))
                {
                    error = StringResourceProvider.GetString("admin.sagepaypi.error.nolongercapturable");
                }

                result = error;
            }
            return(result);
        }
        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));
        }
        protected void Page_Load(object sender, EventArgs e)
        {
            IModelFactory modelFactory = Vortx.OnePageCheckout.ObjectFactory.CreateModelFactory();
            IConfigurationProviderFactory configurationFactory = Vortx.OnePageCheckout.ObjectFactory.CreateConfigurationFactory();

            ConfigurationProvider.DefaultProvider = configurationFactory.CreateConfigurationProvider();

            this.StringResourceProvider = modelFactory.CreateStringResourceProvider();

            this.AccountModel = modelFactory.CreateAccountModel();
            this.AccountModel.CreateAccountCompleted         += new CreateAccountHandler(AccountModel_CreateAccountCompleted);
            this.AccountModel.FindAccountCompleted           += new FindAccountHandler(AccountModel_FindAccountCompleted);
            this.AccountModel.LogOnCompleted                 += new LogOnHandler(AccountModel_LogOnCompleted);
            this.AccountModel.LogOutCompleted                += new LogOutHandler(AccountModel_LogOutCompleted);
            this.AccountModel.AccountChanged                 += new AccountChangedHandler(AccountModel_AccountChanged);
            this.AccountModel.BillingAddress.AddressChanged  += new AddressChangedEventHandler(BillingAddressEditModel_AddressChanged);
            this.AccountModel.ShippingAddress.AddressChanged += new AddressChangedEventHandler(ShippingAddressEditModel_AddressChanged);
            this.AccountModel.PasswordChanged                += new PasswordChangedHandler(AccountModel_PasswordChanged);

            this.LoginView.StringResourceProvider = this.StringResourceProvider;
            this.LoginView.SetModel(this.AccountModel);

            this.CreateAccountView.StringResourceProvider = this.StringResourceProvider;
            this.CreateAccountView.SetModel(this.AccountModel);
            this.CreateAccountView.AccountCreationActivated += (o, ea) => ApplyAccountCreation();

            // Create shopping cart models
            this.ShoppingCartModel = modelFactory.CreateShoppingCartModel();
            this.ShoppingCartModel.AccountModel         = this.AccountModel;
            this.ShoppingCartModel.ItemQuantityChanged += new ItemQuantityChangedHandler(ShoppingCartModel_ItemQuantityChanged);
            this.ShoppingCartModel.ItemRemoved         += new ItemRemovedHandler(ShoppingCartModel_ItemRemoved);
            this.ShoppingCartModel.ShipMethodChanged   += new ShipMethodChangedEventHandler(ShipMethodModel_ShipMethodChanged);

            // Create shopping cart views
            this.ShipMethodView.StringResourceProvider = this.StringResourceProvider;
            this.ShipMethodView.SetModel(this.ShoppingCartModel);

            this.MiniCartView.StringResourceProvider = this.StringResourceProvider;
            this.MiniCartView.SetModel(this.ShoppingCartModel);

            this.MiniCartCartSummary.StringResourceProvider = this.StringResourceProvider;
            this.MiniCartCartSummary.SetModel(this.ShoppingCartModel);

            this.AddressBookView.StringResourceProvider = this.StringResourceProvider;
            this.AddressBookView.SetModel(this.AccountModel);
            this.AddressBookView.SetAddressType(AddressType.Shipping);

            this.ShippingAddressEditView.StringResourceProvider = this.StringResourceProvider;
            this.ShippingAddressEditView.SetModel(this.AccountModel.ShippingAddress);

            this.ShippingAddressEditUKView.StringResourceProvider = this.StringResourceProvider;
            this.ShippingAddressEditUKView.SetModel(this.AccountModel.ShippingAddress);

            this.ShippingAddressNoZipEditView.StringResourceProvider = this.StringResourceProvider;
            this.ShippingAddressNoZipEditView.SetModel(this.AccountModel.ShippingAddress);

            this.ShippingAddressStaticView.StringResourceProvider = this.StringResourceProvider;
            this.ShippingAddressStaticView.SetModel(this.AccountModel.ShippingAddress);
            this.ShippingAddressStaticView.AddressEdit += new AddressEditEventHandler(ShippingAddressStaticView_AddressEdit);

            // Create payment model
            this.PaymentModel = modelFactory.CreatePaymentModel();
            this.PaymentModel.ActivePaymentMethodChanged += new ActivePaymentMethodChangedHandler(PaymentMethodModel_ActivePaymentMethodChanged);
            this.PaymentModel.ProcessPaymentComplete     += new ProcessPaymentCompleteHandler(PaymentModel_ProcessPaymentComplete);

            if (!ConfigurationProvider.DefaultProvider.ShowCreateAccount &&
                !ConfigurationProvider.DefaultProvider.PasswordIsOptionalDuringCheckout)
            {
                throw new Exception(StringResourceProvider.GetString("smartcheckout.aspx.129"));
            }

            GatewayCheckoutByAmazon.CheckoutByAmazon checkoutByAmazon = new GatewayCheckoutByAmazon.CheckoutByAmazon();

            // Setup payment events
            PaymentMethodBaseModel paymentMethod = null;

            if (checkoutByAmazon.IsEnabled && checkoutByAmazon.IsCheckingOut && (this.PaymentModel.ActivePaymentMethod == null || this.PaymentModel.ActivePaymentMethod.Name.ToLower() != PaymentType.CheckoutByAmazon.ToString().ToLower()))
            {
                this.PaymentModel.SetActivePaymentMethod(PaymentType.CheckoutByAmazon.ToString());
            }
            else
            {
                paymentMethod = this.PaymentModel.PaymentMethods.FirstOrDefault(pm => pm.Key == PaymentType.CreditCard).Value;
                if (paymentMethod != null)
                {
                    this.CreditCardModel = (CreditCardPaymentModel)paymentMethod;
                    this.CreditCardModel.BillingEqualsShippingChanged += new BillingEqualsShippingChangedHandler(CreditCardModel_BillingEqualsShippingChanged);
                }
            }

            // registered payment data changed events
            foreach (var kvp in this.PaymentModel.PaymentMethods)
            {
                var method = kvp.Value;
                method.PaymentDataChanged += new PaymentDataChangedHandler(PaymentModel_PaymentDataChanged);
            }

            // Create payment views
            this.PaymentView.StringResourceProvider = this.StringResourceProvider;
            this.PaymentView.SetModel(this.PaymentModel);

            this.BillingAddressEditView = this.PaymentView.BillingAddressEditView;
            this.BillingAddressEditView.StringResourceProvider = this.StringResourceProvider;
            this.BillingAddressEditView.SetModel(this.AccountModel.BillingAddress);

            this.BillingAddressStaticView = this.PaymentView.BillingAddressStaticView;
            this.BillingAddressStaticView.StringResourceProvider = this.StringResourceProvider;
            this.BillingAddressStaticView.SetModel(this.AccountModel.BillingAddress);

            this.BillingAddressBookView = this.PaymentView.AddressBookView;
            this.BillingAddressBookView.StringResourceProvider = this.StringResourceProvider;
            this.BillingAddressBookView.SetModel(this.AccountModel);

            this.AccountModel.PrimaryShippingAddressChanged += new PrimaryShippingAddressChangedHandler(AccountModel_PrimaryShippingAddressChanged);
            this.AccountModel.PrimaryBillingAddressChanged  += new PrimaryBillingAddressChangedHandler(AccountModel_PrimaryBillingAddressChanged);

            this.CustomerServiceModel = modelFactory.CreateContentModel();
            this.CustomerServiceModel.LoadContext(Vortx.OnePageCheckout.Settings.ConfigurationProvider.DefaultProvider.CustomerServiceTopic);
            this.CustomerServicePanel.StringResourceProvider = this.StringResourceProvider;
            this.CustomerServicePanel.SetModel(this.CustomerServiceModel);
            this.CustomerServicePanel.Initialize();
            this.CustomerServicePanel.Show();
            this.CustomerServicePanel.BindView();

            // if billing equals shipping then copy the shipping address to the billing address
            // TODO: evaluate whether or not this logic is neccessary
            if (this.PaymentModel.ActivePaymentMethod != null)
            {
                if (this.PaymentModel.ActivePaymentMethod.PaymentType == PaymentType.CreditCard)
                {
                    if (this.CreditCardModel != null)
                    {
                        if (this.ShoppingCartModel.ShippingRequired && this.CreditCardModel.BillingEqualsShipping)
                        {
                            this.AccountModel.CopyShippingAddressToBilling();
                        }
                    }
                }
            }

            if (ConfigurationProvider.DefaultProvider.RequireTermsAndConditions)
            {
                IContentModel termsModel = modelFactory.CreateContentModel();
                termsModel.LoadContext(ConfigurationProvider.DefaultProvider.TermsAndConditionsTopicName);
                ContentPanelTerms.StringResourceProvider = this.StringResourceProvider;
                ContentPanelTerms.SetModel(termsModel);
                ContentPanelTerms.BindView();
            }

            if (!Page.IsPostBack)
            {
                this.InitializePage();

                string error = Request.QueryString["error"];
                if (error != null && error.Equals("true"))
                {
                    this.PaymentView.ShowError(StringResourceProvider.GetString("smartcheckout.aspx.130"));
                }

                Page.DataBind();
            }

            StylesheetLiteral.Text = "<link rel=\"stylesheet\" href=\"OPCControls/" + ConfigurationProvider.DefaultProvider.OPCStyleSheetName + "\" />";

            this.UpdatePanelOnePageCheckoutMain.Update();

            ScriptManager.RegisterClientScriptBlock(Page, Page.GetType(), "registerBuySafeKickers", "try{WriteBuySafeKickers();}catch(err){}", true);
            if (ConfigurationProvider.DefaultProvider.BuySafeEnabled)
            {
                OPC_BuySafeWrap.Attributes.Add("style", "height:102px;");
            }
        }
        public ActionResult BraintreeThreeDSecureFail()
        {
            var customer = HttpContext.GetCustomer();
            var persistedCheckoutContext = PersistedCheckoutContextProvider.LoadCheckoutContext(customer);

            var updatedPersistedCheckoutContext = new PersistedCheckoutContextBuilder()
                                                  .From(persistedCheckoutContext)
                                                  .WithBraintree(new BraintreeDetails(
                                                                     nonce: persistedCheckoutContext.Braintree.Nonce,
                                                                     token: persistedCheckoutContext.Braintree.Token,
                                                                     paymentMethod: persistedCheckoutContext.Braintree.PaymentMethod,
                                                                     threeDSecureApproved: false))
                                                  .WithoutOffsiteRequiredBillingAddressId()
                                                  .WithoutOffsiteRequiredShippingAddressId()
                                                  .Build();

            PersistedCheckoutContextProvider.SaveCheckoutContext(customer, updatedPersistedCheckoutContext);

            NoticeProvider.PushNotice(StringResourceProvider.GetString("braintree.liabilityshiftfailed"), NoticeType.Failure);

            return(RedirectToAction(ActionNames.Index, ControllerNames.Checkout));
        }