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(int?addressId, string addressType, string returnUrl, bool makePrimary = false)
        {
            var customer = HttpContext.GetCustomer();

            var safeReturnUrl = Url.MakeSafeReturnUrl(returnUrl, Url.Action(ActionNames.Index));

            var address = ControllerHelper.GetCustomerAddress(addressId, customer);

            var addressTypeValue = GetAddressType(addressType);

            var countries = SelectListBuilder.BuildCountrySelectList(address.Country);
            var states    = SelectListBuilder.BuildStateSelectList(countries.SelectedValue.ToString(), address.State);

            return(View(new AddressDetailViewModel(
                            address: address,
                            residenceTypeOptions: SelectListBuilder.BuildResidenceTypeSelectList(address.ResidenceType),
                            stateOptions: states,
                            countryOptions: countries,
                            showCompanyField: AddressSettings.ShowCompanyField,
                            showNickName: AddressSettings.ShowNickName,
                            showSuite: AddressSettings.ShowSuite,
                            showResidenceTypeField: ShowResidenceTypeField(addressTypeValue),
                            returnUrl: safeReturnUrl,
                            header: AddressHeaderProvider.GetHeaderText(address.Id, addressTypeValue),
                            showPostalCodeLookup: PostalCodeLookupProvider.IsEnabled(countries.SelectedValue.ToString()),
                            addressType: addressTypeValue,
                            makePrimary: makePrimary,
                            enablePhoneInputMask: AddressSettings.UsePhoneNumberMask)));
        }
Beispiel #3
0
        public ActionResult Detail(int?addressId, string addressType, string returnUrl, bool makePrimary = false)
        {
            var customer = HttpContext.GetCustomer();

            var safeReturnUrl = Url.MakeSafeReturnUrl(returnUrl, Url.Action(ActionNames.Index));

            ViewBag.MetaTitle = "Your Address Book";

            var address = ControllerHelper.GetCustomerAddress(addressId, customer);

            AddressTypes addressTypeValue;

            if (!Enum.TryParse(addressType, out addressTypeValue))
            {
                addressTypeValue = AddressTypes.Unknown;
            }

            return(View(new AddressDetailViewModel(
                            address: address,
                            residenceTypeOptions: SelectListBuilder.BuildResidenceTypeSelectList(address.ResidenceType),
                            stateOptions: SelectListBuilder.BuildStateSelectList(address.Country, address.State),
                            countryOptions: SelectListBuilder.BuildCountrySelectList(address.Country),
                            showCompanyField: ShowCompanyField,
                            showNickName: ShowNickName,
                            showResidenceTypeField: addressTypeValue == AddressTypes.Shipping || !AllowDifferentShipTo,
                            returnUrl: safeReturnUrl,
                            header: AddressHeaderProvider.GetHeaderText(address.Id, addressTypeValue),
                            showPostalCodeLookup: PostalCodeLookupProvider.IsEnabled(string.IsNullOrEmpty(address.Country)
                                        ? AppLogic.GetCountryNameFromTwoLetterISOCode("US")
                                        : address.Country),
                            addressType: addressTypeValue,
                            makePrimary: makePrimary)));
        }
        public ActionResult Index()
        {
            var customer = HttpContext.GetCustomer();

            var shippingAddress = AddressViewModelConverter.ConvertToAddressViewModel(
                customer.PrimaryShippingAddress,
                customer);

            return(View(new AddressDetailViewModel(
                            address: shippingAddress,
                            residenceTypeOptions: AddressSelectListBuilder.BuildResidenceTypeSelectList(shippingAddress.ResidenceType.ToString()),
                            stateOptions: AddressSelectListBuilder.BuildStateSelectList(shippingAddress.Country, shippingAddress.State),
                            countryOptions: AddressSelectListBuilder.BuildCountrySelectList(shippingAddress.Country),
                            showCompanyField: ShowCompanyField,
                            showNickName: ShowNickName,
                            showResidenceTypeField: true,
                            showPostalCodeLookup: PostalCodeLookupProvider.IsEnabled(shippingAddress.Country),
                            returnUrl: string.Empty,
                            header: AddressHeaderProvider.GetHeaderText(shippingAddress.Id, AddressTypes.Shipping))));
        }