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 Details

  • 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 interface com.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 interface com.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 interface com.broadleafcommerce.paymentgateway.service.PaymentGatewayWebhookHandler
    • getSupportedWebhookNotificationTypes

      public List<String> getSupportedWebhookNotificationTypes()
      Specified by:
      getSupportedWebhookNotificationTypes in interface com.broadleafcommerce.paymentgateway.service.PaymentGatewayWebhookHandler
    • getGatewayType

      public String getGatewayType()
      Specified by:
      getGatewayType in interface com.broadleafcommerce.paymentgateway.service.PaymentGatewayTypeAware
    • convertRequestBody

      protected CheckoutComWebhookResponse convertRequestBody(String rawRequestBody)
    • getTransactionIdentifier

      protected com.broadleafcommerce.paymentgateway.domain.TransactionIdentifier getTransactionIdentifier(CheckoutComWebhookResponse webhookResponse)
      Builds a TransactionIdentifier based on the transactionReferenceId & tenantId values gathered from the provided CheckoutComWebhookResponse.
      Parameters:
      webhookResponse - The webhook transaction result payload
      Returns:
      A TransactionIdentifier based on the transactionReferenceId & tenantId values gathered from the CheckoutComWebhookResponse
    • 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

      protected boolean isKnetPayment(@NonNull @NonNull CheckoutComWebhookResponse webhookResponse)
      Determines if the payment type is KNET for the given CheckoutComWebhookResponse.
      Parameters:
      webhookResponse - the CheckoutComWebhookResponse 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

      protected javax.money.MonetaryAmount getAmountInMajorUnits(@NonNull @NonNull Long amount, @NonNull @NonNull String currencyCode)
    • 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 headers
      rawRequestBody - 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()