Class DefaultPaymentPriorityStrategy
java.lang.Object
com.broadleafcommerce.orderoperation.service.payment.DefaultPaymentPriorityStrategy
- All Implemented Interfaces:
PaymentPriorityStrategy
- Author:
- Samarth Dhruva (samarthd), Sunny Yu
-
Field Summary
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprotected String
getApplicationIdFromContext
(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) 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
.protected OrderOperationPaymentProperties
protected int
getRefundPriority
(PaymentSummary payment) Deprecated.protected String
getTenantIdFromContext
(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) void
setOrderOperationPaymentProperties
(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 givenPaymentSummaries
based 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:PaymentPriorityStrategy
Given a list ofPaymentSummaries
, sorts them in order of which should be executed first.- Specified by:
sortByPaymentGatewayPriorityForCapture
in 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
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 ofPaymentSummaries
, sorts them in order of which should be executed first.- Specified by:
sortByPaymentGatewayPriorityForRefund
in 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
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 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:
sortByPaymentGatewayPriorityForCancelFulfillment
in 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
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 givenPaymentSummaries
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 prioritiespayments
- thePaymentSummaries
to 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
- thePaymentSummary
to 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:PaymentPriorityStrategy
Given a list ofPaymentSummaries
, sorts them in order of which should be refunded first.- Specified by:
sortByRefundPriority
in interfacePaymentPriorityStrategy
- 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.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)