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
-
Constructor Summary
ConstructorDescriptionDefaultCheckoutComGatewayWebhookHandler
(WebhookSignatureUtil signatureUtil, com.fasterxml.jackson.databind.ObjectMapper objectMapper, com.broadleafcommerce.common.extension.TypeFactory typeFactory) -
Method Summary
Modifier and TypeMethodDescriptionprotected CheckoutComWebhookResponse
convertRequestBody
(String rawRequestBody) protected com.broadleafcommerce.paymentgateway.domain.PaymentResponse
convertToPaymentResponse
(@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 javax.money.MonetaryAmount
getAmountInMajorUnits
(@NonNull Long amount, @NonNull String currencyCode) protected String
getApplicationId
(@NonNull CheckoutComWebhookResponse webhookResponse) protected com.fasterxml.jackson.databind.ObjectMapper
protected WebhookSignatureUtil
protected String
getTenantId
(@NonNull CheckoutComWebhookResponse webhookResponse) protected javax.money.MonetaryAmount
getTransactionAmount
(@NonNull com.broadleafcommerce.paymentgateway.domain.enums.TransactionType transactionType, @NonNull CheckoutComWebhookResponse webhookResponse) protected Long
getTransactionAmount
(@NonNull com.broadleafcommerce.paymentgateway.domain.enums.TransactionType transactionType, CheckoutComWebhookResponse.Data.Balance balance) protected com.broadleafcommerce.paymentgateway.domain.TransactionIdentifier
getTransactionIdentifier
(CheckoutComWebhookResponse webhookResponse) Builds aTransactionIdentifier
based on thetransactionReferenceId
&tenantId
values gathered from the providedCheckoutComWebhookResponse
.protected com.broadleafcommerce.common.extension.TypeFactory
protected CheckoutComWebhookType
getWebhookType
(@NonNull CheckoutComWebhookResponse webhookResponse) protected com.broadleafcommerce.paymentgateway.domain.enums.TransactionType
identifyTransactionType
(@NonNull CheckoutComWebhookResponse webhookResponse, @NonNull CheckoutComWebhookType webhookType) protected boolean
isKnetPayment
(@NonNull CheckoutComWebhookResponse webhookResponse) Determines if the payment type is KNET for the givenCheckoutComWebhookResponse
.protected boolean
isSignatureValid
(@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.boolean
shouldHandleRequest
(@NonNull org.springframework.http.HttpHeaders headers, @NonNull String requestBody, @NonNull Map<String, String> parameters) void
validate
(@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, wait
Methods inherited from interface com.broadleafcommerce.paymentgateway.service.PaymentGatewayWebhookHandler
buildFailedWebhookResponse, buildSuccessfulWebhookResponse, convertToPaymentResponse, getEventId, 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
-
shouldHandleRequest
public boolean shouldHandleRequest(@NonNull @NonNull org.springframework.http.HttpHeaders headers, @NonNull @NonNull String requestBody, @NonNull @NonNull Map<String, String> parameters) - Specified by:
shouldHandleRequest
in interfacecom.broadleafcommerce.paymentgateway.service.PaymentGatewayWebhookHandler
-
validate
public void validate(@NonNull @NonNull org.springframework.http.HttpHeaders headers, @NonNull @NonNull String requestBody, @NonNull @NonNull Map<String, String> parameters) - Specified by:
validate
in 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:
convertToPaymentResponse
in interfacecom.broadleafcommerce.paymentgateway.service.PaymentGatewayWebhookHandler
-
getSupportedWebhookNotificationTypes
- Specified by:
getSupportedWebhookNotificationTypes
in interfacecom.broadleafcommerce.paymentgateway.service.PaymentGatewayWebhookHandler
-
getGatewayType
- Specified by:
getGatewayType
in interfacecom.broadleafcommerce.paymentgateway.service.PaymentGatewayTypeAware
-
convertRequestBody
-
getTransactionIdentifier
protected com.broadleafcommerce.paymentgateway.domain.TransactionIdentifier getTransactionIdentifier(CheckoutComWebhookResponse webhookResponse) Builds aTransactionIdentifier
based on thetransactionReferenceId
&tenantId
values gathered from the providedCheckoutComWebhookResponse
.- Parameters:
webhookResponse
- The webhook transaction result payload- Returns:
- A
TransactionIdentifier
based on thetransactionReferenceId
&tenantId
values gathered from theCheckoutComWebhookResponse
-
convertToPaymentResponse
protected com.broadleafcommerce.paymentgateway.domain.PaymentResponse convertToPaymentResponse(@NonNull @NonNull CheckoutComWebhookResponse webhookResponse, @NonNull @NonNull String requestBody) -
getWebhookType
@Nullable protected CheckoutComWebhookType getWebhookType(@NonNull @NonNull CheckoutComWebhookResponse webhookResponse) -
identifyTransactionType
protected com.broadleafcommerce.paymentgateway.domain.enums.TransactionType identifyTransactionType(@NonNull @NonNull CheckoutComWebhookResponse webhookResponse, @NonNull @NonNull CheckoutComWebhookType webhookType) -
isKnetPayment
Determines if the payment type is KNET for the givenCheckoutComWebhookResponse
.- Parameters:
webhookResponse
- theCheckoutComWebhookResponse
to check the payment type- Returns:
- true if the payment type is KNET for the given
CheckoutComWebhookResponse
, otherwise false
-
getTransactionAmount
@Nullable protected javax.money.MonetaryAmount getTransactionAmount(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.enums.TransactionType transactionType, @NonNull @NonNull CheckoutComWebhookResponse webhookResponse) -
getTransactionAmount
@Nullable protected Long getTransactionAmount(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.enums.TransactionType transactionType, @Nullable CheckoutComWebhookResponse.Data.Balance balance) -
getAmountInMajorUnits
-
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()
-