Class DefaultStripeGatewayWebhookHandler
java.lang.Object
com.broadleafcommerce.payment.service.gateway.webhooks.DefaultStripeGatewayWebhookHandler
- All Implemented Interfaces:
StripeGatewayWebhookHandler,com.broadleafcommerce.paymentgateway.service.PaymentGatewayTypeAware,com.broadleafcommerce.paymentgateway.service.PaymentGatewayWebhookHandler
public class DefaultStripeGatewayWebhookHandler
extends Object
implements StripeGatewayWebhookHandler
- Author:
- Dima Myroniuk (dmyroniuk)
-
Field Summary
Fields -
Constructor Summary
ConstructorsConstructorDescriptionDefaultStripeGatewayWebhookHandler(StripeRestConfigurationProperties configurationProperties, com.broadleafcommerce.common.extension.TypeFactory typeFactory) -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddRawResponse(@NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, @NonNull Object response) protected org.apache.commons.lang3.tuple.Pair<com.broadleafcommerce.paymentgateway.domain.TransactionIdentifier,com.broadleafcommerce.paymentgateway.domain.PaymentResponse> buildChargeCapturedResponse(@NonNull com.stripe.model.Event event, @NonNull com.stripe.model.Charge charge, @NonNull org.springframework.http.HttpHeaders headers, @NonNull Map<String, String> parameters) protected org.apache.commons.lang3.tuple.Pair<com.broadleafcommerce.paymentgateway.domain.TransactionIdentifier,com.broadleafcommerce.paymentgateway.domain.PaymentResponse> buildChargeFailedResponse(@NonNull com.stripe.model.Event event, @NonNull com.stripe.model.Charge charge, @NonNull org.springframework.http.HttpHeaders headers, @NonNull Map<String, String> parameters) protected org.apache.commons.lang3.tuple.Pair<com.broadleafcommerce.paymentgateway.domain.TransactionIdentifier,com.broadleafcommerce.paymentgateway.domain.PaymentResponse> buildChargeRefundedResponse(@NonNull com.stripe.model.Event event, @NonNull com.stripe.model.Charge charge, @NonNull org.springframework.http.HttpHeaders headers, @NonNull Map<String, String> parameters) protected org.apache.commons.lang3.tuple.Pair<com.broadleafcommerce.paymentgateway.domain.TransactionIdentifier,com.broadleafcommerce.paymentgateway.domain.PaymentResponse> buildChargeSucceededResponse(@NonNull com.stripe.model.Event event, @NonNull com.stripe.model.Charge charge, @NonNull org.springframework.http.HttpHeaders headers, @NonNull Map<String, String> parameters) protected org.apache.commons.lang3.tuple.Pair<com.broadleafcommerce.paymentgateway.domain.TransactionIdentifier,com.broadleafcommerce.paymentgateway.domain.PaymentResponse> buildPaymentIntentFailedResponse(@NonNull com.stripe.model.Event event, @NonNull com.stripe.model.PaymentIntent paymentIntent, @NonNull org.springframework.http.HttpHeaders headers, @NonNull Map<String, String> parameters) protected com.stripe.net.RequestOptionsbuildRequestOptions(@NonNull String idempotencyKey, @NonNull org.springframework.http.HttpHeaders headers, @NonNull Map<String, String> parameters) protected org.apache.commons.lang3.tuple.Pair<com.broadleafcommerce.paymentgateway.domain.TransactionIdentifier,com.broadleafcommerce.paymentgateway.domain.PaymentResponse> buildReviewClosedResponse(@NonNull com.stripe.model.Event event, @NonNull com.stripe.model.Review review, @NonNull org.springframework.http.HttpHeaders headers, @NonNull Map<String, String> parameters) protected com.stripe.model.EventconstructEvent(@NonNull org.springframework.http.HttpHeaders headers, @NonNull String requestBody, @NonNull Map<String, String> parameters) Deprecated, for removal: This API element is subject to removal in a future version.org.apache.commons.lang3.tuple.Pair<com.broadleafcommerce.paymentgateway.domain.TransactionIdentifier,com.broadleafcommerce.paymentgateway.domain.PaymentResponse> convertToPaymentResponse(@NonNull org.springframework.http.HttpHeaders headers, @NonNull String requestBody, @NonNull Map<String, String> parameters) protected javax.money.MonetaryAmountgetAmountInMajorUnits(@NonNull Long amount, @NonNull String currencyCode) protected StringgetApplicationId(@NonNull Map<String, String> parameters) protected Stringprotected StripeConfigurationPropertiesprotected StripeRestConfigurationPropertiesgetEventId(@NonNull org.springframework.http.HttpHeaders headers, @NonNull String requestBody, @NonNull Map<String, String> parameters) protected StringgetFailureMessage(@NonNull com.stripe.model.Charge charge) protected StringgetGatewayResponseCode(@NonNull com.stripe.model.PaymentIntent paymentIntent) protected StringgetGatewayTransactionId(@NonNull com.stripe.model.StripeObject stripeObject) protected com.stripe.model.PaymentIntentgetPaymentIntent(@NonNull com.stripe.model.Review review, @NonNull org.springframework.http.HttpHeaders headers, @NonNull Map<String, String> parameters) getPaymentMethodPropertiesForFutureUse(@NonNull com.stripe.model.Charge charge) protected com.stripe.model.StripeObjectgetStripeObject(@NonNull com.stripe.model.Event event) protected StripeWebhookEventServiceprotected StringgetTenantId(@NonNull Map<String, String> parameters) protected Stringprotected com.broadleafcommerce.paymentgateway.domain.TransactionIdentifiergetTransactionIdentifier(@NonNull com.stripe.model.Event event, @NonNull com.stripe.model.Charge charge, @NonNull Map<String, String> parameters) protected com.broadleafcommerce.paymentgateway.domain.TransactionIdentifiergetTransactionIdentifier(@NonNull com.stripe.model.Event event, @NonNull com.stripe.model.PaymentIntent paymentIntent, @NonNull Map<String, String> parameters) protected com.broadleafcommerce.paymentgateway.domain.TransactionIdentifiergetTransactionIdentifier(@NonNull com.stripe.model.Event event, @NonNull Map<String, String> metadata, @NonNull Map<String, String> parameters) protected com.broadleafcommerce.paymentgateway.domain.enums.DefaultTransactionTypesgetTransactionType(@NonNull com.stripe.model.PaymentIntent paymentIntent) protected com.broadleafcommerce.paymentgateway.domain.enums.TransactionTypegetTransactionType(com.stripe.model.Charge charge) protected com.broadleafcommerce.common.extension.TypeFactoryprotected StringidentifyFailureType(String responseCode, String transactionReferenceId) protected booleanisAchPayment(@NonNull com.stripe.model.PaymentIntent paymentIntent) voidsetConfigProperties(StripeConfigurationProperties configProperties) voidsetStripeWebhookEventService(StripeWebhookEventService stripeWebhookEventService) booleanshouldHandleRequest(@NonNull org.springframework.http.HttpHeaders headers, @NonNull String requestBody, @NonNull Map<String, String> parameters) voidvalidate(@NonNull org.springframework.http.HttpHeaders headers, @NonNull String requestBody, @NonNull Map<String, String> parameters) protected com.stripe.model.EventvalidateAndConstructEvent(@NonNull org.springframework.http.HttpHeaders headers, @NonNull String requestBody, @NonNull Map<String, String> parameters) Deprecated, for removal: This API element is subject to removal in a future version.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface com.broadleafcommerce.paymentgateway.service.PaymentGatewayWebhookHandler
buildFailedWebhookResponse, buildSuccessfulWebhookResponse, convertToPaymentResponse, shouldHandleRequest, validate
-
Field Details
-
STRIPE_SIGNATURE_HEADER
- See Also:
-
STRIPE_ACCOUNT_HEADER
- See Also:
-
-
Constructor Details
-
DefaultStripeGatewayWebhookHandler
public DefaultStripeGatewayWebhookHandler(StripeRestConfigurationProperties configurationProperties, com.broadleafcommerce.common.extension.TypeFactory typeFactory)
-
-
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:
validatein interfacecom.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:
shouldHandleRequestin interfacecom.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:
convertToPaymentResponsein interfacecom.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:
getEventIdin interfacecom.broadleafcommerce.paymentgateway.service.PaymentGatewayWebhookHandler
-
getSupportedWebhookNotificationTypes
- Specified by:
getSupportedWebhookNotificationTypesin interfacecom.broadleafcommerce.paymentgateway.service.PaymentGatewayWebhookHandler
-
getGatewayType
- Specified by:
getGatewayTypein interfacecom.broadleafcommerce.paymentgateway.service.PaymentGatewayTypeAware
-
getStripeObject
protected com.stripe.model.StripeObject getStripeObject(@NonNull @NonNull com.stripe.model.Event event) -
isAchPayment
protected boolean isAchPayment(@NonNull @NonNull com.stripe.model.PaymentIntent paymentIntent) -
validateAndConstructEvent
@Deprecated(forRemoval=true) protected com.stripe.model.Event validateAndConstructEvent(@NonNull @NonNull org.springframework.http.HttpHeaders headers, @NonNull @NonNull String requestBody, @NonNull @NonNull Map<String, String> parameters) throws ExceptionDeprecated, for removal: This API element is subject to removal in a future version.- Throws:
Exception
-
constructEvent
@Deprecated(forRemoval=true) protected com.stripe.model.Event constructEvent(@NonNull @NonNull org.springframework.http.HttpHeaders headers, @NonNull @NonNull String requestBody, @NonNull @NonNull Map<String, String> parameters) Deprecated, for removal: This API element is subject to removal in a future version. -
buildReviewClosedResponse
protected org.apache.commons.lang3.tuple.Pair<com.broadleafcommerce.paymentgateway.domain.TransactionIdentifier,com.broadleafcommerce.paymentgateway.domain.PaymentResponse> buildReviewClosedResponse(@NonNull @NonNull com.stripe.model.Event event, @NonNull @NonNull com.stripe.model.Review review, @NonNull @NonNull org.springframework.http.HttpHeaders headers, @NonNull @NonNull Map<String, String> parameters) throws com.stripe.exception.StripeException- Throws:
com.stripe.exception.StripeException
-
getPaymentIntent
protected com.stripe.model.PaymentIntent getPaymentIntent(@NonNull @NonNull com.stripe.model.Review review, @NonNull @NonNull org.springframework.http.HttpHeaders headers, @NonNull @NonNull Map<String, String> parameters) throws com.stripe.exception.StripeException- Throws:
com.stripe.exception.StripeException
-
buildChargeCapturedResponse
protected org.apache.commons.lang3.tuple.Pair<com.broadleafcommerce.paymentgateway.domain.TransactionIdentifier,com.broadleafcommerce.paymentgateway.domain.PaymentResponse> buildChargeCapturedResponse(@NonNull @NonNull com.stripe.model.Event event, @NonNull @NonNull com.stripe.model.Charge charge, @NonNull @NonNull org.springframework.http.HttpHeaders headers, @NonNull @NonNull Map<String, String> parameters) -
getGatewayTransactionId
@Nullable protected String getGatewayTransactionId(@NonNull @NonNull com.stripe.model.StripeObject stripeObject) -
buildChargeRefundedResponse
protected org.apache.commons.lang3.tuple.Pair<com.broadleafcommerce.paymentgateway.domain.TransactionIdentifier,com.broadleafcommerce.paymentgateway.domain.PaymentResponse> buildChargeRefundedResponse(@NonNull @NonNull com.stripe.model.Event event, @NonNull @NonNull com.stripe.model.Charge charge, @NonNull @NonNull org.springframework.http.HttpHeaders headers, @NonNull @NonNull Map<String, String> parameters) -
buildChargeSucceededResponse
protected org.apache.commons.lang3.tuple.Pair<com.broadleafcommerce.paymentgateway.domain.TransactionIdentifier,com.broadleafcommerce.paymentgateway.domain.PaymentResponse> buildChargeSucceededResponse(@NonNull @NonNull com.stripe.model.Event event, @NonNull @NonNull com.stripe.model.Charge charge, @NonNull @NonNull org.springframework.http.HttpHeaders headers, @NonNull @NonNull Map<String, String> parameters) -
buildChargeFailedResponse
protected org.apache.commons.lang3.tuple.Pair<com.broadleafcommerce.paymentgateway.domain.TransactionIdentifier,com.broadleafcommerce.paymentgateway.domain.PaymentResponse> buildChargeFailedResponse(@NonNull @NonNull com.stripe.model.Event event, @NonNull @NonNull com.stripe.model.Charge charge, @NonNull @NonNull org.springframework.http.HttpHeaders headers, @NonNull @NonNull Map<String, String> parameters) -
buildPaymentIntentFailedResponse
protected org.apache.commons.lang3.tuple.Pair<com.broadleafcommerce.paymentgateway.domain.TransactionIdentifier,com.broadleafcommerce.paymentgateway.domain.PaymentResponse> buildPaymentIntentFailedResponse(@NonNull @NonNull com.stripe.model.Event event, @NonNull @NonNull com.stripe.model.PaymentIntent paymentIntent, @NonNull @NonNull org.springframework.http.HttpHeaders headers, @NonNull @NonNull Map<String, String> parameters) -
getTransactionType
protected com.broadleafcommerce.paymentgateway.domain.enums.DefaultTransactionTypes getTransactionType(@NonNull @NonNull com.stripe.model.PaymentIntent paymentIntent) -
getTransactionType
protected com.broadleafcommerce.paymentgateway.domain.enums.TransactionType getTransactionType(com.stripe.model.Charge charge) -
getApplicationId
-
getTenantId
-
getTenantId
-
getApplicationId
-
getTransactionIdentifier
-
getTransactionIdentifier
-
getTransactionIdentifier
-
identifyFailureType
-
buildRequestOptions
-
getAmountInMajorUnits
-
getSupportedEventTypes
-
getGatewayResponseCode
@Nullable protected String getGatewayResponseCode(@NonNull @NonNull com.stripe.model.PaymentIntent paymentIntent) -
getFailureMessage
-
getPaymentMethodPropertiesForFutureUse
-
addRawResponse
protected void addRawResponse(@NonNull @NonNull com.broadleafcommerce.paymentgateway.domain.PaymentResponse paymentResponse, @NonNull @NonNull Object response) -
getConfigurationProperties
-
getTypeFactory
protected com.broadleafcommerce.common.extension.TypeFactory getTypeFactory() -
getConfigProperties
-
setConfigProperties
-
getStripeWebhookEventService
-
setStripeWebhookEventService
@Autowired public void setStripeWebhookEventService(StripeWebhookEventService stripeWebhookEventService)
-
StripeWebhookEventService.constructEvent(HttpHeaders, String, Map).