IPN simulator check always return INVALID
<p>I'm trying to help a friend (a Grails programmer) that has a problem testing the Paypal IPN listener with IPN simulator: he get always an INVALID response to the post.
So i wrote a Ruby version of the listener using Sinatra and http gem but i got stuck me too.</p>

<p>Here the very short piece of code for Sinatra server:</p>

<pre><code>require 'sinatra'
require 'http'

post '/' do
  request.body.rewind
  response = HTTP.post("https://ipnpb.sandbox.paypal.com/cgi-bin/webscr", body: "cmd=_notify-validate&amp;#{request.body.read}")
  logger.info "response word: #{response.to_s}" # INVALID
  logger.info "response code: #{response.code}" # 200
end
</code></pre>

<p>I ran a tunnel to localhost (where Sinatra app is listening) using ngrok.
The app receive correctly the POST from the Paypal <a href="https://developer.paypal.com/developer/ipnSimulator/" rel="nofollow">IPN simulator</a>, add the required pair <code>cmd=_notify-validate</code>, return a POST. But the response is always "INVALID".</p>

<p>I tried to run the code on Heroku but in vain.</p>

<p>Any idea?
Thanks</p>