org.broadleafcommerce.core.web.controller.checkout
Class BroadleafCheckoutController

java.lang.Object
  extended by org.broadleafcommerce.common.web.controller.BroadleafAbstractController
      extended by org.broadleafcommerce.core.web.controller.checkout.AbstractCheckoutController
          extended by org.broadleafcommerce.core.web.controller.checkout.BroadleafCheckoutController

public class BroadleafCheckoutController
extends AbstractCheckoutController

In charge of performing the various checkout operations

Author:
Andre Azzolini (apazzolini), Elbert Bautista (elbertbautista), Joshua Skorton (jskorton)

Field Summary
protected static String baseConfirmationView
           
protected static String cartPageRedirect
           
protected static String checkoutPageRedirect
           
protected static String checkoutView
           
protected static String multishipAddAddressSuccessView
           
protected static String multishipAddAddressView
           
protected static String multishipSuccessView
           
protected static String multishipView
           
 
Fields inherited from class org.broadleafcommerce.core.web.controller.checkout.AbstractCheckoutController
addressService, checkoutControllerExtensionManager, checkoutService, countryService, customerAddressService, customerService, fulfillmentGroupService, fulfillmentOptionService, fulfillmentPricingService, multishipAddAddressFormValidator, orderInfoFormValidator, orderMultishipOptionService, orderService, paymentInfoServiceExtensionManager, paymentInfoTypeService, shippingInfoFormValidator, stateService
 
Constructor Summary
BroadleafCheckoutController()
           
 
Method Summary
 String checkout(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes)
          Renders the default checkout page and allows modules to add variables to the model.
 String completeCheckout(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, BillingInfoForm billingForm, org.springframework.validation.BindingResult result)
          Processes the request to complete checkout.
 String convertToSingleship(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.ui.Model model)
          Converts the order to single ship by collapsing all of the shippable fulfillment groups into the default (first) shippable fulfillment group.
protected  List<PaymentInfoType> createPaymentInfoTypeList(BillingInfoForm billingForm)
          A help method that creates a list of PaymentInfos based on payment method in the billingInfoForm.
 String getBaseConfirmationView()
           
 String getCartPageRedirect()
           
 String getCheckoutPageRedirect()
           
 String getCheckoutView()
           
protected  String getConfirmationView(String orderNumber)
           
 String getMultishipAddAddressSuccessView()
           
 String getMultishipAddAddressView()
           
 String getMultishipSuccessView()
           
 String getMultishipView()
           
protected  String handleCheckoutError(javax.servlet.http.HttpServletRequest request, org.springframework.ui.Model model)
          A helper method used to handle checkout errors.
protected  boolean hasValidOrderInfo(Order cart)
          A helper method used to determine the validity of order info
protected  boolean hasValidShippingAddresses(Order cart)
          A helper method used to determine the validity of the fulfillment groups
protected  void initBinder(javax.servlet.http.HttpServletRequest request, org.springframework.web.bind.ServletRequestDataBinder binder)
          Initializes some custom binding operations for the checkout flow.
protected  List<String> populateExpirationMonths()
          A helper method used to construct a list of Credit Card Expiration Months Useful for expiration dropdown menus.
protected  List<String> populateExpirationYears()
          A helper method used to construct a list of Credit Card Expiration Years Useful for expiration dropdown menus.
protected  void populateModelWithReferenceData(javax.servlet.http.HttpServletRequest request, org.springframework.ui.Model model)
           
protected  void putFulfillmentOptionsAndEstimationOnModel(org.springframework.ui.Model model)
          A helper method to retrieve all fulfillment options for the cart and estimate the cost of applying fulfillment options on the first shippable fulfillment group.
 String saveGlobalOrderDetails(javax.servlet.http.HttpServletRequest request, org.springframework.ui.Model model, OrderInfoForm orderInfoForm, org.springframework.validation.BindingResult result)
          Attempts to attach the user's email to the order so that they may proceed anonymously
 String saveMultiship(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, OrderMultishipOptionForm orderMultishipOptionForm, org.springframework.validation.BindingResult result)
          Processes the given options for multiship.
 String saveMultishipAddAddress(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, ShippingInfoForm addressForm, org.springframework.validation.BindingResult result)
          Processes the requested add address from the multiship process.
 String saveMultiShipInstruction(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, MultiShipInstructionForm instructionForm)
           
 String savePaymentForm(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.ui.Model model)
           
 String saveSingleShip(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.ui.Model model, ShippingInfoForm shippingForm, org.springframework.validation.BindingResult result)
          Processes the request to save a single shipping address.
 String showMultiship(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.ui.Model model)
          Renders the multiship page.
 String showMultishipAddAddress(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.ui.Model model)
          Renders the add address form during the multiship process
 
Methods inherited from class org.broadleafcommerce.common.web.controller.BroadleafAbstractController
addDeepLink, getContextPath, isAjaxRequest
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

cartPageRedirect

protected static String cartPageRedirect

checkoutView

protected static String checkoutView

checkoutPageRedirect

protected static String checkoutPageRedirect

multishipView

protected static String multishipView

multishipAddAddressView

protected static String multishipAddAddressView

multishipAddAddressSuccessView

protected static String multishipAddAddressSuccessView

multishipSuccessView

protected static String multishipSuccessView

baseConfirmationView

protected static String baseConfirmationView
Constructor Detail

BroadleafCheckoutController

public BroadleafCheckoutController()
Method Detail

checkout

public String checkout(javax.servlet.http.HttpServletRequest request,
                       javax.servlet.http.HttpServletResponse response,
                       org.springframework.ui.Model model,
                       org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes)
Renders the default checkout page and allows modules to add variables to the model.

Parameters:
request -
response -
model -
Returns:
the return path

convertToSingleship

public String convertToSingleship(javax.servlet.http.HttpServletRequest request,
                                  javax.servlet.http.HttpServletResponse response,
                                  org.springframework.ui.Model model)
                           throws PricingException
Converts the order to single ship by collapsing all of the shippable fulfillment groups into the default (first) shippable fulfillment group. Allows modules to add module specific shipping logic.

Parameters:
request -
response -
model -
Returns:
a redirect to /checkout
Throws:
PricingException

saveGlobalOrderDetails

public String saveGlobalOrderDetails(javax.servlet.http.HttpServletRequest request,
                                     org.springframework.ui.Model model,
                                     OrderInfoForm orderInfoForm,
                                     org.springframework.validation.BindingResult result)
                              throws ServiceException
Attempts to attach the user's email to the order so that they may proceed anonymously

Parameters:
request -
model -
errors -
emailAddress -
Returns:
the return path
Throws:
ServiceException

saveSingleShip

public String saveSingleShip(javax.servlet.http.HttpServletRequest request,
                             javax.servlet.http.HttpServletResponse response,
                             org.springframework.ui.Model model,
                             ShippingInfoForm shippingForm,
                             org.springframework.validation.BindingResult result)
                      throws PricingException,
                             ServiceException
Processes the request to save a single shipping address. Allows modules to add module specific shipping logic. Note: the default Broadleaf implementation creates an order with a single fulfillment group. In the case of shipping to multiple addresses, the multiship methods should be used.

Parameters:
request -
response -
model -
shippingForm -
Returns:
the return path
Throws:
ServiceException
PricingException

savePaymentForm

public String savePaymentForm(javax.servlet.http.HttpServletRequest request,
                              javax.servlet.http.HttpServletResponse response,
                              org.springframework.ui.Model model)
                       throws PricingException
Throws:
PricingException

showMultiship

public String showMultiship(javax.servlet.http.HttpServletRequest request,
                            javax.servlet.http.HttpServletResponse response,
                            org.springframework.ui.Model model)
Renders the multiship page. This page is used by the user when shipping items to different locations (or with different FulfillmentOptions) is desired. Note that the default Broadleaf implementation will require the user to input an Address and FulfillmentOption for each quantity of each DiscreteOrderItem.

Parameters:
request -
response -
model -
Returns:
the return path

saveMultiship

public String saveMultiship(javax.servlet.http.HttpServletRequest request,
                            javax.servlet.http.HttpServletResponse response,
                            org.springframework.ui.Model model,
                            OrderMultishipOptionForm orderMultishipOptionForm,
                            org.springframework.validation.BindingResult result)
                     throws PricingException,
                            ServiceException
Processes the given options for multiship. Validates that all options are selected before performing any actions. Allows modules to add module specific shipping logic.

Parameters:
request -
response -
model -
orderMultishipOptionForm -
Returns:
a redirect to the checkout page
Throws:
PricingException
ServiceException
See Also:
showMultiship(HttpServletRequest, HttpServletResponse, Model)

showMultishipAddAddress

public String showMultishipAddAddress(javax.servlet.http.HttpServletRequest request,
                                      javax.servlet.http.HttpServletResponse response,
                                      org.springframework.ui.Model model)
Renders the add address form during the multiship process

Parameters:
request -
response -
model -
Returns:
the return path

saveMultishipAddAddress

public String saveMultishipAddAddress(javax.servlet.http.HttpServletRequest request,
                                      javax.servlet.http.HttpServletResponse response,
                                      org.springframework.ui.Model model,
                                      ShippingInfoForm addressForm,
                                      org.springframework.validation.BindingResult result)
                               throws ServiceException
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.

Parameters:
request -
response -
model -
addressForm -
Returns:
the return path to the multiship page
Throws:
ServiceException

saveMultiShipInstruction

public String saveMultiShipInstruction(javax.servlet.http.HttpServletRequest request,
                                       javax.servlet.http.HttpServletResponse response,
                                       org.springframework.ui.Model model,
                                       MultiShipInstructionForm instructionForm)
                                throws ServiceException,
                                       PricingException
Throws:
ServiceException
PricingException

completeCheckout

public String completeCheckout(javax.servlet.http.HttpServletRequest request,
                               javax.servlet.http.HttpServletResponse response,
                               org.springframework.ui.Model model,
                               BillingInfoForm billingForm,
                               org.springframework.validation.BindingResult result)
                        throws CheckoutException,
                               PricingException,
                               ServiceException
Processes the request to complete checkout. An extension manager is used to collect payment methods. A default Collect On Delivery(COD) extension handler and a default credit card extension handler are included in the framework. The paymentInfoTypeList stores the types of payments that should be added to the payments map. An extension handler will need to match a type in the paymentInfoTypeList in order for that extension handler to execute its addAdditionalPaymentInfos method. An exception to this pattern is the customer credit extension handler. The customer credit extension handler will always be run regardless of whether or not CUSTOMER_CREDIT is in the paymentInfoTypeList. This method assumes that a credit card payment info will be either sent to a third party gateway or saved in a secure schema. If the transaction is successful, the order will be assigned an order number, its status change to SUBMITTED, and given a submit date. The method then returns the default confirmation path "/confirmation/{orderNumber}" If the transaction is unsuccessful, (e.g. the gateway declines payment) processFailedOrderCheckout() is called and reverses the state of the order. Note: this method removes any existing PaymentInfos not of type CUSTOMER_CREDIT or GIFT_CARD before running the extension manager to add new PaymentInfos.

Parameters:
request -
response -
model -
billingForm -
Returns:
the return path
Throws:
ServiceException
CheckoutException
PricingException

handleCheckoutError

protected String handleCheckoutError(javax.servlet.http.HttpServletRequest request,
                                     org.springframework.ui.Model model)
A helper method used to handle checkout errors.

Parameters:
request -
model -
Returns:

createPaymentInfoTypeList

protected List<PaymentInfoType> createPaymentInfoTypeList(BillingInfoForm billingForm)
A help method that creates a list of PaymentInfos based on payment method in the billingInfoForm. Default behavior looks for only credit card and COD.

Parameters:
billingForm -
Returns:

hasValidShippingAddresses

protected boolean hasValidShippingAddresses(Order cart)
A helper method used to determine the validity of the fulfillment groups

Parameters:
cart -
Returns:
boolean indicating whether or not the fulfillment groups on the cart have addresses.

hasValidOrderInfo

protected boolean hasValidOrderInfo(Order cart)
A helper method used to determine the validity of order info

Parameters:
cart -
Returns:
boolean indicating whether or not the order has valid info

putFulfillmentOptionsAndEstimationOnModel

protected void putFulfillmentOptionsAndEstimationOnModel(org.springframework.ui.Model model)
A helper method to retrieve all fulfillment options for the cart and estimate the cost of applying fulfillment options on the first shippable fulfillment group.


populateExpirationMonths

protected List<String> populateExpirationMonths()
A helper method used to construct a list of Credit Card Expiration Months Useful for expiration dropdown menus. Will use locale to determine language if a locale is available.

Returns:
List containing expiration months of the form "01 - January"

populateExpirationYears

protected List<String> populateExpirationYears()
A helper method used to construct a list of Credit Card Expiration Years Useful for expiration dropdown menus.

Returns:
List of the next ten years starting with the current year.

initBinder

protected void initBinder(javax.servlet.http.HttpServletRequest request,
                          org.springframework.web.bind.ServletRequestDataBinder binder)
                   throws Exception
Initializes some custom binding operations for the checkout flow. More specifically, this method will attempt to bind state and country abbreviations to actual State and Country objects when the String representation of the abbreviation is submitted.

Parameters:
request -
binder -
Throws:
Exception

populateModelWithReferenceData

protected void populateModelWithReferenceData(javax.servlet.http.HttpServletRequest request,
                                              org.springframework.ui.Model model)

getCartPageRedirect

public String getCartPageRedirect()

getCheckoutView

public String getCheckoutView()

getCheckoutPageRedirect

public String getCheckoutPageRedirect()

getMultishipView

public String getMultishipView()

getMultishipAddAddressView

public String getMultishipAddAddressView()

getMultishipSuccessView

public String getMultishipSuccessView()

getMultishipAddAddressSuccessView

public String getMultishipAddAddressSuccessView()

getBaseConfirmationView

public String getBaseConfirmationView()

getConfirmationView

protected String getConfirmationView(String orderNumber)


Copyright © 2013. All Rights Reserved.