Skip to content
Browse files

handle 400 errors and XML returns, correct comments to match parms

  • Loading branch information...
1 parent 11c76ef commit 59b99e404908bc7075c6c79510c585499b27d561 @neophiliac neophiliac committed
Showing with 8 additions and 7 deletions.
  1. +1 −1 VERSION
  2. +1 −1 lib/simplepay.rb
  3. +6 −5 lib/simplepay/helpers/notification_helper.rb
View
2 VERSION
@@ -1 +1 @@
-0.2.2.1
+0.2.2.2
View
2 lib/simplepay.rb
@@ -17,7 +17,7 @@
module Simplepay
- VERSION = '0.2.2.1' unless const_defined?(:VERSION)
+ VERSION = '0.2.2.2' unless const_defined?(:VERSION)
mattr_accessor :aws_access_key_id
@@aws_access_key_id = ''
View
11 lib/simplepay/helpers/notification_helper.rb
@@ -8,13 +8,13 @@ module Helpers
##
# Adds a +valid_simplepay_request?+ method to your ActionControllers.
#
- # In order to use this, you should just directly hand your +params+ into
- # the method:
+ # In order to use this, you should just directly hand your ipn endpoint and
+ # +params+ into the method:
#
# class FooController < ApplicationController
#
# def receive_ipn
- # if valid_simplepay_request?(params)
+ # if valid_simplepay_request?(endpoint, request.query_params)
# ... record something useful ...
# else
# ... maybe log a bad request? ...
@@ -41,14 +41,15 @@ module NotificationHelper
#
def valid_simplepay_request?(endpoint, query)
url = Simplepay.use_sandbox ? 'https://fps.sandbox.amazonaws.com' : 'https://fps.amazonaws.com'
+
endpoint = CGI.escape(endpoint)
query = CGI.escape(query)
url_and_query = url + "/?Action=VerifySignature&Version=2008-09-17&UrlEndPoint=#{endpoint}&HttpParameters=#{query}"
+
result = Nokogiri::XML(open(url_and_query)) rescue false
- result.css("VerificationStatus").children.to_s == "Success"
+ return (result ? (result.css("VerificationStatus").children.to_s == "Success") : false)
end
-
end
end

0 comments on commit 59b99e4

Please sign in to comment.
Something went wrong with that request. Please try again.