Class DefaultPaymentPriorityStrategy
java.lang.Object
com.broadleafcommerce.orderoperation.service.payment.DefaultPaymentPriorityStrategy
- All Implemented Interfaces:
PaymentPriorityStrategy
- Author:
- Samarth Dhruva (samarthd), Sunny Yu
-
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected StringgetApplicationIdFromContext(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected intgetGatewayPriority(List<String> prioritizedPaymentGatewayTypes, PaymentSummary payment) Gets the priority of the givenPaymentSummary, which is represented by the index of thePaymentSummary.getGatewayType()in the givenprioritizedPaymentGatewayTypes.protected OrderOperationPaymentPropertiesprotected intgetRefundPriority(PaymentSummary payment) Deprecated.protected StringgetTenantIdFromContext(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) voidsetOrderOperationPaymentProperties(OrderOperationPaymentProperties orderOperationPaymentProperties) protected List<PaymentSummary>sortByPaymentGatewayPriority(BiFunction<String, String, List<String>> paymentGatewayPrioritiesGetter, List<PaymentSummary> payments, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Sorts the givenPaymentSummariesbased on the payment gateway priorities.sortByPaymentGatewayPriorityForCancelFulfillment(List<PaymentSummary> payments, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Given a list ofPaymentSummaries, sorts them in order of which should be refunded or reversed first when the fulfillment is cancelled.sortByPaymentGatewayPriorityForCapture(List<PaymentSummary> payments, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Given a list ofPaymentSummaries, sorts them in order of which should be executed first.sortByPaymentGatewayPriorityForRefund(List<PaymentSummary> payments, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Given a list ofPaymentSummaries, sorts them in order of which should be executed first.sortByRefundPriority(List<PaymentSummary> payments) Deprecated.
-
Field Details
-
FIRST
protected static final int FIRST- See Also:
-
LAST
protected static final int LAST- See Also:
-
-
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:PaymentPriorityStrategyGiven a list ofPaymentSummaries, sorts them in order of which should be executed first.- Specified by:
sortByPaymentGatewayPriorityForCapturein interfacePaymentPriorityStrategy- Parameters:
payments- the payments to sortcontextInfo- context information surrounding sandboxing and multitenant state- Returns:
- a new list representing the sorted result. Will be empty if
paymentsis 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:PaymentPriorityStrategyGiven a list ofPaymentSummaries, sorts them in order of which should be executed first.- Specified by:
sortByPaymentGatewayPriorityForRefundin interfacePaymentPriorityStrategy- Parameters:
payments- the payments to sortcontextInfo- context information surrounding sandboxing and multitenant state- Returns:
- a new list representing the sorted result. Will be empty if
paymentsis 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:PaymentPriorityStrategyGiven a list ofPaymentSummaries, 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:
sortByPaymentGatewayPriorityForCancelFulfillmentin interfacePaymentPriorityStrategy- Parameters:
payments- the payments to sortcontextInfo- context information surrounding sandboxing and multitenant state- Returns:
- a new list representing the sorted result. Will be empty if
paymentsis 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 givenPaymentSummariesbased 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 prioritiespayments- thePaymentSummariesto sortcontextInfo- 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 givenPaymentSummary, which is represented by the index of thePaymentSummary.getGatewayType()in the givenprioritizedPaymentGatewayTypes.- Parameters:
prioritizedPaymentGatewayTypes- an ordered list of payment gateway types representing the priorities of the payment gateways based on its indexpayment- thePaymentSummaryto get the priority for- Returns:
- the priority of the given
PaymentSummary, which is represented by the index of thePaymentSummary.getGatewayType()
-
sortByRefundPriority
Deprecated.Description copied from interface:PaymentPriorityStrategyGiven a list ofPaymentSummaries, sorts them in order of which should be refunded first.- Specified by:
sortByRefundPriorityin interfacePaymentPriorityStrategy- Parameters:
payments- the payments to sort- Returns:
- a new list representing the sorted result. Will be empty if
paymentsis null or empty.
-
getRefundPriority
Deprecated.since 1.7.2, in favor ofgetGatewayPriority(List, PaymentSummary) -
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
-
setOrderOperationPaymentProperties
@Autowired public void setOrderOperationPaymentProperties(OrderOperationPaymentProperties orderOperationPaymentProperties)
-
getGatewayPriority(List, PaymentSummary)