Paypal ipn returns nil

while testing IPN validations with the PayPal gem,

I keep getting a nil object message for notify.acknowledge

even though notify is not empty

notify = Paypal::Notification.new(request.raw_post)

notify
=> #<Paypal::Notification:0x398d9d0
@raw="receiver_id=D31B7IUDQITUL&business=paypal%40yourdo…etc etc

notify.acknowledge
NoMethodError: You have a nil object when you didn’t expect it!
The error occured while evaluating nil.verify_mode
from d:/ruby/lib/ruby/1.8/net/http.rb:565:in connect' from d:/ruby/lib/ruby/1.8/net/http.rb:555:indo_start’
from d:/ruby/lib/ruby/1.8/net/http.rb:544:in start' from d:/ruby/lib/ruby/1.8/net/http.rb:1031:inrequest’
from
./script/…/config/…/config/…/vendor/plugins/paypal/lib/notification.rb:209:in
`acknowledge’
from (irb):107
from :0

has anyone seen this before?

cheers

dion

www.blogsaic.com
search, post, blog

Hello Dion,

2006/8/29, Dion H. [email protected]:

while testing IPN validations with the PayPal gem,

./script/…/config/…/config/…/vendor/plugins/paypal/lib/notification.rb:209:in
`acknowledge’
from (irb):107
from :0

Did you look at line 209 of notification ? That should give you a clue.

Check Paypal::Notification.ipn_url is not nil before calling too.

Hope that helps !

François Beausoleil
http://blog.teksol.info/
http://piston.rubyforge.org/

hi there

I set ipn.url in my controller to the test script I am using

notify.ipn_url = ‘http://www.eliteweaver.co.uk/cgi-bin/webscr

how can I test line 204 http = Net::HTTP.new(uri.host, uri.port) from
the
console

as I suspect it is http that is nil

notification.rb

def acknowledge
payload = raw

  uri = URI.parse(self.class.ipn_url)
  request_path = "#{uri.path}?cmd=_notify-validate"

  request = Net::HTTP::Post.new(request_path)
  request['Content-Length'] = "#{payload.size}"
  request['User-Agent']     = "paypal-ruby --

http://rubyforge.org/projects/paypal/"

  http = Net::HTTP.new(uri.host, uri.port)

  http.verify_mode = OpenSSL::SSL::VERIFY_NONE unless @ssl_strict
  http.use_ssl = true

  request = http.request(request, payload)

  raise StandardError.new("Faulty paypal result: #{request.body}")

unless [“VERIFIED”, “INVALID”].include?(request.body)

  request.body == "VERIFIED"
end

cheers

dion

On 8/29/06, Francois B. [email protected] wrote:

    from :0

www.blogsaic.com
search, post, blog

while evaluating this from the console, http returns false, which is why
I
must be getting nil

@notify.ipn_url = ‘http://www.eliteweaver.co.uk/testing/ipntest.php
=> “http://www.eliteweaver.co.uk/testing/ipntest.php

uri = URI.parse(@notify.ipn_url)
=> #<URI::HTTP:0x1c53c50 URL:
http://www.eliteweaver.co.uk/testing/ipntest.php>

http = Net::HTTP.new(uri.host, uri.port)
=> #<Net::HTTP www.eliteweaver.co.uk:80 open=false>

On 8/29/06, Dion H. [email protected] wrote:

as I suspect it is http that is nil
request[‘Content-Length’] = “#{payload.size}”
raise StandardError.new(“Faulty paypal result: #{request.body}”)
On 8/29/06, Francois B. < [email protected]> wrote:

    from (irb):107

http://piston.rubyforge.org/

www.blogsaic.com
search, post, blog

www.blogsaic.com
search, post, blog

2006/8/29, Dion H. [email protected]:

http = Net::HTTP.new(uri.host, uri.port)
=> #<Net::HTTP www.eliteweaver.co.uk:80 open=false>

That only says that the connection is not open. Not that it’s false.
You need to initiate the request. Continue testing in the console /
irb to see where it leads you.

Sorry I can’t be more specific. You’re on the right track though.

Also, nothing prevents you from editing notification.rb and adding
logging statements. I often do:

RAILS_DEFAULT_LOGGER.debug “some logging statement”

in the libraries. Since the library’s running under Rails, it
automatically gets access to the same logger the rest of Rails is
using.

Bye !

François Beausoleil
http://blog.teksol.info/
http://piston.rubyforge.org/