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 Details

    • applyPaymentToOrder

      Long applyPaymentToOrder(PaymentResponseDTO responseDTO, PaymentGatewayConfiguration config) throws IllegalArgumentException
      Parameters:
      responseDTO - the response that came back from the gateway
      config - 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 the PaymentResponseDTO#getValid() returns false or if the order that the PaymentResponseDTO is attempted to be applied to has already gone through checkout
    • markPaymentAsInvalid

      void markPaymentAsInvalid(Long orderPaymentId)
      Marks a given order payment as invalid. In the default implementation, this archives the payment. This can be determined from the result of applyPaymentToOrder(PaymentResponseDTO, PaymentGatewayConfiguration)
      Parameters:
      orderPaymentId - the payment ID to mark as invalid
    • initiateCheckout

      String initiateCheckout(Long orderId) throws Exception
      Initiates the checkout process for a given orderId. This is usually from PaymentResponseDTO.getOrderId()
      Parameters:
      orderId - the order to check out
      Returns:
      the order number generated when checking out the order
      Throws:
      Exception
    • lookupOrderNumberFromOrderId

      String lookupOrderNumberFromOrderId(PaymentResponseDTO responseDTO) throws IllegalArgumentException
      Looks up the order number for a particular order id from the PaymentResponseDTO. 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 the PaymentResponseDTO