title: Locally test event handler for Stripe webhooks in Rails
body: <p>I'm using the <a href="https://github.com/integrallis/stripe_event" rel="nofollow">stripe_event gem</a> to set up my event handler for Stripe webhooks. I would like to send an email that notifies the customer if their subscription wasn't renewed. One such setup is as follows:</p>
  
  <pre><code># config/initializers/stripe.rb
  
  StripeEvent.setup do
  
    subscribe 'customer.subscription.updated' do |event|
      subscription = event.data.object
      customer_id = subscription.customer
      user = User.find_by_customer_id(customer_id)
  
      UserMailer.delay.past_due_email(user) if subscription.status == 'past_due'
    end
  
  end
  </code></pre>
  
  <p><strong>Now my goal is to test the event handler above locally</strong> (without relying on ngrok or ultrahook and such). </p>
  
  <p>In my spec, I built a fake Stripe webhook event of type <code>"customer.subscription.updated"</code>. It also contains a POST request to <code>localhost:3000/stripe</code>:</p>
  
  <pre><code>RestClient.post('localhost:3000/stripe', fake_webhook_event)
  </code></pre>
  
  <p>I start the rails server locally and run the spec. The server is receiving the POST request and the event handler is being run, but the subscription object contained in the request has the status of <code>active</code> rather than <code>past_due</code>. The other attributes, such as the event id, are the same as the fake webhook I've written. Very strange. </p>
  
  <p>I have a feeling I shouldn't be sending the request to the development server, but perhaps somewhere else? Any advice? Thank you in advance!</p>