Class DefaultPaymentSummaryService
java.lang.Object
com.broadleafcommerce.paymenttransaction.service.summary.DefaultPaymentSummaryService
- All Implemented Interfaces:
PaymentSummaryService
Default implementation of the
PaymentSummaryService
.- Author:
- Dima Myroniuk (dmyroniuk)
-
Field Summary
-
Constructor Summary
ConstructorDescriptionDefaultPaymentSummaryService
(com.broadleafcommerce.paymentgateway.service.provider.PaymentGatewayResourceProvider paymentGatewayResourceProvider, com.broadleafcommerce.common.extension.TypeFactory typeFactory) -
Method Summary
Modifier and TypeMethodDescriptionprotected PaymentSummary
buildBasePaymentSummary
(Payment payment) Builds the basePaymentSummary
from the givenPayment
.buildPaymentSummary
(@NonNull Payment payment, @NonNull Set<String> sourceEntityTypes) DeterminesPaymentSummary
based on thePayment's
PaymentTransactions
and the givenPaymentTransaction.getSourceEntityType()
andPaymentTransaction.getSourceEntityId()
.buildPaymentSummary
(@NonNull Payment payment, String sourceEntityType, String sourceEntityId) DeterminesPaymentSummary
based on thePayment's
PaymentTransactions
and the givenPaymentTransaction.getSourceEntityType()
andPaymentTransaction.getSourceEntityId()
.protected javax.money.MonetaryAmount
determineAmountAwaiting3DSResults
(@NonNull PaymentSummary paymentSummary, @NonNull List<PaymentTransaction> transactions) Determines the amount awaiting 3DS results.protected javax.money.MonetaryAmount
determineAmountAwaitingExternalResults
(@NonNull PaymentSummary paymentSummary, @NonNull List<PaymentTransaction> transactions) Determines the amount awaiting external results.protected javax.money.MonetaryAmount
determineAuthorizeAmountAwaitingResult
(@NonNull PaymentSummary paymentSummary, @NonNull List<PaymentTransaction> transactions) Determines the authorize amount awaiting payment gateway result from the payment transactions.protected javax.money.MonetaryAmount
determineAuthorizedAmount
(@NonNull PaymentSummary paymentSummary, @NonNull List<PaymentTransaction> transactions) Determines the authorized amount of the payment transactions - "total authorized - total reverse-authed".protected javax.money.MonetaryAmount
determineCaptureAmountAwaitingResult
(@NonNull PaymentSummary paymentSummary, @NonNull List<PaymentTransaction> transactions) Determines the capture amount awaiting payment gateway result from the payment transactions.protected javax.money.MonetaryAmount
determineCapturedAmount
(@NonNull PaymentSummary paymentSummary, @NonNull List<PaymentTransaction> transactions) Determines the captured amount of the payment transactions - "total captured - total refunded".protected javax.money.MonetaryAmount
determineDetachedCreditAmount
(@NonNull PaymentSummary paymentSummary, @NonNull List<PaymentTransaction> transactions) Determines the detached amount of the payment transactions.protected javax.money.MonetaryAmount
determineRefundAmountAwaitingResult
(@NonNull PaymentSummary paymentSummary, @NonNull List<PaymentTransaction> transactions) Determines the refund amount awaiting payment gateway result from the payment transactions.protected javax.money.MonetaryAmount
determineRefundedAmount
(@NonNull PaymentSummary paymentSummary, @NonNull List<PaymentTransaction> transactions) Determines the refunded amount of the payment transactions.protected javax.money.MonetaryAmount
determineReverseAuthAmountAwaitingResult
(@NonNull PaymentSummary paymentSummary, @NonNull List<PaymentTransaction> transactions) Determines the reverse authorize amount awaiting payment gateway result from the payment transactions.protected javax.money.MonetaryAmount
determineTotalEverCaptured
(@NonNull PaymentSummary paymentSummary, @NonNull List<PaymentTransaction> transactions) Determines the total amount ever captured by the payment transactions.protected List<PaymentTransaction>
filterByTransactionSourceEntity
(@NonNull List<PaymentTransaction> transactions, String sourceEntityType, String sourceEntityId) protected List<PaymentTransaction>
filterByTransactionSourceEntityTypes
(List<PaymentTransaction> transactions, Set<String> sourceEntityTypes) protected List<PaymentTransaction>
filterOutNonSuccessfulAndReversedTransactions
(@NonNull List<PaymentTransaction> transactions) protected com.broadleafcommerce.paymentgateway.service.provider.PaymentGatewayResourceProvider
protected String
getTenantId
(@NonNull Payment payment) protected com.broadleafcommerce.common.extension.TypeFactory
protected boolean
hasTransactionFlaggedForManualReview
(@NonNull List<PaymentTransaction> filteredTransactions) protected Optional<PaymentTransaction>
identifyTransactionRequiringNextAction
(@NonNull PaymentSummary paymentSummary, @NonNull List<PaymentTransaction> transactions, String tenantId) Returns the list of transactions that requires to execute theNextAction
.protected boolean
isDetachedCreditActingAsRefund
(@NonNull PaymentTransaction transaction) protected boolean
isPartialReverseAuthSupported
(@NonNull Payment payment) protected boolean
isReverseAuthRemainder
(@NonNull Payment payment) protected void
setNextActionIfNeeded
(@NonNull PaymentSummary paymentSummary, @NonNull List<PaymentTransaction> transactions, String tenantId) Sets thePaymentSummary.getNextAction()
for thePaymentTransaction.getNextAction()
if exists.protected void
updatePaymentSummaryForAmountAwaiting3DSResults
(PaymentSummary paymentSummary, List<PaymentTransaction> transactions) UpdatePaymentSummary
forPaymentTransactions
that are awaiting 3DS results.protected void
updatePaymentSummaryForAmountAwaitingExternalResults
(PaymentSummary paymentSummary, List<PaymentTransaction> transactions) UpdatePaymentSummary
forPaymentTransactions
that are awaiting external results.protected void
updatePaymentSummaryForPendingAmounts
(PaymentSummary paymentSummary, List<PaymentTransaction> transactions) UpdatePaymentSummary
forPaymentTransactions
that are awaiting async results or 3DS results.protected void
updatePaymentSummaryProcessedAmounts
(PaymentSummary paymentSummary, List<PaymentTransaction> nonReversedTransactions) UpdatePaymentSummary
forPaymentTransactions
that are successful.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface com.broadleafcommerce.paymenttransaction.service.summary.PaymentSummaryService
buildPaymentSummaries, buildPaymentSummary
-
Field Details
-
CREDIT_ACCOUNT_NUMBER_ATTR_NAME
- See Also:
-
-
Constructor Details
-
DefaultPaymentSummaryService
public DefaultPaymentSummaryService(com.broadleafcommerce.paymentgateway.service.provider.PaymentGatewayResourceProvider paymentGatewayResourceProvider, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-
-
Method Details
-
buildPaymentSummary
public PaymentSummary buildPaymentSummary(@NonNull @NonNull Payment payment, @Nullable String sourceEntityType, @Nullable String sourceEntityId) Description copied from interface:PaymentSummaryService
DeterminesPaymentSummary
based on thePayment's
PaymentTransactions
and the givenPaymentTransaction.getSourceEntityType()
andPaymentTransaction.getSourceEntityId()
.- Specified by:
buildPaymentSummary
in interfacePaymentSummaryService
- Parameters:
payment
- the payment to determine the summarysourceEntityType
- thePaymentTransaction.getSourceEntityType()
to filter thePayment.getTransactions()
bysourceEntityId
- thePaymentTransaction.getSourceEntityId()
to filter thePayment.getTransactions()
by- Returns:
- the payment summary for the specified payment
-
buildPaymentSummary
public PaymentSummary buildPaymentSummary(@NonNull @NonNull Payment payment, @NonNull @NonNull Set<String> sourceEntityTypes) Description copied from interface:PaymentSummaryService
DeterminesPaymentSummary
based on thePayment's
PaymentTransactions
and the givenPaymentTransaction.getSourceEntityType()
andPaymentTransaction.getSourceEntityId()
.- Specified by:
buildPaymentSummary
in interfacePaymentSummaryService
- Parameters:
payment
- the payment to determine the summarysourceEntityTypes
- the set ofPaymentTransaction.getSourceEntityType()
to filter thePayment.getTransactions()
by- Returns:
- the payment summary for the specified payment
-
updatePaymentSummaryForAmountAwaiting3DSResults
protected void updatePaymentSummaryForAmountAwaiting3DSResults(PaymentSummary paymentSummary, List<PaymentTransaction> transactions) UpdatePaymentSummary
forPaymentTransactions
that are awaiting 3DS results.- Parameters:
paymentSummary
- thePaymentSummary
to updatetransactions
- thePaymentTransactions
-
updatePaymentSummaryForAmountAwaitingExternalResults
protected void updatePaymentSummaryForAmountAwaitingExternalResults(PaymentSummary paymentSummary, List<PaymentTransaction> transactions) UpdatePaymentSummary
forPaymentTransactions
that are awaiting external results.- Parameters:
paymentSummary
- thePaymentSummary
to updatetransactions
- thePaymentTransactions
-
setNextActionIfNeeded
protected void setNextActionIfNeeded(@NonNull @NonNull PaymentSummary paymentSummary, @NonNull @NonNull List<PaymentTransaction> transactions, @Nullable String tenantId) Sets thePaymentSummary.getNextAction()
for thePaymentTransaction.getNextAction()
if exists.- Parameters:
paymentSummary
- thePaymentSummary
to updatetransactions
- thePaymentTransactions
tenantId
- the id of the payment's tenant
-
identifyTransactionRequiringNextAction
protected Optional<PaymentTransaction> identifyTransactionRequiringNextAction(@NonNull @NonNull PaymentSummary paymentSummary, @NonNull @NonNull List<PaymentTransaction> transactions, @Nullable String tenantId) Returns the list of transactions that requires to execute theNextAction
.- Parameters:
paymentSummary
- thePaymentSummary
owning the provided transactionstransactions
- thePaymentTransactions
tenantId
- the id of the payment's tenant- Returns:
- the list of transactions that requires to execute the
NextAction
-
updatePaymentSummaryProcessedAmounts
protected void updatePaymentSummaryProcessedAmounts(PaymentSummary paymentSummary, List<PaymentTransaction> nonReversedTransactions) UpdatePaymentSummary
forPaymentTransactions
that are successful.- Parameters:
paymentSummary
- thePaymentSummary
to updatenonReversedTransactions
- the non-reversed or reversalPaymentTransactions
-
updatePaymentSummaryForPendingAmounts
protected void updatePaymentSummaryForPendingAmounts(PaymentSummary paymentSummary, List<PaymentTransaction> transactions) UpdatePaymentSummary
forPaymentTransactions
that are awaiting async results or 3DS results.- Parameters:
paymentSummary
- thePaymentSummary
to updatetransactions
- thePaymentTransactions
-
filterOutNonSuccessfulAndReversedTransactions
protected List<PaymentTransaction> filterOutNonSuccessfulAndReversedTransactions(@NonNull @NonNull List<PaymentTransaction> transactions) -
filterByTransactionSourceEntity
protected List<PaymentTransaction> filterByTransactionSourceEntity(@NonNull @NonNull List<PaymentTransaction> transactions, @Nullable String sourceEntityType, @Nullable String sourceEntityId) Filters thePaymentTransactions
byPaymentTransaction.getSourceEntityType()
andPaymentTransaction.getSourceEntityId()
.- Parameters:
transactions
- thePaymentTransactions
to filtersourceEntityType
- thePaymentTransaction.getSourceEntityType()
to filter bysourceEntityId
- thePaymentTransaction.getSourceEntityId()
to filter by- Returns:
- the
PaymentTransactions
matching the givenPaymentTransaction.getSourceEntityType()
andPaymentTransaction.getSourceEntityId()
.
-
filterByTransactionSourceEntityTypes
protected List<PaymentTransaction> filterByTransactionSourceEntityTypes(List<PaymentTransaction> transactions, Set<String> sourceEntityTypes) Filters thePaymentTransactions
byPaymentTransaction.getSourceEntityType()
andPaymentTransaction.getSourceEntityId()
.- Parameters:
transactions
- thePaymentTransactions
to filtersourceEntityTypes
- the set ofPaymentTransaction.getSourceEntityType()
to filter by- Returns:
- the
PaymentTransactions
matching the givenPaymentTransaction.getSourceEntityType()
andPaymentTransaction.getSourceEntityId()
.
-
buildBasePaymentSummary
Builds the basePaymentSummary
from the givenPayment
.- Parameters:
payment
- thePayment
to build thePaymentSummary
from- Returns:
- the base
PaymentSummary
from the givenPayment
-
isPartialReverseAuthSupported
-
isReverseAuthRemainder
-
determineAuthorizedAmount
protected javax.money.MonetaryAmount determineAuthorizedAmount(@NonNull @NonNull PaymentSummary paymentSummary, @NonNull @NonNull List<PaymentTransaction> transactions) Determines the authorized amount of the payment transactions - "total authorized - total reverse-authed".- Parameters:
paymentSummary
- thePaymentSummary
for the paymenttransactions
- the payment transactions- Returns:
- the authorized amount of the payment transactions
-
determineCapturedAmount
protected javax.money.MonetaryAmount determineCapturedAmount(@NonNull @NonNull PaymentSummary paymentSummary, @NonNull @NonNull List<PaymentTransaction> transactions) Determines the captured amount of the payment transactions - "total captured - total refunded".- Parameters:
paymentSummary
- thePaymentSummary
for the paymenttransactions
- the payment transactions- Returns:
- the captured amount of the payment transactions
-
determineTotalEverCaptured
protected javax.money.MonetaryAmount determineTotalEverCaptured(@NonNull @NonNull PaymentSummary paymentSummary, @NonNull @NonNull List<PaymentTransaction> transactions) Determines the total amount ever captured by the payment transactions.- Parameters:
paymentSummary
- thePaymentSummary
for the paymenttransactions
- the payment transactions- Returns:
- the total amount ever captured by the payment transactions
-
determineDetachedCreditAmount
protected javax.money.MonetaryAmount determineDetachedCreditAmount(@NonNull @NonNull PaymentSummary paymentSummary, @NonNull @NonNull List<PaymentTransaction> transactions) Determines the detached amount of the payment transactions. If the transaction has the parent transaction withDefaultTransactionTypes.CAPTURE
orDefaultTransactionTypes.AUTHORIZE_AND_CAPTURE
type the detached amount is skipped and will be added toPaymentSummary.getAmountRefunded()
.- Parameters:
paymentSummary
- thePaymentSummary
for the paymenttransactions
- the payment transactions- Returns:
- the detached amount of the payment transactions
-
determineRefundedAmount
protected javax.money.MonetaryAmount determineRefundedAmount(@NonNull @NonNull PaymentSummary paymentSummary, @NonNull @NonNull List<PaymentTransaction> transactions) Determines the refunded amount of the payment transactions. If there is theDefaultTransactionTypes.DETACHED_CREDIT
transaction with theDefaultTransactionTypes.CAPTURE
orDefaultTransactionTypes.AUTHORIZE_AND_CAPTURE
parent transaction the detached amount will be included in refunded amount.- Parameters:
paymentSummary
- thePaymentSummary
for the paymenttransactions
- the payment transactions- Returns:
- the refunded amount of the payment transactions
-
determineAmountAwaiting3DSResults
protected javax.money.MonetaryAmount determineAmountAwaiting3DSResults(@NonNull @NonNull PaymentSummary paymentSummary, @NonNull @NonNull List<PaymentTransaction> transactions) Determines the amount awaiting 3DS results.- Parameters:
paymentSummary
- thePaymentSummary
for the paymenttransactions
- the payment's collection of transactions- Returns:
- the amount awaiting 3DS results.
-
determineAmountAwaitingExternalResults
protected javax.money.MonetaryAmount determineAmountAwaitingExternalResults(@NonNull @NonNull PaymentSummary paymentSummary, @NonNull @NonNull List<PaymentTransaction> transactions) Determines the amount awaiting external results.- Parameters:
paymentSummary
- thePaymentSummary
for the paymenttransactions
- the payment's collection of transactions- Returns:
- the amount awaiting external results.
-
determineAuthorizeAmountAwaitingResult
protected javax.money.MonetaryAmount determineAuthorizeAmountAwaitingResult(@NonNull @NonNull PaymentSummary paymentSummary, @NonNull @NonNull List<PaymentTransaction> transactions) Determines the authorize amount awaiting payment gateway result from the payment transactions.- Parameters:
paymentSummary
- thePaymentSummary
for the paymenttransactions
- the payment transactions- Returns:
- the authorize amount awaiting payment gateway result from the payment transactions
-
determineCaptureAmountAwaitingResult
protected javax.money.MonetaryAmount determineCaptureAmountAwaitingResult(@NonNull @NonNull PaymentSummary paymentSummary, @NonNull @NonNull List<PaymentTransaction> transactions) Determines the capture amount awaiting payment gateway result from the payment transactions.- Parameters:
paymentSummary
- thePaymentSummary
for the paymenttransactions
- the payment transactions- Returns:
- the capture amount awaiting payment gateway result from the payment transactions
-
determineReverseAuthAmountAwaitingResult
protected javax.money.MonetaryAmount determineReverseAuthAmountAwaitingResult(@NonNull @NonNull PaymentSummary paymentSummary, @NonNull @NonNull List<PaymentTransaction> transactions) Determines the reverse authorize amount awaiting payment gateway result from the payment transactions.- Parameters:
paymentSummary
- thePaymentSummary
for the paymenttransactions
- the payment transactions- Returns:
- the reverse authorize amount awaiting payment gateway result from the payment transactions
-
determineRefundAmountAwaitingResult
protected javax.money.MonetaryAmount determineRefundAmountAwaitingResult(@NonNull @NonNull PaymentSummary paymentSummary, @NonNull @NonNull List<PaymentTransaction> transactions) Determines the refund amount awaiting payment gateway result from the payment transactions.- Parameters:
paymentSummary
- thePaymentSummary
for the paymenttransactions
- the payment transactions- Returns:
- the refund amount awaiting payment gateway result from the payment transactions
-
isDetachedCreditActingAsRefund
-
hasTransactionFlaggedForManualReview
protected boolean hasTransactionFlaggedForManualReview(@NonNull @NonNull List<PaymentTransaction> filteredTransactions) -
getTenantId
-
getPaymentGatewayResourceProvider
protected com.broadleafcommerce.paymentgateway.service.provider.PaymentGatewayResourceProvider getPaymentGatewayResourceProvider() -
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
-