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
ConstructorsConstructorDescriptionDefaultTransactionWebhookService(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 PaymentTransactioncreateChildTransactionAndRecordResponse(@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 PaymentTransactioncreateChildTransactionAndRecordResponse(@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.ContextInfogetContextInfo(@NonNull com.broadleafcommerce.paymentgateway.domain.TransactionIdentifier transactionIdentifier) protected com.fasterxml.jackson.databind.ObjectMapperprotected com.broadleafcommerce.paymentgateway.service.provider.PaymentGatewayResourceProviderprotected PaymentLockService<Payment>protected PaymentService<Payment>protected PaymentTransactionService<PaymentTransaction>protected TransactionExecutionServiceprotected TransactionWebhookMessageServiceprotected com.broadleafcommerce.common.extension.TypeFactoryprotected static Stringprotected static Stringprotected PaymentTransactionhandleAwaitingAsyncTransactionResult(@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, @NonNull PaymentTransaction paymentTransaction, @NonNull Payment payment, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected PaymentTransactionhandleFraudReviewTransactionResult(@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 PaymentTransactionhandleHostedPaymentPageSetupTransactionResult(@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, @NonNull PaymentTransaction paymentTransaction, @NonNull Payment payment, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected PaymentTransactionhandleSubsequentTransactionResult(@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 PaymentTransactionhandleThreeDSTransactionResult(@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 PaymentTransactionidentifyParentTransaction(@NonNull Payment payment, @NonNull PaymentTransaction paymentTransaction, @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse) protected PaymentidentifyPaymentForTransaction(com.broadleafcommerce.paymentgateway.domain.TransactionIdentifier transactionIdentifier, PaymentTransaction paymentTransaction, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected PaymentTransactionidentifyTransaction(@NonNull com.broadleafcommerce.paymentgateway.domain.TransactionIdentifier transactionIdentifier, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected booleanisFraudReviewResult(@NonNull PaymentTransaction paymentTransaction, @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse) protected booleanisHostedPaymentPageSetupTransaction(@NonNull PaymentTransaction paymentTransaction) protected booleanisNotificationTypeSupported(@NonNull com.broadleafcommerce.paymentgateway.service.PaymentGatewayWebhookHandler webhookHandler, @NonNull com.broadleafcommerce.paymentgateway.domain.enums.SupportedWebhookNotificationType webhookNotificationType) protected booleanisSubsequentTransactionAlreadyCreated(@NonNull Payment payment, @NonNull String eventId) protected booleanisSubsequentTransactionResult(@NonNull Payment payment, @NonNull PaymentTransaction paymentTransaction, @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse) Determines if thePaymentResponseresults represent a subsequent transaction that was executed after the knownPaymentTransaction.protected PaymentTransactionrecordFraudReviewResults(@NonNull PaymentTransaction paymentTransaction, @NonNull Payment payment, @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) Updates the providedPaymentTransactionto indicate that the fraud review is finalized/closed & records the results of that review.protected PaymentTransactionrecordImpliedReverseAuth(@NonNull Payment payment, @NonNull PaymentTransaction captureTransaction, @NonNull PaymentTransaction parentAuthTransaction, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected PaymentTransactionrecordImpliedReverseAuth(@NonNull Payment payment, @NonNull PaymentTransaction captureTransaction, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected PaymentTransactionrecordSubsequentTransactionResults(@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 aPaymentTransactionbased on thePaymentResponsewhich has been identified as a subsequent transaction to the provided parent transaction.protected PaymentTransactionrecordTransactionResponse(@NonNull PaymentTransaction paymentTransaction, @NonNull Payment payment, @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected voidsendTransactionWebhookMessage(Payment payment, PaymentTransaction transaction, boolean transactionRequiredExternalInteraction, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) voidsetTypeFactory(com.broadleafcommerce.common.extension.TypeFactory typeFactory) protected booleanshouldRecordImpliedReverseAuth(@NonNull Payment payment, @NonNull PaymentTransaction captureTransaction) protected PaymentTransactionupdateChild3DSTransaction(@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 PaymentTransactionupdateChildTransactionResults(@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, waitMethods 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:TransactionWebhookServiceHandles the payment webhook request for the specified gateway type.- Specified by:
handleWebhookin interfaceTransactionWebhookService- Parameters:
gatewayType- the gateway type that is used to identify the appropriatePaymentGatewayWebhookHandlerheaders- the webhook request headersrequestBody- the webhook request bodyparameters- the webhook request parameters- Returns:
- a
ResponseEntitymeant 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 providedPaymentTransactionto indicate that the fraud review is finalized/closed & records the results of that review.- Parameters:
paymentTransaction- ThePaymentTransactiontransaction to be updated.payment- ThePaymentthat owns the payment transaction.paymentResponse- ThePaymentResponsedescribing 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 thePaymentResponseresults 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 newPaymentTransactionfor thisPaymentResponse. In that case, this method should return true.- Parameters:
payment- The payment owning thePaymentTransactionpaymentTransaction- The knownPaymentTransactionpaymentResponse- The transaction results- Returns:
- boolean declaring if the
PaymentResponseresults 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 aPaymentTransactionbased on thePaymentResponsewhich has been identified as a subsequent transaction to the provided parent transaction.- Parameters:
parentTransaction- The parent of the subsequent transaction.payment- ThePaymentthat owns the parent & subsequent transactions.paymentResponse- ThePaymentResponsedescribing the subsequent transaction's results.eventId- The id of the webhook eventcontextInfo- context information related to multi-tenancy.- Returns:
- The
PaymentTransactioncreated 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 resultPaymentTransactionto updatepayment- thePaymentthat this transaction belongs topaymentResponse- thePaymentResponseto 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 3DSPaymentTransactionto updatepayment- thePaymentthat this transaction belongs topaymentResponse- thePaymentResponseto 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)
-