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 Summary
All Methods Instance Methods Abstract Methods Default Methods Modifier and Type Method Description default org.springframework.http.ResponseEntity<?>
buildFailedWebhookResponse(Exception e)
Builds & returns aResponseEntity
meant to communicate to the gateway that the webhook request was unsuccessfully processed.default org.springframework.http.ResponseEntity<?>
buildSuccessfulWebhookResponse()
Builds & returns aResponseEntity
meant to communicate to the gateway that the webhook request was successfully processed.org.apache.commons.lang3.tuple.Pair<TransactionIdentifier,PaymentResponse>
convertToPaymentResponse(org.springframework.http.HttpHeaders headers, String requestBody)
Builds & returns a pair ofTransactionIdentifier
&PaymentResponse
based on the contents of the webhook request.default boolean
shouldHandleRequest(org.springframework.http.HttpHeaders headers, String requestBody)
Determines if the webhook request should be handled.void
validate(org.springframework.http.HttpHeaders headers, String requestBody)
Validates that the webhook request came from the gateway & that it wasn't tampered with.-
Methods inherited from interface com.broadleafcommerce.paymentgateway.service.PaymentGatewayTypeAware
getGatewayType
-
-
-
-
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 headersrequestBody
- The webhook raw request body in the form of a String- Throws:
WebhookValidationException
- if the webhook request is invalid.
-
convertToPaymentResponse
org.apache.commons.lang3.tuple.Pair<TransactionIdentifier,PaymentResponse> convertToPaymentResponse(org.springframework.http.HttpHeaders headers, String requestBody)
Builds & returns a pair ofTransactionIdentifier
&PaymentResponse
based on the contents of the webhook request.- Parameters:
headers
- The webhook request headersrequestBody
- The webhook raw request body in the form of a String- Returns:
- a pair of
TransactionIdentifier
&PaymentResponse
based on the contents of the webhook request.
-
buildSuccessfulWebhookResponse
default org.springframework.http.ResponseEntity<?> buildSuccessfulWebhookResponse()
Builds & returns aResponseEntity
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 aResponseEntity
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.
-
-