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:in do_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:in `request'
    from ./script/../config/../config/../vendor/plugins/paypal/lib/notification.rb:209:in `acknowledge'
    from (irb):107

has anyone seen this before?

cheers

dion

Hello Dion,

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 !

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

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>

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 !