Class DefaultMyFatoorahGatewayWebhookHandler

java.lang.Object
com.broadleafcommerce.myfatoorah.service.webhook.DefaultMyFatoorahGatewayWebhookHandler
All Implemented Interfaces:
MyFatoorahGatewayWebhookHandler, com.broadleafcommerce.paymentgateway.service.PaymentGatewayTypeAware, com.broadleafcommerce.paymentgateway.service.PaymentGatewayWebhookHandler

public class DefaultMyFatoorahGatewayWebhookHandler extends Object implements MyFatoorahGatewayWebhookHandler
Author:
Divyank Chavan.
  • Field Details

  • Constructor Details

    • DefaultMyFatoorahGatewayWebhookHandler

      public DefaultMyFatoorahGatewayWebhookHandler(MyFatoorahConfigurationProperties configurationProperties, com.broadleafcommerce.common.extension.TypeFactory typeFactory, com.fasterxml.jackson.databind.ObjectMapper objectMapper, MyFatoorahProvider myFatoorahProvider)
  • 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:
      validate in interface com.broadleafcommerce.paymentgateway.service.PaymentGatewayWebhookHandler
    • 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
    • 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
    • getEventId

      public String getEventId(@NonNull @NonNull org.springframework.http.HttpHeaders headers, @NonNull @NonNull String requestBody, @NonNull @NonNull Map<String,String> parameters)
      Specified by:
      getEventId 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
    • validateAndConstructEvent

      protected MyFatoorahWebhookRequest validateAndConstructEvent(@NonNull @NonNull org.springframework.http.HttpHeaders headers, @NonNull @NonNull String requestBody, @NonNull @NonNull Map<String,String> parameters)
    • validateSignature

      protected boolean validateSignature(@NonNull @NonNull String requestBody, @NonNull @NonNull String sigHeader, String webhookEndpointSecret)
    • sortDataPropertiesFromEvent

      protected Map<String,String> sortDataPropertiesFromEvent(@NonNull @NonNull String requestBody)
    • isNull

      protected boolean isNull(com.fasterxml.jackson.databind.JsonNode jsonNode)
    • calculateSignature

      protected String calculateSignature(@NonNull @NonNull String webhookEndpointSecret, @NonNull @NonNull String params)
    • constructEvent

      protected MyFatoorahWebhookRequest constructEvent(@NonNull @NonNull String requestBody)
    • buildTransactionStatusChangedResponse

      protected org.apache.commons.lang3.tuple.Pair<com.broadleafcommerce.paymentgateway.domain.TransactionIdentifier,com.broadleafcommerce.paymentgateway.domain.PaymentResponse> buildTransactionStatusChangedResponse(@NonNull @NonNull MyFatoorahWebhookRequest webhookRequest, @NonNull @NonNull org.springframework.http.HttpHeaders headers, @NonNull @NonNull String requestBody, @NonNull @NonNull Map<String,String> parameters)
    • buildGatewayTransactionId

      protected String buildGatewayTransactionId(MyFatoorahWebhookRequest.Data data)
    • buildRefundStatusChangedResponse

      protected org.apache.commons.lang3.tuple.Pair<com.broadleafcommerce.paymentgateway.domain.TransactionIdentifier,com.broadleafcommerce.paymentgateway.domain.PaymentResponse> buildRefundStatusChangedResponse(@NonNull @NonNull MyFatoorahWebhookRequest webhookRequest, @NonNull @NonNull org.springframework.http.HttpHeaders headers, @NonNull @NonNull String requestBody, @NonNull @NonNull Map<String,String> parameters)
    • getTransactionAmount

      @Nullable protected javax.money.MonetaryAmount getTransactionAmount(@NonNull @NonNull String amount, @NonNull @NonNull String currencyCode)
    • buildResponseMapForRefundStatusChangedEvent

      protected void buildResponseMapForRefundStatusChangedEvent(@NonNull MyFatoorahWebhookRequest.Data data, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse)
    • buildResponseMapForTransactionStatusChangedEvent

      protected void buildResponseMapForTransactionStatusChangedEvent(@NonNull MyFatoorahWebhookRequest.Data data, @NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse)
    • putIfNotBlank

      protected void putIfNotBlank(@NonNull @NonNull Map<String,String> map, @NonNull @NonNull String key, @Nullable String value)
    • buildTransactionIdentifier

      protected com.broadleafcommerce.paymentgateway.domain.TransactionIdentifier buildTransactionIdentifier(@NonNull @NonNull String gatewayTransactionId, @Nullable String tenantId)
    • identifyLatestTransaction

      protected MyFatoorahResponse.InvoiceTransaction identifyLatestTransaction(@NonNull @NonNull MyFatoorahResponse myFatoorahResponse)
    • getPaymentId

      @Nullable protected String getPaymentId(@NonNull @NonNull MyFatoorahWebhookRequest.Data data)
    • identifyFailureType

      protected String identifyFailureType(String reasonCode, String gatewayTransactionId)
    • isSuccessful

      protected boolean isSuccessful(MyFatoorahWebhookRequest.Data data)
    • isRefunded

      protected boolean isRefunded(MyFatoorahWebhookRequest.Data data)
    • getSupportedEventTypes

      protected List<String> getSupportedEventTypes()
    • getApplicationId

      @Nullable protected String getApplicationId(@NonNull @NonNull Map<String,String> parameters)
    • getTenantId

      @Nullable protected String getTenantId(@NonNull @NonNull Map<String,String> parameters)
    • getConfigurationProperties

      protected MyFatoorahConfigurationProperties getConfigurationProperties()
    • getTypeFactory

      protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory()
    • getObjectMapper

      protected com.fasterxml.jackson.databind.ObjectMapper getObjectMapper()
    • getMyFatoorahProvider

      protected MyFatoorahProvider getMyFatoorahProvider()