Class DefaultCheckoutComGatewayWebhookHandler
java.lang.Object
com.broadleafcommerce.payment.service.gateway.webhooks.DefaultCheckoutComGatewayWebhookHandler
- All Implemented Interfaces:
CheckoutComGatewayWebhookHandler,com.broadleafcommerce.paymentgateway.service.PaymentGatewayTypeAware,com.broadleafcommerce.paymentgateway.service.PaymentGatewayWebhookHandler
public class DefaultCheckoutComGatewayWebhookHandler
extends Object
implements CheckoutComGatewayWebhookHandler
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefaultCheckoutComGatewayWebhookHandler(WebhookSignatureUtil signatureUtil, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory) -
Method Summary
Modifier and TypeMethodDescriptionprotected CheckoutComWebhookResponseconvertRequestBody(String rawRequestBody) protected com.broadleafcommerce.paymentgateway.domain.PaymentResponseconvertToPaymentResponse(@NonNull CheckoutComWebhookResponse webhookResponse, @NonNull String requestBody) org.apache.commons.lang3.tuple.Pair<com.broadleafcommerce.paymentgateway.domain.TransactionIdentifier,com.broadleafcommerce.paymentgateway.domain.PaymentResponse> convertToPaymentResponse(@NonNull org.springframework.http.HttpHeaders headers, @NonNull String requestBody, @NonNull Map<String, String> parameters) protected StringgetApplicationId(@NonNull CheckoutComWebhookResponse webhookResponse) protected com.fasterxml.jackson.databind.ObjectMapperprotected WebhookSignatureUtilprotected StringgetTenantId(@NonNull CheckoutComWebhookResponse webhookResponse) protected com.broadleafcommerce.paymentgateway.domain.TransactionIdentifiergetTransactionIdentifier(CheckoutComWebhookResponse webhookResponse) Builds aTransactionIdentifierbased on thetransactionReferenceId&tenantIdvalues gathered from the providedCheckoutComWebhookResponse.protected com.broadleafcommerce.common.extension.TypeFactoryprotected booleanisSignatureValid(@NonNull org.springframework.http.HttpHeaders headers, @NonNull String rawRequestBody) Determines whether the CKO-Signature header is valid by building a hash of the request body, leveraging the secret API key as the hash key.voidvalidate(@NonNull org.springframework.http.HttpHeaders headers, @NonNull String requestBody, @NonNull Map<String, String> parameters) Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.broadleafcommerce.paymentgateway.service.PaymentGatewayWebhookHandler
buildFailedWebhookResponse, buildSuccessfulWebhookResponse, convertToPaymentResponse, getEventId, shouldHandleRequest, shouldHandleRequest, validate
-
Field Details
-
CKO_SIGNATURE
- See Also:
-
CKO_REQUEST_ID
- See Also:
-
-
Constructor Details
-
DefaultCheckoutComGatewayWebhookHandler
public DefaultCheckoutComGatewayWebhookHandler(WebhookSignatureUtil signatureUtil, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-
-
Method Details
-
validate
public void validate(@NonNull @NonNull org.springframework.http.HttpHeaders headers, @NonNull @NonNull String requestBody, @NonNull @NonNull Map<String, String> parameters) - Specified by:
validatein interfacecom.broadleafcommerce.paymentgateway.service.PaymentGatewayWebhookHandler
-
convertToPaymentResponse
public org.apache.commons.lang3.tuple.Pair<com.broadleafcommerce.paymentgateway.domain.TransactionIdentifier,com.broadleafcommerce.paymentgateway.domain.PaymentResponse> convertToPaymentResponse(@NonNull @NonNull org.springframework.http.HttpHeaders headers, @NonNull @NonNull String requestBody, @NonNull @NonNull Map<String, String> parameters) - Specified by:
convertToPaymentResponsein interfacecom.broadleafcommerce.paymentgateway.service.PaymentGatewayWebhookHandler
-
getSupportedWebhookNotificationTypes
- Specified by:
getSupportedWebhookNotificationTypesin interfacecom.broadleafcommerce.paymentgateway.service.PaymentGatewayWebhookHandler
-
getGatewayType
- Specified by:
getGatewayTypein interfacecom.broadleafcommerce.paymentgateway.service.PaymentGatewayTypeAware
-
convertRequestBody
-
getTransactionIdentifier
protected com.broadleafcommerce.paymentgateway.domain.TransactionIdentifier getTransactionIdentifier(CheckoutComWebhookResponse webhookResponse) Builds aTransactionIdentifierbased on thetransactionReferenceId&tenantIdvalues gathered from the providedCheckoutComWebhookResponse.- Parameters:
webhookResponse- The webhook transaction result payload- Returns:
- A
TransactionIdentifierbased on thetransactionReferenceId&tenantIdvalues gathered from theCheckoutComWebhookResponse
-
convertToPaymentResponse
protected com.broadleafcommerce.paymentgateway.domain.PaymentResponse convertToPaymentResponse(@NonNull @NonNull CheckoutComWebhookResponse webhookResponse, @NonNull @NonNull String requestBody) -
isSignatureValid
protected boolean isSignatureValid(@NonNull @NonNull org.springframework.http.HttpHeaders headers, @NonNull @NonNull String rawRequestBody) Determines whether the CKO-Signature header is valid by building a hash of the request body, leveraging the secret API key as the hash key.- Parameters:
headers- The webhook request headersrawRequestBody- The raw webhook request body, in the form of a String- Returns:
- whether the CKO-Signature header is valid
-
getApplicationId
-
getTenantId
-
getSignatureUtil
-
getObjectMapper
protected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper() -
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
-