Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save yortz/113006 to your computer and use it in GitHub Desktop.
Save yortz/113006 to your computer and use it in GitHub Desktop.
.....
# create a transaction which records the details of the notification
object.txns.create(:transaction_id => ipn.transaction_id,
:amount => ipn.gross,
:fee => ipn.fee,
:currency_type => ipn.currency,
:status => ipn.status,
:received_at => ipn.received_at)
# if ipn.acknowledge
ack = nil
begin
ack = ipn.instance_eval do
payload = raw
puts "PayPal::pp_acknowledge payload = #{payload.inspect} "
uri = URI.parse('https://www.sandbox.paypal.com/cgi-bin/webscr')
request_path = "#{uri.path}?cmd=_notify-validate"
puts "PayPal::pp_acknowledge before create a new post"
request = Net::HTTP::Post.new(request_path)
request['Content-Length'] = "#{payload.size}"
request['User-Agent'] = "paypal-ruby -- http://rubyforge.org/projects/paypal/"
http = Net::HTTP.new(uri.host, uri.port)
http.verify_mode = OpenSSL::SSL::VERIFY_NONE unless @ssl_strict
http.use_ssl = true
puts "PayPal::pp_acknowledge before request"
request = http.request(request, payload)
puts "PayPal::pp_acknowledge request = #{request.inspect} "
puts "PayPal::pp_acknowledge request body = #{request.body.inspect} "
raise StandardError.new("Faulty paypal result: #{request.body}") unless ["VERIFIED", "INVALID"].include?(request.body)
request.body == "VERIFIED"
end
rescue Exception => e
logger.info "Exception! #{e.message}"
end
if ack
case ipn.status
when "Completed"
...
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment