Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

Use nokogiri to more accurately parse validation response

  • Loading branch information...
commit 11c76ef0830ebe59474a10674402c91da4be4ba7 1 parent d6387ac
@neophiliac neophiliac authored
Showing with 4 additions and 2 deletions.
  1. +1 −0  Rakefile
  2. +3 −2 lib/simplepay/helpers/notification_helper.rb
View
1  Rakefile
@@ -10,6 +10,7 @@ begin
p.summary = 'Amazon SimplePay helpers for Rails 3'
p.files = Dir["*", "{lib}/**/*"]
p.add_dependency 'activesupport', '~>3.0.0'
+ p.add_dependency 'nokogiri', '~>1.4'
end
Jeweler::GemcutterTasks.new
rescue LoadError
View
5 lib/simplepay/helpers/notification_helper.rb
@@ -1,4 +1,5 @@
require 'cgi'
+require 'nokogiri'
require 'open-uri'
module Simplepay
@@ -44,8 +45,8 @@ def valid_simplepay_request?(endpoint, query)
query = CGI.escape(query)
url_and_query = url + "/?Action=VerifySignature&Version=2008-09-17&UrlEndPoint=#{endpoint}&HttpParameters=#{query}"
- result = open(url_and_query) rescue false
- result.read =~ /Success/ ? true : false
+ result = Nokogiri::XML(open(url_and_query)) rescue false
+ result.css("VerificationStatus").children.to_s == "Success"
end
end
Please sign in to comment.
Something went wrong with that request. Please try again.