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, logger = nil) ⇒ Object



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

def send_back(data, logger = nil)
  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"

  logger.request(path, data, "") if logger
  resp, response_data = http.post(path, data)
  logger.response(resp.code, response_data) if logger
  
  @verified = response_data == "VERIFIED"
end

#verified?Boolean

Returns:

  • (Boolean)


30
31
32
# File 'lib/ipn_notification.rb', line 30

def verified?
  @verified
end