Class PaymentGatewayAbstractController

java.lang.Object
org.broadleafcommerce.common.web.controller.BroadleafAbstractController
org.broadleafcommerce.common.web.payment.controller.PaymentGatewayAbstractController

public abstract class PaymentGatewayAbstractController extends BroadleafAbstractController

Abstract controller that provides convenience methods and resource declarations to facilitate payment gateway communication between the implementing module and the Spring injected checkout engine. This class provides generic flows and operations that are common across payment gateway integration methods. You may notice that this intentionally resides in "common" as this supports the use case where an implementing module can be used outside the scope of Broadleaf's "core" commerce engine.

If used in conjunction with the core framework, Broadleaf provides all the necessary spring resources, such as "blPaymentGatewayCheckoutService" that are needed for this class. If you are using the common jars without the framework dependency, you will either have to implement the blPaymentGatewayCheckoutService yourself, or override the "applyPaymentToOrder" and the "markPaymentAsInvalid" methods accordingly.

Author:
Elbert Bautista (elbertbautista)
  • Field Details

    • PAYMENT_PROCESSING_ERROR

      public static final String PAYMENT_PROCESSING_ERROR
      See Also:
    • LOG

      protected static final org.apache.commons.logging.Log LOG
    • baseRedirect

      protected static String baseRedirect
    • baseErrorView

      protected static String baseErrorView
    • baseOrderReviewRedirect

      protected static String baseOrderReviewRedirect
    • baseConfirmationRedirect

      protected static String baseConfirmationRedirect
    • baseCartRedirect

      protected static String baseCartRedirect
    • processingErrorMessage

      protected static String processingErrorMessage
    • cartReqAttributeNotProvidedMessage

      protected static String cartReqAttributeNotProvidedMessage
    • paymentGatewayCheckoutService

      @Autowired(required=false) @Qualifier("blPaymentGatewayCheckoutService") protected PaymentGatewayCheckoutService paymentGatewayCheckoutService
    • webResponsePrintService

      protected PaymentGatewayWebResponsePrintService webResponsePrintService
  • Constructor Details

    • PaymentGatewayAbstractController

      public PaymentGatewayAbstractController()
  • Method Details

    • getProcessingErrorMessage

      public static String getProcessingErrorMessage()
    • getCartReqAttributeNotProvidedMessage

      public static String getCartReqAttributeNotProvidedMessage()
    • applyPaymentToOrder

      public Long applyPaymentToOrder(PaymentResponseDTO responseDTO) throws IllegalArgumentException
      Throws:
      IllegalArgumentException
    • initiateCheckout

      public String initiateCheckout(Long orderId) throws Exception
      Throws:
      Exception
    • lookupOrderNumberFromOrderId

      public String lookupOrderNumberFromOrderId(PaymentResponseDTO responseDTO)
    • process

      public String process(org.springframework.ui.Model model, jakarta.servlet.http.HttpServletRequest request, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes) throws PaymentException
      This method is intended to initiate the final steps in checkout either via a request coming directly from a Payment Gateway (i.e. a Transparent Redirect) or from some sort of tokenization mechanism client-side.

      The assumption is that the implementing gateway's controller that extends this class will have implemented a PaymentGatewayWebResponseService with the ability to translate an HttpServletRequest into a PaymentResponseDTO which will then be used by the framework to create the appropriate order payments and transactions as well as invoke the checkout workflow if configured to do so.

      The general flow is as follows:

      try { translate http request to DTO apply payment to order (if unsuccessful, payment will be archived) if (not successful or not valid) redirect to error view if (complete checkout on callback == true) initiateCheckout(order id); else show review page; } catch (Exception e) { log error handle processing exception }

      Parameters:
      model - - Spring MVC model
      request - - the HTTPServletRequest (originating either from a Payment Gateway or from the implementing checkout engine)
      redirectAttributes - - Spring MVC redirect attributes
      Returns:
      the resulting view
      Throws:
      PaymentException
    • handleProcessingException

      public abstract void handleProcessingException(Exception e, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes) throws PaymentException
      Throws:
      PaymentException
    • handleUnsuccessfulTransaction

      public abstract void handleUnsuccessfulTransaction(org.springframework.ui.Model model, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes, PaymentResponseDTO responseDTO) throws PaymentException
      Throws:
      PaymentException
    • getGatewayContextKey

      public abstract String getGatewayContextKey()
    • getWebResponseService

      public abstract PaymentGatewayWebResponseService getWebResponseService()
    • getConfiguration

      public abstract PaymentGatewayConfiguration getConfiguration()
    • returnEndpoint

      public abstract String returnEndpoint(org.springframework.ui.Model model, jakarta.servlet.http.HttpServletRequest request, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes, Map<String,String> pathVars) throws PaymentException
      Throws:
      PaymentException
    • errorEndpoint

      public abstract String errorEndpoint(org.springframework.ui.Model model, jakarta.servlet.http.HttpServletRequest request, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes, Map<String,String> pathVars) throws PaymentException
      Throws:
      PaymentException
    • getErrorViewRedirect

      protected String getErrorViewRedirect()
    • getCartViewRedirect

      protected String getCartViewRedirect()
    • getOrderReviewRedirect

      public String getOrderReviewRedirect()
    • getBaseConfirmationRedirect

      public String getBaseConfirmationRedirect()
    • getConfirmationViewRedirect

      protected String getConfirmationViewRedirect(String orderNumber)