Class DefaultPaymentPriorityStrategy

java.lang.Object
com.broadleafcommerce.orderoperation.service.payment.DefaultPaymentPriorityStrategy
All Implemented Interfaces:
PaymentPriorityStrategy

public class DefaultPaymentPriorityStrategy extends Object implements PaymentPriorityStrategy
Author:
Samarth Dhruva (samarthd), Sunny Yu
  • Field Details

  • Constructor Details

    • DefaultPaymentPriorityStrategy

      public DefaultPaymentPriorityStrategy()
  • Method Details

    • sortByPaymentGatewayPriorityForCapture

      public List<PaymentSummary> sortByPaymentGatewayPriorityForCapture(@Nullable List<PaymentSummary> payments, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: PaymentPriorityStrategy
      Given a list of PaymentSummaries, sorts them in order of which should be executed first.
      Specified by:
      sortByPaymentGatewayPriorityForCapture in interface PaymentPriorityStrategy
      Parameters:
      payments - the payments to sort
      contextInfo - context information surrounding sandboxing and multitenant state
      Returns:
      a new list representing the sorted result. Will be empty if payments is null or empty.
    • sortByPaymentGatewayPriorityForRefund

      public List<PaymentSummary> sortByPaymentGatewayPriorityForRefund(@Nullable List<PaymentSummary> payments, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: PaymentPriorityStrategy
      Given a list of PaymentSummaries, sorts them in order of which should be executed first.
      Specified by:
      sortByPaymentGatewayPriorityForRefund in interface PaymentPriorityStrategy
      Parameters:
      payments - the payments to sort
      contextInfo - context information surrounding sandboxing and multitenant state
      Returns:
      a new list representing the sorted result. Will be empty if payments is null or empty.
    • sortByPaymentGatewayPriorityForCancelFulfillment

      public List<PaymentSummary> sortByPaymentGatewayPriorityForCancelFulfillment(@Nullable List<PaymentSummary> payments, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Description copied from interface: PaymentPriorityStrategy
      Given a list of PaymentSummaries, sorts them in order of which should be refunded or reversed first when the fulfillment is cancelled. The default implementation is added for backward compatibility, and this method should also be implemented when this interface is implemented.
      Specified by:
      sortByPaymentGatewayPriorityForCancelFulfillment in interface PaymentPriorityStrategy
      Parameters:
      payments - the payments to sort
      contextInfo - context information surrounding sandboxing and multitenant state
      Returns:
      a new list representing the sorted result. Will be empty if payments is null or empty.
    • sortByPaymentGatewayPriority

      protected List<PaymentSummary> sortByPaymentGatewayPriority(BiFunction<String,String,List<String>> paymentGatewayPrioritiesGetter, @Nullable List<PaymentSummary> payments, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
      Sorts the given PaymentSummaries based on the payment gateway priorities.

      The payment priorities are represented by an ordered list of payment gateways using its index, the lower the index, the higher the priority.

      Parameters:
      paymentGatewayPrioritiesGetter - the getter to retrieve the ordered list of payment gateways representing their priorities
      payments - the PaymentSummaries to sort
      contextInfo - context information surrounding sandboxing and multitenant state
      Returns:
      the sorted list of PaymentSummaries
    • getGatewayPriority

      protected int getGatewayPriority(List<String> prioritizedPaymentGatewayTypes, PaymentSummary payment)
      Gets the priority of the given PaymentSummary, which is represented by the index of the PaymentSummary.getGatewayType() in the given prioritizedPaymentGatewayTypes.
      Parameters:
      prioritizedPaymentGatewayTypes - an ordered list of payment gateway types representing the priorities of the payment gateways based on its index
      payment - the PaymentSummary to get the priority for
      Returns:
      the priority of the given PaymentSummary, which is represented by the index of the PaymentSummary.getGatewayType()
    • sortByRefundPriority

      @Deprecated public List<PaymentSummary> sortByRefundPriority(List<PaymentSummary> payments)
      Deprecated.
      Description copied from interface: PaymentPriorityStrategy
      Given a list of PaymentSummaries, sorts them in order of which should be refunded first.
      Specified by:
      sortByRefundPriority in interface PaymentPriorityStrategy
      Parameters:
      payments - the payments to sort
      Returns:
      a new list representing the sorted result. Will be empty if payments is null or empty.
    • getRefundPriority

      @Deprecated protected int getRefundPriority(PaymentSummary payment)
      Deprecated.
    • getApplicationIdFromContext

      @Nullable protected String getApplicationIdFromContext(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • getTenantIdFromContext

      @Nullable protected String getTenantIdFromContext(@Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
    • getOrderOperationPaymentProperties

      protected OrderOperationPaymentProperties getOrderOperationPaymentProperties()
    • setOrderOperationPaymentProperties

      @Autowired public void setOrderOperationPaymentProperties(OrderOperationPaymentProperties orderOperationPaymentProperties)