cbraspag 0.9.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +9 -0
- data/.rspec +1 -0
- data/Gemfile +4 -0
- data/Guardfile +10 -0
- data/LICENSE.md +23 -0
- data/README.md +539 -0
- data/RELEASES.md +20 -0
- data/Rakefile +6 -0
- data/cbraspag.gemspec +30 -0
- data/lib/cbraspag.rb +93 -0
- data/lib/cbraspag/core/connection.rb +96 -0
- data/lib/cbraspag/core/converter.rb +160 -0
- data/lib/cbraspag/core/customer.rb +36 -0
- data/lib/cbraspag/core/order.rb +235 -0
- data/lib/cbraspag/core/poster.rb +37 -0
- data/lib/cbraspag/core/response.rb +25 -0
- data/lib/cbraspag/crypto/jar_webservice.rb +91 -0
- data/lib/cbraspag/crypto/no_crypto.rb +6 -0
- data/lib/cbraspag/crypto/webservice.rb +95 -0
- data/lib/cbraspag/payment/billet.rb +58 -0
- data/lib/cbraspag/payment/credit_card.rb +203 -0
- data/lib/cbraspag/payment/eft.rb +90 -0
- data/lib/cbraspag/version.rb +3 -0
- data/spec/core/connection_spec.rb +95 -0
- data/spec/core/converter_spec.rb +84 -0
- data/spec/core/customer_spec.rb +49 -0
- data/spec/core/order_spec.rb +382 -0
- data/spec/core/poster_spec.rb +63 -0
- data/spec/core/response_spec.rb +5 -0
- data/spec/crypto/jar_webservice_spec.rb +183 -0
- data/spec/crypto/webservice_spec.rb +142 -0
- data/spec/payment/billet_spec.rb +156 -0
- data/spec/payment/credit_card_spec.rb +609 -0
- data/spec/payment/eft_spec.rb +103 -0
- data/spec/spec_helper.rb +11 -0
- metadata +224 -0
@@ -0,0 +1,103 @@
|
|
1
|
+
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
2
|
+
|
3
|
+
describe Braspag::Connection do
|
4
|
+
let(:braspag_homologation_url) { "https://homologacao.pagador.com.br" }
|
5
|
+
let(:braspag_production_url) { "https://transaction.pagador.com.br" }
|
6
|
+
let(:merchant_id) { "um id qualquer" }
|
7
|
+
|
8
|
+
pending ".generate_eft" do
|
9
|
+
let(:params) do
|
10
|
+
{
|
11
|
+
:order_id => 11,
|
12
|
+
:amount => 3,
|
13
|
+
:payment_method => :bradesco,
|
14
|
+
:installments => 1,
|
15
|
+
:has_interest => 0
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
let(:params_with_merchant_id) do
|
20
|
+
params.merge!(:merchant_id => merchant_id)
|
21
|
+
end
|
22
|
+
|
23
|
+
let(:action_url) { "https://bla.com/foo/bar/baz" }
|
24
|
+
|
25
|
+
before do
|
26
|
+
@connection.should_receive(:merchant_id)
|
27
|
+
|
28
|
+
Braspag::Eft.should_receive(:action_url)
|
29
|
+
.and_return(action_url)
|
30
|
+
|
31
|
+
Braspag::Eft.should_receive(:normalize_params)
|
32
|
+
.with(params_with_merchant_id)
|
33
|
+
.and_return(params_with_merchant_id)
|
34
|
+
|
35
|
+
Braspag::Eft.should_receive(:check_params)
|
36
|
+
.and_return(true)
|
37
|
+
end
|
38
|
+
|
39
|
+
it "should return a html form" do
|
40
|
+
html = "<form id=\"form_tef_11\" name=\"form_tef_11\" action=\"#{action_url}\" method=\"post\">" +
|
41
|
+
"<input type=\"text\" name=\"Id_Loja\" value=\"#{merchant_id}\" />" +
|
42
|
+
'<input type="text" name="VENDAID" value="11" />' +
|
43
|
+
'<input type="text" name="nome" value="" />' +
|
44
|
+
'<input type="text" name="CPF" value="" />' +
|
45
|
+
'<input type="text" name="VALOR" value="3,00" />' +
|
46
|
+
'<input type="text" name="CODPAGAMENTO" value="11" />' +
|
47
|
+
'<input type="text" name="PARCELAS" value="1" />' +
|
48
|
+
'<input type="text" name="TIPOPARCELADO" value="0" />' +
|
49
|
+
'</form>' +
|
50
|
+
'<script type="text/javascript" charset="utf-8">document.forms["form_tef_11"].submit();</script>'
|
51
|
+
|
52
|
+
Braspag::Eft.generate(params).should == html
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should return a html form when crypto strategy is given" do
|
56
|
+
crypto = mock
|
57
|
+
crypto.should_receive(:encrypt)
|
58
|
+
.with(a_kind_of(Hash))
|
59
|
+
.and_return("vei na boa")
|
60
|
+
|
61
|
+
html = "<form id=\"form_tef_11\" name=\"form_tef_11\" action=\"#{action_url}\" method=\"post\">" +
|
62
|
+
"<input type=\"text\" name=\"Id_Loja\" value=\"#{merchant_id}\" />" +
|
63
|
+
'<input type="text" name="crypt" value="vei na boa" />' +
|
64
|
+
'</form>' +
|
65
|
+
'<script type="text/javascript" charset="utf-8">document.forms["form_tef_11"].submit();</script>'
|
66
|
+
|
67
|
+
Braspag::Eft.generate(params, crypto).should == html
|
68
|
+
end
|
69
|
+
end
|
70
|
+
end
|
71
|
+
|
72
|
+
|
73
|
+
describe Braspag::EFT do
|
74
|
+
|
75
|
+
context "on generate" do
|
76
|
+
it "should not allow blank for crypto" do
|
77
|
+
subject.crypto = ''
|
78
|
+
subject.valid?(:generate)
|
79
|
+
subject.errors.messages[:crypto].should include("can't be blank")
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should not allow invalid crypto" do
|
83
|
+
subject.crypto = 1234
|
84
|
+
subject.valid?(:generate)
|
85
|
+
subject.errors.messages[:crypto].should include("invalid crypto")
|
86
|
+
end
|
87
|
+
|
88
|
+
[ Braspag::Crypto::Webservice.new,
|
89
|
+
Braspag::Crypto::NoCrypto.new,
|
90
|
+
Braspag::Crypto::JarWebservice.new(
|
91
|
+
:url => "http://0.0.0.0:9292",
|
92
|
+
:key => "123456123456"
|
93
|
+
)
|
94
|
+
].each do |crypto|
|
95
|
+
it "should accept valid crypto: #{crypto.class}" do
|
96
|
+
subject.crypto = crypto
|
97
|
+
subject.valid?(:generate)
|
98
|
+
subject.errors.messages[:crypto].should be(nil)
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
102
|
+
|
103
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,224 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cbraspag
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.9.0
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- CodeMiner42
|
9
|
+
- Renato Elias
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
date: 2012-10-19 00:00:00.000000000 Z
|
14
|
+
dependencies:
|
15
|
+
- !ruby/object:Gem::Dependency
|
16
|
+
name: active_attr
|
17
|
+
requirement: !ruby/object:Gem::Requirement
|
18
|
+
none: false
|
19
|
+
requirements:
|
20
|
+
- - ! '>='
|
21
|
+
- !ruby/object:Gem::Version
|
22
|
+
version: '0.6'
|
23
|
+
type: :runtime
|
24
|
+
prerelease: false
|
25
|
+
version_requirements: !ruby/object:Gem::Requirement
|
26
|
+
none: false
|
27
|
+
requirements:
|
28
|
+
- - ! '>='
|
29
|
+
- !ruby/object:Gem::Version
|
30
|
+
version: '0.6'
|
31
|
+
- !ruby/object:Gem::Dependency
|
32
|
+
name: httpi
|
33
|
+
requirement: !ruby/object:Gem::Requirement
|
34
|
+
none: false
|
35
|
+
requirements:
|
36
|
+
- - ! '>='
|
37
|
+
- !ruby/object:Gem::Version
|
38
|
+
version: 0.9.6
|
39
|
+
type: :runtime
|
40
|
+
prerelease: false
|
41
|
+
version_requirements: !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ! '>='
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: 0.9.6
|
47
|
+
- !ruby/object:Gem::Dependency
|
48
|
+
name: json
|
49
|
+
requirement: !ruby/object:Gem::Requirement
|
50
|
+
none: false
|
51
|
+
requirements:
|
52
|
+
- - ! '>='
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: 1.6.1
|
55
|
+
type: :runtime
|
56
|
+
prerelease: false
|
57
|
+
version_requirements: !ruby/object:Gem::Requirement
|
58
|
+
none: false
|
59
|
+
requirements:
|
60
|
+
- - ! '>='
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: 1.6.1
|
63
|
+
- !ruby/object:Gem::Dependency
|
64
|
+
name: nokogiri
|
65
|
+
requirement: !ruby/object:Gem::Requirement
|
66
|
+
none: false
|
67
|
+
requirements:
|
68
|
+
- - ! '>='
|
69
|
+
- !ruby/object:Gem::Version
|
70
|
+
version: 1.4.7
|
71
|
+
type: :runtime
|
72
|
+
prerelease: false
|
73
|
+
version_requirements: !ruby/object:Gem::Requirement
|
74
|
+
none: false
|
75
|
+
requirements:
|
76
|
+
- - ! '>='
|
77
|
+
- !ruby/object:Gem::Version
|
78
|
+
version: 1.4.7
|
79
|
+
- !ruby/object:Gem::Dependency
|
80
|
+
name: savon
|
81
|
+
requirement: !ruby/object:Gem::Requirement
|
82
|
+
none: false
|
83
|
+
requirements:
|
84
|
+
- - ! '>='
|
85
|
+
- !ruby/object:Gem::Version
|
86
|
+
version: 0.9.9
|
87
|
+
type: :runtime
|
88
|
+
prerelease: false
|
89
|
+
version_requirements: !ruby/object:Gem::Requirement
|
90
|
+
none: false
|
91
|
+
requirements:
|
92
|
+
- - ! '>='
|
93
|
+
- !ruby/object:Gem::Version
|
94
|
+
version: 0.9.9
|
95
|
+
- !ruby/object:Gem::Dependency
|
96
|
+
name: rake
|
97
|
+
requirement: !ruby/object:Gem::Requirement
|
98
|
+
none: false
|
99
|
+
requirements:
|
100
|
+
- - ! '>='
|
101
|
+
- !ruby/object:Gem::Version
|
102
|
+
version: '0'
|
103
|
+
type: :development
|
104
|
+
prerelease: false
|
105
|
+
version_requirements: !ruby/object:Gem::Requirement
|
106
|
+
none: false
|
107
|
+
requirements:
|
108
|
+
- - ! '>='
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
- !ruby/object:Gem::Dependency
|
112
|
+
name: rspec
|
113
|
+
requirement: !ruby/object:Gem::Requirement
|
114
|
+
none: false
|
115
|
+
requirements:
|
116
|
+
- - ! '>='
|
117
|
+
- !ruby/object:Gem::Version
|
118
|
+
version: '0'
|
119
|
+
type: :development
|
120
|
+
prerelease: false
|
121
|
+
version_requirements: !ruby/object:Gem::Requirement
|
122
|
+
none: false
|
123
|
+
requirements:
|
124
|
+
- - ! '>='
|
125
|
+
- !ruby/object:Gem::Version
|
126
|
+
version: '0'
|
127
|
+
- !ruby/object:Gem::Dependency
|
128
|
+
name: pry
|
129
|
+
requirement: !ruby/object:Gem::Requirement
|
130
|
+
none: false
|
131
|
+
requirements:
|
132
|
+
- - ! '>='
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
version: '0'
|
135
|
+
type: :development
|
136
|
+
prerelease: false
|
137
|
+
version_requirements: !ruby/object:Gem::Requirement
|
138
|
+
none: false
|
139
|
+
requirements:
|
140
|
+
- - ! '>='
|
141
|
+
- !ruby/object:Gem::Version
|
142
|
+
version: '0'
|
143
|
+
description: ! 'Braspag: brazilian gateway, agnostic, support all features in braspag'
|
144
|
+
email:
|
145
|
+
- contato@codeminer42.com
|
146
|
+
- renato.elias@gmail.com
|
147
|
+
executables: []
|
148
|
+
extensions: []
|
149
|
+
extra_rdoc_files: []
|
150
|
+
files:
|
151
|
+
- .gitignore
|
152
|
+
- .rspec
|
153
|
+
- Gemfile
|
154
|
+
- Gemfile.lock
|
155
|
+
- Guardfile
|
156
|
+
- LICENSE.md
|
157
|
+
- README.md
|
158
|
+
- RELEASES.md
|
159
|
+
- Rakefile
|
160
|
+
- cbraspag.gemspec
|
161
|
+
- lib/cbraspag.rb
|
162
|
+
- lib/cbraspag/core/connection.rb
|
163
|
+
- lib/cbraspag/core/converter.rb
|
164
|
+
- lib/cbraspag/core/customer.rb
|
165
|
+
- lib/cbraspag/core/order.rb
|
166
|
+
- lib/cbraspag/core/poster.rb
|
167
|
+
- lib/cbraspag/core/response.rb
|
168
|
+
- lib/cbraspag/crypto/jar_webservice.rb
|
169
|
+
- lib/cbraspag/crypto/no_crypto.rb
|
170
|
+
- lib/cbraspag/crypto/webservice.rb
|
171
|
+
- lib/cbraspag/payment/billet.rb
|
172
|
+
- lib/cbraspag/payment/credit_card.rb
|
173
|
+
- lib/cbraspag/payment/eft.rb
|
174
|
+
- lib/cbraspag/version.rb
|
175
|
+
- spec/core/connection_spec.rb
|
176
|
+
- spec/core/converter_spec.rb
|
177
|
+
- spec/core/customer_spec.rb
|
178
|
+
- spec/core/order_spec.rb
|
179
|
+
- spec/core/poster_spec.rb
|
180
|
+
- spec/core/response_spec.rb
|
181
|
+
- spec/crypto/jar_webservice_spec.rb
|
182
|
+
- spec/crypto/webservice_spec.rb
|
183
|
+
- spec/payment/billet_spec.rb
|
184
|
+
- spec/payment/credit_card_spec.rb
|
185
|
+
- spec/payment/eft_spec.rb
|
186
|
+
- spec/spec_helper.rb
|
187
|
+
homepage: http://github.com/codeminer42/braspag
|
188
|
+
licenses: []
|
189
|
+
post_install_message:
|
190
|
+
rdoc_options: []
|
191
|
+
require_paths:
|
192
|
+
- lib
|
193
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
194
|
+
none: false
|
195
|
+
requirements:
|
196
|
+
- - ! '>='
|
197
|
+
- !ruby/object:Gem::Version
|
198
|
+
version: '0'
|
199
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
200
|
+
none: false
|
201
|
+
requirements:
|
202
|
+
- - ! '>='
|
203
|
+
- !ruby/object:Gem::Version
|
204
|
+
version: '0'
|
205
|
+
requirements: []
|
206
|
+
rubyforge_project: nowarning
|
207
|
+
rubygems_version: 1.8.23
|
208
|
+
signing_key:
|
209
|
+
specification_version: 3
|
210
|
+
summary: ! 'Braspag: brazilian gateway, agnostic, support all features in braspag'
|
211
|
+
test_files:
|
212
|
+
- spec/core/connection_spec.rb
|
213
|
+
- spec/core/converter_spec.rb
|
214
|
+
- spec/core/customer_spec.rb
|
215
|
+
- spec/core/order_spec.rb
|
216
|
+
- spec/core/poster_spec.rb
|
217
|
+
- spec/core/response_spec.rb
|
218
|
+
- spec/crypto/jar_webservice_spec.rb
|
219
|
+
- spec/crypto/webservice_spec.rb
|
220
|
+
- spec/payment/billet_spec.rb
|
221
|
+
- spec/payment/credit_card_spec.rb
|
222
|
+
- spec/payment/eft_spec.rb
|
223
|
+
- spec/spec_helper.rb
|
224
|
+
has_rdoc:
|