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
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefaultPaymentSummaryService(com.broadleafcommerce.paymentgateway.service.provider.PaymentGatewayResourceProvider paymentGatewayResourceProvider, com.broadleafcommerce.common.extension.TypeFactory typeFactory) -
Method Summary
Modifier and TypeMethodDescriptionprotected PaymentSummarybuildBasePaymentSummary(Payment payment) Builds the basePaymentSummaryfrom the givenPayment.buildPaymentSummary(@NonNull Payment payment, @NonNull Set<String> sourceEntityTypes) DeterminesPaymentSummarybased on thePayment'sPaymentTransactionsand the givenPaymentTransaction.getSourceEntityType()andPaymentTransaction.getSourceEntityId().buildPaymentSummary(@NonNull Payment payment, String sourceEntityType, String sourceEntityId) DeterminesPaymentSummarybased on thePayment'sPaymentTransactionsand the givenPaymentTransaction.getSourceEntityType()andPaymentTransaction.getSourceEntityId().protected javax.money.MonetaryAmountdetermineAmountAwaiting3DSResults(@NonNull PaymentSummary paymentSummary, @NonNull List<PaymentTransaction> transactions) Determines the amount awaiting 3DS results.protected javax.money.MonetaryAmountdetermineAmountAwaitingExternalResults(@NonNull PaymentSummary paymentSummary, @NonNull List<PaymentTransaction> transactions) Determines the amount awaiting external results.protected javax.money.MonetaryAmountdetermineAuthorizeAmountAwaitingResult(@NonNull PaymentSummary paymentSummary, @NonNull List<PaymentTransaction> transactions) Determines the authorize amount awaiting payment gateway result from the payment transactions.protected javax.money.MonetaryAmountdetermineAuthorizedAmount(@NonNull PaymentSummary paymentSummary, @NonNull List<PaymentTransaction> transactions) Determines the authorized amount of the payment transactions - "total authorized - total reverse-authed".protected javax.money.MonetaryAmountdetermineCaptureAmountAwaitingResult(@NonNull PaymentSummary paymentSummary, @NonNull List<PaymentTransaction> transactions) Determines the capture amount awaiting payment gateway result from the payment transactions.protected javax.money.MonetaryAmountdetermineCapturedAmount(@NonNull PaymentSummary paymentSummary, @NonNull List<PaymentTransaction> transactions) Determines the captured amount of the payment transactions - "total captured - total refunded".protected javax.money.MonetaryAmountdetermineDetachedCreditAmount(@NonNull PaymentSummary paymentSummary, @NonNull List<PaymentTransaction> transactions) Determines the detached amount of the payment transactions.protected javax.money.MonetaryAmountdetermineRefundAmountAwaitingResult(@NonNull PaymentSummary paymentSummary, @NonNull List<PaymentTransaction> transactions) Determines the refund amount awaiting payment gateway result from the payment transactions.protected javax.money.MonetaryAmountdetermineRefundedAmount(@NonNull PaymentSummary paymentSummary, @NonNull List<PaymentTransaction> transactions) Determines the refunded amount of the payment transactions.protected javax.money.MonetaryAmountdetermineReverseAuthAmountAwaitingResult(@NonNull PaymentSummary paymentSummary, @NonNull List<PaymentTransaction> transactions) Determines the reverse authorize amount awaiting payment gateway result from the payment transactions.protected javax.money.MonetaryAmountdetermineTotalEverCaptured(@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.PaymentGatewayResourceProviderprotected StringgetTenantId(@NonNull Payment payment) protected com.broadleafcommerce.common.extension.TypeFactoryprotected booleanhasTransactionFlaggedForManualReview(@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 booleanisDetachedCreditActingAsRefund(@NonNull PaymentTransaction transaction) protected booleanisPartialReverseAuthSupported(@NonNull Payment payment) protected booleanisReverseAuthRemainder(@NonNull Payment payment) protected voidsetNextActionIfNeeded(@NonNull PaymentSummary paymentSummary, @NonNull List<PaymentTransaction> transactions, String tenantId) Sets thePaymentSummary.getNextAction()for thePaymentTransaction.getNextAction()if exists.protected voidupdatePaymentSummaryForAmountAwaiting3DSResults(PaymentSummary paymentSummary, List<PaymentTransaction> transactions) UpdatePaymentSummaryforPaymentTransactionsthat are awaiting 3DS results.protected voidupdatePaymentSummaryForAmountAwaitingExternalResults(PaymentSummary paymentSummary, List<PaymentTransaction> transactions) UpdatePaymentSummaryforPaymentTransactionsthat are awaiting external results.protected voidupdatePaymentSummaryForPendingAmounts(PaymentSummary paymentSummary, List<PaymentTransaction> transactions) UpdatePaymentSummaryforPaymentTransactionsthat are awaiting async results or 3DS results.protected voidupdatePaymentSummaryProcessedAmounts(PaymentSummary paymentSummary, List<PaymentTransaction> nonReversedTransactions) UpdatePaymentSummaryforPaymentTransactionsthat are successful.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods 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:PaymentSummaryServiceDeterminesPaymentSummarybased on thePayment'sPaymentTransactionsand the givenPaymentTransaction.getSourceEntityType()andPaymentTransaction.getSourceEntityId().- Specified by:
buildPaymentSummaryin 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:PaymentSummaryServiceDeterminesPaymentSummarybased on thePayment'sPaymentTransactionsand the givenPaymentTransaction.getSourceEntityType()andPaymentTransaction.getSourceEntityId().- Specified by:
buildPaymentSummaryin 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) UpdatePaymentSummaryforPaymentTransactionsthat are awaiting 3DS results.- Parameters:
paymentSummary- thePaymentSummaryto updatetransactions- thePaymentTransactions
-
updatePaymentSummaryForAmountAwaitingExternalResults
protected void updatePaymentSummaryForAmountAwaitingExternalResults(PaymentSummary paymentSummary, List<PaymentTransaction> transactions) UpdatePaymentSummaryforPaymentTransactionsthat are awaiting external results.- Parameters:
paymentSummary- thePaymentSummaryto 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- thePaymentSummaryto updatetransactions- thePaymentTransactionstenantId- 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- thePaymentSummaryowning the provided transactionstransactions- thePaymentTransactionstenantId- 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) UpdatePaymentSummaryforPaymentTransactionsthat are successful.- Parameters:
paymentSummary- thePaymentSummaryto updatenonReversedTransactions- the non-reversed or reversalPaymentTransactions
-
updatePaymentSummaryForPendingAmounts
protected void updatePaymentSummaryForPendingAmounts(PaymentSummary paymentSummary, List<PaymentTransaction> transactions) UpdatePaymentSummaryforPaymentTransactionsthat are awaiting async results or 3DS results.- Parameters:
paymentSummary- thePaymentSummaryto 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 thePaymentTransactionsbyPaymentTransaction.getSourceEntityType()andPaymentTransaction.getSourceEntityId().- Parameters:
transactions- thePaymentTransactionsto filtersourceEntityType- thePaymentTransaction.getSourceEntityType()to filter bysourceEntityId- thePaymentTransaction.getSourceEntityId()to filter by- Returns:
- the
PaymentTransactionsmatching the givenPaymentTransaction.getSourceEntityType()andPaymentTransaction.getSourceEntityId().
-
filterByTransactionSourceEntityTypes
protected List<PaymentTransaction> filterByTransactionSourceEntityTypes(List<PaymentTransaction> transactions, Set<String> sourceEntityTypes) Filters thePaymentTransactionsbyPaymentTransaction.getSourceEntityType()andPaymentTransaction.getSourceEntityId().- Parameters:
transactions- thePaymentTransactionsto filtersourceEntityTypes- the set ofPaymentTransaction.getSourceEntityType()to filter by- Returns:
- the
PaymentTransactionsmatching the givenPaymentTransaction.getSourceEntityType()andPaymentTransaction.getSourceEntityId().
-
buildBasePaymentSummary
Builds the basePaymentSummaryfrom the givenPayment.- Parameters:
payment- thePaymentto build thePaymentSummaryfrom- Returns:
- the base
PaymentSummaryfrom 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- thePaymentSummaryfor 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- thePaymentSummaryfor 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- thePaymentSummaryfor 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.CAPTUREorDefaultTransactionTypes.AUTHORIZE_AND_CAPTUREtype the detached amount is skipped and will be added toPaymentSummary.getAmountRefunded().- Parameters:
paymentSummary- thePaymentSummaryfor 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_CREDITtransaction with theDefaultTransactionTypes.CAPTUREorDefaultTransactionTypes.AUTHORIZE_AND_CAPTUREparent transaction the detached amount will be included in refunded amount.- Parameters:
paymentSummary- thePaymentSummaryfor 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- thePaymentSummaryfor 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- thePaymentSummaryfor 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- thePaymentSummaryfor 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- thePaymentSummaryfor 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- thePaymentSummaryfor 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- thePaymentSummaryfor 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()
-