rbraspag 0.0.11 → 0.0.12
Sign up to get free protection for your applications and to get access to all the features.
- data/Gemfile.lock +3 -3
- data/config/braspag.yml +12 -0
- data/lib/rbraspag/bill.rb +79 -79
- data/lib/rbraspag/connection.rb +15 -5
- data/lib/rbraspag/credit_card.rb +52 -42
- data/lib/rbraspag/crypto/jar_webservice.rb +12 -14
- data/lib/rbraspag/crypto/webservice.rb +14 -17
- data/lib/rbraspag/eft.rb +32 -48
- data/lib/rbraspag/order.rb +7 -37
- data/lib/rbraspag/utils.rb +27 -3
- data/lib/rbraspag/version.rb +1 -1
- data/lib/rbraspag.rb +0 -7
- data/rbraspag-0.0.11.gem +0 -0
- data/spec/bill_spec.rb +399 -314
- data/spec/connection_spec.rb +101 -26
- data/spec/credit_card_spec.rb +117 -48
- data/spec/crypto/jar_webservice_spec.rb +3 -6
- data/spec/crypto/webservice_spec.rb +9 -31
- data/spec/eft_spec.rb +137 -156
- data/spec/order_spec.rb +10 -24
- data/spec/utils_spec.rb +2 -0
- metadata +22 -20
data/spec/eft_spec.rb
CHANGED
@@ -2,161 +2,153 @@
|
|
2
2
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
3
3
|
|
4
4
|
describe Braspag::Eft do
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
describe ".new" do
|
11
|
-
|
12
|
-
it "should raise an error when no connection is given" do
|
13
|
-
expect {
|
14
|
-
Braspag::Eft.new("", {})
|
15
|
-
}.to raise_error(Braspag::InvalidConnection)
|
5
|
+
let!(:key) { "1234561246" }
|
6
|
+
describe ".payment_method_from_id" do
|
7
|
+
it 'Eft' do
|
8
|
+
Braspag::Eft.payment_method_from_id(31).should == :unibanco
|
9
|
+
Braspag::Eft.payment_method_from_id(31).should be_kind_of Symbol
|
16
10
|
end
|
11
|
+
end
|
17
12
|
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
13
|
+
describe ".generate" do
|
14
|
+
context "consistencies" do
|
15
|
+
|
16
|
+
it "should raise an error when :order_id is not present" do
|
17
|
+
expect {
|
18
|
+
Braspag::Eft.generate({
|
19
|
+
:amount => "100.00",
|
20
|
+
:payment_method => :bradesco
|
21
|
+
})
|
22
|
+
}.to raise_error(Braspag::IncompleteParams)
|
23
|
+
end
|
26
24
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
25
|
+
it "should raise an error when :amount is not present" do
|
26
|
+
expect {
|
27
|
+
Braspag::Eft.generate({
|
28
|
+
:order_id => "12",
|
29
|
+
:payment_method => :bradesco
|
30
|
+
})
|
31
|
+
}.to raise_error(Braspag::IncompleteParams)
|
32
|
+
end
|
35
33
|
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
34
|
+
it "should raise an error when :payment_method is not present" do
|
35
|
+
expect {
|
36
|
+
Braspag::Eft.generate({
|
37
|
+
:order_id => "13",
|
38
|
+
:amount => "120.00"
|
39
|
+
})
|
40
|
+
}.to raise_error(Braspag::IncompleteParams)
|
41
|
+
end
|
44
42
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
43
|
+
it "should raise an error when :order_id is less than 1 character" do
|
44
|
+
expect {
|
45
|
+
Braspag::Eft.generate({
|
46
|
+
:order_id => "",
|
47
|
+
:amount => "123.00",
|
48
|
+
:payment_method => :bradesco
|
49
|
+
})
|
50
|
+
}.to raise_error(Braspag::InvalidOrderId)
|
51
|
+
end
|
54
52
|
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
53
|
+
it "should raise an error when :order_id is more than 50 characters" do
|
54
|
+
expect {
|
55
|
+
Braspag::Eft.generate({
|
56
|
+
:order_id => "1" * 51,
|
57
|
+
:amount => "12.00",
|
58
|
+
:payment_method => :bradesco
|
59
|
+
})
|
60
|
+
}.to raise_error(Braspag::InvalidOrderId)
|
61
|
+
end
|
64
62
|
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
63
|
+
it "should raise an error when :customer_name is less than 1 character" do
|
64
|
+
expect {
|
65
|
+
Braspag::Eft.generate({
|
66
|
+
:order_id => "102",
|
67
|
+
:amount => "42.00",
|
68
|
+
:payment_method => :bradesco,
|
69
|
+
:customer_name => ""
|
70
|
+
})
|
71
|
+
}.to raise_error(Braspag::InvalidCustomerName)
|
72
|
+
end
|
75
73
|
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
74
|
+
it "should raise an error when :customer_name is more than 255 characters" do
|
75
|
+
expect {
|
76
|
+
Braspag::Eft.generate({
|
77
|
+
:order_id => "112",
|
78
|
+
:amount => "121.00",
|
79
|
+
:payment_method => :bradesco,
|
80
|
+
:customer_name => "A" * 256
|
81
|
+
})
|
82
|
+
}.to raise_error(Braspag::InvalidCustomerName)
|
83
|
+
end
|
86
84
|
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
|
96
|
-
|
85
|
+
it "should raise an error when :customer_id is less than 11 characters" do
|
86
|
+
expect {
|
87
|
+
Braspag::Eft.generate({
|
88
|
+
:order_id => "23",
|
89
|
+
:amount => "251.00",
|
90
|
+
:payment_method => :bradesco,
|
91
|
+
:customer_id => "2" * 10
|
92
|
+
})
|
93
|
+
}.to raise_error(Braspag::InvalidCustomerId)
|
94
|
+
end
|
97
95
|
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
96
|
+
it "should raise an error when :customer_id is more than 18 characters" do
|
97
|
+
expect {
|
98
|
+
Braspag::Eft.generate({
|
99
|
+
:order_id => "90",
|
100
|
+
:amount => "90.00",
|
101
|
+
:payment_method => :bradesco,
|
102
|
+
:customer_id => "3" * 19
|
103
|
+
})
|
104
|
+
}.to raise_error(Braspag::InvalidCustomerId)
|
105
|
+
end
|
108
106
|
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
107
|
+
it "should raise an error when :installments is less than 1 character" do
|
108
|
+
expect {
|
109
|
+
Braspag::Eft.generate({
|
110
|
+
:order_id => "900",
|
111
|
+
:amount => "92.00",
|
112
|
+
:payment_method => :bradesco,
|
113
|
+
:installments => ""
|
114
|
+
})
|
115
|
+
}.to raise_error(Braspag::InvalidInstallments)
|
116
|
+
end
|
119
117
|
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
|
124
|
-
|
125
|
-
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
118
|
+
it "should raise an error when :installments is more than 2 characters" do
|
119
|
+
expect {
|
120
|
+
Braspag::Eft.generate({
|
121
|
+
:order_id => "91",
|
122
|
+
:amount => "80.00",
|
123
|
+
:payment_method => :bradesco,
|
124
|
+
:installments => "5" * 3
|
125
|
+
})
|
126
|
+
}.to raise_error(Braspag::InvalidInstallments)
|
127
|
+
end
|
130
128
|
|
131
|
-
|
132
|
-
|
133
|
-
|
134
|
-
|
135
|
-
|
136
|
-
|
137
|
-
|
138
|
-
|
139
|
-
|
140
|
-
|
129
|
+
it "should raise an error when :installments is not a number" do
|
130
|
+
expect {
|
131
|
+
Braspag::Eft.generate({
|
132
|
+
:order_id => "91",
|
133
|
+
:amount => "80.00",
|
134
|
+
:payment_method => :bradesco,
|
135
|
+
:installments => "A" * 2
|
136
|
+
})
|
137
|
+
}.to raise_error(Braspag::InvalidInstallments)
|
138
|
+
end
|
141
139
|
|
142
|
-
|
143
|
-
|
144
|
-
|
145
|
-
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
140
|
+
it "should raise an error when :has_interest is not boolean" do
|
141
|
+
expect {
|
142
|
+
Braspag::Eft.generate({
|
143
|
+
:order_id => "76",
|
144
|
+
:amount => "50.00",
|
145
|
+
:payment_method => :bradesco,
|
146
|
+
:has_interest => []
|
147
|
+
})
|
148
|
+
}.to raise_error(Braspag::InvalidHasInterest)
|
149
|
+
end
|
151
150
|
end
|
152
|
-
end
|
153
151
|
|
154
|
-
describe ".generate" do
|
155
|
-
let!(:crypto_key) {"{84BE7E7F-698A-6C74-F820-AE359C2A07C2}"}
|
156
|
-
let!(:braspag_crypto_jar_webservice) {Braspag::Crypto::JarWebservice.new(crypto_key, "http://localhost:9292")}
|
157
|
-
let!(:braspag_crypto_webservice) {Braspag::Crypto::Webservice.new(connection)}
|
158
|
-
|
159
|
-
|
160
152
|
it "should return form fields in strategy without crypto" do
|
161
153
|
html = <<-EOHTML
|
162
154
|
<form id="form_tef_1234123125" name="form_tef_1234123125" action="https://homologacao.pagador.com.br/pagador/passthru.asp" method="post">
|
@@ -174,11 +166,11 @@ describe Braspag::Eft do
|
|
174
166
|
</script>
|
175
167
|
EOHTML
|
176
168
|
|
177
|
-
Braspag::Eft.
|
169
|
+
Braspag::Eft.generate({
|
178
170
|
:order_id => "1234123125",
|
179
171
|
:amount => "123.00",
|
180
172
|
:payment_method => :bradesco
|
181
|
-
}).
|
173
|
+
}).should == html
|
182
174
|
end
|
183
175
|
|
184
176
|
it "should return form fields in strategy with braspag.jar crypto service" do
|
@@ -199,17 +191,16 @@ describe Braspag::Eft do
|
|
199
191
|
</script>
|
200
192
|
EOHTML
|
201
193
|
|
202
|
-
Braspag::Eft.
|
194
|
+
Braspag::Eft.generate({
|
203
195
|
:order_id => "1234123125",
|
204
196
|
:amount => "123.00",
|
205
197
|
:payment_method => :bradesco
|
206
|
-
} ,
|
198
|
+
} , Braspag::Crypto::JarWebservice ).should == html
|
207
199
|
|
208
200
|
FakeWeb.clean_registry
|
209
201
|
|
210
202
|
end
|
211
203
|
|
212
|
-
let!(:key) { "12312312312313123123" }
|
213
204
|
it "should return form fields in strategy with braspag crypto webservice" do
|
214
205
|
|
215
206
|
FakeWeb.register_uri(:post,
|
@@ -226,23 +217,13 @@ describe Braspag::Eft do
|
|
226
217
|
</script>
|
227
218
|
EOHTML
|
228
219
|
|
229
|
-
Braspag::Eft.
|
220
|
+
Braspag::Eft.generate({
|
230
221
|
:order_id => "1234123125",
|
231
222
|
:amount => "123.00",
|
232
223
|
:payment_method => :bradesco
|
233
|
-
} ,
|
224
|
+
} , Braspag::Crypto::Webservice ).should == html
|
234
225
|
|
235
226
|
FakeWeb.clean_registry
|
236
|
-
|
237
227
|
end
|
238
|
-
|
239
|
-
context ".payment_method_from_id" do
|
240
|
-
it 'Eft' do
|
241
|
-
Braspag::Eft.payment_method_from_id(31).should == :unibanco
|
242
|
-
Braspag::Eft.payment_method_from_id(31).should be_kind_of Symbol
|
243
|
-
end
|
244
|
-
end
|
245
|
-
|
246
228
|
end
|
247
|
-
|
248
229
|
end
|
data/spec/order_spec.rb
CHANGED
@@ -2,33 +2,24 @@
|
|
2
2
|
require File.expand_path(File.dirname(__FILE__) + '/spec_helper')
|
3
3
|
|
4
4
|
describe Braspag::Order do
|
5
|
-
|
6
|
-
let!(:merchant_id) {"{84BE7E7F-698A-6C74-F820-AE359C2A07C2}"}
|
7
|
-
let!(:connection) {Braspag::Connection.new(merchant_id, :test)}
|
5
|
+
let!(:braspag_url) { "https://homologacao.pagador.com.br" }
|
8
6
|
|
9
7
|
describe "#status" do
|
10
|
-
|
11
|
-
it "should raise an error when no connection is given" do
|
12
|
-
expect {
|
13
|
-
Braspag::Order.status("", nil)
|
14
|
-
}.to raise_error(Braspag::InvalidConnection)
|
15
|
-
end
|
16
|
-
|
17
8
|
it "should raise an error when no order_id is given" do
|
18
9
|
expect {
|
19
|
-
Braspag::Order.status(
|
10
|
+
Braspag::Order.status(nil)
|
20
11
|
}.to raise_error(Braspag::InvalidOrderId)
|
21
12
|
end
|
22
13
|
|
23
14
|
it "should raise an error when order_id is empty" do
|
24
15
|
expect {
|
25
|
-
Braspag::Order.status(
|
16
|
+
Braspag::Order.status("")
|
26
17
|
}.to raise_error(Braspag::InvalidOrderId)
|
27
18
|
end
|
28
19
|
|
29
20
|
it "should raise an error when order_id is more than 50 characters" do
|
30
21
|
expect {
|
31
|
-
Braspag::Order.status(
|
22
|
+
Braspag::Order.status("1" * 51)
|
32
23
|
}.to raise_error(Braspag::InvalidOrderId)
|
33
24
|
end
|
34
25
|
|
@@ -41,17 +32,16 @@ describe Braspag::Order do
|
|
41
32
|
xmlns="http://www.pagador.com.br/" />
|
42
33
|
EOXML
|
43
34
|
|
44
|
-
FakeWeb.register_uri(:post, "#{
|
35
|
+
FakeWeb.register_uri(:post, "#{braspag_url}/pagador/webservice/pedido.asmx/GetDadosPedido",
|
45
36
|
:body => xml)
|
46
37
|
|
47
38
|
expect {
|
48
|
-
Braspag::Order.status(
|
39
|
+
Braspag::Order.status("sadpoakjspodqdouq09wduwq")
|
49
40
|
}.to raise_error(Braspag::Order::InvalidData)
|
50
41
|
|
51
|
-
new_connection = Braspag::Connection.new("{12345678-1234-1234-1234-123456789012}", :test)
|
52
42
|
|
53
43
|
expect {
|
54
|
-
Braspag::Order.status(
|
44
|
+
Braspag::Order.status("asdnasdniousa")
|
55
45
|
}.to raise_error(Braspag::Order::InvalidData)
|
56
46
|
|
57
47
|
FakeWeb.clean_registry
|
@@ -78,9 +68,9 @@ describe Braspag::Order do
|
|
78
68
|
</DadosPedido>
|
79
69
|
EOXML
|
80
70
|
|
81
|
-
FakeWeb.register_uri(:post, "#{
|
82
|
-
|
83
|
-
order_info = Braspag::Order.status(
|
71
|
+
FakeWeb.register_uri(:post, "#{braspag_url}/pagador/webservice/pedido.asmx/GetDadosPedido",
|
72
|
+
:body => xml)
|
73
|
+
order_info = Braspag::Order.status("12345")
|
84
74
|
FakeWeb.clean_registry
|
85
75
|
order_info
|
86
76
|
}
|
@@ -108,11 +98,7 @@ describe Braspag::Order do
|
|
108
98
|
it "should return a Hash with :#{key.to_s} key" do
|
109
99
|
order_info[key].should == value
|
110
100
|
end
|
111
|
-
|
112
101
|
end
|
113
102
|
end
|
114
|
-
|
115
103
|
end
|
116
|
-
|
117
104
|
end
|
118
|
-
|
data/spec/utils_spec.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rbraspag
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.12
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -14,12 +14,12 @@ authors:
|
|
14
14
|
autorequire:
|
15
15
|
bindir: bin
|
16
16
|
cert_chain: []
|
17
|
-
date: 2011-
|
17
|
+
date: 2011-08-04 00:00:00.000000000 -03:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
21
21
|
name: cs-httpi
|
22
|
-
requirement: &
|
22
|
+
requirement: &85379830 !ruby/object:Gem::Requirement
|
23
23
|
none: false
|
24
24
|
requirements:
|
25
25
|
- - ! '>='
|
@@ -27,10 +27,10 @@ dependencies:
|
|
27
27
|
version: 0.9.5.2
|
28
28
|
type: :runtime
|
29
29
|
prerelease: false
|
30
|
-
version_requirements: *
|
30
|
+
version_requirements: *85379830
|
31
31
|
- !ruby/object:Gem::Dependency
|
32
32
|
name: json
|
33
|
-
requirement: &
|
33
|
+
requirement: &85379620 !ruby/object:Gem::Requirement
|
34
34
|
none: false
|
35
35
|
requirements:
|
36
36
|
- - ! '>='
|
@@ -38,10 +38,10 @@ dependencies:
|
|
38
38
|
version: '0'
|
39
39
|
type: :runtime
|
40
40
|
prerelease: false
|
41
|
-
version_requirements: *
|
41
|
+
version_requirements: *85379620
|
42
42
|
- !ruby/object:Gem::Dependency
|
43
43
|
name: nokogiri
|
44
|
-
requirement: &
|
44
|
+
requirement: &85379390 !ruby/object:Gem::Requirement
|
45
45
|
none: false
|
46
46
|
requirements:
|
47
47
|
- - ! '>='
|
@@ -49,10 +49,10 @@ dependencies:
|
|
49
49
|
version: '0'
|
50
50
|
type: :runtime
|
51
51
|
prerelease: false
|
52
|
-
version_requirements: *
|
52
|
+
version_requirements: *85379390
|
53
53
|
- !ruby/object:Gem::Dependency
|
54
54
|
name: rspec
|
55
|
-
requirement: &
|
55
|
+
requirement: &85379180 !ruby/object:Gem::Requirement
|
56
56
|
none: false
|
57
57
|
requirements:
|
58
58
|
- - ! '>='
|
@@ -60,10 +60,10 @@ dependencies:
|
|
60
60
|
version: '0'
|
61
61
|
type: :development
|
62
62
|
prerelease: false
|
63
|
-
version_requirements: *
|
63
|
+
version_requirements: *85379180
|
64
64
|
- !ruby/object:Gem::Dependency
|
65
65
|
name: fakeweb
|
66
|
-
requirement: &
|
66
|
+
requirement: &85378970 !ruby/object:Gem::Requirement
|
67
67
|
none: false
|
68
68
|
requirements:
|
69
69
|
- - ! '>='
|
@@ -71,10 +71,10 @@ dependencies:
|
|
71
71
|
version: '0'
|
72
72
|
type: :development
|
73
73
|
prerelease: false
|
74
|
-
version_requirements: *
|
74
|
+
version_requirements: *85378970
|
75
75
|
- !ruby/object:Gem::Dependency
|
76
76
|
name: shoulda-matchers
|
77
|
-
requirement: &
|
77
|
+
requirement: &85378760 !ruby/object:Gem::Requirement
|
78
78
|
none: false
|
79
79
|
requirements:
|
80
80
|
- - ! '>='
|
@@ -82,10 +82,10 @@ dependencies:
|
|
82
82
|
version: '0'
|
83
83
|
type: :development
|
84
84
|
prerelease: false
|
85
|
-
version_requirements: *
|
85
|
+
version_requirements: *85378760
|
86
86
|
- !ruby/object:Gem::Dependency
|
87
87
|
name: guard-rspec
|
88
|
-
requirement: &
|
88
|
+
requirement: &85378550 !ruby/object:Gem::Requirement
|
89
89
|
none: false
|
90
90
|
requirements:
|
91
91
|
- - ! '>='
|
@@ -93,10 +93,10 @@ dependencies:
|
|
93
93
|
version: '0'
|
94
94
|
type: :development
|
95
95
|
prerelease: false
|
96
|
-
version_requirements: *
|
96
|
+
version_requirements: *85378550
|
97
97
|
- !ruby/object:Gem::Dependency
|
98
98
|
name: guard-bundler
|
99
|
-
requirement: &
|
99
|
+
requirement: &85378340 !ruby/object:Gem::Requirement
|
100
100
|
none: false
|
101
101
|
requirements:
|
102
102
|
- - ! '>='
|
@@ -104,10 +104,10 @@ dependencies:
|
|
104
104
|
version: '0'
|
105
105
|
type: :development
|
106
106
|
prerelease: false
|
107
|
-
version_requirements: *
|
107
|
+
version_requirements: *85378340
|
108
108
|
- !ruby/object:Gem::Dependency
|
109
109
|
name: ruby-debug19
|
110
|
-
requirement: &
|
110
|
+
requirement: &85378130 !ruby/object:Gem::Requirement
|
111
111
|
none: false
|
112
112
|
requirements:
|
113
113
|
- - ! '>='
|
@@ -115,7 +115,7 @@ dependencies:
|
|
115
115
|
version: '0'
|
116
116
|
type: :development
|
117
117
|
prerelease: false
|
118
|
-
version_requirements: *
|
118
|
+
version_requirements: *85378130
|
119
119
|
description: rbraspag gem to use Braspag gateway
|
120
120
|
email:
|
121
121
|
- tinorj@gmail.com
|
@@ -135,6 +135,7 @@ files:
|
|
135
135
|
- Guardfile
|
136
136
|
- README.md
|
137
137
|
- Rakefile
|
138
|
+
- config/braspag.yml
|
138
139
|
- lib/rbraspag.rb
|
139
140
|
- lib/rbraspag/bill.rb
|
140
141
|
- lib/rbraspag/connection.rb
|
@@ -147,6 +148,7 @@ files:
|
|
147
148
|
- lib/rbraspag/payment_method.rb
|
148
149
|
- lib/rbraspag/utils.rb
|
149
150
|
- lib/rbraspag/version.rb
|
151
|
+
- rbraspag-0.0.11.gem
|
150
152
|
- rbraspag.gemspec
|
151
153
|
- spec/bill_spec.rb
|
152
154
|
- spec/connection_spec.rb
|