diff --git a/lib/pagseguro/notification.rb b/lib/pagseguro/notification.rb index b56a970..14c4b0a 100644 --- a/lib/pagseguro/notification.rb +++ b/lib/pagseguro/notification.rb @@ -13,7 +13,8 @@ class Notification :transaction_id => "TransacaoID", :shipping_type => "TipoFrete", :shipping => "ValorFrete", - :notes => "Anotacao" + :notes => "Anotacao", + :extras => "Extras" } # Map order status from PagSeguro. @@ -205,23 +206,43 @@ def to_price(amount) def validates? return true if PagSeguro.developer? - # include the params to validate our request - request_params = params.merge({ - :Comando => "validar", - :Token => @token || PagSeguro.config["authenticity_token"] - }).dup - - # do the request - uri = URI.parse(API_URL) - http = Net::HTTP.new(uri.host, uri.port) - http.use_ssl = true - http.verify_mode = OpenSSL::SSL::VERIFY_PEER - http.ca_file = File.dirname(__FILE__) + "/cacert.pem" - - request = Net::HTTP::Post.new(uri.path) - request.form_data = denormalize(request_params) - response = http.start {|r| r.request request } - (response.body =~ /VERIFICADO/) != nil + begin + # include the params to validate our request + request_params = params.merge({ + :Comando => "validar", + :Token => @token || PagSeguro.config["authenticity_token"] + }).dup + + # do the request + uri = URI.parse(API_URL) + http = Net::HTTP.new(uri.host, uri.port) + http.use_ssl = true + http.verify_mode = OpenSSL::SSL::VERIFY_NONE + + request = Net::HTTP::Post.new(uri.path) + request.form_data = denormalize(request_params) + response = http.start {|r| r.request request } + (response.body =~ /VERIFICADO/) != nil + rescue + # include the params to validate our request + request_params = params.merge({ + :Comando => "validar", + :Token => @token || PagSeguro.config["authenticity_token"] + }).dup + + # do the request + uri = URI.parse(API_URL) + http = Net::HTTP.new(uri.host, uri.port) + http.use_ssl = true + http.verify_mode = OpenSSL::SSL::VERIFY_PEER + http.ssl_version = :SSLv3 + http.ca_file = File.dirname(__FILE__) + "/cacert.pem" + + request = Net::HTTP::Post.new(uri.path) + request.form_data = denormalize(request_params) + response = http.start {|r| r.request request } + (response.body =~ /VERIFICADO/) != nil + end end end end