I've build a listener for my IPN. I can receive the request via IPN Simulator and all the parameters are correct, but when I send it back to link for sending my request to make validations it will ALWAYS return INVALID.
I've tried changing the encoding on my PayPal account to UTF-8 but it didn't work.
I'm not using any gem for this and I'm not looking forward to this.
class PaymentNotificationController [:create] #Otherwise the request from PayPal wouldn't make it to the controller def create response = validate_IPN_notification(request.raw_post) case response when "VERIFIED" P 'worked' when "INVALID" p 'did not work' else end render :nothing => true, :status => 200, :content_type => 'text/html' end protected def validate_IPN_notification(raw) uri = URI.parse('https://www.sandbox.paypal.com/cgi-bin/webscr?cmd=_notify-validate') #uri = URI.parse('https://www.paypal.com/cgi-bin/webscr?cmd=_notify-validate') http = Net::HTTP.new(uri.host, uri.port) http.open_timeout = 60 http.read_timeout = 60 http.verify_mode = OpenSSL::SSL::VERIFY_NONE http.use_ssl = true response = http.post(uri.request_uri, raw, 'Content-Length' => "#{raw.size}", 'User-Agent' => "My custom user agent" ).body end end
Please help me, I've been stuck with it all afternoon and can't get it figured out.