lib/pagseguro/notification.rb in pagseguro-0.1.8 vs lib/pagseguro/notification.rb in pagseguro-0.1.9.beta.0
- old
+ new
@@ -37,42 +37,35 @@
attr_accessor :params
# Expects the params object from the current request
def initialize(params, token = nil)
@token = token
- @params = PagSeguro.utf8? ? params : normalize(params)
+ @params = PagSeguro.developer? ? params : normalize(params)
end
# Normalize the specified hash converting all data to UTF-8
def normalize(hash)
each_value(hash) do |value|
Utils.to_utf8(value)
end
end
- # Denormalize the specified hash converting all data to ISO-8859-1
- def denormalize(hash)
- each_value(hash) do |value|
- Utils.to_iso8859(value)
- end
- end
-
# Return a list of products sent by PagSeguro.
# The values will be normalized
# (e.g. currencies will be converted to cents, quantity will be an integer)
def products
@products ||= begin
items = []
for i in (1..params["NumItens"].to_i)
items << {
- :id => params["ProdID_#{i}"],
+ :id => params["ProdID_#{i}"],
:description => params["ProdDescricao_#{i}"],
- :quantity => params["ProdQuantidade_#{i}"].to_i,
- :price => to_price(params["ProdValor_#{i}"]),
- :shipping => to_price(params["ProdFrete_#{i}"]),
- :fees => to_price(params["ProdExtras_#{i}"])
+ :quantity => params["ProdQuantidade_#{i}"].to_i,
+ :price => to_price(params["ProdValor_#{i}"]),
+ :shipping => to_price(params["ProdFrete_#{i}"]),
+ :fees => to_price(params["ProdExtras_#{i}"])
}
end
items
end
@@ -176,10 +169,10 @@
# developer mode.
def validates?
return true if PagSeguro.developer?
# include the params to validate our request
- request_params = denormalize params.merge({
+ request_params = params.merge({
:Comando => "validar",
:Token => @token || PagSeguro.config["authenticity_token"]
}).dup
# do the request