cielo_old 1.0.1 → 1.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile +5 -6
- data/Gemfile.lock +30 -69
- data/Rakefile +2 -48
- data/lib/cielo/connection.rb +1 -1
- data/lib/cielo/transaction.rb +1 -1
- data/lib/cielo/version.rb +1 -1
- data/spec/cielo/token_spec.rb +78 -1
- data/spec/spec_helper.rb +11 -1
- metadata +4 -6
- data/cielo-0.2.5.gem +0 -0
- data/lib/cielo/string.rb +0 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: b3c0ecfcdb2c5810ea8d0bd84058f56773aee053
|
4
|
+
data.tar.gz: abf6678c660515537cfe9f45a16b8df17870e34f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6cec2db42b13d4904901a4699a12c7d84871052b99c283d71835bd59420cb432d7a43dd60f45c2e795841d17d9b416d294ed38d8defc105721bc68c33f29674c
|
7
|
+
data.tar.gz: 18ebd0e2e7024b0b3b55b31d18d1519297c3ff82aefee0fe4d925d159d6a6de9c7a17f479cd8a1b83aa5f05e12c25a92c581b33701c25ed1758e584f2b1d1d44
|
data/Gemfile
CHANGED
@@ -1,12 +1,12 @@
|
|
1
|
-
ruby '2.1
|
2
|
-
#ruby=2.1
|
1
|
+
ruby '2.3.1'
|
2
|
+
#ruby=2.3.1@cielo
|
3
3
|
source 'http://rubygems.org'
|
4
4
|
|
5
5
|
# Add dependencies required to use your gem here.
|
6
6
|
# Example:
|
7
|
-
gem 'activesupport', '>= 3.0.7'
|
8
7
|
gem 'i18n'
|
9
|
-
gem 'builder'
|
8
|
+
gem 'builder'
|
9
|
+
gem 'activesupport'
|
10
10
|
|
11
11
|
# Add dependencies to develop your gem here.
|
12
12
|
# Include everything needed to run rake, tests, features, etc.
|
@@ -14,7 +14,6 @@ group :development do
|
|
14
14
|
gem 'watir-webdriver'
|
15
15
|
gem 'shoulda', '>= 0'
|
16
16
|
gem 'bundler'
|
17
|
-
gem 'jeweler'
|
18
17
|
gem 'rspec'
|
19
18
|
gem 'fakeweb'
|
20
|
-
end
|
19
|
+
end
|
data/Gemfile.lock
CHANGED
@@ -1,105 +1,66 @@
|
|
1
1
|
GEM
|
2
2
|
remote: http://rubygems.org/
|
3
3
|
specs:
|
4
|
-
activesupport (
|
4
|
+
activesupport (5.0.0.1)
|
5
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
5
6
|
i18n (~> 0.7)
|
6
|
-
json (~> 1.7, >= 1.7.7)
|
7
7
|
minitest (~> 5.1)
|
8
|
-
thread_safe (~> 0.3, >= 0.3.4)
|
9
8
|
tzinfo (~> 1.1)
|
10
|
-
addressable (2.3.8)
|
11
9
|
builder (3.2.2)
|
12
|
-
childprocess (0.5.
|
10
|
+
childprocess (0.5.9)
|
13
11
|
ffi (~> 1.0, >= 1.0.11)
|
14
|
-
|
15
|
-
thread_safe (~> 0.3, >= 0.3.1)
|
12
|
+
concurrent-ruby (1.0.2)
|
16
13
|
diff-lcs (1.2.5)
|
17
14
|
fakeweb (1.3.0)
|
18
|
-
|
19
|
-
multipart-post (>= 1.2, < 3)
|
20
|
-
ffi (1.9.10)
|
21
|
-
git (1.2.9.1)
|
22
|
-
github_api (0.12.3)
|
23
|
-
addressable (~> 2.3)
|
24
|
-
descendants_tracker (~> 0.0.4)
|
25
|
-
faraday (~> 0.8, < 0.10)
|
26
|
-
hashie (>= 3.3)
|
27
|
-
multi_json (>= 1.7.5, < 2.0)
|
28
|
-
nokogiri (~> 1.6.3)
|
29
|
-
oauth2
|
30
|
-
hashie (3.4.2)
|
31
|
-
highline (1.7.2)
|
15
|
+
ffi (1.9.14)
|
32
16
|
i18n (0.7.0)
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
rdoc
|
42
|
-
json (1.8.3)
|
43
|
-
jwt (1.5.1)
|
44
|
-
mini_portile (0.6.2)
|
45
|
-
minitest (5.7.0)
|
46
|
-
multi_json (1.11.2)
|
47
|
-
multi_xml (0.5.5)
|
48
|
-
multipart-post (2.0.0)
|
49
|
-
nokogiri (1.6.6.2)
|
50
|
-
mini_portile (~> 0.6.0)
|
51
|
-
oauth2 (1.0.0)
|
52
|
-
faraday (>= 0.8, < 0.10)
|
53
|
-
jwt (~> 1.0)
|
54
|
-
multi_json (~> 1.3)
|
55
|
-
multi_xml (~> 0.5)
|
56
|
-
rack (~> 1.2)
|
57
|
-
rack (1.6.4)
|
58
|
-
rake (10.4.2)
|
59
|
-
rdoc (4.2.0)
|
60
|
-
json (~> 1.4)
|
61
|
-
rspec (3.3.0)
|
62
|
-
rspec-core (~> 3.3.0)
|
63
|
-
rspec-expectations (~> 3.3.0)
|
64
|
-
rspec-mocks (~> 3.3.0)
|
65
|
-
rspec-core (3.3.1)
|
66
|
-
rspec-support (~> 3.3.0)
|
67
|
-
rspec-expectations (3.3.0)
|
17
|
+
minitest (5.9.1)
|
18
|
+
rspec (3.5.0)
|
19
|
+
rspec-core (~> 3.5.0)
|
20
|
+
rspec-expectations (~> 3.5.0)
|
21
|
+
rspec-mocks (~> 3.5.0)
|
22
|
+
rspec-core (3.5.4)
|
23
|
+
rspec-support (~> 3.5.0)
|
24
|
+
rspec-expectations (3.5.0)
|
68
25
|
diff-lcs (>= 1.2.0, < 2.0)
|
69
|
-
rspec-support (~> 3.
|
70
|
-
rspec-mocks (3.
|
26
|
+
rspec-support (~> 3.5.0)
|
27
|
+
rspec-mocks (3.5.0)
|
71
28
|
diff-lcs (>= 1.2.0, < 2.0)
|
72
|
-
rspec-support (~> 3.
|
73
|
-
rspec-support (3.
|
74
|
-
rubyzip (1.
|
75
|
-
selenium-webdriver (
|
29
|
+
rspec-support (~> 3.5.0)
|
30
|
+
rspec-support (3.5.0)
|
31
|
+
rubyzip (1.2.0)
|
32
|
+
selenium-webdriver (3.0.1)
|
76
33
|
childprocess (~> 0.5)
|
77
|
-
multi_json (~> 1.0)
|
78
34
|
rubyzip (~> 1.0)
|
79
35
|
websocket (~> 1.0)
|
80
36
|
shoulda (3.5.0)
|
81
37
|
shoulda-context (~> 1.0, >= 1.0.1)
|
82
38
|
shoulda-matchers (>= 1.4.1, < 3.0)
|
83
|
-
shoulda-context (1.2.
|
39
|
+
shoulda-context (1.2.2)
|
84
40
|
shoulda-matchers (2.8.0)
|
85
41
|
activesupport (>= 3.0.0)
|
86
42
|
thread_safe (0.3.5)
|
87
43
|
tzinfo (1.2.2)
|
88
44
|
thread_safe (~> 0.1)
|
89
|
-
watir-webdriver (0.
|
45
|
+
watir-webdriver (0.9.9)
|
90
46
|
selenium-webdriver (>= 2.46.2)
|
91
|
-
websocket (1.2.
|
47
|
+
websocket (1.2.3)
|
92
48
|
|
93
49
|
PLATFORMS
|
94
50
|
ruby
|
95
51
|
|
96
52
|
DEPENDENCIES
|
97
|
-
activesupport
|
98
|
-
builder
|
53
|
+
activesupport
|
54
|
+
builder
|
99
55
|
bundler
|
100
56
|
fakeweb
|
101
57
|
i18n
|
102
|
-
jeweler
|
103
58
|
rspec
|
104
59
|
shoulda
|
105
60
|
watir-webdriver
|
61
|
+
|
62
|
+
RUBY VERSION
|
63
|
+
ruby 2.3.1p112
|
64
|
+
|
65
|
+
BUNDLED WITH
|
66
|
+
1.13.6
|
data/Rakefile
CHANGED
@@ -1,48 +1,2 @@
|
|
1
|
-
|
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_old"
|
21
|
-
gem.license = "MIT"
|
22
|
-
gem.summary = 'Integração com a cielo'
|
23
|
-
gem.description = 'Integração com a cielo'
|
24
|
-
gem.email = 'ton.garcia.jr@gmail.com'
|
25
|
-
gem.authors = ['Ilton']
|
26
|
-
gem.version = Cielo::VERSION
|
27
|
-
# dependencies defined in Gemfile
|
28
|
-
end
|
29
|
-
Jeweler::RubygemsDotOrgTasks.new
|
30
|
-
|
31
|
-
require 'rake/testtask'
|
32
|
-
Rake::TestTask.new(:test) do |test|
|
33
|
-
test.libs << 'lib' << 'test'
|
34
|
-
test.pattern = 'test/**/test_*.rb'
|
35
|
-
test.verbose = true
|
36
|
-
end
|
37
|
-
|
38
|
-
task :default => :test
|
39
|
-
|
40
|
-
require 'rdoc/task'
|
41
|
-
Rake::RDocTask.new do |rdoc|
|
42
|
-
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
43
|
-
|
44
|
-
rdoc.rdoc_dir = 'rdoc'
|
45
|
-
rdoc.title = "cielo #{version}"
|
46
|
-
rdoc.rdoc_files.include('README*')
|
47
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
48
|
-
end
|
1
|
+
require "bundler/gem_tasks"
|
2
|
+
task :default => :spec
|
data/lib/cielo/connection.rb
CHANGED
data/lib/cielo/transaction.rb
CHANGED
@@ -24,7 +24,7 @@ module Cielo
|
|
24
24
|
message = @connection.xml_builder('requisicao-transacao') do |xml|
|
25
25
|
xml.tag!("dados-portador") do
|
26
26
|
if parameters[:token].present?
|
27
|
-
xml.tag!('token', parameters[:token])
|
27
|
+
xml.tag!('token', CGI.escape(parameters[:token]))
|
28
28
|
else
|
29
29
|
xml.tag!('numero', parameters[:cartao_numero])
|
30
30
|
xml.tag!('validade', parameters[:cartao_validade])
|
data/lib/cielo/version.rb
CHANGED
data/spec/cielo/token_spec.rb
CHANGED
@@ -3,6 +3,7 @@ require 'spec_helper'
|
|
3
3
|
|
4
4
|
describe Cielo::Token do
|
5
5
|
let(:card_params) { { :cartao_numero => '4012888888881881', :cartao_validade => '201508', :cartao_portador => 'Nome portador' } }
|
6
|
+
let(:generate_token_params) { { capturar: true, produto: 1, 'gerar-token': true, 'url-retorno': 'a.com', autorizar: 3, valor: 1323, numero: 5, moeda: 986, cartao_numero: 4012001037141112, cartao_validade: '201805', cartao_seguranca: 123, cartao_portador: 'Afranio', bandeira: 'visa' } }
|
6
7
|
|
7
8
|
before do
|
8
9
|
@token = Cielo::Token.new
|
@@ -13,7 +14,7 @@ describe Cielo::Token do
|
|
13
14
|
Cielo.stub(:numero_afiliacao).and_return('1006993069')
|
14
15
|
Cielo.stub(:chave_acesso).and_return('25fbb99741c739dd84d7b06ec78c9bac718838630f30b112d033ce2e621b34f3')
|
15
16
|
|
16
|
-
@params =
|
17
|
+
@params = generate_token_params
|
17
18
|
end
|
18
19
|
|
19
20
|
it 'delivers an successful message and have a card token' do
|
@@ -30,4 +31,80 @@ describe Cielo::Token do
|
|
30
31
|
end
|
31
32
|
end
|
32
33
|
|
34
|
+
describe 'charge with a generated token' do
|
35
|
+
before do
|
36
|
+
FakeWeb.allow_net_connect = true
|
37
|
+
Cielo.environment = :production
|
38
|
+
|
39
|
+
@secrets = Helper.secrets
|
40
|
+
store_settings = @secrets[Cielo.environment.to_s]['store_settings']
|
41
|
+
allow(Cielo).to receive(:numero_afiliacao).and_return(store_settings['membership'])
|
42
|
+
allow(Cielo).to receive(:chave_acesso).and_return(store_settings['access_key'])
|
43
|
+
@transaction = Cielo::Transaction.new
|
44
|
+
|
45
|
+
mock_token_charged_json = '{"transacao":{"tid":"1063542305000000040A","pan":"OYV1BjLr7lL/jgE2qpPIg03YZhk7i/rUXy0ylv3ljp8=","dados-pedido":{"numero":"5","valor":"110","moeda":"986","data-hora":"2016-11-14T19:59:57.751-02:00","idioma":"PT","taxa-embarque":"0"},"forma-pagamento":{"bandeira":"visa","produto":"1","parcelas":"1"},"status":"6","autenticacao":{"codigo":"6","mensagem":"Transacao sem autenticacao","data-hora":"2016-11-14T19:59:57.769-02:00","valor":"110","eci":"7"},"autorizacao":{"codigo":"6","mensagem":"Transação autorizada","data-hora":"2016-11-14T19:59:57.776-02:00","valor":"110","lr":"00","arp":"786906","nsu":"000064"},"captura":{"codigo":"6","mensagem":"Transacao capturada com sucesso","data-hora":"2016-11-14T19:59:58.921-02:00","valor":"110"}}}'
|
46
|
+
mock_generated_token_json = '{"transacao":{"tid":"106354230500000003CA","pan":"OYV1BjLr7lL/jgE2qpPIg03YZhk7i/rUXy0ylv3ljp8=","dados-pedido":{"numero":"5","valor":"110","moeda":"986","data-hora":"2016-11-14T19:57:09.257-02:00","idioma":"PT","taxa-embarque":"0"},"forma-pagamento":{"bandeira":"visa","produto":"1","parcelas":"1"},"status":"6","autenticacao":{"codigo":"6","mensagem":"Transacao sem autenticacao","data-hora":"2016-11-14T19:57:09.291-02:00","valor":"110","eci":"7"},"autorizacao":{"codigo":"6","mensagem":"Transação autorizada","data-hora":"2016-11-14T19:57:09.334-02:00","valor":"110","lr":"00","arp":"780914","nsu":"000060"},"captura":{"codigo":"6","mensagem":"Transacao capturada com sucesso","data-hora":"2016-11-14T19:57:10.427-02:00","valor":"110"},"token":{"dados-token":{"codigo-token":"44TyuILHFX+dtxOVvDdy2ypB5AfG8Cm93G7H9h2dKnw=","status":"1","numero-cartao-truncado":"498423******8979"}}}}'
|
47
|
+
mock_generated_token = JSON.parse(mock_generated_token_json).deep_symbolize_keys
|
48
|
+
mock_token_charged = JSON.parse(mock_token_charged_json).deep_symbolize_keys
|
49
|
+
|
50
|
+
card = @secrets['production']['card']
|
51
|
+
charge_gen_token_params = {
|
52
|
+
capturar: true,
|
53
|
+
produto: 1,
|
54
|
+
'gerar-token': true,
|
55
|
+
'url-retorno': 'a.com',
|
56
|
+
autorizar: 3,
|
57
|
+
valor: 110,
|
58
|
+
numero: 5,
|
59
|
+
moeda: 986,
|
60
|
+
cartao_numero: card['number'],
|
61
|
+
cartao_validade: card['expiration'],
|
62
|
+
cartao_seguranca: card['cvv'],
|
63
|
+
cartao_portador: card['holder'],
|
64
|
+
bandeira: card['brand']
|
65
|
+
}
|
66
|
+
|
67
|
+
@generated_token = mock_generated_token
|
68
|
+
# @generated_token = @transaction.create! charge_gen_token_params, :store
|
69
|
+
@token_data = @generated_token[:transacao][:token][:'dados-token']
|
70
|
+
|
71
|
+
base_generated_token_params = charge_gen_token_params.except(:'gerar-token', :cartao_validade, :cartao_seguranca, :cartao_portador, :cartao_numero)
|
72
|
+
token_charge_params = base_generated_token_params.merge(token: @token_data[:'codigo-token'])
|
73
|
+
|
74
|
+
# @token_charged = @transaction.create! token_charge_params, :store
|
75
|
+
@token_charged = mock_token_charged
|
76
|
+
|
77
|
+
# Expectation aux variables
|
78
|
+
@generated_token_transaction = @generated_token[:transacao]
|
79
|
+
@token_charged_transaction = @token_charged[:transacao]
|
80
|
+
|
81
|
+
@token_charged_card_brand = @token_charged_transaction[:'forma-pagamento'][:bandeira]
|
82
|
+
@generated_token_card_brand = @generated_token_transaction[:'forma-pagamento'][:bandeira]
|
83
|
+
|
84
|
+
@token_charged_purchase = @token_charged_transaction[:'dados-pedido'][:numero]
|
85
|
+
@generated_token_purchase = @generated_token_transaction[:'dados-pedido'][:numero]
|
86
|
+
|
87
|
+
@token_charged_value = @token_charged_transaction[:'dados-pedido'][:valor]
|
88
|
+
@generated_token_value = @generated_token_transaction[:'dados-pedido'][:valor]
|
89
|
+
end
|
90
|
+
|
91
|
+
it 'retrieves a successful token generated from a charge' do
|
92
|
+
expect(@token_data[:'codigo-token']).to_not be_nil
|
93
|
+
expect(@token_data[:'numero-cartao-truncado']).to_not be_nil
|
94
|
+
end
|
95
|
+
|
96
|
+
it 'must have a transaction with a valid TID' do
|
97
|
+
expect(@token_charged_transaction).to_not be_nil
|
98
|
+
expect(@token_charged_transaction[:tid]).to_not be_nil
|
99
|
+
end
|
100
|
+
|
101
|
+
it 'charged purchase token must be the same which generated it' do
|
102
|
+
expect(@token_charged_purchase).to eq(@generated_token_purchase)
|
103
|
+
end
|
104
|
+
|
105
|
+
it 'charged token value must be the same the purchase generator value' do
|
106
|
+
expect(@token_charged_value).to eq(@generated_token_value)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
33
110
|
end
|
data/spec/spec_helper.rb
CHANGED
@@ -1,5 +1,15 @@
|
|
1
|
+
require 'json'
|
2
|
+
require 'yaml'
|
1
3
|
require 'cielo'
|
2
4
|
require 'fakeweb'
|
3
5
|
require 'watir-webdriver'
|
4
6
|
|
5
|
-
FakeWeb.allow_net_connect = false
|
7
|
+
FakeWeb.allow_net_connect = false
|
8
|
+
|
9
|
+
module Helper
|
10
|
+
@secrets
|
11
|
+
def self.secrets
|
12
|
+
@secrets = YAML.load_file('./spec/secrets.yml') if @secrets.nil?
|
13
|
+
@secrets
|
14
|
+
end
|
15
|
+
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cielo_old
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.0.
|
4
|
+
version: 1.0.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Ilton
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2014-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|
@@ -136,7 +136,7 @@ dependencies:
|
|
136
136
|
- - ">="
|
137
137
|
- !ruby/object:Gem::Version
|
138
138
|
version: '0'
|
139
|
-
description: Integração com a
|
139
|
+
description: Integração com a Cielo
|
140
140
|
email: ton.garcia.jr@gmail.com
|
141
141
|
executables: []
|
142
142
|
extensions: []
|
@@ -151,11 +151,9 @@ files:
|
|
151
151
|
- LICENSE.txt
|
152
152
|
- README.rdoc
|
153
153
|
- Rakefile
|
154
|
-
- cielo-0.2.5.gem
|
155
154
|
- cielo.gemspec
|
156
155
|
- lib/cielo.rb
|
157
156
|
- lib/cielo/connection.rb
|
158
|
-
- lib/cielo/string.rb
|
159
157
|
- lib/cielo/token.rb
|
160
158
|
- lib/cielo/transaction.rb
|
161
159
|
- lib/cielo/version.rb
|
@@ -185,7 +183,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
185
183
|
version: '0'
|
186
184
|
requirements: []
|
187
185
|
rubyforge_project:
|
188
|
-
rubygems_version: 2.
|
186
|
+
rubygems_version: 2.5.1
|
189
187
|
signing_key:
|
190
188
|
specification_version: 4
|
191
189
|
summary: Integração com a cielo
|
data/cielo-0.2.5.gem
DELETED
Binary file
|