Class: PaypalAdaptive::IpnNotification

Inherits:
Object
  • Object
show all
Defined in:
lib/ipn_notification.rb

Instance Method Summary collapse

Constructor Details

#initialize(env = nil) ⇒ IpnNotification

Returns a new instance of IpnNotification.



9
10
11
12
13
# File 'lib/ipn_notification.rb', line 9

def initialize(env=nil)
  @env = env
  @@config ||= PaypalAdaptive::Config.new(@env)
  @@paypal_base_url ||= @@config.paypal_base_url
end

Instance Method Details

#send_back(data) ⇒ Object



15
16
17
18
19
20
21
22
23
24
25
# File 'lib/ipn_notification.rb', line 15

def send_back(data)
  data = "cmd=_notify-validate&#{data}"
  url = URI.parse @@paypal_base_url
  http = Net::HTTP.new(url.host, 443)
  http.use_ssl = (url.scheme == 'https')
  
  path = "#{@@paypal_base_url}/cgi-bin/webscr"
  resp, response_data = http.post(path, data)
  
  @verified = response_data == "VERIFIED"
end

#verified?Boolean

Returns:

  • (Boolean)


27
28
29
# File 'lib/ipn_notification.rb', line 27

def verified?
  @verified
end