Package org.broadleafcommerce.profile.core.domain

Examples of org.broadleafcommerce.profile.core.domain.Address


    }

    protected void populateBillTo(Order order, PaymentRequestDTO requestDTO) {
        for (OrderPayment payment : order.getPayments()) {
            if (payment.isActive() && PaymentType.CREDIT_CARD.equals(payment.getType())) {
                Address billAddress = payment.getBillingAddress();
                if (billAddress != null) {
                    String stateAbbr = null;
                    String countryAbbr = null;
                    String phone = null;

                    if (billAddress.getState() != null) {
                        stateAbbr = billAddress.getState().getAbbreviation();
                    }

                    if (billAddress.getCountry() != null) {
                        countryAbbr = billAddress.getCountry().getAbbreviation();
                    }

                    if (billAddress.getPhonePrimary() != null) {
                        phone = billAddress.getPhonePrimary().getPhoneNumber();
                    }

                    requestDTO.billTo()
                            .addressFirstName(billAddress.getFirstName())
                            .addressLastName(billAddress.getLastName())
                            .addressCompanyName(billAddress.getCompanyName())
                            .addressLine1(billAddress.getAddressLine1())
                            .addressLine2(billAddress.getAddressLine2())
                            .addressCityLocality(billAddress.getCity())
                            .addressStateRegion(stateAbbr)
                            .addressPostalCode(billAddress.getPostalCode())
                            .addressCountryCode(countryAbbr)
                            .addressPhone(phone)
                            .addressEmail(billAddress.getEmailAddress());
                }
            }
        }
    }
View Full Code Here


    }

    protected void populateBillingAddressOnRequest(PaymentRequestDTO requestDTO, OrderPayment payment) {

        if (payment != null && payment.getBillingAddress() != null) {
            Address address = payment.getBillingAddress();
            String addressLine2 = address.getAddressLine2();
            if (StringUtils.isNotBlank(address.getAddressLine3())) {
                addressLine2 = addressLine2 + " " + address.getAddressLine3();
            }

            String state = address.getState() != null ? address.getState().getAbbreviation() : null;
            String country = address.getCountry() != null ? address.getCountry().getAbbreviation() : null;
            String phone = address.getPhonePrimary() != null ? address.getPhonePrimary().getPhoneNumber() : null;

            requestDTO.billTo()
                    .addressFirstName(address.getFirstName())
                    .addressLastName(address.getLastName())
                    .addressLine1(address.getAddressLine1())
                    .addressLine2(addressLine2)
                    .addressCityLocality(address.getCity())
                    .addressStateRegion(state)
                    .addressPostalCode(address.getPostalCode())
                    .addressCountryCode(country)
                    .addressEmail(address.getEmailAddress())
                    .addressPhone(phone)
                    .addressCompanyName(address.getCompanyName())
                    .done();
        }

    }
View Full Code Here

        payment.setAmount(responseDTO.getAmount());

        // If this gateway does not support multiple payments then mark all of the existing payments
        // as invalid before adding the new one
        List<OrderPayment> paymentsToInvalidate = new ArrayList<OrderPayment>();
        Address tempBillingAddress = null;
        if (!config.handlesMultiplePayments()) {
            PaymentGatewayType gateway = config.getGatewayType();
            for (OrderPayment p : order.getPayments()) {
                // A Payment on the order will be invalidated if:
                // - It's a temporary order payment: There may be a temporary Order Payment on the Order (e.g. to save the billing address)
View Full Code Here

       
        return payment.getId();
    }

    protected void populateBillingInfo(PaymentResponseDTO responseDTO, OrderPayment payment, Address tempBillingAddress) {
        Address billingAddress = tempBillingAddress;
        if (responseDTO.getBillTo() != null && isUseBillingAddressFromGateway()) {
            billingAddress = addressService.create();
            AddressDTO<PaymentResponseDTO> billToDTO = responseDTO.getBillTo();
            billingAddress.setFirstName(billToDTO.getAddressFirstName());
            billingAddress.setLastName(billToDTO.getAddressLastName());
            billingAddress.setAddressLine1(billToDTO.getAddressLine1());
            billingAddress.setAddressLine2(billToDTO.getAddressLine2());
            billingAddress.setCity(billToDTO.getAddressCityLocality());

            //TODO: what happens if State and Country cannot be found?
            State state = null;
            if(billToDTO.getAddressStateRegion() != null) {
                state = stateService.findStateByAbbreviation(billToDTO.getAddressStateRegion());
            }
            if (state == null) {
                LOG.warn("The given state from the response: " + billToDTO.getAddressStateRegion() + " could not be found"
                        + " as a state abbreviation in BLC_STATE");
            }
            billingAddress.setState(state);

            billingAddress.setPostalCode(billToDTO.getAddressPostalCode());

            Country country = null;
            if (billToDTO.getAddressCountryCode() != null) {
                country = countryService.findCountryByAbbreviation(billToDTO.getAddressCountryCode());
            }
            if (country == null) {
                LOG.warn("The given country from the response: " + billToDTO.getAddressCountryCode() + " could not be found"
                        + " as a country abbreviation in BLC_COUNTRY");
            }
            billingAddress.setCountry(country);

            if (billToDTO.getAddressPhone() != null) {
                Phone billingPhone = phoneService.create();
                billingPhone.setPhoneNumber(billToDTO.getAddressPhone());
                billingAddress.setPhonePrimary(billingPhone);
            }
        }

        payment.setBillingAddress(billingAddress);
View Full Code Here

    }

    protected void populateShippingInfo(PaymentResponseDTO responseDTO, Order order) {
        FulfillmentGroup shippableFulfillmentGroup = fulfillmentGroupService.getFirstShippableFulfillmentGroup(order);
        Address shippingAddress = null;
        if (responseDTO.getShipTo() != null && shippableFulfillmentGroup != null) {
            shippingAddress = addressService.create();
            AddressDTO<PaymentResponseDTO> shipToDTO = responseDTO.getShipTo();
            shippingAddress.setFirstName(shipToDTO.getAddressFirstName());
            shippingAddress.setLastName(shipToDTO.getAddressLastName());
            shippingAddress.setAddressLine1(shipToDTO.getAddressLine1());
            shippingAddress.setAddressLine2(shipToDTO.getAddressLine2());
            shippingAddress.setCity(shipToDTO.getAddressCityLocality());
           
            State state = null;
            if(shipToDTO.getAddressStateRegion() != null) {
                state = stateService.findStateByAbbreviation(shipToDTO.getAddressStateRegion());
            }
            if (state == null) {
                LOG.warn("The given state from the response: " + shipToDTO.getAddressStateRegion() + " could not be found"
                        + " as a state abbreviation in BLC_STATE");
            }
            shippingAddress.setState(state);

            shippingAddress.setPostalCode(shipToDTO.getAddressPostalCode());

            Country country = null;
            if (shipToDTO.getAddressCountryCode() != null) {
                country = countryService.findCountryByAbbreviation(shipToDTO.getAddressCountryCode());
            }
            if (country == null) {
                LOG.warn("The given country from the response: " + shipToDTO.getAddressCountryCode() + " could not be found"
                        + " as a country abbreviation in BLC_COUNTRY");
            }
            shippingAddress.setCountry(country);

            if (shipToDTO.getAddressPhone() != null) {
                Phone shippingPhone = phoneService.create();
                shippingPhone.setPhoneNumber(shipToDTO.getAddressPhone());
                shippingAddress.setPhonePrimary(shippingPhone);
            }

            shippableFulfillmentGroup = fulfillmentGroupService.findFulfillmentGroupById(shippableFulfillmentGroup.getId());
            if (shippableFulfillmentGroup != null) {
                shippableFulfillmentGroup.setAddress(shippingAddress);
View Full Code Here

            fulfillmentGroup.setShippingPrice(BroadleafCurrencyUtils.getMoney(BigDecimal.ZERO, fulfillmentGroup.getOrder().getCurrency()));
            fulfillmentGroup.setSaleShippingPrice(BroadleafCurrencyUtils.getMoney(BigDecimal.ZERO, fulfillmentGroup.getOrder().getCurrency()));
            fulfillmentGroup.setRetailShippingPrice(BroadleafCurrencyUtils.getMoney(BigDecimal.ZERO, fulfillmentGroup.getOrder().getCurrency()));
            return;
        }
        Address address = fulfillmentGroup.getAddress();
        String state = (address != null && address.getState() != null) ? address.getState().getAbbreviation() : null;
        BigDecimal retailTotal = new BigDecimal(0);
        String feeType = feeTypeMapping.get(fulfillmentGroup.getMethod());
        String feeSubType = ((feeSubTypeMapping.get(state) == null) ? feeSubTypeMapping.get("ALL") : feeSubTypeMapping.get(state));

        for (FulfillmentGroupItem fulfillmentGroupItem : fulfillmentGroup.getFulfillmentGroupItems()) {
View Full Code Here

        state.setName("Texas");
        state.setCountry(country);

        state = stateService.save(state);
       
        Address address = new AddressImpl();
        address.setAddressLine1("123 Test Rd");
        address.setCity("Dallas");
        address.setFirstName("Jeff");
        address.setLastName("Fischer");
        address.setPostalCode("75240");
        address.setPrimaryPhone("972-978-9067");

        address.setState(state);
        address.setCountry(country);
        group1.setAddress(address);
        group1.setOrder(order);

        // setup group2 - truck
        group2.setMethod("truck");
View Full Code Here

     */
    public Customer createCustomerWithAddresses() {
        createCountry();
        createState();
        CustomerAddress ca1 = new CustomerAddressImpl();
        Address address1 = new AddressImpl();
        address1.setAddressLine1("1234 Merit Drive");
        address1.setCity("Bozeman");
        address1.setPostalCode("75251");
        ca1.setAddress(address1);
        ca1.setAddressName("address1");
        CustomerAddress caResult = createCustomerWithAddress(ca1);
        assert caResult != null;
        assert caResult.getCustomer() != null;
        Customer customer = caResult.getCustomer();

        CustomerAddress ca2 = new CustomerAddressImpl();
        Address address2 = new AddressImpl();
        address2.setAddressLine1("12 Testing Drive");
        address2.setCity("Portland");
        address2.setPostalCode("75251");
        ca2.setAddress(address2);
        ca2.setAddressName("address2");
        ca2.setCustomer(customer);
        CustomerAddress addResult = saveCustomerAddress(ca2);
        assert addResult != null;
View Full Code Here

    public void testCheckout() throws Exception {
        String userName = "customer1";
        Customer customer = customerService.readCustomerByUsername(userName);
        Order order = orderService.createNewCartForCustomer(customer);

        Address address = buildAddress();
        FulfillmentGroup group = buildFulfillmentGroup(order, address);
        addSampleItemToOrder(order, group);
        order.setTotalShipping(new Money(0D));
        addPaymentToOrder(order, address);
View Full Code Here

        group.setService(ShippingServiceType.BANDED_SHIPPING.getType());
        return group;
    }

    private Address buildAddress() {
        Address address = new AddressImpl();
        address.setAddressLine1("123 Test Rd");
        address.setCity("Dallas");
        address.setFirstName("Jeff");
        address.setLastName("Fischer");
        address.setPostalCode("75240");
        address.setPrimaryPhone("972-978-9067");
        State state = new StateImpl();
        state.setAbbreviation("ALL");
        state.setName("ALL");
        address.setState(state);
        Country country = new CountryImpl();
        country.setAbbreviation("US");
        country.setName("United States");
        state.setCountry(country);
        address.setCountry(country);
        return address;
    }
View Full Code Here

TOP

Related Classes of org.broadleafcommerce.profile.core.domain.Address

Copyright © 2018 www.massapicom. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.