コード例 #1
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;
  }
コード例 #2
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;
  }