Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure IPN can be verified under Ruby 2.0 #76

Merged
merged 1 commit into from
Jan 8, 2014
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions lib/paypal_adaptive/ipn_notification.rb
Original file line number Diff line number Diff line change
@@ -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