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 Modifier and Type Field Description static StringCKO_REQUEST_IDstatic StringCKO_SIGNATURE
-
Constructor Summary
Constructors Constructor Description DefaultCheckoutComGatewayWebhookHandler(WebhookSignatureUtil signatureUtil, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description protected 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)protected StringgetApplicationId(@NonNull CheckoutComWebhookResponse webhookResponse)StringgetGatewayType()protected com.fasterxml.jackson.databind.ObjectMappergetObjectMapper()protected WebhookSignatureUtilgetSignatureUtil()protected 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.TypeFactorygetTypeFactory()protected 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(org.springframework.http.HttpHeaders headers, String rawRequestBody)
-
-
-
Field Detail
-
CKO_SIGNATURE
public static final String CKO_SIGNATURE
- See Also:
- Constant Field Values
-
CKO_REQUEST_ID
public static final String CKO_REQUEST_ID
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
DefaultCheckoutComGatewayWebhookHandler
public DefaultCheckoutComGatewayWebhookHandler(WebhookSignatureUtil signatureUtil, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-
-
Method Detail
-
validate
public void validate(org.springframework.http.HttpHeaders headers, String rawRequestBody) throws com.broadleafcommerce.paymentgateway.service.exception.WebhookValidationException- Specified by:
validatein interfacecom.broadleafcommerce.paymentgateway.service.PaymentGatewayWebhookHandler- Throws:
com.broadleafcommerce.paymentgateway.service.exception.WebhookValidationException
-
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)- Specified by:
convertToPaymentResponsein interfacecom.broadleafcommerce.paymentgateway.service.PaymentGatewayWebhookHandler
-
getGatewayType
public String getGatewayType()
- Specified by:
getGatewayTypein interfacecom.broadleafcommerce.paymentgateway.service.PaymentGatewayTypeAware
-
convertRequestBody
protected CheckoutComWebhookResponse convertRequestBody(String rawRequestBody)
-
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
protected String getApplicationId(@NonNull @NonNull CheckoutComWebhookResponse webhookResponse)
-
getTenantId
protected String getTenantId(@NonNull @NonNull CheckoutComWebhookResponse webhookResponse)
-
getSignatureUtil
protected WebhookSignatureUtil getSignatureUtil()
-
getObjectMapper
protected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
-
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
-
-