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.
Modifier and Type | Field and Description |
---|---|
protected static String |
baseCartRedirect |
protected static String |
baseConfirmationRedirect |
protected static String |
baseErrorView |
protected static String |
baseOrderReviewRedirect |
protected static String |
baseRedirect |
protected static String |
cartReqAttributeNotProvidedMessage |
protected static org.apache.commons.logging.Log |
LOG |
static String |
PAYMENT_PROCESSING_ERROR |
protected PaymentGatewayCheckoutService |
paymentGatewayCheckoutService |
protected static String |
processingErrorMessage |
protected PaymentGatewayWebResponsePrintService |
webResponsePrintService |
Constructor and Description |
---|
PaymentGatewayAbstractController() |
Modifier and Type | Method and Description |
---|---|
Long |
applyPaymentToOrder(PaymentResponseDTO responseDTO) |
abstract String |
errorEndpoint(org.springframework.ui.Model model,
javax.servlet.http.HttpServletRequest request,
org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes,
Map<String,String> pathVars) |
String |
getBaseConfirmationRedirect() |
static String |
getCartReqAttributeNotProvidedMessage() |
protected String |
getCartViewRedirect() |
abstract PaymentGatewayConfiguration |
getConfiguration() |
protected String |
getConfirmationViewRedirect(String orderNumber) |
protected String |
getErrorViewRedirect() |
abstract String |
getGatewayContextKey() |
String |
getOrderReviewRedirect() |
static String |
getProcessingErrorMessage() |
abstract PaymentGatewayWebResponseService |
getWebResponseService() |
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) |
String |
initiateCheckout(Long orderId) |
String |
lookupOrderNumberFromOrderId(PaymentResponseDTO responseDTO) |
String |
process(org.springframework.ui.Model model,
javax.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.
|
abstract String |
returnEndpoint(org.springframework.ui.Model model,
javax.servlet.http.HttpServletRequest request,
org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes,
Map<String,String> pathVars) |
addDeepLink, getContextPath, isAjaxRequest, jsonResponse
protected static final org.apache.commons.logging.Log LOG
public static final String PAYMENT_PROCESSING_ERROR
protected static String baseRedirect
protected static String baseErrorView
protected static String baseOrderReviewRedirect
protected static String baseConfirmationRedirect
protected static String baseCartRedirect
protected static String processingErrorMessage
protected static String cartReqAttributeNotProvidedMessage
@Autowired(required=false) @Qualifier(value="blPaymentGatewayCheckoutService") protected PaymentGatewayCheckoutService paymentGatewayCheckoutService
protected PaymentGatewayWebResponsePrintService webResponsePrintService
public Long applyPaymentToOrder(PaymentResponseDTO responseDTO) throws IllegalArgumentException
IllegalArgumentException
public String lookupOrderNumberFromOrderId(PaymentResponseDTO responseDTO)
public String process(org.springframework.ui.Model model, javax.servlet.http.HttpServletRequest request, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes) throws PaymentException
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
}model
- - Spring MVC modelrequest
- - the HTTPServletRequest (originating either from a Payment Gateway or from the implementing checkout engine)redirectAttributes
- - Spring MVC redirect attributesPaymentException
public abstract void handleProcessingException(Exception e, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes) throws PaymentException
PaymentException
public abstract void handleUnsuccessfulTransaction(org.springframework.ui.Model model, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes, PaymentResponseDTO responseDTO) throws PaymentException
PaymentException
public abstract String getGatewayContextKey()
public abstract PaymentGatewayWebResponseService getWebResponseService()
public abstract PaymentGatewayConfiguration getConfiguration()
public abstract String returnEndpoint(org.springframework.ui.Model model, javax.servlet.http.HttpServletRequest request, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes, Map<String,String> pathVars) throws PaymentException
PaymentException
public abstract String errorEndpoint(org.springframework.ui.Model model, javax.servlet.http.HttpServletRequest request, org.springframework.web.servlet.mvc.support.RedirectAttributes redirectAttributes, Map<String,String> pathVars) throws PaymentException
PaymentException
protected String getErrorViewRedirect()
protected String getCartViewRedirect()
public String getOrderReviewRedirect()
public String getBaseConfirmationRedirect()
public static String getProcessingErrorMessage()
public static String getCartReqAttributeNotProvidedMessage()
Copyright © 2022. All rights reserved.