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 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 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
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 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
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
(PaymentTransaction paymentTransaction, Payment payment, 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
(PaymentTransaction paymentTransaction, Payment payment, com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) protected void
sendTransactionWebhookMessage
(Payment payment, PaymentTransaction transaction, 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
.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.
-
isFraudReviewResult
protected boolean isFraudReviewResult(@NonNull @NonNull PaymentTransaction paymentTransaction, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse) -
recordFraudReviewResults
protected PaymentTransaction recordFraudReviewResults(PaymentTransaction paymentTransaction, Payment payment, com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, @Nullable 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, @Nullable 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) -
sendTransactionWebhookMessage
protected void sendTransactionWebhookMessage(Payment payment, PaymentTransaction transaction, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
recordTransactionResponse
protected PaymentTransaction recordTransactionResponse(PaymentTransaction paymentTransaction, Payment payment, com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, @Nullable com.broadleafcommerce.data.tracking.core.context.ContextInfo contextInfo) -
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) -
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) -
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)
-