Interface PaymentGatewaySavedPaymentMethodWebhookHandler

All Superinterfaces:
PaymentGatewayTypeAware

public interface PaymentGatewaySavedPaymentMethodWebhookHandler 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 results of creating the saved payment method.
Author:
Dima Myroniuk (dmyroniuk)
  • Method Details

    • validate

      void validate(org.springframework.http.HttpHeaders headers, String requestBody, Map<String,String> parameters)
      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
      parameters - The request parameters passed into the webhook
      Throws:
      WebhookValidationException - if the webhook request is invalid.
    • shouldHandleRequest

      boolean shouldHandleRequest(org.springframework.http.HttpHeaders headers, String requestBody, Map<String,String> parameters)
      Determines if the webhook request should be handled.
      Parameters:
      headers - The webhook request headers
      requestBody - The webhook raw request body in the form of a String
      parameters - The request parameters passed into the webhook
      Returns:
      true if the webhook request should be handled, otherwise false
    • convertWebhookRequest

      SavedPaymentMethodSetupResult convertWebhookRequest(org.springframework.http.HttpHeaders headers, String requestBody, Map<String,String> parameters)
      Builds & returns a SavedPaymentMethodSetupResult based on the content of the webhook request.
      Parameters:
      headers - The webhook request headers
      requestBody - The webhook raw request body in the form of a String
      parameters - The request parameters passed into the webhook
      Returns:
      a SavedPaymentMethodSetupResult based on the contents of the webhook request.
    • 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.