Class DefaultTransactionExecutionRequestValidator
java.lang.Object
com.broadleafcommerce.paymenttransaction.service.DefaultTransactionExecutionRequestValidator
- All Implemented Interfaces:
TransactionExecutionRequestValidator
public class DefaultTransactionExecutionRequestValidator
extends Object
implements TransactionExecutionRequestValidator
-
Field Summary
-
Constructor Summary
ConstructorDescriptionDefaultTransactionExecutionRequestValidator
(PaymentTransactionService<PaymentTransaction> paymentTransactionService, PaymentSummaryService paymentSummaryService, TransactionExecutionUtil transactionExecutionUtil) -
Method Summary
Modifier and TypeMethodDescriptionprotected String
buildInvalidParentTransactionTypeMessage
(@NonNull String transactionType, @NonNull PaymentTransaction parentTransaction, @NonNull String... expectedParentTransactionTypes) protected boolean
canTransactionAmountBeLessThanAvailableAmount
(TransactionExecutionRequest request, Payment payment) Deprecated, for removal: This API element is subject to removal in a future version.protected boolean
canTransactionAmountBeLessThanAvailableAmount
(TransactionExecutionRequest request, PaymentSummary paymentSummary) Determines if the transaction amount can be less than the available amount.protected javax.money.MonetaryAmount
getAmountAvailableForTransactionType
(@NonNull Payment payment, @NonNull String transactionType) Deprecated, for removal: This API element is subject to removal in a future version.protected javax.money.MonetaryAmount
getAmountAvailableForTransactionType
(@NonNull PaymentSummary paymentSummary, @NonNull String transactionType) protected PaymentSummaryService
protected PaymentTransactionService<PaymentTransaction>
protected TransactionExecutionUtil
void
validate
(@NonNull TransactionExecutionRequest request, @NonNull Payment payment, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Checks whether or not theTransactionExecutionRequest
is valid.protected void
validateParentTransaction
(@NonNull TransactionExecutionRequest request, @NonNull Payment payment) protected void
validateParentTransactionAmounts
(List<TransactionWithExecutableAmount> parentTransactionWithExecutableAmounts, @NonNull javax.money.MonetaryAmount transactionAmount) Validates the total amount from parent transactions is sufficient for the giventransactionAmount
.protected void
validateParentTransactionCurrency
(PaymentTransaction parentTransaction, @NonNull javax.money.MonetaryAmount transactionAmount) protected void
validateParentTransactionType
(PaymentTransaction parentTransaction, @NonNull String transactionType) protected void
validateSource
(@NonNull TransactionExecutionRequest request, @NonNull Payment payment, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected void
validateTransactionAmount
(@NonNull TransactionExecutionRequest request, @NonNull Payment payment) protected void
validateTransactionType
(@NonNull TransactionExecutionRequest request, @NonNull Payment payment, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
-
Field Details
-
TRANSACTION_AMOUNT_MUST_BE_POSITIVE
- See Also:
-
TRANSACTION_CURRENCY_MUST_MATCH_PAYMENT_CURRENCY
- See Also:
-
TRANSACTION_AMOUNT_MUST_BE_VALID_FOR_PAYMENT
- See Also:
-
TRANSACTION_AMOUNT_MUST_BE_EQUAL_TO_AVAILABLE
- See Also:
-
TRANSACTION_SOURCE_REQUIRED
- See Also:
-
TRANSACTION_SOURCE_ENTITY_TYPE_REQUIRED
- See Also:
-
TRANSACTION_SOURCE_ENTITY_ID_REQUIRED
- See Also:
-
DETACHED_CREDIT_AMOUNT_MUST_BE_LESS_THAN_OR_EQUAL_TO_THE_PARENT_TRANSACTION_AMOUNT
public static final String DETACHED_CREDIT_AMOUNT_MUST_BE_LESS_THAN_OR_EQUAL_TO_THE_PARENT_TRANSACTION_AMOUNT- See Also:
-
-
Constructor Details
-
DefaultTransactionExecutionRequestValidator
public DefaultTransactionExecutionRequestValidator(PaymentTransactionService<PaymentTransaction> paymentTransactionService, PaymentSummaryService paymentSummaryService, TransactionExecutionUtil transactionExecutionUtil)
-
-
Method Details
-
validate
public void validate(@NonNull @NonNull TransactionExecutionRequest request, @NonNull @NonNull Payment payment, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Description copied from interface:TransactionExecutionRequestValidator
Checks whether or not theTransactionExecutionRequest
is valid.- Specified by:
validate
in interfaceTransactionExecutionRequestValidator
- Parameters:
request
- TheTransactionExecutionRequest
to be checked.payment
- The relatedPayment
that the request will act against.contextInfo
- Context information related to multitenancy.
-
validateTransactionType
protected void validateTransactionType(@NonNull @NonNull TransactionExecutionRequest request, @NonNull @NonNull Payment payment, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
validateTransactionAmount
protected void validateTransactionAmount(@NonNull @NonNull TransactionExecutionRequest request, @NonNull @NonNull Payment payment) -
getAmountAvailableForTransactionType
@Deprecated(forRemoval=true) protected javax.money.MonetaryAmount getAmountAvailableForTransactionType(@NonNull @NonNull Payment payment, @NonNull @NonNull String transactionType) Deprecated, for removal: This API element is subject to removal in a future version. -
getAmountAvailableForTransactionType
protected javax.money.MonetaryAmount getAmountAvailableForTransactionType(@NonNull @NonNull PaymentSummary paymentSummary, @NonNull @NonNull String transactionType) -
canTransactionAmountBeLessThanAvailableAmount
@Deprecated(forRemoval=true) protected boolean canTransactionAmountBeLessThanAvailableAmount(TransactionExecutionRequest request, Payment payment) Deprecated, for removal: This API element is subject to removal in a future version.Determines if the transaction amount can be less than the available amount.- Parameters:
request
- theTransactionExecutionRequest
being validatedpayment
- thePayment
being executed against- Returns:
- true if the transaction can be less than the available amount, otherwise false
-
canTransactionAmountBeLessThanAvailableAmount
protected boolean canTransactionAmountBeLessThanAvailableAmount(TransactionExecutionRequest request, PaymentSummary paymentSummary) Determines if the transaction amount can be less than the available amount.- Parameters:
request
- theTransactionExecutionRequest
being validatedpaymentSummary
- thePaymentSummary
being executed against- Returns:
- true if the transaction can be less than the available amount, otherwise false
-
validateParentTransaction
protected void validateParentTransaction(@NonNull @NonNull TransactionExecutionRequest request, @NonNull @NonNull Payment payment) -
validateParentTransactionType
protected void validateParentTransactionType(PaymentTransaction parentTransaction, @NonNull @NonNull String transactionType) -
validateParentTransactionAmounts
protected void validateParentTransactionAmounts(List<TransactionWithExecutableAmount> parentTransactionWithExecutableAmounts, @NonNull @NonNull javax.money.MonetaryAmount transactionAmount) Validates the total amount from parent transactions is sufficient for the giventransactionAmount
.- Parameters:
parentTransactionWithExecutableAmounts
- A list ofTransactionWithExecutableAmounts
representing all the parent transactions.transactionAmount
- The amount to validate- See Also:
-
validateParentTransactionCurrency
protected void validateParentTransactionCurrency(PaymentTransaction parentTransaction, @NonNull @NonNull javax.money.MonetaryAmount transactionAmount) -
buildInvalidParentTransactionTypeMessage
protected String buildInvalidParentTransactionTypeMessage(@NonNull @NonNull String transactionType, @NonNull @NonNull PaymentTransaction parentTransaction, @NonNull @NonNull String... expectedParentTransactionTypes) -
validateSource
protected void validateSource(@NonNull @NonNull TransactionExecutionRequest request, @NonNull @NonNull Payment payment, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
getPaymentTransactionService
-
getPaymentSummaryService
-
getTransactionExecutionUtil
-
canTransactionAmountBeLessThanAvailableAmount(TransactionExecutionRequest, PaymentSummary)