Class StripeWebhook

All Implemented Interfaces:
spark.Route

public class StripeWebhook extends PostRoute
A route that listens for Stripe events.
  • Field Details

    • webhookSecret

      private String webhookSecret
      The webhook secret used to verify events.
    • logger

      private org.slf4j.Logger logger
      The logger used to log events from this class.
  • Constructor Details

    • StripeWebhook

      public StripeWebhook(App app)
  • Method Details

    • handlePost

      public void handlePost(spark.Request request, spark.Response response) throws SQLException
      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 class PostRoute
      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