Package io.github.sigmacasino.routes
Class StripeWebhook
java.lang.Object
io.github.sigmacasino.HTTPRoute
io.github.sigmacasino.PostRoute
io.github.sigmacasino.routes.StripeWebhook
- All Implemented Interfaces:
spark.Route
A route that listens for Stripe events.
-
Field Summary
FieldsModifier and TypeFieldDescriptionprivate org.slf4j.Logger
The logger used to log events from this class.private String
The webhook secret used to verify events.Fields inherited from class io.github.sigmacasino.HTTPRoute
app, loginRequired, path
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprivate void
fulfillCheckout
(String sessionId) Fulfills a Checkout Session if it is completed.void
handlePost
(spark.Request request, spark.Response response) Handles a POST request to the Stripe webhook endpoint.Methods inherited from class io.github.sigmacasino.PostRoute
handle, parseBodyParams, registerSparkRoute
-
Field Details
-
webhookSecret
The webhook secret used to verify events. -
logger
private org.slf4j.Logger loggerThe logger used to log events from this class.
-
-
Constructor Details
-
StripeWebhook
-
-
Method Details
-
handlePost
Handles a POST request to the Stripe webhook endpoint. Verifies the event and fulfills the checkout session if it is completed.- Specified by:
handlePost
in classPostRoute
- Parameters:
request
- The HTTP request.response
- The HTTP response.- Throws:
SQLException
- See Also:
-
fulfillCheckout
private void fulfillCheckout(String sessionId) throws com.stripe.exception.StripeException, SQLException Fulfills a Checkout Session if it is completed. Updates the user's balance and logs the deposit in the database.- Parameters:
sessionId
- The ID of the Checkout Session to fulfill.- Throws:
com.stripe.exception.StripeException
- If an error occurs while fulfilling the Checkout Session.SQLException
-