コード例 #1
0
  @RequestMapping(value = "/billingaddressform", method = RequestMethod.GET)
  public String getCountryAddressForm(
      @RequestParam("countryIsoCode") final String countryIsoCode,
      @RequestParam("useDeliveryAddress") final boolean useDeliveryAddress,
      final Model model) {
    model.addAttribute("supportedCountries", getCountries());
    model.addAttribute("regions", getI18NFacade().getRegionsForCountryIso(countryIsoCode));
    model.addAttribute("country", countryIsoCode);

    final SopPaymentDetailsForm sopPaymentDetailsForm = new SopPaymentDetailsForm();
    model.addAttribute("sopPaymentDetailsForm", sopPaymentDetailsForm);
    if (useDeliveryAddress) {
      final AddressData deliveryAddress =
          getCheckoutFacade().getCheckoutCart().getDeliveryAddress();

      if (deliveryAddress.getRegion() != null
          && !StringUtils.isEmpty(deliveryAddress.getRegion().getIsocode())) {
        sopPaymentDetailsForm.setBillTo_state(deliveryAddress.getRegion().getIsocodeShort());
      }

      sopPaymentDetailsForm.setBillTo_titleCode(deliveryAddress.getTitleCode());
      sopPaymentDetailsForm.setBillTo_firstName(deliveryAddress.getFirstName());
      sopPaymentDetailsForm.setBillTo_lastName(deliveryAddress.getLastName());
      sopPaymentDetailsForm.setBillTo_street1(deliveryAddress.getLine1());
      sopPaymentDetailsForm.setBillTo_street2(deliveryAddress.getLine2());
      sopPaymentDetailsForm.setBillTo_city(deliveryAddress.getTown());
      sopPaymentDetailsForm.setBillTo_postalCode(deliveryAddress.getPostalCode());
      sopPaymentDetailsForm.setBillTo_country(deliveryAddress.getCountry().getIsocode());
      sopPaymentDetailsForm.setBillTo_phoneNumber(deliveryAddress.getPhone());
    }
    return ControllerConstants.Views.Fragments.Checkout.BillingAddressForm;
  }
コード例 #2
0
  @RequestMapping(
      value = "/summary/getPaymentDetailsForm.json",
      method = {RequestMethod.GET, RequestMethod.POST})
  @RequireHardLogIn
  public String getPaymentDetailsForm(
      final Model model,
      @RequestParam(value = "paymentId") final String paymentId,
      @RequestParam(value = "createUpdateStatus") final String createUpdateStatus) {
    CCPaymentInfoData paymentInfoData = null;
    if (StringUtils.isNotBlank(paymentId)) {
      paymentInfoData = getUserFacade().getCCPaymentInfoForCode(paymentId);
    }

    final PaymentDetailsForm paymentDetailsForm = new PaymentDetailsForm();

    if (paymentInfoData != null) {
      paymentDetailsForm.setPaymentId(paymentInfoData.getId());
      paymentDetailsForm.setCardTypeCode(paymentInfoData.getCardType());
      paymentDetailsForm.setNameOnCard(paymentInfoData.getAccountHolderName());
      paymentDetailsForm.setCardNumber(paymentInfoData.getCardNumber());
      paymentDetailsForm.setStartMonth(paymentInfoData.getStartMonth());
      paymentDetailsForm.setStartYear(paymentInfoData.getStartYear());
      paymentDetailsForm.setExpiryMonth(paymentInfoData.getExpiryMonth());
      paymentDetailsForm.setExpiryYear(paymentInfoData.getExpiryYear());
      paymentDetailsForm.setSaveInAccount(Boolean.valueOf(paymentInfoData.isSaved()));
      paymentDetailsForm.setIssueNumber(paymentInfoData.getIssueNumber());

      final AddressForm addressForm = new AddressForm();
      final AddressData addressData = paymentInfoData.getBillingAddress();
      if (addressData != null) {
        addressForm.setAddressId(addressData.getId());
        addressForm.setTitleCode(addressData.getTitleCode());
        addressForm.setFirstName(addressData.getFirstName());
        addressForm.setLastName(addressData.getLastName());
        addressForm.setLine1(addressData.getLine1());
        addressForm.setLine2(addressData.getLine2());
        addressForm.setTownCity(addressData.getTown());
        addressForm.setPostcode(addressData.getPostalCode());
        addressForm.setCountryIso(addressData.getCountry().getIsocode());
        addressForm.setShippingAddress(Boolean.valueOf(addressData.isShippingAddress()));
        addressForm.setBillingAddress(Boolean.valueOf(addressData.isBillingAddress()));
      }

      paymentDetailsForm.setBillingAddress(addressForm);
    }

    model.addAttribute("edit", Boolean.valueOf(paymentInfoData != null));
    model.addAttribute("paymentInfoData", getUserFacade().getCCPaymentInfos(true));
    model.addAttribute(paymentDetailsForm);
    model.addAttribute("createUpdateStatus", createUpdateStatus);
    return ControllerConstants.Views.Fragments.SingleStepCheckout.PaymentDetailsFormPopup;
  }
 /**
  * Gets the customer bill to data.
  *
  * @param addressData the address data
  * @return the customer bill to data
  */
 private CustomerBillToData getCustomerBillToData(final AddressData addressData) {
   final CustomerBillToData billToData = new CustomerBillToData();
   billToData.setBillToCity(addressData.getTown());
   billToData.setBillToFirstName(addressData.getFirstName());
   billToData.setBillToLastName(addressData.getLastName());
   billToData.setBillToStreet1(addressData.getLine1());
   billToData.setBillToStreet2(addressData.getLine2());
   final RegionData regionData = addressData.getRegion();
   String regionIsoCode = "MH";
   if (regionData != null) {
     regionIsoCode = regionData.getIsocode();
   }
   billToData.setBillToState(regionIsoCode);
   billToData.setBillToCountry(addressData.getCountry().getIsocode());
   billToData.setBillToPostalCode(addressData.getPostalCode());
   return billToData;
 }
コード例 #4
0
  @RequestMapping(
      value = "/summary/getDeliveryAddressForm.json",
      method = {RequestMethod.GET, RequestMethod.POST})
  @RequireHardLogIn
  public String getDeliveryAddressForm(
      final Model model,
      @RequestParam(value = "addressId") final String addressId,
      @RequestParam(value = "createUpdateStatus") final String createUpdateStatus) {
    AddressData addressData = null;
    if (addressId != null && !addressId.isEmpty()) {
      addressData = getCheckoutFacade().getDeliveryAddressForCode(addressId);
    }

    final AddressForm addressForm = new AddressForm();

    final boolean hasAddressData = addressData != null;
    if (hasAddressData) {
      addressForm.setAddressId(addressData.getId());
      addressForm.setTitleCode(addressData.getTitleCode());
      addressForm.setFirstName(addressData.getFirstName());
      addressForm.setLastName(addressData.getLastName());
      addressForm.setLine1(addressData.getLine1());
      addressForm.setLine2(addressData.getLine2());
      addressForm.setTownCity(addressData.getTown());
      addressForm.setPostcode(addressData.getPostalCode());
      addressForm.setCountryIso(addressData.getCountry().getIsocode());
      addressForm.setShippingAddress(Boolean.valueOf(addressData.isShippingAddress()));
      addressForm.setBillingAddress(Boolean.valueOf(addressData.isBillingAddress()));
    }

    model.addAttribute("edit", Boolean.valueOf(hasAddressData));
    model.addAttribute("noAddresses", Boolean.valueOf(getUserFacade().isAddressBookEmpty()));

    model.addAttribute(addressForm);
    model.addAttribute("createUpdateStatus", createUpdateStatus);

    // Work out if the address form should be displayed based on the payment type
    final B2BPaymentTypeData paymentType = getCheckoutFacade().getCheckoutCart().getPaymentType();
    final boolean payOnAccount =
        paymentType != null && CheckoutPaymentType.ACCOUNT.getCode().equals(paymentType.getCode());
    model.addAttribute("showAddressForm", Boolean.valueOf(!payOnAccount));

    return ControllerConstants.Views.Fragments.SingleStepCheckout.DeliveryAddressFormPopup;
  }
コード例 #5
0
  @RequestMapping(value = "/addressform", method = RequestMethod.GET)
  public String getCountryAddressForm(
      @RequestParam("addressCode") final String addressCode,
      @RequestParam("countryIsoCode") final String countryIsoCode,
      final Model model) {
    model.addAttribute("supportedCountries", getCountries());
    model.addAttribute("regions", getI18NFacade().getRegionsForCountryIso(countryIsoCode));
    model.addAttribute("country", countryIsoCode);

    final AddressForm addressForm = new AddressForm();
    model.addAttribute("addressForm", addressForm);
    for (final AddressData addressData : userFacade.getAddressBook()) {
      if (addressData.getId() != null
          && addressData.getId().equals(addressCode)
          && countryIsoCode.equals(addressData.getCountry().getIsocode())) {
        model.addAttribute("addressData", addressData);
        addressForm.setAddressId(addressData.getId());
        addressForm.setTitleCode(addressData.getTitleCode());
        addressForm.setFirstName(addressData.getFirstName());
        addressForm.setLastName(addressData.getLastName());
        addressForm.setLine1(addressData.getLine1());
        addressForm.setLine2(addressData.getLine2());
        addressForm.setTownCity(addressData.getTown());
        addressForm.setPostcode(addressData.getPostalCode());
        addressForm.setCountryIso(addressData.getCountry().getIsocode());

        if (addressData.getRegion() != null
            && !StringUtils.isEmpty(addressData.getRegion().getIsocode())) {
          addressForm.setRegionIso(addressData.getRegion().getIsocode());
        }

        break;
      }
    }
    return ControllerConstants.Views.Fragments.Account.CountryAddressForm;
  }
コード例 #6
0
  @RequestMapping(
      value = "/edit-address/" + ADDRESS_CODE_PATH_VARIABLE_PATTERN,
      method = RequestMethod.GET)
  @RequireHardLogIn
  public String editAddress(
      @PathVariable("addressCode") final String addressCode, final Model model)
      throws CMSItemNotFoundException {
    final AddressForm addressForm = new AddressForm();
    model.addAttribute("countryData", checkoutFacade.getDeliveryCountries());
    model.addAttribute("titleData", userFacade.getTitles());
    model.addAttribute("addressForm", addressForm);
    model.addAttribute("addressBookEmpty", Boolean.valueOf(userFacade.isAddressBookEmpty()));

    for (final AddressData addressData : userFacade.getAddressBook()) {
      if (addressData.getId() != null && addressData.getId().equals(addressCode)) {
        model.addAttribute(
            "regions",
            getI18NFacade().getRegionsForCountryIso(addressData.getCountry().getIsocode()));
        model.addAttribute("country", addressData.getCountry().getIsocode());
        model.addAttribute("addressData", addressData);
        addressForm.setAddressId(addressData.getId());
        addressForm.setTitleCode(addressData.getTitleCode());
        addressForm.setFirstName(addressData.getFirstName());
        addressForm.setLastName(addressData.getLastName());
        addressForm.setLine1(addressData.getLine1());
        addressForm.setLine2(addressData.getLine2());
        addressForm.setTownCity(addressData.getTown());
        addressForm.setPostcode(addressData.getPostalCode());
        addressForm.setCountryIso(addressData.getCountry().getIsocode());
        if (addressData.getRegion() != null
            && !StringUtils.isEmpty(addressData.getRegion().getIsocode())) {
          addressForm.setRegionIso(addressData.getRegion().getIsocode());
        }

        if (isDefaultAddress(addressData.getId())) {
          addressForm.setDefaultAddress(Boolean.TRUE);
          model.addAttribute("isDefaultAddress", Boolean.TRUE);
        } else {
          addressForm.setDefaultAddress(Boolean.FALSE);
          model.addAttribute("isDefaultAddress", Boolean.FALSE);
        }
        break;
      }
    }

    storeCmsPageInModel(model, getContentPageForLabelOrId(ADD_EDIT_ADDRESS_CMS_PAGE));
    setUpMetaDataForContentPage(model, getContentPageForLabelOrId(ADD_EDIT_ADDRESS_CMS_PAGE));

    final List<Breadcrumb> breadcrumbs = accountBreadcrumbBuilder.getBreadcrumbs(null);
    breadcrumbs.add(
        new Breadcrumb(
            "/my-account/address-book",
            getMessageSource()
                .getMessage("text.account.addressBook", null, getI18nService().getCurrentLocale()),
            null));
    breadcrumbs.add(
        new Breadcrumb(
            "#",
            getMessageSource()
                .getMessage(
                    "text.account.addressBook.addEditAddress",
                    null,
                    getI18nService().getCurrentLocale()),
            null));
    model.addAttribute("breadcrumbs", breadcrumbs);
    model.addAttribute("metaRobots", "no-index,no-follow");
    model.addAttribute("edit", Boolean.TRUE);
    return ControllerConstants.Views.Pages.Account.AccountEditAddressPage;
  }