pagseguro 0.1.8 → 0.1.9.beta.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -39,7 +39,7 @@ module PagSeguro
39
39
  # Expects the params object from the current request
40
40
  def initialize(params, token = nil)
41
41
  @token = token
42
- @params = PagSeguro.utf8? ? params : normalize(params)
42
+ @params = PagSeguro.developer? ? params : normalize(params)
43
43
  end
44
44
 
45
45
  # Normalize the specified hash converting all data to UTF-8
@@ -49,13 +49,6 @@ module PagSeguro
49
49
  end
50
50
  end
51
51
 
52
- # Denormalize the specified hash converting all data to ISO-8859-1
53
- def denormalize(hash)
54
- each_value(hash) do |value|
55
- Utils.to_iso8859(value)
56
- end
57
- end
58
-
59
52
  # Return a list of products sent by PagSeguro.
60
53
  # The values will be normalized
61
54
  # (e.g. currencies will be converted to cents, quantity will be an integer)
@@ -65,12 +58,12 @@ module PagSeguro
65
58
 
66
59
  for i in (1..params["NumItens"].to_i)
67
60
  items << {
68
- :id => params["ProdID_#{i}"],
61
+ :id => params["ProdID_#{i}"],
69
62
  :description => params["ProdDescricao_#{i}"],
70
- :quantity => params["ProdQuantidade_#{i}"].to_i,
71
- :price => to_price(params["ProdValor_#{i}"]),
72
- :shipping => to_price(params["ProdFrete_#{i}"]),
73
- :fees => to_price(params["ProdExtras_#{i}"])
63
+ :quantity => params["ProdQuantidade_#{i}"].to_i,
64
+ :price => to_price(params["ProdValor_#{i}"]),
65
+ :shipping => to_price(params["ProdFrete_#{i}"]),
66
+ :fees => to_price(params["ProdExtras_#{i}"])
74
67
  }
75
68
  end
76
69
 
@@ -178,7 +171,7 @@ module PagSeguro
178
171
  return true if PagSeguro.developer?
179
172
 
180
173
  # include the params to validate our request
181
- request_params = denormalize params.merge({
174
+ request_params = params.merge({
182
175
  :Comando => "validar",
183
176
  :Token => @token || PagSeguro.config["authenticity_token"]
184
177
  }).dup
@@ -2,14 +2,6 @@ module PagSeguro
2
2
  module Utils
3
3
  extend self
4
4
 
5
- def encode(string)
6
- if PagSeguro.utf8?
7
- string
8
- else
9
- to_iso8859(string)
10
- end
11
- end
12
-
13
5
  def to_utf8(string)
14
6
  string.to_s.unpack('C*').pack('U*')
15
7
  end
@@ -2,7 +2,7 @@ module PagSeguro
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 1
5
- PATCH = 8
6
- STRING = "#{MAJOR}.#{MINOR}.#{PATCH}"
5
+ PATCH = 9
6
+ STRING = "#{MAJOR}.#{MINOR}.#{PATCH}.beta.0"
7
7
  end
8
8
  end
@@ -1,5 +1,6 @@
1
- <form accept-charset="<%= PagSeguro.encoding %>" action="<%= PagSeguro.gateway_url %>" class="pagseguro" method="post">
1
+ <form action="<%= PagSeguro.gateway_url %>" class="pagseguro" method="post">
2
2
  <div>
3
+ <%= hidden_field_tag "encoding", "UTF-8" %>
3
4
  <%= hidden_field_tag "email_cobranca", options.fetch(:email, PagSeguro.config["email"]) %>
4
5
  <%= hidden_field_tag "tipo", "CP" %>
5
6
  <%= hidden_field_tag "moeda", "BRL" %>
@@ -10,14 +11,14 @@
10
11
  <% i += 1 %>
11
12
  <%= hidden_field_tag "item_quant_#{i}", product[:quantity] %>
12
13
  <%= hidden_field_tag "item_id_#{i}", product[:id] %>
13
- <%= hidden_field_tag "item_descr_#{i}", PagSeguro::Utils.encode(product[:description]) %>
14
+ <%= hidden_field_tag "item_descr_#{i}", product[:description] %>
14
15
  <%= hidden_field_tag "item_valor_#{i}", product[:price] %>
15
16
  <%= hidden_field_tag "item_peso_#{i}", product[:weight].to_i if product[:weight] %>
16
17
  <%= hidden_field_tag "item_frete_#{i}", product[:shipping].to_i if product[:shipping] %>
17
18
  <% end %>
18
19
 
19
20
  <% order.billing.each do |name, value| %>
20
- <%= hidden_field_tag PagSeguro::Order::BILLING_MAPPING[name.to_sym], PagSeguro::Utils.encode(value) %>
21
+ <%= hidden_field_tag PagSeguro::Order::BILLING_MAPPING[name.to_sym], value %>
21
22
  <% end %>
22
23
 
23
24
  <%= submit_tag options[:submit] %>
@@ -12,9 +12,9 @@ describe PagSeguro::Helper do
12
12
  }
13
13
 
14
14
  context "with default attributes" do
15
- it { should have_attr("accept-charset", "ISO-8859-1") }
16
15
  it { should have_attr("action", PagSeguro::GATEWAY_URL) }
17
16
  it { should have_attr("class", "pagseguro") }
17
+ it { should have_input(:name => "encoding", :value => "UTF-8") }
18
18
  it { should have_input(:name => "tipo", :value => "CP") }
19
19
  it { should have_input(:name => "moeda", :value => "BRL") }
20
20
  it { should have_input(:name => "ref_transacao", :value => "I1001") }
@@ -23,14 +23,6 @@ describe PagSeguro::Helper do
23
23
  it { should have_input(:type => "submit", :value => "Pagar com PagSeguro") }
24
24
  end
25
25
 
26
- context "when running development mode" do
27
- before do
28
- PagSeguro.stub :developer? => true
29
- end
30
-
31
- it { should have_attr("accept-charset", "UTF-8") }
32
- end
33
-
34
26
  it "should include shipping type" do
35
27
  @order.shipping_type = "SD"
36
28
  subject.should have_input(:name => "tipo_frete", :value => "SD")
@@ -283,23 +283,6 @@ describe PagSeguro::Notification do
283
283
 
284
284
  @notification.valid?
285
285
  end
286
-
287
- it "should propagate params in ISO-8859-1" do
288
- param!("CliNome", "João Doão")
289
- PagSeguro.stub!(:config).and_return("authenticity_token" => "ABCDEF")
290
-
291
- post = mock("post").as_null_object
292
- post.should_receive(:set_form_data).with({
293
- :Comando => "validar",
294
- :Token => "ABCDEF",
295
- "CliNome" => to_iso("João Doão")
296
- })
297
-
298
- Net::HTTP.should_receive(:new).and_return(mock("http").as_null_object)
299
- Net::HTTP::Post.should_receive(:new).and_return(post)
300
-
301
- @notification.valid?
302
- end
303
286
  end
304
287
 
305
288
  private
@@ -315,10 +298,6 @@ describe PagSeguro::Notification do
315
298
  @notification.params.merge!(name => value)
316
299
  end
317
300
 
318
- def to_iso(str)
319
- str.unpack('U*').pack('C*')
320
- end
321
-
322
301
  def set_product!(options={})
323
302
  @__products ||= []
324
303
 
@@ -11,16 +11,6 @@ describe PagSeguro do
11
11
  module PagSeguro; @@config = nil; end
12
12
  end
13
13
 
14
- it "should set encoding as UTF-8 when running in development mode" do
15
- PagSeguro.stub :developer? => true
16
- PagSeguro.encoding.should == "UTF-8"
17
- end
18
-
19
- it "should set encoding as ISO-8859-1 when running in production mode" do
20
- PagSeguro.stub :developer? => false
21
- PagSeguro.encoding.should == "ISO-8859-1"
22
- end
23
-
24
14
  it "should raise error if configuration is not found" do
25
15
  File.should_receive(:exist?).with(@config_file).and_return(false)
26
16
  expect { PagSeguro.config }.to raise_error(PagSeguro::MissingConfigurationError)
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: pagseguro
3
3
  version: !ruby/object:Gem::Version
4
- prerelease:
5
- version: 0.1.8
4
+ prerelease: 6
5
+ version: 0.1.9.beta.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Nando Vieira
@@ -10,8 +10,7 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-04-04 00:00:00 -03:00
14
- default_executable:
13
+ date: 2011-04-13 00:00:00 Z
15
14
  dependencies:
16
15
  - !ruby/object:Gem::Dependency
17
16
  name: rails
@@ -137,7 +136,6 @@ files:
137
136
  - spec/support/tmp/.gitkeep
138
137
  - spec/support/tmp/pagseguro-test.yml
139
138
  - templates/config.yml
140
- has_rdoc: true
141
139
  homepage: http://rubygems.org/gems/pagseguro
142
140
  licenses: []
143
141
 
@@ -155,13 +153,13 @@ required_ruby_version: !ruby/object:Gem::Requirement
155
153
  required_rubygems_version: !ruby/object:Gem::Requirement
156
154
  none: false
157
155
  requirements:
158
- - - ">="
156
+ - - ">"
159
157
  - !ruby/object:Gem::Version
160
- version: "0"
158
+ version: 1.3.1
161
159
  requirements: []
162
160
 
163
161
  rubyforge_project:
164
- rubygems_version: 1.6.0
162
+ rubygems_version: 1.7.2
165
163
  signing_key:
166
164
  specification_version: 3
167
165
  summary: The official PagSeguro library