title: Stripe Java API Webhook Error when casting to a Customer
body: <p>I found this post: "<a href="https://stackoverflow.com/questions/39342251/retrieve-stripe-data-from-stripe-webhook-event">Retrieve stripe data from stripe webhook event</a>" and it tells you to get the object type you have to cast from StripeObject, like<br>
  <code>Invoice invoice = (Invoice) event.getData().getObject();</code><br>
  Class: <code>StripeWebhook</code></p>
  
  <pre><code>41    Event event = ApiResource.GSON.fromJson(request.body(), Event.class);
  42    if (event.getType().equals("invoice.payment_failed") || event.getType().equals("charge.failed") || event.getType().equals("charge.refunded") || event.getType().equals("customer.subscription.deleted")) {
  43 -&gt;     Customer customer = (Customer)event.getData().getObject();`
  44        Plan plan = (Plan)event.getData().getObject();
  45    }
  </code></pre>
  
  <p>Stacktrace:    </p>
  
  <pre><code>[qtp2043543300-35] ERROR spark.http.matching.GeneralError -
  java.lang.ClassCastException: class com.stripe.model.Subscription cannot be cast to class com.stripe.model.Customer (com.stripe.model.Subscription and com.stripe.model.Customer are in unnamed module of loader 'app')
          at us.verif.bot.Stripe.StripeWebhook.lambda$startListener$0(StripeWebhook.java:43)
          at spark.RouteImpl$1.handle(RouteImpl.java:72)
          at spark.http.matching.Routes.execute(Routes.java:61)
          at spark.http.matching.MatcherFilter.doFilter(MatcherFilter.java:130)
          at spark.embeddedserver.jetty.JettyHandler.doHandle(JettyHandler.java:50)
          at org.eclipse.jetty.server.session.SessionHandler.doScope(SessionHandler.java:1568)
          at org.eclipse.jetty.server.handler.ScopedHandler.handle(ScopedHandler.java:141)
          at org.eclipse.jetty.server.handler.HandlerWrapper.handle(HandlerWrapper.java:132)
          at org.eclipse.jetty.server.Server.handle(Server.java:530)
          at org.eclipse.jetty.server.HttpChannel.handle(HttpChannel.java:347)
          at org.eclipse.jetty.server.HttpConnection.onFillable(HttpConnection.java:256)
          at org.eclipse.jetty.io.AbstractConnection$ReadCallback.succeeded(AbstractConnection.java:279)
          at org.eclipse.jetty.io.FillInterest.fillable(FillInterest.java:102)
          at org.eclipse.jetty.io.ChannelEndPoint$2.run(ChannelEndPoint.java:124)
          at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.doProduce(EatWhatYouKill.java:247)
          at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.produce(EatWhatYouKill.java:140)
          at org.eclipse.jetty.util.thread.strategy.EatWhatYouKill.run(EatWhatYouKill.java:131)
          at org.eclipse.jetty.util.thread.ReservedThreadExecutor$ReservedThread.run(ReservedThreadExecutor.java:382)
          at org.eclipse.jetty.util.thread.QueuedThreadPool.runJob(QueuedThreadPool.java:708)
          at org.eclipse.jetty.util.thread.QueuedThreadPool$2.run(QueuedThreadPool.java:626)
          at java.base/java.lang.Thread.run(Thread.java:834)
  </code></pre>
  
  <p>I don't understand why it would say this because it was never a Subscription object.</p>