Class CheckoutUtilsImpl
- All Implemented Interfaces:
- CheckoutUtils
CheckoutUtilsImpl is the default implementation of the
 CheckoutUtils interface for the application.- Author:
- David Tobey
- See Also:
- 
Field SummaryFields
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionfindCheckoutScreen(BaseForm baseForm) Determines what checkout screen to direct the user to based on the status of the session and the store's database configuration.findShippingOptionFromOrder(Collection options, Order order, BaseForm baseForm) loadShippingOptions(BaseForm baseForm) Loads the active shipping options for display to the user.voidvoidInitializes an instance ofCheckoutAddressesFormwith address and shipping option information.voidprepareCheckoutAddressesForm(CheckoutAddressesForm baseForm, boolean skipDeliveryFields, boolean skipBillingFields) voidprepareCheckoutShippingForm(BaseForm baseForm) Initializes an instance ofCheckoutAddressesFormwith address and shipping option information.voidprepareLoginForm(BaseForm baseForm, org.apache.struts.action.ActionServlet servlet) Initializes an instance ofLoginFormand populates it from request parameters.voidpreparePaymentForm(org.apache.struts.action.ActionForm paymentForm, BaseForm baseForm, org.apache.struts.action.ActionServlet servlet) Prepares a given payment form by populating its properties from the request's parameters.voidpreparePaymentForm(org.apache.struts.action.ActionForm paymentForm, BaseForm baseForm, org.apache.struts.action.ActionServlet servlet, boolean validating) voidpreparePaymentForms(BaseForm baseForm, org.apache.struts.action.ActionServlet servlet) Creates payment form instances and populates them from the request parameters.voidprepareRegisterForm(BaseForm baseForm, org.apache.struts.action.ActionServlet servlet) Initializes an instance ofRegisterFormand populates it from request parameters.org.apache.struts.action.ActionForwardprocessCheckoutAddresses(BaseForm baseForm) Processes submissions to record addresses in the current user's cart.org.apache.struts.action.ActionForwardprocessCheckoutAddresses(BaseForm baseForm, javax.servlet.http.HttpServletResponse response) Processes submissions to record addresses in the current user's cart.org.apache.struts.action.ActionForwardprocessCheckoutConfirm(BaseForm baseForm) Processes a request to confirm an order.org.apache.struts.action.ActionForwardprocessCheckoutLogin(BaseForm baseForm, javax.servlet.http.HttpServletResponse response) Processes a login request during the checkout process.org.apache.struts.action.ActionForwardprocessCheckoutPayment(BaseForm baseForm, org.apache.struts.action.ActionServlet servlet) Processes submissions of payment information by the current user.org.apache.struts.action.ActionForwardprocessCheckoutRegister(BaseForm baseForm) Processes a request to register a new customer account during the checkout process.org.apache.struts.action.ActionForwardprocessCheckoutShipping(BaseForm baseForm) Processes submissions to record shipping options in the current user's cart.org.apache.struts.action.ActionForwardprocessDeclineLogin(BaseForm baseForm) Processes a request to continue the checkout process without logging in or creating an account.processInventoryDiscountCheck(BaseForm baseForm) Performs a check on the inventory and processes discounting for the current user's cart.processOrderComplete(BaseForm baseForm) Invoked when a order has just been completed.intprocessPayment(PaymentProcessor paymentProcessor, org.apache.struts.action.ActionForm paymentForm, BaseForm baseForm) Processes payment information for a request with a given payment processor.processShipping(BaseForm baseForm) Processes shipping charges for the current user's cart.processTax(BaseForm baseForm) Processes tax charges for the current user's cart.protected voidsaveErrors(javax.servlet.http.HttpServletRequest request, org.apache.struts.action.ActionMessages errors) protected voidsaveMessages(javax.servlet.http.HttpServletRequest request, org.apache.struts.action.ActionMessages messages) validateAddress(BaseForm baseForm) booleanvalidateBillingFields(BaseForm baseForm) Validates the required billing address fields in the user's cart.booleanvalidateDeliveryFields(BaseForm baseForm) Validates the required delivery address fields in the user's cart.booleanvalidatePaymentForm(org.apache.struts.action.ActionForm paymentForm, BaseForm baseForm) Validates a given payment form for a given request.
- 
Field Details- 
logstatic org.apache.commons.logging.Log log
 
- 
- 
Constructor Details- 
CheckoutUtilsImplpublic CheckoutUtilsImpl()
 
- 
- 
Method Details- 
findCheckoutScreenDescription copied from interface:CheckoutUtilsDetermines what checkout screen to direct the user to based on the status of the session and the store's database configuration. The possible screen names returned are:- "catalogMode", if the store's "catalogMode" database setting is set.
- "cart", if the user's cart is empty.
- "forceLogin", if the "forceLogin" database setting is set and the user is not logged in.
- "inviteLogin", if the "inviteLogin" database setting is set and the user has not declined to log in and is not logged in.
- "checkoutAddresses", if the user has not entered in all the required address fields for the order, and the "useComboScreen" setting is not set.
- "checkoutPayment", if payment information is required, the total of the current order is greater than zero, and the "useComboScreen" setting is not set.
- "checkoutCombo", if the user has not entered in all the required address fields, or if payment information is required, and if the "useComboScreen" setting is set.
- "checkoutConfirm", if none of the other screens apply.
 The above screen names correspond to ActionForwards defined in the "/WEB-INF/conf/order/struts-config-order.xml" file.- Specified by:
- findCheckoutScreenin interface- CheckoutUtils
- Parameters:
- baseForm- The form class corresponding to the current request. Holds various properties of the request to help action classes communicate with the rest of the application.
- Returns:
- A string identifying the name of the checkout screen to direct the user to.
- Throws:
- Exception
 
- 
validateBillingFieldsDescription copied from interface:CheckoutUtilsValidates the required billing address fields in the user's cart. Loops through the "billingRequired" database setting to check which fields are required.- Specified by:
- validateBillingFieldsin interface- CheckoutUtils
- Parameters:
- baseForm- The form class corresponding to the current request. Holds various properties of the request to help action classes communicate with the rest of the application.
- Returns:
- trueif all the required billing fields are present in the user's cart.- falseif not.
- Throws:
- Exception
 
- 
validateDeliveryFieldsDescription copied from interface:CheckoutUtilsValidates the required delivery address fields in the user's cart. Loops through the "deliveryRequired" database setting to check which fields are required.- Specified by:
- validateDeliveryFieldsin interface- CheckoutUtils
- Parameters:
- baseForm- The form class corresponding to the current request. Holds various properties of the request to help action classes communicate with the rest of the application.
- Returns:
- trueif all the required billing fields are present in the user's cart.- falseif not.
- Throws:
- Exception
 
- 
prepareLoginFormpublic void prepareLoginForm(BaseForm baseForm, org.apache.struts.action.ActionServlet servlet) throws Exception Description copied from interface:CheckoutUtilsInitializes an instance ofLoginFormand populates it from request parameters. Used on the invite login screen and the force login screen.- Specified by:
- prepareLoginFormin interface- CheckoutUtils
- Parameters:
- baseForm- The form class corresponding to the current request. Holds various properties of the request to help action classes communicate with the rest of the application.
- Throws:
- Exception
 
- 
prepareRegisterFormpublic void prepareRegisterForm(BaseForm baseForm, org.apache.struts.action.ActionServlet servlet) throws Exception Description copied from interface:CheckoutUtilsInitializes an instance ofRegisterFormand populates it from request parameters. Used on the checkout register screen.- Specified by:
- prepareRegisterFormin interface- CheckoutUtils
- Parameters:
- baseForm- The form class corresponding to the current request. Holds various properties of the request to help action classes communicate with the rest of the application.
- Throws:
- Exception
 
- 
processCheckoutLoginpublic org.apache.struts.action.ActionForward processCheckoutLogin(BaseForm baseForm, javax.servlet.http.HttpServletResponse response) throws Exception Description copied from interface:CheckoutUtilsProcesses a login request during the checkout process. Used when a user logs in from the invite login screen or the force login screen.The method runs CustomerProcessor.processLogin(Map)to process the login request.- Specified by:
- processCheckoutLoginin interface- CheckoutUtils
- Parameters:
- baseForm- The form class corresponding to the current request. Holds various properties of the request to help action classes communicate with the rest of the application.
- Returns:
- An ActionForwardcorresponding to the results of the processing. TheActionForwardwill be named "failureInvalidLogin" or "success".
- Throws:
- Exception
 
- 
processCheckoutRegisterpublic org.apache.struts.action.ActionForward processCheckoutRegister(BaseForm baseForm) throws Exception Description copied from interface:CheckoutUtilsProcesses a request to register a new customer account during the checkout process. Used when a user registers from the checkout register screen.This method runs CustomerProcessor.processRegister(Map)to process the register request.- Specified by:
- processCheckoutRegisterin interface- CheckoutUtils
- Parameters:
- baseForm- The form class corresponding to the current request. Holds various properties of the request to help action classes communicate with the rest of the application.
- Returns:
- An ActionForwardcorresponding to the results of the processing. TheActionForwardwill be named "failureUserName" if the user name is already taken, or "success".
- Throws:
- Exception
 
- 
processDeclineLoginpublic org.apache.struts.action.ActionForward processDeclineLogin(BaseForm baseForm) throws Exception Description copied from interface:CheckoutUtilsProcesses a request to continue the checkout process without logging in or creating an account. Used when a user declines to log in from the invite login screen.This method places an attribute in the user's session named "declinedLoginBeforeCheckout". - Specified by:
- processDeclineLoginin interface- CheckoutUtils
- Parameters:
- baseForm- The form class corresponding to the current request. Holds various properties of the request to help action classes communicate with the rest of the application.
- Returns:
- An ActionForwardcorresponding to the results of the processing. Always returns the "success"ActionForward.
- Throws:
- Exception
 
- 
loadShippingOptionsDescription copied from interface:CheckoutUtilsLoads the active shipping options for display to the user. Used on the checkout addresses screen. Loops through the classes in the "activeShippingProcessors" database setting and invokes theloadShippingOptionsmethod in each to get the available options.- Specified by:
- loadShippingOptionsin interface- CheckoutUtils
- Parameters:
- baseForm- The form class corresponding to the current request. Holds various properties of the request to help action classes communicate with the rest of the application.
- Returns:
- A Collectioncontaining each of the shipping option available for the user to select.
- Throws:
- Exception
- See Also:
 
- 
findShippingOptionFromOrder
- 
prepareCheckoutAddressesAddressBookFormpublic void prepareCheckoutAddressesAddressBookForm(CheckoutAddressesForm baseForm) throws Exception - Specified by:
- prepareCheckoutAddressesAddressBookFormin interface- CheckoutUtils
- Throws:
- Exception
 
- 
prepareCheckoutAddressesFormDescription copied from interface:CheckoutUtilsInitializes an instance ofCheckoutAddressesFormwith address and shipping option information. Used on the checkout addresses screen. If the current user is a logged in customer, populates the form with the account's address information.- Specified by:
- prepareCheckoutAddressesFormin interface- CheckoutUtils
- Parameters:
- baseForm- The form class corresponding to the current request. Holds various properties of the request to help action classes communicate with the rest of the application.
- Throws:
- Exception
 
- 
prepareCheckoutAddressesFormpublic void prepareCheckoutAddressesForm(CheckoutAddressesForm baseForm, boolean skipDeliveryFields, boolean skipBillingFields) throws Exception - Throws:
- Exception
 
- 
prepareCheckoutShippingFormDescription copied from interface:CheckoutUtilsInitializes an instance ofCheckoutAddressesFormwith address and shipping option information. Used on the checkout addresses screen. If the current user is a logged in customer, populates the form with the account's address information.- Specified by:
- prepareCheckoutShippingFormin interface- CheckoutUtils
- Parameters:
- baseForm- The form class corresponding to the current request. Holds various properties of the request to help action classes communicate with the rest of the application.
- Throws:
- Exception
 
- 
processCheckoutAddressespublic org.apache.struts.action.ActionForward processCheckoutAddresses(BaseForm baseForm) throws Exception Description copied from interface:CheckoutUtilsProcesses submissions to record addresses in the current user's cart. Used for requests to "/CheckoutAddresses.do".Invokes CartProcessor.processCheckoutAddresses(Map)to process the submitted address information. Then invokesCheckoutUtils.processInventoryDiscountCheck(BaseForm)to perform a check on inventory and discounts for items in the cart.- Specified by:
- processCheckoutAddressesin interface- CheckoutUtils
- Parameters:
- baseForm- The form class corresponding to the current request. Holds various properties of the request to help action classes communicate with the rest of the application.
- Returns:
- An ActionForwardcorresponding to the results of the processing. TheActionForwardwill be named "failureItemsAdjusted", "failureAllItemsRemoved", or "success".
- Throws:
- Exception
 
- 
processCheckoutAddressespublic org.apache.struts.action.ActionForward processCheckoutAddresses(BaseForm baseForm, javax.servlet.http.HttpServletResponse response) throws Exception Description copied from interface:CheckoutUtilsProcesses submissions to record addresses in the current user's cart. Used for requests to "/CheckoutAddresses.do".Invokes CartProcessor.processCheckoutAddresses(Map)to process the submitted address information. Then invokesCheckoutUtils.processInventoryDiscountCheck(BaseForm)to perform a check on inventory and discounts for items in the cart.- Specified by:
- processCheckoutAddressesin interface- CheckoutUtils
- Parameters:
- baseForm- The form class corresponding to the current request. Holds various properties of the request to help action classes communicate with the rest of the application.
- response- The HttpServletResponse object associated with the request. If present and the "autoSavedCartToken" cookie is present, that cookie will be removed so no personal information is retrievable through the cookie.
- Returns:
- An ActionForwardcorresponding to the results of the processing. TheActionForwardwill be named "failureItemsAdjusted", "failureAllItemsRemoved", or "success".
- Throws:
- Exception
 
- 
validateAddress
- 
processInventoryDiscountCheckDescription copied from interface:CheckoutUtilsPerforms a check on the inventory and processes discounting for the current user's cart. Makes sure that if products are to be decremented on checkout, no skus are out of stock.- Specified by:
- processInventoryDiscountCheckin interface- CheckoutUtils
- Parameters:
- baseForm- The form class corresponding to the current request. Holds various properties of the request to help action classes communicate with the rest of the application.
- Returns:
- A Map containing a key named resultCode: 0 indicates no changes, 1 indicates the cart was adjusted, 2 indicates all order items were removed (due to inventory being out of stock).
- Throws:
- Exception
 
- 
processCheckoutShippingpublic org.apache.struts.action.ActionForward processCheckoutShipping(BaseForm baseForm) throws Exception Description copied from interface:CheckoutUtilsProcesses submissions to record shipping options in the current user's cart. Used for requests to "/CheckoutShipping.do".Invokes CheckoutUtils.processShipping(BaseForm)to process shipping charges andCheckoutUtils.processTax(BaseForm)to process tax charges.- Specified by:
- processCheckoutShippingin interface- CheckoutUtils
- Parameters:
- baseForm- The form class corresponding to the current request. Holds various properties of the request to help action classes communicate with the rest of the application.
- Returns:
- An ActionForwardcorresponding to the results of the processing. TheActionForwardwill be named "failureShippingProcess", "failureTaxProcess", "success", "successNoPaymentRequired", or "successNoPaymentRequiredConfirm".
- Throws:
- Exception
 
- 
processShippingDescription copied from interface:CheckoutUtilsProcesses shipping charges for the current user's cart. Called when the checkout addresses form is processed.Goes through the classes in the "activeShippingProcessors" database setting and invokes the processShipping(Map)method in each to process the charges. The incomingbaseFormshould have a property namedshippingOptioncontaining the shipping option selected by the user.- Specified by:
- processShippingin interface- CheckoutUtils
- Parameters:
- baseForm- The form class corresponding to the current request. Holds various properties of the request to help action classes communicate with the rest of the application.
- Returns:
- A Map with a key named resultCode, which is 0, if the processing was successful. A non-zero integer indicates there was a problem and further processing should stop.
- Throws:
- Exception
- See Also:
 
- 
processTaxDescription copied from interface:CheckoutUtilsProcesses tax charges for the current user's cart. Called when the checkout addresses form is processed.Goes through the classes in the "activeTaxProcessors" database setting and invokes the processTax(Map)method in each to process the charges.- Specified by:
- processTaxin interface- CheckoutUtils
- Parameters:
- baseForm- The form class corresponding to the current request. Holds various properties of the request to help action classes communicate with the rest of the application.
- Returns:
- A Map with a key named resultCode, which is 0, if the processing was successful. A non-zero integer indicates there was a problem and further processing should stop.
- Throws:
- Exception
 
- 
preparePaymentFormspublic void preparePaymentForms(BaseForm baseForm, org.apache.struts.action.ActionServlet servlet) throws Exception Description copied from interface:CheckoutUtilsCreates payment form instances and populates them from the request parameters. Used on the checkout payment screen so each of the active payment forms can be displayed. Loops through the "activePaymentForms" database setting to find the class names of the payment forms to create.- Specified by:
- preparePaymentFormsin interface- CheckoutUtils
- Parameters:
- baseForm- The form class corresponding to the current request. Holds various properties of the request to help action classes communicate with the rest of the application.
- Throws:
- Exception
 
- 
preparePaymentFormpublic void preparePaymentForm(org.apache.struts.action.ActionForm paymentForm, BaseForm baseForm, org.apache.struts.action.ActionServlet servlet) throws Exception Description copied from interface:CheckoutUtilsPrepares a given payment form by populating its properties from the request's parameters.- Specified by:
- preparePaymentFormin interface- CheckoutUtils
- Parameters:
- paymentForm- The payment form being populated from the request.
- baseForm- The form class corresponding to the current request. Holds various properties of the request to help action classes communicate with the rest of the application.
- Throws:
- Exception
 
- 
preparePaymentFormpublic void preparePaymentForm(org.apache.struts.action.ActionForm paymentForm, BaseForm baseForm, org.apache.struts.action.ActionServlet servlet, boolean validating) throws Exception - Throws:
- Exception
 
- 
processCheckoutPaymentpublic org.apache.struts.action.ActionForward processCheckoutPayment(BaseForm baseForm, org.apache.struts.action.ActionServlet servlet) throws Exception Description copied from interface:CheckoutUtilsProcesses submissions of payment information by the current user. Used for requests to "/CheckoutPayment.do".Loops through each of the classes in the "activePaymentForms" and "activePaymentProcessors" database settings to find the payment form that was used to submit payment information, and its corresponding PaymentProcessor. Uses the "paymentFormCount" request parameter to determine which form was submitted.Invokes CheckoutUtils.validatePaymentForm(ActionForm, BaseForm)to validate the submission, and if valid,CheckoutUtils.processPayment(PaymentProcessor, ActionForm, BaseForm)to process it.If a confirmation screen must be displayed, this method places the payment form and the name of the payment processor in the customer's session, so that the processCheckoutConfirmmethod can retrieve them.- Specified by:
- processCheckoutPaymentin interface- CheckoutUtils
- Parameters:
- baseForm- The form class corresponding to the current request. Holds various properties of the request to help action classes communicate with the rest of the application.
- Returns:
- An ActionForwardcorresponding to the results of the processing. TheActionForwardwill be named "failureFormValidation", "failurePaymentProcess", "success", or "successCheckoutConfirm".
- Throws:
- Exception
 
- 
validatePaymentFormpublic boolean validatePaymentForm(org.apache.struts.action.ActionForm paymentForm, BaseForm baseForm) throws Exception Description copied from interface:CheckoutUtilsValidates a given payment form for a given request. Used when a submission is made from the checkout payment screen to validate the submission of payment information. The method simply runs thevalidatemethod of the payment form, saving any validation errors to the request.- Specified by:
- validatePaymentFormin interface- CheckoutUtils
- Parameters:
- paymentForm- The payment form that was used by the user to submit payment information.
- baseForm- The form class corresponding to the current request. Holds various properties of the request to help action classes communicate with the rest of the application.
- Returns:
- trueif the submission passes validation.- falseif not.
- Throws:
- Exception
 
- 
processPaymentpublic int processPayment(PaymentProcessor paymentProcessor, org.apache.struts.action.ActionForm paymentForm, BaseForm baseForm) throws Exception Description copied from interface:CheckoutUtilsProcesses payment information for a request with a given payment processor. Used when a submission is made from the checkout payment screen to process payment information.This method runs the processPayment(Map)method of the incomingPaymentProcessor, which returns a Map that includes a key named resultCode. This method returns the int value of that resultCode.If the resultCode is not equal to zero, it indicates an error in the processing of the payment. This method will look up an error message in the "/WEB-INF/classes/resources/payment/application.properties" file corresponding to the resultCode and the name of the payment processor. For example, the error message for the message key payment.errorPayflowProProcessor10000will be placed in the request, if the payment processor was PayflowProProcessor and the resultCode was 10000. Additional error messages that follow the same naming pattern can be placed in the "/WEB-INF/classes/resources/payment/application.properties" file.- Specified by:
- processPaymentin interface- CheckoutUtils
- Parameters:
- paymentProcessor- The- PaymentProcessorcorresponding to the payment form used by the user to submit payment information.
- baseForm- The form class corresponding to the current request. Holds various properties of the request to help action classes communicate with the rest of the application.
- Returns:
- trueif the submission passes validation.- falseif not.
- Throws:
- Exception
 
- 
processCheckoutConfirmpublic org.apache.struts.action.ActionForward processCheckoutConfirm(BaseForm baseForm) throws Exception Description copied from interface:CheckoutUtilsProcesses a request to confirm an order. Processes the payment form stored in the session with the session's payment processor. If processing fails, a failure is returned. Otherwise, theprocessOrderCompletemethod is run.- Specified by:
- processCheckoutConfirmin interface- CheckoutUtils
- Parameters:
- baseForm- The form class corresponding to the current request. Holds various properties of the request to help action classes communicate with the rest of the application.
- Throws:
- Exception
 
- 
processOrderCompleteDescription copied from interface:CheckoutUtilsInvoked when a order has just been completed. Decrements inventory if called for, and places the currentUserobject, as well as thebaseFormobject in the request scope, for use by the JSP templates that display the invoice and send out the notification and confirmation emails.- Specified by:
- processOrderCompletein interface- CheckoutUtils
- Parameters:
- baseForm- The form class corresponding to the current request. Holds various properties of the request to help action classes communicate with the rest of the application.
- Throws:
- Exception
 
- 
saveErrorsprotected void saveErrors(javax.servlet.http.HttpServletRequest request, org.apache.struts.action.ActionMessages errors) 
- 
saveMessagesprotected void saveMessages(javax.servlet.http.HttpServletRequest request, org.apache.struts.action.ActionMessages messages) 
 
-