Class PaymentGatewayAbstractController
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 Summary
FieldsModifier and TypeFieldDescriptionprotected static String
protected static String
protected static String
protected static String
protected static String
protected static String
protected static final org.apache.commons.logging.Log
static final String
protected PaymentGatewayCheckoutService
protected static String
protected PaymentGatewayWebResponsePrintService
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionapplyPaymentToOrder
(PaymentResponseDTO responseDTO) 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) static String
protected String
abstract PaymentGatewayConfiguration
protected String
getConfirmationViewRedirect
(String orderNumber) protected String
abstract String
static String
abstract PaymentGatewayWebResponseService
abstract void
handleProcessingException
(Exception e, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes) abstract void
handleUnsuccessfulTransaction
(org.springframework.ui.Model model, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes, PaymentResponseDTO responseDTO) initiateCheckout
(Long orderId) lookupOrderNumberFromOrderId
(PaymentResponseDTO responseDTO) process
(org.springframework.ui.Model model, jakarta.servlet.http.HttpServletRequest request, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes) 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.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) Methods inherited from class org.broadleafcommerce.common.web.controller.BroadleafAbstractController
addDeepLink, getContextPath, isAjaxRequest, jsonResponse
-
Field Details
-
PAYMENT_PROCESSING_ERROR
- See Also:
-
LOG
protected static final org.apache.commons.logging.Log LOG -
baseRedirect
-
baseErrorView
-
baseOrderReviewRedirect
-
baseConfirmationRedirect
-
baseCartRedirect
-
processingErrorMessage
-
cartReqAttributeNotProvidedMessage
-
paymentGatewayCheckoutService
@Autowired(required=false) @Qualifier("blPaymentGatewayCheckoutService") protected PaymentGatewayCheckoutService paymentGatewayCheckoutService -
webResponsePrintService
-
-
Constructor Details
-
PaymentGatewayAbstractController
public PaymentGatewayAbstractController()
-
-
Method Details
-
getProcessingErrorMessage
-
getCartReqAttributeNotProvidedMessage
-
applyPaymentToOrder
- Throws:
IllegalArgumentException
-
initiateCheckout
- Throws:
Exception
-
lookupOrderNumberFromOrderId
-
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 anHttpServletRequest
into aPaymentResponseDTO
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 modelrequest
- - 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
-
getWebResponseService
-
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
-
getCartViewRedirect
-
getOrderReviewRedirect
-
getBaseConfirmationRedirect
-
getConfirmationViewRedirect
-