Class DefaultTransactionWebhookService
java.lang.Object
com.broadleafcommerce.paymenttransaction.service.webhook.DefaultTransactionWebhookService
- All Implemented Interfaces:
TransactionWebhookService
The default implementation of
TransactionWebhookService
- Author:
- Dima Myroniuk (dmyroniuk)
-
Constructor Summary
ConstructorDescriptionDefaultTransactionWebhookService
(com.broadleafcommerce.paymentgateway.service.provider.PaymentGatewayResourceProvider paymentGatewayResourceProvider, PaymentService<Payment> paymentService, PaymentTransactionService<PaymentTransaction> paymentTransactionService, PaymentLockService<Payment> paymentLockService, TransactionExecutionService transactionExecutionService, TransactionWebhookMessageService transactionWebhookMessageService, com.fasterxml.jackson.databind.ObjectMapper objectMapper) -
Method Summary
Modifier and TypeMethodDescriptionprotected org.springframework.http.ResponseEntity<?>
buildErrorResponse
(com.broadleafcommerce.paymentgateway.service.PaymentGatewayWebhookHandler webhookHandler, @NonNull Exception e) protected PaymentTransaction
createChildTransactionAndRecordResponse
(@NonNull PaymentTransaction parentTransaction, @NonNull Payment payment, @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, @NonNull String managementStateReason, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected PaymentTransaction
createChildTransactionAndRecordResponse
(@NonNull PaymentTransaction parentTransaction, @NonNull Payment payment, @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected Optional<PaymentTransaction>
get3DSTransactionResult
(@NonNull Payment payment, @NonNull PaymentTransaction transactionRequiring3DS) protected Optional<PaymentTransaction>
getChildTransactionResult
(@NonNull Payment payment, @NonNull PaymentTransaction transactionRequiringExternalInteraction) protected com.broadleafcommerce.data.tracking.core.context.ContextInfo
getContextInfo
(@NonNull com.broadleafcommerce.paymentgateway.domain.TransactionIdentifier transactionIdentifier) protected com.fasterxml.jackson.databind.ObjectMapper
protected com.broadleafcommerce.paymentgateway.service.provider.PaymentGatewayResourceProvider
protected PaymentLockService<Payment>
protected PaymentService<Payment>
protected PaymentTransactionService<PaymentTransaction>
protected TransactionExecutionService
protected TransactionWebhookMessageService
protected com.broadleafcommerce.common.extension.TypeFactory
protected static String
protected static String
protected PaymentTransaction
handleAwaitingAsyncTransactionResult
(@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, @NonNull PaymentTransaction paymentTransaction, @NonNull Payment payment, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected PaymentTransaction
handleFraudReviewTransactionResult
(@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, @NonNull PaymentTransaction paymentTransaction, @NonNull Payment payment, @NonNull String eventId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected PaymentTransaction
handleHostedPaymentPageSetupTransactionResult
(@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, @NonNull PaymentTransaction paymentTransaction, @NonNull Payment payment, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected PaymentTransaction
handleSubsequentTransactionResult
(@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, @NonNull PaymentTransaction paymentTransaction, @NonNull Payment payment, @NonNull String eventId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected PaymentTransaction
handleThreeDSTransactionResult
(@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, @NonNull PaymentTransaction paymentTransaction, @NonNull Payment payment, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) org.springframework.http.ResponseEntity<?>
handleWebhook
(String gatewayType, @NonNull org.springframework.http.HttpHeaders headers, String requestBody, @NonNull Map<String, String> parameters) Handles the payment webhook request for the specified gateway type.protected PaymentTransaction
identifyParentTransaction
(@NonNull Payment payment, @NonNull PaymentTransaction paymentTransaction, @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse) protected Payment
identifyPaymentForTransaction
(com.broadleafcommerce.paymentgateway.domain.TransactionIdentifier transactionIdentifier, PaymentTransaction paymentTransaction, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected PaymentTransaction
identifyTransaction
(@NonNull com.broadleafcommerce.paymentgateway.domain.TransactionIdentifier transactionIdentifier, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected boolean
isFraudReviewResult
(@NonNull PaymentTransaction paymentTransaction, @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse) protected boolean
isHostedPaymentPageSetupTransaction
(@NonNull PaymentTransaction paymentTransaction) protected boolean
isNotificationTypeSupported
(@NonNull com.broadleafcommerce.paymentgateway.service.PaymentGatewayWebhookHandler webhookHandler, @NonNull com.broadleafcommerce.paymentgateway.domain.enums.SupportedWebhookNotificationType webhookNotificationType) protected boolean
isSubsequentTransactionAlreadyCreated
(@NonNull Payment payment, @NonNull String eventId) protected boolean
isSubsequentTransactionResult
(@NonNull Payment payment, @NonNull PaymentTransaction paymentTransaction, @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse) Determines if thePaymentResponse
results represent a subsequent transaction that was executed after the knownPaymentTransaction
.protected PaymentTransaction
recordFraudReviewResults
(@NonNull PaymentTransaction paymentTransaction, @NonNull Payment payment, @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Updates the providedPaymentTransaction
to indicate that the fraud review is finalized/closed & records the results of that review.protected PaymentTransaction
recordImpliedReverseAuth
(@NonNull Payment payment, @NonNull PaymentTransaction captureTransaction, @NonNull PaymentTransaction parentAuthTransaction, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected PaymentTransaction
recordImpliedReverseAuth
(@NonNull Payment payment, @NonNull PaymentTransaction captureTransaction, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected PaymentTransaction
recordSubsequentTransactionResults
(@NonNull PaymentTransaction parentTransaction, @NonNull Payment payment, @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, @NonNull String eventId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds & records aPaymentTransaction
based on thePaymentResponse
which has been identified as a subsequent transaction to the provided parent transaction.protected PaymentTransaction
recordTransactionResponse
(@NonNull PaymentTransaction paymentTransaction, @NonNull Payment payment, @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected void
sendTransactionWebhookMessage
(Payment payment, PaymentTransaction transaction, boolean transactionRequiredExternalInteraction, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) void
setTypeFactory
(com.broadleafcommerce.common.extension.TypeFactory typeFactory) protected boolean
shouldRecordImpliedReverseAuth
(@NonNull Payment payment, @NonNull PaymentTransaction captureTransaction) protected PaymentTransaction
updateChild3DSTransaction
(@NonNull PaymentTransaction threeDSResultTransaction, @NonNull Payment payment, @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Updates the child 3DS transaction based on the givenPaymentResponse
.protected PaymentTransaction
updateChildTransactionResults
(@NonNull PaymentTransaction externalTransactionResult, @NonNull Payment payment, @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, @NonNull String managementStateReason, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Updates the child external transaction based on the givenPaymentResponse
.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.webhook.TransactionWebhookService
handleWebhook
-
Constructor Details
-
DefaultTransactionWebhookService
public DefaultTransactionWebhookService(com.broadleafcommerce.paymentgateway.service.provider.PaymentGatewayResourceProvider paymentGatewayResourceProvider, PaymentService<Payment> paymentService, PaymentTransactionService<PaymentTransaction> paymentTransactionService, PaymentLockService<Payment> paymentLockService, TransactionExecutionService transactionExecutionService, TransactionWebhookMessageService transactionWebhookMessageService, com.fasterxml.jackson.databind.ObjectMapper objectMapper)
-
-
Method Details
-
handleWebhook
public org.springframework.http.ResponseEntity<?> handleWebhook(String gatewayType, @NonNull @NonNull org.springframework.http.HttpHeaders headers, String requestBody, @NonNull @NonNull Map<String, String> parameters) Description copied from interface:TransactionWebhookService
Handles the payment webhook request for the specified gateway type.- Specified by:
handleWebhook
in interfaceTransactionWebhookService
- Parameters:
gatewayType
- the gateway type that is used to identify the appropriatePaymentGatewayWebhookHandler
headers
- the webhook request headersrequestBody
- the webhook request bodyparameters
- the webhook request parameters- Returns:
- a
ResponseEntity
meant to communicate to the gateway with the processing result of the webhook.
-
handleHostedPaymentPageSetupTransactionResult
protected PaymentTransaction handleHostedPaymentPageSetupTransactionResult(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, @NonNull @NonNull PaymentTransaction paymentTransaction, @NonNull @NonNull Payment payment, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
handleThreeDSTransactionResult
protected PaymentTransaction handleThreeDSTransactionResult(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, @NonNull @NonNull PaymentTransaction paymentTransaction, @NonNull @NonNull Payment payment, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
handleAwaitingAsyncTransactionResult
protected PaymentTransaction handleAwaitingAsyncTransactionResult(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, @NonNull @NonNull PaymentTransaction paymentTransaction, @NonNull @NonNull Payment payment, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
handleSubsequentTransactionResult
protected PaymentTransaction handleSubsequentTransactionResult(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, @NonNull @NonNull PaymentTransaction paymentTransaction, @NonNull @NonNull Payment payment, @NonNull @NonNull String eventId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
handleFraudReviewTransactionResult
protected PaymentTransaction handleFraudReviewTransactionResult(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, @NonNull @NonNull PaymentTransaction paymentTransaction, @NonNull @NonNull Payment payment, @NonNull @NonNull String eventId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
isNotificationTypeSupported
protected boolean isNotificationTypeSupported(@NonNull @NonNull com.broadleafcommerce.paymentgateway.service.PaymentGatewayWebhookHandler webhookHandler, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.enums.SupportedWebhookNotificationType webhookNotificationType) -
isFraudReviewResult
protected boolean isFraudReviewResult(@NonNull @NonNull PaymentTransaction paymentTransaction, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse) -
recordFraudReviewResults
protected PaymentTransaction recordFraudReviewResults(@NonNull @NonNull PaymentTransaction paymentTransaction, @NonNull @NonNull Payment payment, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Updates the providedPaymentTransaction
to indicate that the fraud review is finalized/closed & records the results of that review.- Parameters:
paymentTransaction
- ThePaymentTransaction
transaction to be updated.payment
- ThePayment
that owns the payment transaction.paymentResponse
- ThePaymentResponse
describing the transaction's result.contextInfo
- context information related to multi-tenancy.- Returns:
- The updated
PaymentTransaction
.
-
isSubsequentTransactionResult
protected boolean isSubsequentTransactionResult(@NonNull @NonNull Payment payment, @NonNull @NonNull PaymentTransaction paymentTransaction, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse) Determines if thePaymentResponse
results represent a subsequent transaction that was executed after the knownPaymentTransaction
. If the transaction was triggered within PaymentTransactionServices, then the transaction types should be the same between thePaymentResponse
& thePaymentTransaction
. In that case, this method should return false. If the transaction was triggered outside of PaymentTransactionServices, but we have knowledge of a previous transaction (i.e. thePaymentTransaction
), then we need to record a newPaymentTransaction
for thisPaymentResponse
. In that case, this method should return true.- Parameters:
payment
- The payment owning thePaymentTransaction
paymentTransaction
- The knownPaymentTransaction
paymentResponse
- The transaction results- Returns:
- boolean declaring if the
PaymentResponse
results represent a subsequent transaction that was executed after the knownPaymentTransaction
.
-
identifyParentTransaction
protected PaymentTransaction identifyParentTransaction(@NonNull @NonNull Payment payment, @NonNull @NonNull PaymentTransaction paymentTransaction, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse) -
isSubsequentTransactionAlreadyCreated
-
recordSubsequentTransactionResults
protected PaymentTransaction recordSubsequentTransactionResults(@NonNull @NonNull PaymentTransaction parentTransaction, @NonNull @NonNull Payment payment, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, @NonNull @NonNull String eventId, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Builds & records aPaymentTransaction
based on thePaymentResponse
which has been identified as a subsequent transaction to the provided parent transaction.- Parameters:
parentTransaction
- The parent of the subsequent transaction.payment
- ThePayment
that owns the parent & subsequent transactions.paymentResponse
- ThePaymentResponse
describing the subsequent transaction's results.eventId
- The id of the webhook eventcontextInfo
- context information related to multi-tenancy.- Returns:
- The
PaymentTransaction
created to represent the subsequent transaction.
-
shouldRecordImpliedReverseAuth
protected boolean shouldRecordImpliedReverseAuth(@NonNull @NonNull Payment payment, @NonNull @NonNull PaymentTransaction captureTransaction) -
recordImpliedReverseAuth
protected PaymentTransaction recordImpliedReverseAuth(@NonNull @NonNull Payment payment, @NonNull @NonNull PaymentTransaction captureTransaction, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
recordImpliedReverseAuth
protected PaymentTransaction recordImpliedReverseAuth(@NonNull @NonNull Payment payment, @NonNull @NonNull PaymentTransaction captureTransaction, @NonNull @NonNull PaymentTransaction parentAuthTransaction, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
recordTransactionResponse
protected PaymentTransaction recordTransactionResponse(@NonNull @NonNull PaymentTransaction paymentTransaction, @NonNull @NonNull Payment payment, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
isHostedPaymentPageSetupTransaction
protected boolean isHostedPaymentPageSetupTransaction(@NonNull @NonNull PaymentTransaction paymentTransaction) -
getChildTransactionResult
protected Optional<PaymentTransaction> getChildTransactionResult(@NonNull @NonNull Payment payment, @NonNull @NonNull PaymentTransaction transactionRequiringExternalInteraction) -
updateChildTransactionResults
protected PaymentTransaction updateChildTransactionResults(@NonNull @NonNull PaymentTransaction externalTransactionResult, @NonNull @NonNull Payment payment, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, @NonNull @NonNull String managementStateReason, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Updates the child external transaction based on the givenPaymentResponse
.- Parameters:
externalTransactionResult
- the transaction resultPaymentTransaction
to updatepayment
- thePayment
that this transaction belongs topaymentResponse
- thePaymentResponse
to update the transaction withmanagementStateReason
- transaction management reason.contextInfo
- context information related to multitenancy.- Returns:
- the updated child transaction based on the given
PaymentResponse
-
get3DSTransactionResult
protected Optional<PaymentTransaction> get3DSTransactionResult(@NonNull @NonNull Payment payment, @NonNull @NonNull PaymentTransaction transactionRequiring3DS) -
createChildTransactionAndRecordResponse
protected PaymentTransaction createChildTransactionAndRecordResponse(@NonNull @NonNull PaymentTransaction parentTransaction, @NonNull @NonNull Payment payment, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
createChildTransactionAndRecordResponse
protected PaymentTransaction createChildTransactionAndRecordResponse(@NonNull @NonNull PaymentTransaction parentTransaction, @NonNull @NonNull Payment payment, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, @NonNull @NonNull String managementStateReason, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
updateChild3DSTransaction
protected PaymentTransaction updateChild3DSTransaction(@NonNull @NonNull PaymentTransaction threeDSResultTransaction, @NonNull @NonNull Payment payment, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Updates the child 3DS transaction based on the givenPaymentResponse
.- Parameters:
threeDSResultTransaction
- the 3DSPaymentTransaction
to updatepayment
- thePayment
that this transaction belongs topaymentResponse
- thePaymentResponse
to update the 3DS transaction withcontextInfo
- context information related to multitenancy.- Returns:
- the updated child 3DS transaction based on the given
PaymentResponse
-
identifyTransaction
protected PaymentTransaction identifyTransaction(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.TransactionIdentifier transactionIdentifier, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
buildErrorResponse
protected org.springframework.http.ResponseEntity<?> buildErrorResponse(@Nullable com.broadleafcommerce.paymentgateway.service.PaymentGatewayWebhookHandler webhookHandler, @NonNull @NonNull Exception e) -
sendTransactionWebhookMessage
protected void sendTransactionWebhookMessage(Payment payment, PaymentTransaction transaction, boolean transactionRequiredExternalInteraction, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
identifyPaymentForTransaction
protected Payment identifyPaymentForTransaction(com.broadleafcommerce.paymentgateway.domain.TransactionIdentifier transactionIdentifier, PaymentTransaction paymentTransaction, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
getContextInfo
protected com.broadleafcommerce.data.tracking.core.context.ContextInfo getContextInfo(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.TransactionIdentifier transactionIdentifier) -
getWEBHOOK_SOURCE_TYPE
-
getWEBHOOK_SOURCE_ENTITY_TYPE
-
getPaymentGatewayResourceProvider
protected com.broadleafcommerce.paymentgateway.service.provider.PaymentGatewayResourceProvider getPaymentGatewayResourceProvider() -
getPaymentService
-
getPaymentTransactionService
-
getPaymentLockService
-
getTransactionExecutionService
-
getTransactionWebhookMessageService
-
getObjectMapper
protected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper() -
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory() -
setTypeFactory
@Autowired public void setTypeFactory(com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-