use of org.broadleafcommerce.profile.core.domain.Customer in project BroadleafCommerce by BroadleafCommerce.
the class BroadleafUpdateAccountController method viewUpdateAccount.
public String viewUpdateAccount(HttpServletRequest request, Model model, UpdateAccountForm form) {
Customer customer = CustomerState.getCustomer();
form.setEmailAddress(customer.getEmailAddress());
form.setFirstName(customer.getFirstName());
form.setLastName(customer.getLastName());
return getUpdateAccountView();
}
use of org.broadleafcommerce.profile.core.domain.Customer in project BroadleafCommerce by BroadleafCommerce.
the class BroadleafOrderConfirmationController method displayOrderConfirmationByOrderId.
public String displayOrderConfirmationByOrderId(Long orderId, Model model, HttpServletRequest request, HttpServletResponse response) {
Customer customer = CustomerState.getCustomer();
if (customer != null) {
Order order = orderService.findOrderById(orderId);
if (order != null && customer.equals(order.getCustomer())) {
extensionManager.getProxy().processAdditionalConfirmationActions(order);
model.addAttribute("order", order);
return getOrderConfirmationView();
}
}
return "redirect:/";
}
use of org.broadleafcommerce.profile.core.domain.Customer in project BroadleafCommerce by BroadleafCommerce.
the class BroadleafOrderConfirmationController method displayOrderConfirmationByOrderNumber.
public String displayOrderConfirmationByOrderNumber(String orderNumber, Model model, HttpServletRequest request, HttpServletResponse response) {
Customer customer = CustomerState.getCustomer();
if (customer != null) {
Order order = orderService.findOrderByOrderNumber(orderNumber);
if (order != null && customer.equals(order.getCustomer())) {
extensionManager.getProxy().processAdditionalConfirmationActions(order);
model.addAttribute("order", order);
return getOrderConfirmationView();
}
}
return "redirect:/";
}
use of org.broadleafcommerce.profile.core.domain.Customer in project BroadleafCommerce by BroadleafCommerce.
the class BroadleafPaymentInfoController method savePaymentInfo.
/**
* Processes the request to save an {@link OrderPayment} based on an existing or new {@link CustomerPayment}.
*
* Note: this default Broadleaf implementation will create a CustomerPayment if one does not exist,
* and copy it's data to a new OrderPayment.
*
* @param request
* @param response
* @param model
* @param paymentForm
* @return the return path
* @throws ServiceException
*/
public String savePaymentInfo(HttpServletRequest request, HttpServletResponse response, Model model, PaymentInfoForm paymentForm, BindingResult result) throws PricingException, ServiceException {
Order cart = CartState.getCart();
Customer customer = CustomerState.getCustomer();
preProcessBillingAddress(paymentForm, cart);
paymentInfoFormValidator.validate(paymentForm, result);
if (!result.hasErrors()) {
if (paymentForm.getShouldSaveNewPayment() && !paymentForm.getShouldUseCustomerPayment()) {
if (paymentForm.getCustomerPaymentId() != null) {
savedPaymentService.updateSavedPayment(customer, paymentForm);
} else if (paymentForm.getCustomerPaymentId() == null) {
Long customerPaymentId = savedPaymentService.addSavedPayment(customer, paymentForm);
paymentForm.setCustomerPaymentId(customerPaymentId);
paymentForm.setShouldUseCustomerPayment(true);
}
}
if (paymentForm.getShouldUseCustomerPayment()) {
CustomerPayment customerPayment = customerPaymentService.readCustomerPaymentById(paymentForm.getCustomerPaymentId());
if (!cartStateService.cartHasCreditCardPaymentWithSameToken(customerPayment.getPaymentToken())) {
orderService.removePaymentsFromOrder(cart, PaymentType.CREDIT_CARD);
orderPaymentService.createOrderPaymentFromCustomerPayment(cart, customerPayment, cart.getTotalAfterAppliedPayments());
}
}
}
if (isAjaxRequest(request)) {
// Add module specific model variables
checkoutControllerExtensionManager.getProxy().addAdditionalModelVariables(model);
return getCheckoutView();
} else {
return getCheckoutPageRedirect();
}
}
use of org.broadleafcommerce.profile.core.domain.Customer in project BroadleafCommerce by BroadleafCommerce.
the class UpdateAccountValidator method validate.
public void validate(UpdateAccountForm form, Errors errors) {
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "emailAddress", "emailAddress.required");
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "firstName", "firstName.required");
ValidationUtils.rejectIfEmptyOrWhitespace(errors, "lastName", "lastName.required");
if (!errors.hasErrors()) {
// is this a valid email address?
if (!GenericValidator.isEmail(form.getEmailAddress())) {
errors.rejectValue("emailAddress", "emailAddress.invalid");
}
// check email address to see if it is already in use by another customer
Customer customerMatchingNewEmail = customerService.readCustomerByEmail(form.getEmailAddress());
if (customerMatchingNewEmail != null && !CustomerState.getCustomer().getId().equals(customerMatchingNewEmail.getId())) {
// customer found with new email entered, and it is not the current customer
errors.rejectValue("emailAddress", "emailAddress.used");
}
}
}
Aggregations