Interface PaymentGatewayCheckoutService
- All Known Implementing Classes:
DefaultPaymentGatewayCheckoutService
public interface PaymentGatewayCheckoutService
The default implementation of this interface is represented in the core Broadleaf framework at
oorg.broadleafcommerce.core.payment.service.DefaultPaymentGatewayCheckoutService
. This is designed as
a generic contract for allowing payment modules to add payments to an order represented in Broadleaf while still
staying decoupled from any of the Broadleaf core framework concepts.
These service methods are usually invoked from the controller that listens to the endpoint hit by the external payment
provider (which should be a subclass of PaymentGatewayAbstractController
).
- Author:
- Elbert Bautista (elbertbautista), Phillip Verheyden (phillipuniverse)
-
Method Summary
Modifier and TypeMethodDescriptionapplyPaymentToOrder
(PaymentResponseDTO responseDTO, PaymentGatewayConfiguration config) initiateCheckout
(Long orderId) Initiates the checkout process for a given orderId.lookupOrderNumberFromOrderId
(PaymentResponseDTO responseDTO) Looks up the order number for a particular order id from thePaymentResponseDTO
.void
markPaymentAsInvalid
(Long orderPaymentId) Marks a given order payment as invalid.
-
Method Details
-
applyPaymentToOrder
Long applyPaymentToOrder(PaymentResponseDTO responseDTO, PaymentGatewayConfiguration config) throws IllegalArgumentException - Parameters:
responseDTO
- the response that came back from the gatewayconfig
- values for the payment gateway- Returns:
- a unique ID of the payment as it is saved in the core commerce engine. If using Broadleaf core,
this ID can be used to retrieve the payment on the Broadleaf side for other methods like
markPaymentAsInvalid(Long)
- Throws:
IllegalArgumentException
- if thePaymentResponseDTO#getValid()
returns false or if the order that thePaymentResponseDTO
is attempted to be applied to has already gone through checkout
-
markPaymentAsInvalid
Marks a given order payment as invalid. In the default implementation, this archives the payment. This can be determined from the result ofapplyPaymentToOrder(PaymentResponseDTO, PaymentGatewayConfiguration)
- Parameters:
orderPaymentId
- the payment ID to mark as invalid
-
initiateCheckout
Initiates the checkout process for a given orderId. This is usually fromPaymentResponseDTO.getOrderId()
- Parameters:
orderId
- the order to check out- Returns:
- the order number generated when checking out the order
- Throws:
Exception
-
lookupOrderNumberFromOrderId
Looks up the order number for a particular order id from thePaymentResponseDTO
. This can be used to redirect the user coming from the payment gateway to the order confirmation page.- Parameters:
responseDTO
- the response from the gateway- Returns:
- The order number for order id. This method can return null if the order number has not already been set (which usually means that the order has not already been checked out)
- Throws:
IllegalArgumentException
- if the order cannot be found from thePaymentResponseDTO
-