pagseguro 0.1.8 → 0.1.9.beta.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/Gemfile.lock +1 -1
- data/README.markdown +13 -14
- data/lib/pagseguro/base.rb +0 -14
- data/lib/pagseguro/cacert.pem +3985 -248
- data/lib/pagseguro/notification.rb +7 -14
- data/lib/pagseguro/utils.rb +0 -8
- data/lib/pagseguro/version.rb +2 -2
- data/lib/pagseguro/views/_form.html.erb +4 -3
- data/spec/helpers/helper_spec.rb +1 -9
- data/spec/pagseguro/notification_spec.rb +0 -21
- data/spec/pagseguro/pagseguro_spec.rb +0 -10
- metadata +6 -8
@@ -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.
|
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
|
61
|
+
:id => params["ProdID_#{i}"],
|
69
62
|
:description => params["ProdDescricao_#{i}"],
|
70
|
-
:quantity
|
71
|
-
:price
|
72
|
-
:shipping
|
73
|
-
:fees
|
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 =
|
174
|
+
request_params = params.merge({
|
182
175
|
:Comando => "validar",
|
183
176
|
:Token => @token || PagSeguro.config["authenticity_token"]
|
184
177
|
}).dup
|
data/lib/pagseguro/utils.rb
CHANGED
data/lib/pagseguro/version.rb
CHANGED
@@ -1,5 +1,6 @@
|
|
1
|
-
<form
|
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}",
|
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],
|
21
|
+
<%= hidden_field_tag PagSeguro::Order::BILLING_MAPPING[name.to_sym], value %>
|
21
22
|
<% end %>
|
22
23
|
|
23
24
|
<%= submit_tag options[:submit] %>
|
data/spec/helpers/helper_spec.rb
CHANGED
@@ -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.
|
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-
|
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:
|
158
|
+
version: 1.3.1
|
161
159
|
requirements: []
|
162
160
|
|
163
161
|
rubyforge_project:
|
164
|
-
rubygems_version: 1.
|
162
|
+
rubygems_version: 1.7.2
|
165
163
|
signing_key:
|
166
164
|
specification_version: 3
|
167
165
|
summary: The official PagSeguro library
|