Class: PaypalAdaptive::IpnNotification
- Inherits:
-
Object
- Object
- PaypalAdaptive::IpnNotification
- Defined in:
- lib/paypal_adaptive/ipn_notification.rb
Instance Method Summary collapse
-
#initialize(env = nil) ⇒ IpnNotification
constructor
A new instance of IpnNotification.
- #send_back(data) ⇒ Object
- #verified? ⇒ Boolean
Constructor Details
#initialize(env = nil) ⇒ IpnNotification
Returns a new instance of IpnNotification.
8 9 10 11 12 13 14 15 |
# File 'lib/paypal_adaptive/ipn_notification.rb', line 8 def initialize(env=nil) config = PaypalAdaptive.config(env) @paypal_base_url = config.paypal_base_url @ssl_cert_path = config.ssl_cert_path @ssl_cert_file = config.ssl_cert_file @api_cert_file = config.api_cert_file @verify_mode = config.verify_mode end |
Instance Method Details
#send_back(data) ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/paypal_adaptive/ipn_notification.rb', line 17 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 = true http.verify_mode = @verify_mode http.ca_path = @ssl_cert_path unless @ssl_cert_path.nil? if @api_cert_file cert = File.read(@api_cert_file) http.cert = OpenSSL::X509::Certificate.new(cert) http.key = OpenSSL::PKey::RSA.new(cert) end http.ca_path = @ssl_cert_path unless @ssl_cert_path.blank? http.ca_file = @ssl_cert_file unless @ssl_cert_file.blank? path = "#{@paypal_base_url}/cgi-bin/webscr" response_data = http.post(path, data).body @verified = response_data == "VERIFIED" end |
#verified? ⇒ Boolean
39 40 41 |
# File 'lib/paypal_adaptive/ipn_notification.rb', line 39 def verified? @verified end |