/** * This method will copy the shipping address of the first fulfillment group on the order * to the billing address on the BillingInfoForm that is passed in. */ protected void copyShippingAddressToBillingAddress(Order order, BillingInfoForm billingInfoForm) { if (order.getFulfillmentGroups().get(0) != null) { Address shipping = order.getFulfillmentGroups().get(0).getAddress(); if (shipping != null) { Address billing = addressService.copyAddress(shipping) ; billingInfoForm.setAddress(billing); } } }
@Override public void populateBillingInfo(PaymentResponseDTO responseDTO, OrderPayment payment, Address tempBillingAddress, boolean isUseBillingAddressFromGateway) { Address billingAddress = tempBillingAddress; if (responseDTO.getBillTo() != null && responseDTO.getBillTo().addressPopulated() && isUseBillingAddressFromGateway) { billingAddress = addressService.create(); AddressDTO<PaymentResponseDTO> billToDTO = responseDTO.getBillTo(); populateAddressInfo(billToDTO, billingAddress); } payment.setBillingAddress(billingAddress); }
protected void preProcessBillingAddress(PaymentInfoForm paymentForm, Order cart) { if (paymentForm.getShouldUseShippingAddress()){ copyShippingAddressToBillingAddress(cart, paymentForm); } Boolean useCustomerPayment = paymentForm.getShouldUseCustomerPayment(); if (useCustomerPayment && paymentForm.getCustomerPaymentId() != null) { copyCustomerPaymentAddressToBillingAddress(paymentForm); } addressService.populateAddressISOCountrySub(paymentForm.getAddress()); }
Address address = customerPayment.getBillingAddress(); if (address != null) { billingForm.setAddress(addressService.copyAddress(address)); addressService.populateAddressISOCountrySub(billingForm.getAddress()); billingInfoFormValidator.validate(billingForm, result); if (result.hasErrors()) { p.setBillingAddress(billingForm.getAddress()); } else { Address updatedAddress = addressService.copyAddress(p.getBillingAddress(), billingForm.getAddress()); p.setBillingAddress(updatedAddress);
public String addCustomerAddress(HttpServletRequest request, Model model, CustomerAddressForm form, BindingResult result, RedirectAttributes redirectAttributes) throws ServiceException { addressService.populateAddressISOCountrySub(form.getAddress()); customerAddressValidator.validate(form, result); if (result.hasErrors()) { return getCustomerAddressesView(); } removeUnusedPhones(form); Address address = addressService.saveAddress(form.getAddress()); CustomerAddress customerAddress = customerAddressService.create(); customerAddress.setAddress(address); customerAddress.setAddressName(form.getAddressName()); customerAddress.setCustomer(CustomerState.getCustomer()); customerAddress = customerAddressService.saveCustomerAddress(customerAddress); if (form.getAddress().isDefault()) { customerAddressService.makeCustomerAddressDefault(customerAddress.getId(), customerAddress.getCustomer().getId()); } form.setCustomerAddressId(customerAddress.getId()); if (!isAjaxRequest(request)) { List<CustomerAddress> addresses = customerAddressService.readActiveCustomerAddressesByCustomerId(CustomerState.getCustomer().getId()); model.addAttribute("addresses", addresses); } redirectAttributes.addFlashAttribute("successMessage", getAddressAddedMessage()); return getCustomerAddressesRedirect(); }
@Override public List<OrderMultishipOption> getOrderMultishipOptionsFromDTOs(Order order, List<OrderMultishipOptionDTO> optionDtos) { List<OrderMultishipOption> orderMultishipOptions = new ArrayList<OrderMultishipOption>(); for (OrderMultishipOptionDTO optionDto : optionDtos) { OrderMultishipOption option = new OrderMultishipOptionImpl(); if (optionDto.getAddressId() != null) { option.setAddress(addressService.readAddressById(optionDto.getAddressId())); } if (optionDto.getFulfillmentOptionId() != null) { option.setFulfillmentOption(fulfillmentOptionService.readFulfillmentOptionById(optionDto.getFulfillmentOptionId())); } option.setId(optionDto.getId()); option.setOrder(order); option.setOrderItem(orderItemService.readOrderItemById(optionDto.getOrderItemId())); orderMultishipOptions.add(option); } return orderMultishipOptions; }
addressService.populateAddressISOCountrySub(shippingForm.getAddress()); shippingInfoFormValidator.validate(shippingForm, result); if (result.hasErrors()) { Address address = addressService.saveAddress(shippingForm.getAddress()); CustomerAddress customerAddress = customerAddressService.create(); customerAddress.setAddress(address);
option.setAddress(addressService.readAddressById(dto.getAddressId())); } else { option.setAddress(null);
protected void copyCustomerPaymentAddressToBillingAddress(PaymentInfoForm paymentForm) { CustomerPayment customerPayment = customerPaymentService.readCustomerPaymentById(paymentForm.getCustomerPaymentId()); if (customerPayment != null) { Address address = customerPayment.getBillingAddress(); if (address != null) { paymentForm.setAddress(addressService.copyAddress(address)); } } }
@Override public void populateShippingInfo(PaymentResponseDTO responseDTO, Order order) { FulfillmentGroup shippableFulfillmentGroup = fulfillmentGroupService.getFirstShippableFulfillmentGroup(order); if (responseDTO.getShipTo() != null && responseDTO.getShipTo().addressPopulated() && shippableFulfillmentGroup != null) { Address shippingAddress = addressService.create(); AddressDTO<PaymentResponseDTO> shipToDTO = responseDTO.getShipTo(); populateAddressInfo(shipToDTO, shippingAddress); shippableFulfillmentGroup = fulfillmentGroupService.findFulfillmentGroupById(shippableFulfillmentGroup.getId()); if (shippableFulfillmentGroup != null) { shippableFulfillmentGroup.setAddress(shippingAddress); fulfillmentGroupService.save(shippableFulfillmentGroup); } } }
/** * Processes the requested add address from the multiship process. * This method will create a CustomerAddress based on the requested Address * and associate it with the current Customer in session. * * @param request * @param response * @param model * @param addressForm * @return the return path to the multiship page * @throws ServiceException */ public String saveMultishipAddAddress(HttpServletRequest request, HttpServletResponse response, Model model, ShippingInfoForm addressForm, BindingResult result) throws ServiceException { addressService.populateAddressISOCountrySub(addressForm.getAddress()); multishipAddAddressFormValidator.validate(addressForm, result); if (result.hasErrors()) { return showMultishipAddAddress(request, response, model); } removeUnusedPhones(addressForm); CustomerAddress customerAddress = customerAddressService.create(); customerAddress.setAddressName(addressForm.getAddressName()); customerAddress.setAddress(addressForm.getAddress()); customerAddress.setCustomer(CustomerState.getCustomer()); customerAddressService.saveCustomerAddress(customerAddress); //append current time to redirect to fix a problem with ajax caching in IE return getMultishipAddAddressSuccessView() + "?_=" + System.currentTimeMillis(); }
/** * This method will copy the shipping address of the first fulfillment group on the order * to the billing address on the PaymentInfoForm that is passed in. */ protected void copyShippingAddressToBillingAddress(Order order, PaymentInfoForm paymentInfoForm) { if (fulfillmentGroupService.getFirstShippableFulfillmentGroup(order) != null) { Address shipping = fulfillmentGroupService.getFirstShippableFulfillmentGroup(order).getAddress(); if (shipping != null) { Address billing = addressService.copyAddress(shipping) ; paymentInfoForm.setAddress(billing); } } }
Address billingAddress = addressService.create(); dtoToEntityService.populateAddressInfo(responseDTO.getBillTo(), billingAddress); customerPayment.setBillingAddress(billingAddress);
public String addCustomerPayment(HttpServletRequest request, Model model, PaymentInfoForm paymentInfoForm, BindingResult bindingResult) { Customer customer = CustomerState.getCustomer(); addressService.populateAddressISOCountrySub(paymentInfoForm.getAddress()); paymentInfoFormValidator.validate(paymentInfoForm, bindingResult); if (!bindingResult.hasErrors()) { if ((paymentInfoForm.getAddress().getPhonePrimary() != null) && (StringUtils.isEmpty(paymentInfoForm.getAddress().getPhonePrimary().getPhoneNumber()))) { paymentInfoForm.getAddress().setPhonePrimary(null); } if ((paymentInfoForm.getAddress().getPhoneSecondary() != null) && (StringUtils.isEmpty(paymentInfoForm.getAddress().getPhoneSecondary().getPhoneNumber()))) { paymentInfoForm.getAddress().setPhoneSecondary(null); } if ((paymentInfoForm.getAddress().getPhoneFax() != null) && (StringUtils.isEmpty(paymentInfoForm.getAddress().getPhoneFax().getPhoneNumber()))) { paymentInfoForm.getAddress().setPhoneFax(null); } savedPaymentService.addSavedPayment(customer, paymentInfoForm); return getCustomerPaymentRedirect(); } return getCustomerPaymentView(); }
/** * This method will copy the billing address of any CREDIT CARD order payment on the order * to the shipping address on the ShippingInfoForm that is passed in. */ protected void copyBillingAddressToShippingAddress(Order order, ShippingInfoForm shippingInfoForm) { if (order.getPayments() != null) { for (OrderPayment payment : order.getPayments()) { if (payment.isActive() && PaymentType.CREDIT_CARD.equals(payment.getType())) { Address billing = payment.getBillingAddress(); if (billing != null) { Address shipping = addressService.copyAddress(billing); shippingInfoForm.setAddress(shipping); } } } } }
@Override public Address createEntity(final AddressDto addressDto) { Address address = addressService.create(); address.setCountry(null); return updateEntity(address, addressDto); }
addressService.populateAddressISOCountrySub(address);
OrderPayment orderPayment = create(); orderPayment.setOrder(order); orderPayment.setBillingAddress(addressService.copyAddress(customerPayment.getBillingAddress()));
@Override @Transactional(value = TransactionUtils.DEFAULT_TRANSACTION_MANAGER) public CustomerPayment createCustomerPaymentFromPaymentTransaction(PaymentTransaction transaction) { CustomerPayment customerPayment = customerPaymentService.create(); customerPayment.setCustomer(transaction.getOrderPayment().getOrder().getCustomer()); customerPayment.setBillingAddress(addressService.copyAddress(transaction.getOrderPayment().getBillingAddress())); customerPayment.setPaymentType(transaction.getOrderPayment().getType()); customerPayment.setPaymentGatewayType(transaction.getOrderPayment().getGatewayType()); customerPayment.setAdditionalFields(transaction.getAdditionalFields()); populateCustomerPaymentToken(customerPayment, transaction); return customerPaymentService.saveCustomerPayment(customerPayment); }