Class ExternalPaymentTransactionResultListener
java.lang.Object
com.broadleafcommerce.cartoperation.service.messaging.finalizecart.ExternalPaymentTransactionResultListener
Listens for
PaymentTransactionResultEvents for transactions
that were executed outside the Broadleaf ecosystem as part of a checkout interaction (e.g. some
3DS interactions and most HPP interactions). From there, it determines if the cart's payments
have successful checkout transactions matching the cart total. If so, then an event is sent to
finalize the cart. Note: This flow all requires that the cart status is
DefaultCartStatuses.AWAITING_PAYMENT_FINALIZATION, which should have been declared with
the initial checkout attempt.- Author:
- mariestandeven
-
Field Summary
FieldsModifier and TypeFieldDescriptionprotected final CartProviderprotected final CartOperationCheckoutPropertiesprotected final com.broadleafcommerce.common.messaging.service.IdempotentMessageConsumptionServiceprotected final PaymentProvider<PaymentSummary>protected final com.broadleafcommerce.common.extension.TypeFactory -
Constructor Summary
ConstructorsConstructorDescriptionExternalPaymentTransactionResultListener(com.broadleafcommerce.common.messaging.service.IdempotentMessageConsumptionService idempotentMessageConsumptionService, com.broadleafcommerce.common.extension.TypeFactory typeFactory, CartProvider cartProvider, PaymentProvider<PaymentSummary> paymentProvider, CartOperationCheckoutProperties checkoutProperties) -
Method Summary
Modifier and TypeMethodDescriptionprotected com.broadleafcommerce.data.tracking.core.context.ContextInfobuildUpdateContextInfoFromCart(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart) Builds aContextInfowithOperationType.UPDATEfrom the givenCart.protected booleancartPaymentAmountsMatchCartTotal(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Determines if all the payments for the givenCartadd up to cart's total.protected booleancheckIfTransactionTypeMatchesExpectedType(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull PaymentTransactionResultEvent transactionResultEvent, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected StringgetApplicationIdFromContext(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected CartProviderprotected CartOperationCheckoutPropertiesprotected StringgetCheckoutTransactionType(@NonNull String gatewayType, @NonNull String paymentType, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected com.broadleafcommerce.common.messaging.service.IdempotentMessageConsumptionServiceprotected PaymentProvider<PaymentSummary>protected StringgetTenantIdFromContext(com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected com.broadleafcommerce.common.extension.TypeFactoryvoidlisten(org.springframework.messaging.Message<PaymentTransactionResultEvent> message) protected voidprocessMessage(@NonNull org.springframework.messaging.Message<PaymentTransactionResultEvent> message) protected com.broadleafcommerce.cart.client.domain.CartretrieveCart(@NonNull PaymentTransactionResultEvent transactionResultEvent, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected booleanshouldFinalizeCart(@NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull PaymentTransactionResultEvent transactionResultEvent, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected booleanshouldProcessTransactionResult(@NonNull PaymentTransactionResultEvent transactionResultEvent, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo)
-
Field Details
-
idempotentMessageConsumptionService
protected final com.broadleafcommerce.common.messaging.service.IdempotentMessageConsumptionService idempotentMessageConsumptionService -
typeFactory
protected final com.broadleafcommerce.common.extension.TypeFactory typeFactory -
cartProvider
-
paymentProvider
-
checkoutProperties
-
-
Constructor Details
-
ExternalPaymentTransactionResultListener
public ExternalPaymentTransactionResultListener(com.broadleafcommerce.common.messaging.service.IdempotentMessageConsumptionService idempotentMessageConsumptionService, com.broadleafcommerce.common.extension.TypeFactory typeFactory, CartProvider cartProvider, PaymentProvider<PaymentSummary> paymentProvider, CartOperationCheckoutProperties checkoutProperties)
-
-
Method Details
-
listen
@StreamListener("externalPaymentTransactionResultInput") public void listen(org.springframework.messaging.Message<PaymentTransactionResultEvent> message) -
processMessage
protected void processMessage(@NonNull @NonNull org.springframework.messaging.Message<PaymentTransactionResultEvent> message) -
shouldProcessTransactionResult
protected boolean shouldProcessTransactionResult(@NonNull @NonNull PaymentTransactionResultEvent transactionResultEvent, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
retrieveCart
protected com.broadleafcommerce.cart.client.domain.Cart retrieveCart(@NonNull @NonNull PaymentTransactionResultEvent transactionResultEvent, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
shouldFinalizeCart
protected boolean shouldFinalizeCart(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull PaymentTransactionResultEvent transactionResultEvent, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
checkIfTransactionTypeMatchesExpectedType
protected boolean checkIfTransactionTypeMatchesExpectedType(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @NonNull @NonNull PaymentTransactionResultEvent transactionResultEvent, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
cartPaymentAmountsMatchCartTotal
protected boolean cartPaymentAmountsMatchCartTotal(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Determines if all the payments for the givenCartadd up to cart's total.If all the cart's payments have results but the amounts don't add up to cart's total, that means one or more payments failed, as failed transactions are excluded from the amounts in
PaymentSummary.- Parameters:
cart- theCartto check againstcontextInfo- context information around sandbox and multitenant state- Returns:
- true if all the payments for the given
Cartmatch the cart's total, otherwise false - Throws:
UnsupportedOperationException- if the checkout transaction type is not supported
-
getCheckoutTransactionType
-
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) -
buildUpdateContextInfoFromCart
protected com.broadleafcommerce.data.tracking.core.context.ContextInfo buildUpdateContextInfoFromCart(@NonNull @NonNull com.broadleafcommerce.cart.client.domain.Cart cart) Builds aContextInfowithOperationType.UPDATEfrom the givenCart.This is useful to make requests for
Cartin the correct context, since scheduled job itself doesn't have application context. This method makes it easier to achieve that rather than creating new endpoints for each operation to ignore application context.- Parameters:
cart- theCartto build the context info from- Returns:
- a
ContextInfowithOperationType.UPDATEfrom the givenCart
-
getIdempotentMessageConsumptionService
protected com.broadleafcommerce.common.messaging.service.IdempotentMessageConsumptionService getIdempotentMessageConsumptionService() -
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory() -
getCartProvider
-
getPaymentProvider
-
getCheckoutProperties
-