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)

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, billingInfoFormValidator, checkoutService, countryService, creditCardPaymentInfoFactory, customerAddressService, customerService, fulfillmentGroupService, fulfillmentOptionService, fulfillmentPricingService, multishipAddAddressFormValidator, orderInfoFormValidator, orderMultishipOptionService, orderService, securePaymentInfoService, 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.
 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 If the paymentMethod is undefined or "creditCard" delegates to the "completeSecureCreditCardCheckout" method.
 String completeSecureCreditCardCheckout(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 using a Credit Card This method assumes that a credit card payment info will be either sent to a third party gateway or saved in a secure schema.
 String convertToSingleship(javax.servlet.http.HttpServletRequest request, javax.servlet.http.HttpServletResponse response, org.springframework.ui.Model model)
          Converts the order to singleship by collapsing all of the fulfillment groups into the default one
protected  void copyShippingAddressToBillingAddress(Order order, BillingInfoForm billingInfoForm)
          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.
 String getBaseConfirmationView()
           
 String getCartPageRedirect()
           
 String getCheckoutPageRedirect()
           
 String getCheckoutView()
           
protected  String getConfirmationView(String orderNumber)
           
 String getMultishipAddAddressSuccessView()
           
 String getMultishipAddAddressView()
           
 String getMultishipSuccessView()
           
 String getMultishipView()
           
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  void initializeOrderForCheckout(Order order)
          This method initializes the order for checkout by setting the order number, status, and the submit date.
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 populateModelWithShippingReferenceData(javax.servlet.http.HttpServletRequest request, org.springframework.ui.Model model)
           
protected  void processFailedOrderCheckout(Order order)
          This method dictates what actions need to be taken if there is a failure during the checkout process.
protected  void putFulfillmentOptionsAndEstimationOnModel(org.springframework.ui.Model model)
          A helper method to retrieve all fulfillment options for the cart
 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 Note that the default Broadleaf implementation creates an order with a single fulfillment group.
 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
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.

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 singleship by collapsing all of the fulfillment groups into the default one

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 Note that the default Broadleaf implementation creates an order with a single fulfillment group. In the case of shipping to mutiple 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.

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 If the paymentMethod is undefined or "creditCard" delegates to the "completeSecureCreditCardCheckout" method. Otherwise, returns an operation not supported. 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 payment infos of type CREDIT_CARD and re-creates it with the information from the BillingInfoForm

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

completeSecureCreditCardCheckout

public String completeSecureCreditCardCheckout(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 using a Credit Card 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 payment infos of type CREDIT_CARD and re-creates it with the information from the BillingInfoForm

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

copyShippingAddressToBillingAddress

protected void copyShippingAddressToBillingAddress(Order order,
                                                   BillingInfoForm billingInfoForm)
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.

Parameters:
billingInfoForm -

initializeOrderForCheckout

protected void initializeOrderForCheckout(Order order)
This method initializes the order for checkout by setting the order number, status, and the submit date.

Parameters:
order -

processFailedOrderCheckout

protected void processFailedOrderCheckout(Order order)
                                   throws PricingException
This method dictates what actions need to be taken if there is a failure during the checkout process. Normally called when either the transaction success is false (e.g. payment declined by gateway) or an unknown error occurs during the Checkout Workflow (e.g. a CheckoutException is thrown) The default behavior is to reverse the status of the order and set the submit date and order number to null.

Parameters:
order -
Throws:
PricingException

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


populateExpirationMonths

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

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

populateModelWithShippingReferenceData

protected void populateModelWithShippingReferenceData(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 © 2012. All Rights Reserved.