Interface PaymentGatewayWebhookHandler

  • All Superinterfaces:
    PaymentGatewayTypeAware

    public interface PaymentGatewayWebhookHandler
    extends PaymentGatewayTypeAware
    A gateway-specific interface to assist with the interpretation & processing of payment gateway webhook requests. Typically, we expect this interface to be used to assist with the recording of payment transaction results. In most cases, webhooks are used as a secondary means of communicating transaction results.
    Author:
    Chris Kittrell (ckittrell)
    • Method Detail

      • shouldHandleRequest

        default boolean shouldHandleRequest​(org.springframework.http.HttpHeaders headers,
                                            String requestBody)
        Determines if the webhook request should be handled.
        Returns:
        true if the webhook request should be handled, otherwise false
      • validate

        void validate​(org.springframework.http.HttpHeaders headers,
                      String requestBody)
        Validates that the webhook request came from the gateway & that it wasn't tampered with.
        Parameters:
        headers - The webhook request headers
        requestBody - The webhook raw request body in the form of a String
        Throws:
        WebhookValidationException - if the webhook request is invalid.
      • buildSuccessfulWebhookResponse

        default org.springframework.http.ResponseEntity<?> buildSuccessfulWebhookResponse()
        Builds & returns a ResponseEntity meant to communicate to the gateway that the webhook request was successfully processed.
        Returns:
        a ResponseEntity meant to communicate to the gateway that the webhook request was successfully processed.
      • buildFailedWebhookResponse

        default org.springframework.http.ResponseEntity<?> buildFailedWebhookResponse​(Exception e)
        Builds & returns a ResponseEntity meant to communicate to the gateway that the webhook request was unsuccessfully processed.
        Returns:
        a ResponseEntity meant to communicate to the gateway that the webhook request was unsuccessfully processed.