cielo 0.1.5 → 1.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.rdoc +9 -7
- metadata +13 -58
- data/.document +0 -5
- data/.travis.yml +0 -6
- data/Gemfile +0 -18
- data/Gemfile.lock +0 -106
- data/Rakefile +0 -49
- data/cielo.gemspec +0 -83
- data/lib/cielo.rb +0 -36
- data/lib/cielo/connection.rb +0 -75
- data/lib/cielo/token.rb +0 -22
- data/lib/cielo/transaction.rb +0 -152
- data/lib/cielo/version.rb +0 -8
- data/lib/generators/cielo/install_generator.rb +0 -14
- data/lib/generators/templates/cielo.rb +0 -22
- data/spec/cielo/connection_spec.rb +0 -48
- data/spec/cielo/token_spec.rb +0 -28
- data/spec/cielo/transaction_spec.rb +0 -227
- data/spec/spec_helper.rb +0 -9
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b921260fbe9520158aa715c12f453f806acdfd21
|
4
|
+
data.tar.gz: bdde2c9a1fa680f7df6dd43d3b1c03c594bcefaf
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 3935e55ed2ad67d32ffdf4303882bd1ea408c98a117afb6b54c4ff149a5c8fed0f036397ebc8827b0a8798d93ad65fb2f2f45cf3a4dc323aec4adcb5e6ace42e
|
7
|
+
data.tar.gz: e0f2c8696c0f076de5b2773ac0fa12c1ab6d0104bfdd28e6e5de57e69da20e710822253f08cd8723b40ca67e190c00e1642e892fefffaf5ca0e20de423ed1022
|
data/README.rdoc
CHANGED
@@ -28,7 +28,7 @@ Integração com a Cielo via WebServices [Buy Page Cielo / Buy Page Loja ]
|
|
28
28
|
valor: "123123",
|
29
29
|
moeda: "986",
|
30
30
|
bandeira: 'visa',
|
31
|
-
|
31
|
+
'url-retorno' => 'http://url.retorno',
|
32
32
|
cartao_numero: '4012001037141112',
|
33
33
|
cartao_validade: '201805',
|
34
34
|
cartao_seguranca: '123',
|
@@ -48,9 +48,9 @@ Integração com a Cielo via WebServices [Buy Page Cielo / Buy Page Loja ]
|
|
48
48
|
token_request = Cielo::Token.new
|
49
49
|
|
50
50
|
token_parameters = {
|
51
|
-
:
|
52
|
-
:
|
53
|
-
:
|
51
|
+
cartao_numero: '4012888888881881',
|
52
|
+
cartao_validade: '201508',
|
53
|
+
cartao_portador: 'Nome portador' }
|
54
54
|
}
|
55
55
|
|
56
56
|
response = token_request.create! token_parameters, :store
|
@@ -73,7 +73,7 @@ Integração com a Cielo via WebServices [Buy Page Cielo / Buy Page Loja ]
|
|
73
73
|
|
74
74
|
Caso seja necessário fazer uma transação recorrente, basta alterar a tag autorizar para 4.
|
75
75
|
|
76
|
-
Uma transação com um o campo
|
76
|
+
Uma transação com um o campo gerar-token": true, gera um token correspondente que pode ser armazenado para transações futuras.
|
77
77
|
|
78
78
|
== Buy Page Cielo
|
79
79
|
|
@@ -84,7 +84,7 @@ Uma transação com um o campo "gerar-token" => true, gera um token corresponden
|
|
84
84
|
valor: "123123",
|
85
85
|
moeda: "986",
|
86
86
|
bandeira: 'visa',
|
87
|
-
|
87
|
+
'url-retorno' => 'http://url.retorno',
|
88
88
|
}
|
89
89
|
|
90
90
|
transaction.create!(transaction_parameters, :cielo) #inicia uma nova transação / :cielo é padrão
|
@@ -115,7 +115,8 @@ Se torna necessário somente configurar o módulo Cielo
|
|
115
115
|
== Avisos
|
116
116
|
|
117
117
|
* O retorno da cielo é convertido em um hash, então, atributos no xml como url-retorno ficam :"url-retorno", cuidado com esses detalhes.
|
118
|
-
*
|
118
|
+
* Gem testada em versões do ruby 2.0.0, 2.1.8, 2.2.4 e 2.3
|
119
|
+
* Para usar em versões anteriores do Ruby, use versões da gem anteriores a 1.0
|
119
120
|
|
120
121
|
== Contributing to cielo
|
121
122
|
|
@@ -135,6 +136,7 @@ Se torna necessário somente configurar o módulo Cielo
|
|
135
136
|
* Gabriel Paladino and Scupen [https://github.com/gabpaladino , https://github.com/scupen] (Ruby 1.8.7 support)
|
136
137
|
* Wilbert Ribeiro [https://github.com/wilbert/cielo, https://twitter.com/wilbertribeiro ]
|
137
138
|
* Elton Okada [https://github.com/eltonokada, https://twitter.com/eltonokada ]
|
139
|
+
* Alex Buschle [https://github.com/alexwbuschle, https://twitter.com/alexwbuschle ]
|
138
140
|
|
139
141
|
== Copyright
|
140
142
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cielo
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 1.1.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Crafters Software Studio
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date:
|
12
|
+
date: 2016-01-19 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activesupport
|
@@ -17,50 +17,22 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - ">="
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: 3.
|
20
|
+
version: 3.2.22
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - ">="
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: 3.
|
28
|
-
- !ruby/object:Gem::Dependency
|
29
|
-
name: i18n
|
30
|
-
requirement: !ruby/object:Gem::Requirement
|
31
|
-
requirements:
|
32
|
-
- - ">="
|
33
|
-
- !ruby/object:Gem::Version
|
34
|
-
version: '0'
|
35
|
-
type: :runtime
|
36
|
-
prerelease: false
|
37
|
-
version_requirements: !ruby/object:Gem::Requirement
|
38
|
-
requirements:
|
39
|
-
- - ">="
|
40
|
-
- !ruby/object:Gem::Version
|
41
|
-
version: '0'
|
27
|
+
version: 3.2.22
|
42
28
|
- !ruby/object:Gem::Dependency
|
43
29
|
name: builder
|
44
|
-
requirement: !ruby/object:Gem::Requirement
|
45
|
-
requirements:
|
46
|
-
- - ">="
|
47
|
-
- !ruby/object:Gem::Version
|
48
|
-
version: 2.0.0
|
49
|
-
type: :runtime
|
50
|
-
prerelease: false
|
51
|
-
version_requirements: !ruby/object:Gem::Requirement
|
52
|
-
requirements:
|
53
|
-
- - ">="
|
54
|
-
- !ruby/object:Gem::Version
|
55
|
-
version: 2.0.0
|
56
|
-
- !ruby/object:Gem::Dependency
|
57
|
-
name: watir-webdriver
|
58
30
|
requirement: !ruby/object:Gem::Requirement
|
59
31
|
requirements:
|
60
32
|
- - ">="
|
61
33
|
- !ruby/object:Gem::Version
|
62
34
|
version: '0'
|
63
|
-
type: :
|
35
|
+
type: :runtime
|
64
36
|
prerelease: false
|
65
37
|
version_requirements: !ruby/object:Gem::Requirement
|
66
38
|
requirements:
|
@@ -68,13 +40,13 @@ dependencies:
|
|
68
40
|
- !ruby/object:Gem::Version
|
69
41
|
version: '0'
|
70
42
|
- !ruby/object:Gem::Dependency
|
71
|
-
name:
|
43
|
+
name: bundler
|
72
44
|
requirement: !ruby/object:Gem::Requirement
|
73
45
|
requirements:
|
74
46
|
- - ">="
|
75
47
|
- !ruby/object:Gem::Version
|
76
48
|
version: '0'
|
77
|
-
type: :
|
49
|
+
type: :runtime
|
78
50
|
prerelease: false
|
79
51
|
version_requirements: !ruby/object:Gem::Requirement
|
80
52
|
requirements:
|
@@ -82,13 +54,13 @@ dependencies:
|
|
82
54
|
- !ruby/object:Gem::Version
|
83
55
|
version: '0'
|
84
56
|
- !ruby/object:Gem::Dependency
|
85
|
-
name:
|
57
|
+
name: rake
|
86
58
|
requirement: !ruby/object:Gem::Requirement
|
87
59
|
requirements:
|
88
60
|
- - ">="
|
89
61
|
- !ruby/object:Gem::Version
|
90
62
|
version: '0'
|
91
|
-
type: :
|
63
|
+
type: :runtime
|
92
64
|
prerelease: false
|
93
65
|
version_requirements: !ruby/object:Gem::Requirement
|
94
66
|
requirements:
|
@@ -96,7 +68,7 @@ dependencies:
|
|
96
68
|
- !ruby/object:Gem::Version
|
97
69
|
version: '0'
|
98
70
|
- !ruby/object:Gem::Dependency
|
99
|
-
name:
|
71
|
+
name: shoulda
|
100
72
|
requirement: !ruby/object:Gem::Requirement
|
101
73
|
requirements:
|
102
74
|
- - ">="
|
@@ -124,7 +96,7 @@ dependencies:
|
|
124
96
|
- !ruby/object:Gem::Version
|
125
97
|
version: '0'
|
126
98
|
- !ruby/object:Gem::Dependency
|
127
|
-
name:
|
99
|
+
name: vcr
|
128
100
|
requirement: !ruby/object:Gem::Requirement
|
129
101
|
requirements:
|
130
102
|
- - ">="
|
@@ -138,7 +110,7 @@ dependencies:
|
|
138
110
|
- !ruby/object:Gem::Version
|
139
111
|
version: '0'
|
140
112
|
- !ruby/object:Gem::Dependency
|
141
|
-
name:
|
113
|
+
name: webmock
|
142
114
|
requirement: !ruby/object:Gem::Requirement
|
143
115
|
requirements:
|
144
116
|
- - ">="
|
@@ -159,25 +131,8 @@ extra_rdoc_files:
|
|
159
131
|
- LICENSE.txt
|
160
132
|
- README.rdoc
|
161
133
|
files:
|
162
|
-
- ".document"
|
163
|
-
- ".travis.yml"
|
164
|
-
- Gemfile
|
165
|
-
- Gemfile.lock
|
166
134
|
- LICENSE.txt
|
167
135
|
- README.rdoc
|
168
|
-
- Rakefile
|
169
|
-
- cielo.gemspec
|
170
|
-
- lib/cielo.rb
|
171
|
-
- lib/cielo/connection.rb
|
172
|
-
- lib/cielo/token.rb
|
173
|
-
- lib/cielo/transaction.rb
|
174
|
-
- lib/cielo/version.rb
|
175
|
-
- lib/generators/cielo/install_generator.rb
|
176
|
-
- lib/generators/templates/cielo.rb
|
177
|
-
- spec/cielo/connection_spec.rb
|
178
|
-
- spec/cielo/token_spec.rb
|
179
|
-
- spec/cielo/transaction_spec.rb
|
180
|
-
- spec/spec_helper.rb
|
181
136
|
homepage: http://github.com/crafters/cielo
|
182
137
|
licenses:
|
183
138
|
- MIT
|
@@ -198,7 +153,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
198
153
|
version: '0'
|
199
154
|
requirements: []
|
200
155
|
rubyforge_project:
|
201
|
-
rubygems_version: 2.
|
156
|
+
rubygems_version: 2.5.1
|
202
157
|
signing_key:
|
203
158
|
specification_version: 4
|
204
159
|
summary: Integração com a cielo
|
data/.document
DELETED
data/.travis.yml
DELETED
data/Gemfile
DELETED
@@ -1,18 +0,0 @@
|
|
1
|
-
source "http://rubygems.org"
|
2
|
-
# Add dependencies required to use your gem here.
|
3
|
-
# Example:
|
4
|
-
gem "activesupport", ">= 3.0.7"
|
5
|
-
gem "i18n"
|
6
|
-
gem 'builder', ">= 2.0.0"
|
7
|
-
|
8
|
-
# Add dependencies to develop your gem here.
|
9
|
-
# Include everything needed to run rake, tests, features, etc.
|
10
|
-
group :development do
|
11
|
-
gem 'watir-webdriver'
|
12
|
-
gem "shoulda", ">= 0"
|
13
|
-
gem "bundler"
|
14
|
-
gem "jeweler"
|
15
|
-
gem "rspec"
|
16
|
-
gem "fakeweb"
|
17
|
-
gem "simplecov"
|
18
|
-
end
|
data/Gemfile.lock
DELETED
@@ -1,106 +0,0 @@
|
|
1
|
-
GEM
|
2
|
-
remote: http://rubygems.org/
|
3
|
-
specs:
|
4
|
-
activesupport (4.0.1)
|
5
|
-
i18n (~> 0.6, >= 0.6.4)
|
6
|
-
minitest (~> 4.2)
|
7
|
-
multi_json (~> 1.3)
|
8
|
-
thread_safe (~> 0.1)
|
9
|
-
tzinfo (~> 0.3.37)
|
10
|
-
addressable (2.3.5)
|
11
|
-
atomic (1.1.14)
|
12
|
-
builder (3.2.2)
|
13
|
-
childprocess (0.4.0)
|
14
|
-
ffi (~> 1.0, >= 1.0.11)
|
15
|
-
diff-lcs (1.2.5)
|
16
|
-
docile (1.1.5)
|
17
|
-
fakeweb (1.3.0)
|
18
|
-
faraday (0.8.8)
|
19
|
-
multipart-post (~> 1.2.0)
|
20
|
-
ffi (1.9.3)
|
21
|
-
git (1.2.6)
|
22
|
-
github_api (0.10.1)
|
23
|
-
addressable
|
24
|
-
faraday (~> 0.8.1)
|
25
|
-
hashie (>= 1.2)
|
26
|
-
multi_json (~> 1.4)
|
27
|
-
nokogiri (~> 1.5.2)
|
28
|
-
oauth2
|
29
|
-
hashie (2.0.5)
|
30
|
-
highline (1.6.20)
|
31
|
-
httpauth (0.2.0)
|
32
|
-
i18n (0.6.5)
|
33
|
-
jeweler (1.8.8)
|
34
|
-
builder
|
35
|
-
bundler (~> 1.0)
|
36
|
-
git (>= 1.2.5)
|
37
|
-
github_api (= 0.10.1)
|
38
|
-
highline (>= 1.6.15)
|
39
|
-
nokogiri (= 1.5.10)
|
40
|
-
rake
|
41
|
-
rdoc
|
42
|
-
json (1.8.1)
|
43
|
-
jwt (0.1.8)
|
44
|
-
multi_json (>= 1.5)
|
45
|
-
minitest (4.7.5)
|
46
|
-
multi_json (1.8.2)
|
47
|
-
multi_xml (0.5.5)
|
48
|
-
multipart-post (1.2.0)
|
49
|
-
nokogiri (1.5.10)
|
50
|
-
oauth2 (0.9.2)
|
51
|
-
faraday (~> 0.8)
|
52
|
-
httpauth (~> 0.2)
|
53
|
-
jwt (~> 0.1.4)
|
54
|
-
multi_json (~> 1.0)
|
55
|
-
multi_xml (~> 0.5)
|
56
|
-
rack (~> 1.2)
|
57
|
-
rack (1.5.2)
|
58
|
-
rake (10.1.0)
|
59
|
-
rdoc (4.0.1)
|
60
|
-
json (~> 1.4)
|
61
|
-
rspec (2.14.1)
|
62
|
-
rspec-core (~> 2.14.0)
|
63
|
-
rspec-expectations (~> 2.14.0)
|
64
|
-
rspec-mocks (~> 2.14.0)
|
65
|
-
rspec-core (2.14.7)
|
66
|
-
rspec-expectations (2.14.4)
|
67
|
-
diff-lcs (>= 1.1.3, < 2.0)
|
68
|
-
rspec-mocks (2.14.4)
|
69
|
-
rubyzip (1.1.0)
|
70
|
-
selenium-webdriver (2.39.0)
|
71
|
-
childprocess (>= 0.2.5)
|
72
|
-
multi_json (~> 1.0)
|
73
|
-
rubyzip (~> 1.0)
|
74
|
-
websocket (~> 1.0.4)
|
75
|
-
shoulda (3.5.0)
|
76
|
-
shoulda-context (~> 1.0, >= 1.0.1)
|
77
|
-
shoulda-matchers (>= 1.4.1, < 3.0)
|
78
|
-
shoulda-context (1.1.6)
|
79
|
-
shoulda-matchers (2.4.0)
|
80
|
-
activesupport (>= 3.0.0)
|
81
|
-
simplecov (0.10.0)
|
82
|
-
docile (~> 1.1.0)
|
83
|
-
json (~> 1.8)
|
84
|
-
simplecov-html (~> 0.10.0)
|
85
|
-
simplecov-html (0.10.0)
|
86
|
-
thread_safe (0.1.3)
|
87
|
-
atomic
|
88
|
-
tzinfo (0.3.38)
|
89
|
-
watir-webdriver (0.6.4)
|
90
|
-
selenium-webdriver (>= 2.18.0)
|
91
|
-
websocket (1.0.7)
|
92
|
-
|
93
|
-
PLATFORMS
|
94
|
-
ruby
|
95
|
-
|
96
|
-
DEPENDENCIES
|
97
|
-
activesupport (>= 3.0.7)
|
98
|
-
builder (>= 2.0.0)
|
99
|
-
bundler
|
100
|
-
fakeweb
|
101
|
-
i18n
|
102
|
-
jeweler
|
103
|
-
rspec
|
104
|
-
shoulda
|
105
|
-
simplecov
|
106
|
-
watir-webdriver
|
data/Rakefile
DELETED
@@ -1,49 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'rubygems'
|
4
|
-
require 'bundler'
|
5
|
-
begin
|
6
|
-
Bundler.setup(:default, :development)
|
7
|
-
rescue Bundler::BundlerError => e
|
8
|
-
$stderr.puts e.message
|
9
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
10
|
-
exit e.status_code
|
11
|
-
end
|
12
|
-
require 'rake'
|
13
|
-
require "rspec/core/rake_task"
|
14
|
-
RSpec::Core::RakeTask.new
|
15
|
-
|
16
|
-
require 'jeweler'
|
17
|
-
require './lib/cielo/version.rb'
|
18
|
-
Jeweler::Tasks.new do |gem|
|
19
|
-
# gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
|
20
|
-
gem.name = "cielo"
|
21
|
-
gem.homepage = "http://github.com/crafters/cielo"
|
22
|
-
gem.license = "MIT"
|
23
|
-
gem.summary = %Q{Integração com a cielo}
|
24
|
-
gem.description = %Q{Integração com a cielo}
|
25
|
-
gem.email = "crafters@crafters.com.br"
|
26
|
-
gem.authors = ["Crafters Software Studio", "Felipe Rodrigues"]
|
27
|
-
gem.version = Cielo::Version::STRING
|
28
|
-
# dependencies defined in Gemfile
|
29
|
-
end
|
30
|
-
Jeweler::RubygemsDotOrgTasks.new
|
31
|
-
|
32
|
-
require 'rake/testtask'
|
33
|
-
Rake::TestTask.new(:test) do |test|
|
34
|
-
test.libs << 'lib' << 'test'
|
35
|
-
test.pattern = 'test/**/test_*.rb'
|
36
|
-
test.verbose = true
|
37
|
-
end
|
38
|
-
|
39
|
-
task :default => :test
|
40
|
-
|
41
|
-
require 'rdoc/task'
|
42
|
-
Rake::RDocTask.new do |rdoc|
|
43
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
44
|
-
|
45
|
-
rdoc.rdoc_dir = 'rdoc'
|
46
|
-
rdoc.title = "cielo #{version}"
|
47
|
-
rdoc.rdoc_files.include('README*')
|
48
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
49
|
-
end
|
data/cielo.gemspec
DELETED
@@ -1,83 +0,0 @@
|
|
1
|
-
# Generated by jeweler
|
2
|
-
# DO NOT EDIT THIS FILE DIRECTLY
|
3
|
-
# Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
|
4
|
-
# -*- encoding: utf-8 -*-
|
5
|
-
# stub: cielo 0.1.5 ruby lib
|
6
|
-
|
7
|
-
Gem::Specification.new do |s|
|
8
|
-
s.name = "cielo"
|
9
|
-
s.version = "0.1.5"
|
10
|
-
|
11
|
-
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
12
|
-
s.authors = ["Crafters Software Studio", "Felipe Rodrigues"]
|
13
|
-
s.date = "2014-01-21"
|
14
|
-
s.description = "Integra\u{e7}\u{e3}o com a cielo"
|
15
|
-
s.email = "crafters@crafters.com.br"
|
16
|
-
s.extra_rdoc_files = [
|
17
|
-
"LICENSE.txt",
|
18
|
-
"README.rdoc"
|
19
|
-
]
|
20
|
-
s.files = [
|
21
|
-
".document",
|
22
|
-
".travis.yml",
|
23
|
-
"Gemfile",
|
24
|
-
"Gemfile.lock",
|
25
|
-
"LICENSE.txt",
|
26
|
-
"README.rdoc",
|
27
|
-
"Rakefile",
|
28
|
-
"cielo.gemspec",
|
29
|
-
"lib/cielo.rb",
|
30
|
-
"lib/cielo/connection.rb",
|
31
|
-
"lib/cielo/token.rb",
|
32
|
-
"lib/cielo/transaction.rb",
|
33
|
-
"lib/cielo/version.rb",
|
34
|
-
"lib/generators/cielo/install_generator.rb",
|
35
|
-
"lib/generators/templates/cielo.rb",
|
36
|
-
"spec/cielo/connection_spec.rb",
|
37
|
-
"spec/cielo/token_spec.rb",
|
38
|
-
"spec/cielo/transaction_spec.rb",
|
39
|
-
"spec/spec_helper.rb"
|
40
|
-
]
|
41
|
-
s.homepage = "http://github.com/crafters/cielo"
|
42
|
-
s.licenses = ["MIT"]
|
43
|
-
s.require_paths = ["lib"]
|
44
|
-
s.rubygems_version = "2.1.9"
|
45
|
-
s.summary = "Integra\u{e7}\u{e3}o com a cielo"
|
46
|
-
|
47
|
-
if s.respond_to? :specification_version then
|
48
|
-
s.specification_version = 4
|
49
|
-
|
50
|
-
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
51
|
-
s.add_runtime_dependency(%q<activesupport>, [">= 3.0.7"])
|
52
|
-
s.add_runtime_dependency(%q<i18n>, [">= 0"])
|
53
|
-
s.add_runtime_dependency(%q<builder>, [">= 2.0.0"])
|
54
|
-
s.add_development_dependency(%q<watir-webdriver>, [">= 0"])
|
55
|
-
s.add_development_dependency(%q<shoulda>, [">= 0"])
|
56
|
-
s.add_development_dependency(%q<bundler>, [">= 0"])
|
57
|
-
s.add_development_dependency(%q<jeweler>, [">= 0"])
|
58
|
-
s.add_development_dependency(%q<rspec>, [">= 0"])
|
59
|
-
s.add_development_dependency(%q<fakeweb>, [">= 0"])
|
60
|
-
else
|
61
|
-
s.add_dependency(%q<activesupport>, [">= 3.0.7"])
|
62
|
-
s.add_dependency(%q<i18n>, [">= 0"])
|
63
|
-
s.add_dependency(%q<builder>, [">= 2.0.0"])
|
64
|
-
s.add_dependency(%q<watir-webdriver>, [">= 0"])
|
65
|
-
s.add_dependency(%q<shoulda>, [">= 0"])
|
66
|
-
s.add_dependency(%q<bundler>, [">= 0"])
|
67
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
68
|
-
s.add_dependency(%q<rspec>, [">= 0"])
|
69
|
-
s.add_dependency(%q<fakeweb>, [">= 0"])
|
70
|
-
end
|
71
|
-
else
|
72
|
-
s.add_dependency(%q<activesupport>, [">= 3.0.7"])
|
73
|
-
s.add_dependency(%q<i18n>, [">= 0"])
|
74
|
-
s.add_dependency(%q<builder>, [">= 2.0.0"])
|
75
|
-
s.add_dependency(%q<watir-webdriver>, [">= 0"])
|
76
|
-
s.add_dependency(%q<shoulda>, [">= 0"])
|
77
|
-
s.add_dependency(%q<bundler>, [">= 0"])
|
78
|
-
s.add_dependency(%q<jeweler>, [">= 0"])
|
79
|
-
s.add_dependency(%q<rspec>, [">= 0"])
|
80
|
-
s.add_dependency(%q<fakeweb>, [">= 0"])
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
data/lib/cielo.rb
DELETED
@@ -1,36 +0,0 @@
|
|
1
|
-
#encoding: utf-8
|
2
|
-
require 'active_support/core_ext/class/attribute_accessors'
|
3
|
-
require 'active_support/core_ext/module/attribute_accessors'
|
4
|
-
require 'active_support/core_ext/hash'
|
5
|
-
require "net/http"
|
6
|
-
require "net/https"
|
7
|
-
require "rexml/document"
|
8
|
-
require "builder"
|
9
|
-
[:connection, :transaction, :token].each { |lib| require "cielo/#{lib}" }
|
10
|
-
|
11
|
-
module Cielo
|
12
|
-
|
13
|
-
class Production
|
14
|
-
BASE_URL = "ecommerce.cbmp.com.br"
|
15
|
-
WS_PATH = "/servicos/ecommwsec.do"
|
16
|
-
end
|
17
|
-
|
18
|
-
class Test
|
19
|
-
BASE_URL = "qasecommerce.cielo.com.br"
|
20
|
-
WS_PATH = "/servicos/ecommwsec.do"
|
21
|
-
end
|
22
|
-
|
23
|
-
@@environment = :test
|
24
|
-
mattr_accessor :environment
|
25
|
-
@@numero_afiliacao = "1001734898"
|
26
|
-
mattr_accessor :numero_afiliacao
|
27
|
-
@@chave_acesso="e84827130b9837473681c2787007da5914d6359947015a5cdb2b8843db0fa832"
|
28
|
-
mattr_accessor :chave_acesso
|
29
|
-
@@return_path = "http://localhost:3000"
|
30
|
-
mattr_accessor :return_path
|
31
|
-
|
32
|
-
def self.setup
|
33
|
-
yield self
|
34
|
-
end
|
35
|
-
class MissingArgumentError < StandardError; end
|
36
|
-
end
|
data/lib/cielo/connection.rb
DELETED
@@ -1,75 +0,0 @@
|
|
1
|
-
#encoding: utf-8
|
2
|
-
|
3
|
-
module Cielo
|
4
|
-
class Connection
|
5
|
-
VERSAO_DEFAULT = '1.2.1'
|
6
|
-
attr_reader :environment
|
7
|
-
attr_reader :numero_afiliacao
|
8
|
-
attr_reader :chave_acesso
|
9
|
-
attr_reader :versao
|
10
|
-
|
11
|
-
def initialize numero_afiliacao = Cielo.numero_afiliacao, chave_acesso = Cielo.chave_acesso, versao = VERSAO_DEFAULT
|
12
|
-
@environment = eval(Cielo.environment.to_s.capitalize)
|
13
|
-
@numero_afiliacao = numero_afiliacao
|
14
|
-
@chave_acesso = chave_acesso
|
15
|
-
@versao = versao
|
16
|
-
port = 443
|
17
|
-
@http = Net::HTTP.new(@environment::BASE_URL,port)
|
18
|
-
@http.ssl_version = :TLSv1 if @http.respond_to? :ssl_version
|
19
|
-
@http.use_ssl = true
|
20
|
-
@http.open_timeout = 10*1000
|
21
|
-
@http.read_timeout = 40*1000
|
22
|
-
end
|
23
|
-
|
24
|
-
def request!(params={})
|
25
|
-
str_params = ""
|
26
|
-
params.each do |key, value|
|
27
|
-
str_params+="&" unless str_params.empty?
|
28
|
-
str_params+="#{key}=#{value}"
|
29
|
-
end
|
30
|
-
@http.request_post(self.environment::WS_PATH, str_params)
|
31
|
-
end
|
32
|
-
|
33
|
-
def xml_builder(group_name, &block)
|
34
|
-
xml = Builder::XmlMarkup.new
|
35
|
-
xml.instruct! :xml, :version=>"1.0", :encoding=>"ISO-8859-1"
|
36
|
-
xml.tag!(group_name, :id => "#{Time.now.to_i}", :versao => @versao) do
|
37
|
-
block.call(xml, :before)
|
38
|
-
xml.tag!("dados-ec") do
|
39
|
-
xml.numero @numero_afiliacao #Cielo.numero_afiliacao
|
40
|
-
xml.chave @chave_acesso #Cielo.chave_acesso
|
41
|
-
end
|
42
|
-
block.call(xml, :after)
|
43
|
-
end
|
44
|
-
xml
|
45
|
-
end
|
46
|
-
|
47
|
-
def make_request!(message)
|
48
|
-
params = { :mensagem => message.target! }
|
49
|
-
result = self.request! params
|
50
|
-
parse_response(result)
|
51
|
-
end
|
52
|
-
|
53
|
-
def parse_response(response)
|
54
|
-
case response
|
55
|
-
when Net::HTTPSuccess
|
56
|
-
document = REXML::Document.new(response.body)
|
57
|
-
parse_elements(document.elements)
|
58
|
-
else
|
59
|
-
{:erro => { :codigo => "000", :mensagem => "Impossível contactar o servidor"}}
|
60
|
-
end
|
61
|
-
end
|
62
|
-
|
63
|
-
def parse_elements(elements)
|
64
|
-
map={}
|
65
|
-
elements.each do |element|
|
66
|
-
element_map = {}
|
67
|
-
element_map = element.text if element.elements.empty? && element.attributes.empty?
|
68
|
-
element_map.merge!("value" => element.text) if element.elements.empty? && !element.attributes.empty?
|
69
|
-
element_map.merge!(parse_elements(element.elements)) unless element.elements.empty?
|
70
|
-
map.merge!(element.name => element_map)
|
71
|
-
end
|
72
|
-
map.symbolize_keys
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
data/lib/cielo/token.rb
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
#encoding: utf-8
|
2
|
-
module Cielo
|
3
|
-
class Token
|
4
|
-
def initialize
|
5
|
-
@connection = Cielo::Connection.new
|
6
|
-
end
|
7
|
-
|
8
|
-
def create!(parameters = {}, buy_page = :cielo)
|
9
|
-
message = @connection.xml_builder('requisicao-token') do |xml, target|
|
10
|
-
if target == :after
|
11
|
-
xml.tag!("dados-portador") do
|
12
|
-
xml.tag!('numero', parameters[:cartao_numero])
|
13
|
-
xml.tag!('validade', parameters[:cartao_validade])
|
14
|
-
xml.tag!('nome-portador', parameters[:cartao_portador])
|
15
|
-
end
|
16
|
-
end
|
17
|
-
end
|
18
|
-
|
19
|
-
@connection.make_request! message
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
data/lib/cielo/transaction.rb
DELETED
@@ -1,152 +0,0 @@
|
|
1
|
-
#encoding: utf-8
|
2
|
-
require 'bigdecimal'
|
3
|
-
module Cielo
|
4
|
-
class Transaction
|
5
|
-
|
6
|
-
attr_reader :numero_afiliacao
|
7
|
-
attr_reader :chave_acesso
|
8
|
-
attr_reader :versao
|
9
|
-
|
10
|
-
def initialize numero_afiliacao = Cielo.numero_afiliacao, chave_acesso = Cielo.chave_acesso, versao = '1.2.1'
|
11
|
-
@numero_afiliacao = numero_afiliacao
|
12
|
-
@chave_acesso = chave_acesso
|
13
|
-
@versao = versao
|
14
|
-
@connection = Cielo::Connection.new @numero_afiliacao, @chave_acesso, @versao
|
15
|
-
end
|
16
|
-
|
17
|
-
def create!(parameters = {}, buy_page = :cielo)
|
18
|
-
if buy_page == :store
|
19
|
-
store_page_create!(parameters)
|
20
|
-
else
|
21
|
-
cielo_page_create!(parameters)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
def store_page_create!(parameters={})
|
26
|
-
analysis_parameters(parameters, :buy_page_store)
|
27
|
-
message = @connection.xml_builder('requisicao-transacao') do |xml, target|
|
28
|
-
if target == :after
|
29
|
-
xml.tag!("dados-portador") do
|
30
|
-
if parameters[:token].present?
|
31
|
-
xml.tag!('token', parameters[:token])
|
32
|
-
else
|
33
|
-
xml.tag!('numero', parameters[:cartao_numero])
|
34
|
-
xml.tag!('validade', parameters[:cartao_validade])
|
35
|
-
xml.tag!('indicador', parameters[:cartao_indicador])
|
36
|
-
xml.tag!('codigo-seguranca', parameters[:cartao_seguranca])
|
37
|
-
xml.tag!('nome-portador', parameters[:cartao_portador])
|
38
|
-
xml.tag!('token', '')
|
39
|
-
end
|
40
|
-
end
|
41
|
-
default_transaction_xml(xml, parameters)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
|
45
|
-
@connection.make_request! message
|
46
|
-
end
|
47
|
-
|
48
|
-
def cielo_page_create!(parameters={})
|
49
|
-
analysis_parameters(parameters, :buy_page_cielo)
|
50
|
-
message = @connection.xml_builder("requisicao-transacao") do |xml, target|
|
51
|
-
if target == :after
|
52
|
-
default_transaction_xml(xml, parameters)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
@connection.make_request! message
|
56
|
-
end
|
57
|
-
|
58
|
-
def verify!(cielo_tid)
|
59
|
-
return nil unless cielo_tid
|
60
|
-
message = @connection.xml_builder("requisicao-consulta") do |xml, target|
|
61
|
-
if target == :before
|
62
|
-
xml.tid "#{cielo_tid}"
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
@connection.make_request! message
|
67
|
-
end
|
68
|
-
|
69
|
-
def catch!(cielo_tid)
|
70
|
-
return nil unless cielo_tid
|
71
|
-
message = @connection.xml_builder("requisicao-captura") do |xml, target|
|
72
|
-
if target == :before
|
73
|
-
xml.tid "#{cielo_tid}"
|
74
|
-
end
|
75
|
-
end
|
76
|
-
@connection.make_request! message
|
77
|
-
end
|
78
|
-
|
79
|
-
def authorize!(cielo_tid)
|
80
|
-
return nil unless cielo_tid
|
81
|
-
message = @connection.xml_builder("requisicao-autorizacao-tid") do |xml, target|
|
82
|
-
if target == :before
|
83
|
-
xml.tid "#{cielo_tid}"
|
84
|
-
end
|
85
|
-
end
|
86
|
-
@connection.make_request! message
|
87
|
-
end
|
88
|
-
|
89
|
-
def cancel!(cielo_tid, valor=0)
|
90
|
-
return nil unless cielo_tid
|
91
|
-
message = @connection.xml_builder("requisicao-cancelamento") do |xml, target|
|
92
|
-
if target == :before
|
93
|
-
xml.tid "#{cielo_tid}"
|
94
|
-
end
|
95
|
-
if target == :after
|
96
|
-
xml.valor "#{valor}" if BigDecimal.new(valor.nil? ? 0 : valor) > 0
|
97
|
-
end
|
98
|
-
end
|
99
|
-
@connection.make_request! message
|
100
|
-
end
|
101
|
-
|
102
|
-
private
|
103
|
-
def default_transaction_xml(xml, parameters)
|
104
|
-
xml.tag!("dados-pedido") do
|
105
|
-
[:numero, :valor, :moeda, :"data-hora", :idioma].each do |key|
|
106
|
-
xml.tag!(key.to_s, parameters[key].to_s)
|
107
|
-
end
|
108
|
-
end
|
109
|
-
xml.tag!("forma-pagamento") do
|
110
|
-
[:bandeira, :produto, :parcelas].each do |key|
|
111
|
-
xml.tag!(key.to_s, parameters[key].to_s)
|
112
|
-
end
|
113
|
-
end
|
114
|
-
xml.tag!("url-retorno", parameters[:"url-retorno"])
|
115
|
-
xml.autorizar parameters[:autorizar].to_s
|
116
|
-
xml.capturar parameters[:capturar].to_s
|
117
|
-
xml.tag!("gerar-token", parameters[:"gerar-token"])
|
118
|
-
end
|
119
|
-
|
120
|
-
def analysis_parameters(parameters={}, buy_page = :buy_page_cielo)
|
121
|
-
to_analyze = [:numero, :valor, :bandeira, :"url-retorno"]
|
122
|
-
|
123
|
-
if buy_page == :buy_page_store
|
124
|
-
if parameters[:token].present?
|
125
|
-
to_analyze.concat([:token])
|
126
|
-
else
|
127
|
-
to_analyze.concat([:cartao_numero, :cartao_validade, :cartao_portador])
|
128
|
-
to_analyze.concat([:cartao_seguranca]) unless ['1.0.0', '1.1.0', '1.1.1'].include?(@versao)
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
to_analyze.each do |parameter|
|
133
|
-
raise Cielo::MissingArgumentError, "Required parameter #{parameter} not found" unless parameters[parameter]
|
134
|
-
end
|
135
|
-
|
136
|
-
parameters.merge!(:moeda => "986") unless parameters[:moeda]
|
137
|
-
parameters.merge!(:"data-hora" => Time.now.strftime("%Y-%m-%dT%H:%M:%S")) unless parameters[:"data-hora"]
|
138
|
-
parameters.merge!(:idioma => "PT") unless parameters[:idioma]
|
139
|
-
parameters.merge!(:produto => "1") unless parameters[:produto]
|
140
|
-
parameters.merge!(:parcelas => "1") unless parameters[:parcelas]
|
141
|
-
parameters.merge!(:autorizar => "2") unless parameters[:autorizar]
|
142
|
-
parameters.merge!(:capturar => "true") unless parameters[:capturar]
|
143
|
-
parameters.merge!(:"url-retorno" => Cielo.return_path) unless parameters[:"url-retorno"]
|
144
|
-
parameters.merge!(:cartao_indicador => '1') unless parameters[:cartao_indicador] && buy_page == :buy_page_store
|
145
|
-
parameters.merge!(:"gerar-token" => false) unless parameters[:"gerar-token"]
|
146
|
-
|
147
|
-
parameters
|
148
|
-
end
|
149
|
-
|
150
|
-
|
151
|
-
end
|
152
|
-
end
|
data/lib/cielo/version.rb
DELETED
@@ -1,14 +0,0 @@
|
|
1
|
-
module Cielo
|
2
|
-
module Generators
|
3
|
-
class InstallGenerator < Rails::Generators::Base
|
4
|
-
source_root File.expand_path("../../templates", __FILE__)
|
5
|
-
|
6
|
-
desc "Cria o initializer da cielo na app rails"
|
7
|
-
|
8
|
-
def copy_initializer
|
9
|
-
template "cielo.rb", "config/initializers/cielo.rb"
|
10
|
-
end
|
11
|
-
|
12
|
-
end
|
13
|
-
end
|
14
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
# Use esse arquivo para configurar a integração com a cielo.
|
3
|
-
Cielo.setup do |config|
|
4
|
-
# Altere para production ao final dos seus testes
|
5
|
-
# config.environment = :test
|
6
|
-
|
7
|
-
# Número de afiliação fornecido pela cielo.
|
8
|
-
# O numero padrão é o número usado para testes.
|
9
|
-
# Utilize "1001734898" para testes Buy page Cielo e "1006993069" para Buy page loja
|
10
|
-
# config.numero_afiliacao = "1001734898"
|
11
|
-
|
12
|
-
# Chave de acesso para autenticação.
|
13
|
-
# O número padrão é o número usado para os testes.
|
14
|
-
# hash para Buy Page Cielo: "e84827130b9837473681c2787007da5914d6359947015a5cdb2b8843db0fa832"
|
15
|
-
# hash para Buy page Loja: "25fbb99741c739dd84d7b06ec78c9bac718838630f30b112d033ce2e621b34f3"
|
16
|
-
# config.chave_acesso = "e84827130b9837473681c2787007da5914d6359947015a5cdb2b8843db0fa832"
|
17
|
-
|
18
|
-
# Após o processamento pela cielo, o usuário será redirecionado para uma página.
|
19
|
-
# que é configurada abaixo, nessa action você pode consultar o status do TID
|
20
|
-
# para poder mostrar na tela.
|
21
|
-
# config.return_path = "http://localhost:3000"
|
22
|
-
end
|
@@ -1,48 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Cielo::Connection do
|
4
|
-
before do
|
5
|
-
FakeWeb.allow_net_connect = true
|
6
|
-
|
7
|
-
@connection = Cielo::Connection.new
|
8
|
-
@connection2 = Cielo::Connection.new "1001734898", "e84827130b9837473681c2787007da5914d6359947015a5cdb2b8843db0fa832"
|
9
|
-
end
|
10
|
-
|
11
|
-
after do
|
12
|
-
FakeWeb.allow_net_connect = false
|
13
|
-
end
|
14
|
-
|
15
|
-
it "should estabilish connection when was created" do
|
16
|
-
@connection.environment.should_not be_nil
|
17
|
-
@connection2.environment.should_not be_nil
|
18
|
-
end
|
19
|
-
|
20
|
-
it 'use version 1.2.1 by default' do
|
21
|
-
@connection.versao.should eq '1.2.1'
|
22
|
-
Cielo::Connection::VERSAO_DEFAULT.should eq '1.2.1'
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'can use other version' do
|
26
|
-
connection = Cielo::Connection.new "1001734898", "e84827130b9837473681c2787007da5914d6359947015a5cdb2b8843db0fa832", "1.1.1"
|
27
|
-
connection.versao.should eq '1.1.1'
|
28
|
-
end
|
29
|
-
|
30
|
-
describe "making a request" do
|
31
|
-
it "should make a request" do
|
32
|
-
response = @connection.request! :data => "Anything"
|
33
|
-
|
34
|
-
response.body.should_not be_nil
|
35
|
-
response.should be_kind_of Net::HTTPSuccess
|
36
|
-
end
|
37
|
-
end
|
38
|
-
|
39
|
-
describe "passing an access key and a client number" do
|
40
|
-
it "should make a request whithout any problem" do
|
41
|
-
response = @connection2.request! :data => "Anything"
|
42
|
-
|
43
|
-
response.body.should_not be_nil
|
44
|
-
response.should be_kind_of Net::HTTPSuccess
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
|
-
end
|
data/spec/cielo/token_spec.rb
DELETED
@@ -1,28 +0,0 @@
|
|
1
|
-
#encoding: utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe Cielo::Token do
|
5
|
-
let(:card_params) { { :cartao_numero => '4012888888881881', :cartao_validade => '201508', :cartao_portador => 'Nome portador' } }
|
6
|
-
let(:token) { Cielo::Token.new }
|
7
|
-
|
8
|
-
describe "create a token for a card" do
|
9
|
-
before do
|
10
|
-
Cielo.stub(:numero_afiliacao).and_return('1006993069')
|
11
|
-
Cielo.stub(:chave_acesso).and_return('25fbb99741c739dd84d7b06ec78c9bac718838630f30b112d033ce2e621b34f3')
|
12
|
-
end
|
13
|
-
|
14
|
-
it 'delivers an successful message and have a card token' do
|
15
|
-
FakeWeb.register_uri(:any, "https://qasecommerce.cielo.com.br/servicos/ecommwsec.do",
|
16
|
-
:body => "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><retorno-token versao=\"1.2.1\" id=\"57239017\" xmlns=\"http://ecommerce.cbmp.com.br\"><token><dados-token><codigo-token>TuS6LeBHWjqFFtE7S3zR052Jl/KUlD+tYJFpAdlA87E=</codigo-token><status>1</status><numero-cartao-truncado>455187******0183</numero-cartao-truncado></dados-token></token></retorno-token>", :content_type => "application/xml")
|
17
|
-
|
18
|
-
response = token.create! card_params, :store
|
19
|
-
|
20
|
-
response[:"retorno-token"][:token][:"dados-token"][:"codigo-token"].should eq 'TuS6LeBHWjqFFtE7S3zR052Jl/KUlD+tYJFpAdlA87E='
|
21
|
-
response[:"retorno-token"][:token][:"dados-token"][:"numero-cartao-truncado"].should eq '455187******0183'
|
22
|
-
|
23
|
-
# Respose type
|
24
|
-
# {:"retorno-token"=>{:token=>{:"dados-token"=>{:"codigo-token"=>"2ta/YqYaeyolf2NHkBWO8grPqZE44j3PvRAQxVQQGgE=", :status=>"1", :"numero-cartao-truncado"=>"401288******1881"}}}}
|
25
|
-
end
|
26
|
-
end
|
27
|
-
|
28
|
-
end
|
@@ -1,227 +0,0 @@
|
|
1
|
-
#encoding: utf-8
|
2
|
-
require 'spec_helper'
|
3
|
-
|
4
|
-
describe Cielo::Transaction do
|
5
|
-
let(:default_params) { {:numero => "1", :valor => "100", :bandeira => "visa", :"url-retorno" => "http://some.thing.com"} }
|
6
|
-
let(:card_params) { { :cartao_numero => '4012888888881881', :cartao_validade => '201508', :cartao_indicador => '1', :cartao_seguranca => '973', :cartao_portador => 'Nome portador' } }
|
7
|
-
let(:card_token_params) { { :cartao_numero => '4012888888881881', :cartao_validade => '201508', :cartao_portador => 'Nome portador' } }
|
8
|
-
let(:authentication_card_params){ { :cartao_numero => '5453010000066167', :cartao_validade => '201805', :cartao_seguranca => "123", :cartao_portador => "Nome portador" }}
|
9
|
-
|
10
|
-
before do
|
11
|
-
@transaction = Cielo::Transaction.new
|
12
|
-
@token = Cielo::Token.new
|
13
|
-
end
|
14
|
-
|
15
|
-
describe "create a buy page store transaction with token" do
|
16
|
-
before do
|
17
|
-
Cielo.stub(:numero_afiliacao).and_return('1006993069')
|
18
|
-
Cielo.stub(:chave_acesso).and_return('25fbb99741c739dd84d7b06ec78c9bac718838630f30b112d033ce2e621b34f3')
|
19
|
-
|
20
|
-
FakeWeb.register_uri(:any, "https://qasecommerce.cielo.com.br/servicos/ecommwsec.do",
|
21
|
-
:body => "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><retorno-token versao=\"1.2.1\" id=\"57239017\" xmlns=\"http://ecommerce.cbmp.com.br\"><token><dados-token><codigo-token>TuS6LeBHWjqFFtE7S3zR052Jl/KUlD+tYJFpAdlA87E=</codigo-token><status>1</status><numero-cartao-truncado>455187******0183</numero-cartao-truncado></dados-token></token></retorno-token>", :content_type => "application/xml")
|
22
|
-
|
23
|
-
response = @token.create! card_token_params, :store
|
24
|
-
token = response[:"retorno-token"][:token][:"dados-token"][:"codigo-token"]
|
25
|
-
|
26
|
-
@params = default_params.merge(:token => token, :autorizar => 3)
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'delivers an successful message' do
|
30
|
-
FakeWeb.register_uri(:any, "https://qasecommerce.cielo.com.br/servicos/ecommwsec.do",
|
31
|
-
:body => "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><transacao versao=\"1.2.1\" id=\"1385758302\" xmlns=\"http://ecommerce.cbmp.com.br\"><tid>10069930690BB0381001</tid><pan>52WC7RsmcNuEUSjrYWAEhCOjoLMnMCm4KMTQBqN7PdM=</pan><dados-pedido><numero>1</numero><valor>100</valor><moeda>986</moeda><data-hora>2013-11-29T18:51:43.854-02:00</data-hora><idioma>PT</idioma><taxa-embarque>0</taxa-embarque></dados-pedido><forma-pagamento><bandeira>visa</bandeira><produto>1</produto><parcelas>1</parcelas></forma-pagamento><status>6</status><autenticacao><codigo>6</codigo><mensagem>Transacao sem autenticacao</mensagem><data-hora>2013-11-29T18:51:43.865-02:00</data-hora><valor>100</valor><eci>7</eci></autenticacao><autorizacao><codigo>6</codigo><mensagem>Transa??o autorizada</mensagem><data-hora>2013-11-29T18:51:43.869-02:00</data-hora><valor>100</valor><lr>00</lr><arp>123456</arp><nsu>766008</nsu></autorizacao><captura><codigo>6</codigo><mensagem>Transacao capturada com sucesso</mensagem><data-hora>2013-11-29T18:51:44.006-02:00</data-hora><valor>100</valor></captura></transacao>", :content_type => "application/xml")
|
32
|
-
|
33
|
-
response = @transaction.create! @params, :store
|
34
|
-
|
35
|
-
# 7 is when transactions was not autenticated
|
36
|
-
response[:transacao][:autenticacao][:eci].should eq("7")
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
describe "create a recurring transaction with token" do
|
41
|
-
before do
|
42
|
-
Cielo.stub(:numero_afiliacao).and_return('1006993069')
|
43
|
-
Cielo.stub(:chave_acesso).and_return('25fbb99741c739dd84d7b06ec78c9bac718838630f30b112d033ce2e621b34f3')
|
44
|
-
|
45
|
-
FakeWeb.register_uri(:any, "https://qasecommerce.cielo.com.br/servicos/ecommwsec.do",
|
46
|
-
:body => "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><retorno-token versao=\"1.2.1\" id=\"57239017\" xmlns=\"http://ecommerce.cbmp.com.br\"><token><dados-token><codigo-token>TuS6LeBHWjqFFtE7S3zR052Jl/KUlD+tYJFpAdlA87E=</codigo-token><status>1</status><numero-cartao-truncado>455187******0183</numero-cartao-truncado></dados-token></token></retorno-token>", :content_type => "application/xml")
|
47
|
-
|
48
|
-
response = @token.create! card_token_params, :store
|
49
|
-
token = response[:"retorno-token"][:token][:"dados-token"][:"codigo-token"]
|
50
|
-
|
51
|
-
# #autorizar => 4 indicates recurring transaction
|
52
|
-
@params = default_params.merge(:token => token, :autorizar => 4)
|
53
|
-
end
|
54
|
-
|
55
|
-
it 'delivers an successful message' do
|
56
|
-
FakeWeb.register_uri(:any, "https://qasecommerce.cielo.com.br/servicos/ecommwsec.do",
|
57
|
-
:body => "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><transacao versao=\"1.2.1\" id=\"1385758302\" xmlns=\"http://ecommerce.cbmp.com.br\"><tid>10069930690BB0381001</tid><pan>52WC7RsmcNuEUSjrYWAEhCOjoLMnMCm4KMTQBqN7PdM=</pan><dados-pedido><numero>1</numero><valor>100</valor><moeda>986</moeda><data-hora>2013-11-29T18:51:43.854-02:00</data-hora><idioma>PT</idioma><taxa-embarque>0</taxa-embarque></dados-pedido><forma-pagamento><bandeira>visa</bandeira><produto>1</produto><parcelas>1</parcelas></forma-pagamento><status>6</status><autenticacao><codigo>6</codigo><mensagem>Transacao sem autenticacao</mensagem><data-hora>2013-11-29T18:51:43.865-02:00</data-hora><valor>100</valor><eci>7</eci></autenticacao><autorizacao><codigo>6</codigo><mensagem>Transa??o autorizada</mensagem><data-hora>2013-11-29T18:51:43.869-02:00</data-hora><valor>100</valor><lr>00</lr><arp>123456</arp><nsu>766008</nsu></autorizacao><captura><codigo>6</codigo><mensagem>Transacao capturada com sucesso</mensagem><data-hora>2013-11-29T18:51:44.006-02:00</data-hora><valor>100</valor></captura></transacao>", :content_type => "application/xml")
|
58
|
-
|
59
|
-
response = @transaction.create! @params, :store
|
60
|
-
|
61
|
-
# 7 is when transactions was not autenticated
|
62
|
-
response[:transacao][:autenticacao][:eci].should eq("7")
|
63
|
-
end
|
64
|
-
end
|
65
|
-
|
66
|
-
# Error on system when uses gerar-token => true (Verify with Cielo)
|
67
|
-
describe "create a buy page store transaction with token generation" do
|
68
|
-
before do
|
69
|
-
FakeWeb.register_uri(:any, "https://qasecommerce.cielo.com.br/servicos/ecommwsec.do",
|
70
|
-
:body => "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?><transacao versao=\"1.2.1\" id=\"1390315327\" xmlns=\"http://ecommerce.cbmp.com.br\"><tid>10069930690DCC341001</tid><pan>52WC7RsmcNuEUSjrYWAEhCOjoLMnMCm4KMTQBqN7PdM=</pan><dados-pedido><numero>1</numero><valor>100</valor><moeda>986</moeda><data-hora>2014-01-21T12:42:08.865-02:00</data-hora><idioma>PT</idioma><taxa-embarque>0</taxa-embarque></dados-pedido><forma-pagamento><bandeira>visa</bandeira><produto>1</produto><parcelas>1</parcelas></forma-pagamento><status>6</status><autenticacao><codigo>6</codigo><mensagem>Transacao sem autenticacao</mensagem><data-hora>2014-01-21T12:42:08.872-02:00</data-hora><valor>100</valor><eci>7</eci></autenticacao><autorizacao><codigo>6</codigo><mensagem>Transa??o autorizada</mensagem><data-hora>2014-01-21T12:42:08.885-02:00</data-hora><valor>100</valor><lr>00</lr><arp>123456</arp><nsu>904244</nsu></autorizacao><captura><codigo>6</codigo><mensagem>Transacao capturada com sucesso</mensagem><data-hora>2014-01-21T12:42:08.912-02:00</data-hora><valor>100</valor></captura><token><dados-token><codigo-token>2ta/YqYaeyolf2NHkBWO8grPqZE44j3PvRAQxVQQGgE=</codigo-token><status>1</status><numero-cartao-truncado>401288******1881</numero-cartao-truncado></dados-token></token></transacao>", :content_type => "application/xml")
|
71
|
-
|
72
|
-
Cielo.stub(:numero_afiliacao).and_return('1006993069')
|
73
|
-
Cielo.stub(:chave_acesso).and_return('25fbb99741c739dd84d7b06ec78c9bac718838630f30b112d033ce2e621b34f3')
|
74
|
-
|
75
|
-
default_params.merge!(:"gerar-token" => true, :autorizar => 3)
|
76
|
-
|
77
|
-
@params = default_params.merge(card_params)
|
78
|
-
end
|
79
|
-
|
80
|
-
it 'delivers an successful message and have a card token' do
|
81
|
-
response = @transaction.create! @params, :store
|
82
|
-
|
83
|
-
response[:transacao][:tid].should_not be_nil
|
84
|
-
response[:transacao][:token][:"dados-token"][:"codigo-token"].should_not be_nil
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
describe "create a buy page store transaction" do
|
89
|
-
before do
|
90
|
-
Cielo.stub(:numero_afiliacao).and_return('1006993069')
|
91
|
-
Cielo.stub(:chave_acesso).and_return('25fbb99741c739dd84d7b06ec78c9bac718838630f30b112d033ce2e621b34f3')
|
92
|
-
|
93
|
-
@params = default_params.merge(card_params)
|
94
|
-
end
|
95
|
-
|
96
|
-
[:cartao_portador, :cartao_numero, :cartao_validade, :cartao_seguranca, :numero, :valor, :bandeira, :"url-retorno"].each do |parameter|
|
97
|
-
it "raises an error when #{parameter} isn't informed" do
|
98
|
-
lambda { @transaction.create!(@params.except!(parameter), :store) }.should raise_error(Cielo::MissingArgumentError)
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
it 'delivers an successful message' do
|
103
|
-
FakeWeb.register_uri(:any, "https://qasecommerce.cielo.com.br/servicos/ecommwsec.do",
|
104
|
-
:body => "<?xml version='1.0' encoding='ISO-8859-1'?><transacao versao='1.2.1' id='1385759313' xmlns='http://ecommerce.cbmp.com.br'><tid>10069930690BB0441001</tid><pan>52WC7RsmcNuEUSjrYWAEhCOjoLMnMCm4KMTQBqN7PdM=</pan><dados-pedido><numero>1</numero><valor>100</valor><moeda>986</moeda><data-hora>2013-11-29T19:08:34.048-02:00</data-hora><idioma>PT</idioma><taxa-embarque>0</taxa-embarque></dados-pedido><forma-pagamento><bandeira>visa</bandeira><produto>1</produto><parcelas>1</parcelas></forma-pagamento><status>0</status><url-autenticacao>https://qasecommerce.cielo.com.br/web/index.cbmp?id=55152147c2c9e44c340cb4e50d171e37</url-autenticacao></transacao>", :content_type => "application/xml")
|
105
|
-
|
106
|
-
response = @transaction.create! @params, :store
|
107
|
-
|
108
|
-
response[:transacao][:tid].should_not be_nil
|
109
|
-
response[:transacao][:"url-autenticacao"].should_not be_nil
|
110
|
-
|
111
|
-
response = @transaction.catch!("1001734898056B3C1001")
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
describe "create a buy page cielo transaction" do
|
116
|
-
before do
|
117
|
-
@params = default_params
|
118
|
-
end
|
119
|
-
[:numero, :valor, :bandeira, :"url-retorno"].each do |parameter|
|
120
|
-
it "raises an error when #{parameter} isn't informed" do
|
121
|
-
lambda { @transaction.create! @params.except!(parameter) }.should raise_error(Cielo::MissingArgumentError)
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
it "delivers an successful message" do
|
126
|
-
response = @transaction.create! @params
|
127
|
-
|
128
|
-
response[:transacao][:tid].should_not be_nil
|
129
|
-
response[:transacao][:"url-autenticacao"].should_not be_nil
|
130
|
-
|
131
|
-
response = @transaction.catch!("1001734898056B3C1001")
|
132
|
-
|
133
|
-
end
|
134
|
-
|
135
|
-
it "delivers a response with error message when status isn't 200" do
|
136
|
-
FakeWeb.register_uri(:any, "https://qasecommerce.cielo.com.br/servicos/ecommwsec.do",
|
137
|
-
:body => "Nothing to be found 'round here",
|
138
|
-
:status => ["404", "Not Found"])
|
139
|
-
response = @transaction.create! @params
|
140
|
-
|
141
|
-
response[:erro].should_not be_nil
|
142
|
-
response[:erro][:codigo].should be_eql("000")
|
143
|
-
end
|
144
|
-
|
145
|
-
it "delivers a response with error message when the server send" do
|
146
|
-
FakeWeb.register_uri(:any, "https://qasecommerce.cielo.com.br/servicos/ecommwsec.do",
|
147
|
-
:body => "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?> <erro xmlns=\"http://ecommerce.cbmp.com.br\"> <codigo>001</codigo> <mensagem>Requisição inválida</mensagem> </erro>", :content_type => "application/xml")
|
148
|
-
response = @transaction.create! @params
|
149
|
-
|
150
|
-
response[:erro].should_not be_nil
|
151
|
-
response[:erro][:codigo].should be_eql("001")
|
152
|
-
end
|
153
|
-
|
154
|
-
end
|
155
|
-
|
156
|
-
describe "Verify a transaction status" do
|
157
|
-
it "returns null when no tid is informed" do
|
158
|
-
@transaction.verify!(nil).should be_nil
|
159
|
-
end
|
160
|
-
it "returns a successfull message" do
|
161
|
-
FakeWeb.register_uri(:any, "https://qasecommerce.cielo.com.br/servicos/ecommwsec.do",
|
162
|
-
:body => "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<transacao id=\"1308170973\" versao=\"1.1.0\" xmlns=\"http://ecommerce.cbmp.com.br\">\n <tid>1001734898056B3C1001</tid>\n <dados-pedido>\n <numero>1</numero>\n <valor>100</valor>\n <moeda>986</moeda>\n <data-hora>2011-06-15T18:45:16.705-02:00</data-hora>\n <idioma>PT</idioma>\n </dados-pedido>\n <forma-pagamento>\n <bandeira>visa</bandeira>\n <produto>1</produto>\n <parcelas>1</parcelas>\n </forma-pagamento>\n <status>0</status>\n</transacao>\n\n", :content_type => "application/xml")
|
163
|
-
|
164
|
-
response = @transaction.verify!("1001734898056B3C1001")
|
165
|
-
|
166
|
-
response[:transacao][:tid].should_not be_nil
|
167
|
-
response[:transacao][:status].should_not be_nil
|
168
|
-
end
|
169
|
-
end
|
170
|
-
|
171
|
-
describe "Catch a transaction" do
|
172
|
-
it "returns null when no tid is informed" do
|
173
|
-
@transaction.catch!(nil).should be_nil
|
174
|
-
end
|
175
|
-
it "returns a successfull message" do
|
176
|
-
FakeWeb.register_uri(:any, "https://qasecommerce.cielo.com.br/servicos/ecommwsec.do",
|
177
|
-
:body => "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<transacao id=\"1308170973\" versao=\"1.1.0\" xmlns=\"http://ecommerce.cbmp.com.br\">\n <tid>1001734898056B3C1001</tid>\n <dados-pedido>\n <numero>1</numero>\n <valor>100</valor>\n <moeda>986</moeda>\n <data-hora>2011-06-15T18:45:16.705-02:00</data-hora>\n <idioma>PT</idioma>\n </dados-pedido>\n <forma-pagamento>\n <bandeira>visa</bandeira>\n <produto>1</produto>\n <parcelas>1</parcelas>\n </forma-pagamento>\n <status>0</status>\n</transacao>\n\n", :content_type => "application/xml")
|
178
|
-
|
179
|
-
response = @transaction.catch!("1001734898056B3C1001")
|
180
|
-
|
181
|
-
response[:transacao][:tid].should_not be_nil
|
182
|
-
response[:transacao][:status].should_not be_nil
|
183
|
-
end
|
184
|
-
end
|
185
|
-
|
186
|
-
describe "Cancel a transaction" do
|
187
|
-
it "returns null when no tid is informed" do
|
188
|
-
@transaction.cancel!(nil).should be_nil
|
189
|
-
end
|
190
|
-
it "returns a successfull message" do
|
191
|
-
FakeWeb.register_uri(:any, "https://qasecommerce.cielo.com.br/servicos/ecommwsec.do",
|
192
|
-
:body => "<?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>\n<transacao id=\"1308170973\" versao=\"1.1.0\" xmlns=\"http://ecommerce.cbmp.com.br\">\n <tid>1001734898056B3C1001</tid>\n <dados-pedido>\n <numero>1</numero>\n <valor>100</valor>\n <moeda>986</moeda>\n <data-hora>2011-06-15T18:45:16.705-02:00</data-hora>\n <idioma>PT</idioma>\n </dados-pedido>\n <forma-pagamento>\n <bandeira>visa</bandeira>\n <produto>1</produto>\n <parcelas>1</parcelas>\n </forma-pagamento>\n <status>0</status>\n</transacao>\n\n", :content_type => "application/xml")
|
193
|
-
|
194
|
-
response = @transaction.cancel!("1001734898056B3C1001")
|
195
|
-
|
196
|
-
response[:transacao][:tid].should_not be_nil
|
197
|
-
response[:transacao][:status].should_not be_nil
|
198
|
-
end
|
199
|
-
end
|
200
|
-
|
201
|
-
describe "Using a production environment" do
|
202
|
-
before do
|
203
|
-
Cielo.setup do |config|
|
204
|
-
config.environment = :production
|
205
|
-
config.numero_afiliacao = "1001734891"
|
206
|
-
config.chave_acesso="e84827130b9837473681c2787007da5914d6359947015a5cdb2b8843db0fa832"
|
207
|
-
end
|
208
|
-
end
|
209
|
-
|
210
|
-
it "must use the production environment" do
|
211
|
-
Cielo.numero_afiliacao.should be_eql "1001734891"
|
212
|
-
end
|
213
|
-
|
214
|
-
it "must use the production client number" do
|
215
|
-
@connection = Cielo::Connection.new
|
216
|
-
@connection.numero_afiliacao.should be_eql "1001734891"
|
217
|
-
end
|
218
|
-
|
219
|
-
it "must use the configuration informed" do
|
220
|
-
@connection2 = Cielo::Connection.new "0100100100", "e84827130b9837473681c2787007da5914d6359947015a5cdb2b8843db0fa800"
|
221
|
-
@connection2.numero_afiliacao.should be_eql "0100100100"
|
222
|
-
@connection2.chave_acesso.should be_eql "e84827130b9837473681c2787007da5914d6359947015a5cdb2b8843db0fa800"
|
223
|
-
end
|
224
|
-
|
225
|
-
end
|
226
|
-
|
227
|
-
end
|