Skip to content

Commit

Permalink
Merge pull request #76 from rchekaluk/master
Browse files Browse the repository at this point in the history
Ensure IPN can be verified under Ruby 2.0
  • Loading branch information
tc committed Jan 8, 2014
2 parents 4724235 + b1989dd commit 4156247
Showing 1 changed file with 7 additions and 3 deletions.
10 changes: 7 additions & 3 deletions lib/paypal_adaptive/ipn_notification.rb
@@ -1,6 +1,7 @@
require 'net/http'
require 'net/https'
require 'json'
require 'rack/utils'

module PaypalAdaptive
class IpnNotification
Expand All @@ -16,7 +17,8 @@ def initialize(env=nil)

def send_back(data)
data = "cmd=_notify-validate&#{data}"
url = URI.parse @paypal_base_url
path = "#{@paypal_base_url}/cgi-bin/webscr"
url = URI.parse path
http = Net::HTTP.new(url.host, 443)
http.use_ssl = true
http.verify_mode = @verify_mode
Expand All @@ -30,8 +32,10 @@ def send_back(data)
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
req = Net::HTTP::Post.new(url.request_uri)
req.set_form_data(Rack::Utils.parse_nested_query(data))
req['Accept-Encoding'] = 'identity'
response_data = http.request(req).body

@verified = response_data == "VERIFIED"
end
Expand Down

0 comments on commit 4156247

Please sign in to comment.