cielo 0.1.0.beta1
Sign up to get free protection for your applications and to get access to all the features.
- data/.document +5 -0
- data/Gemfile +17 -0
- data/Gemfile.lock +38 -0
- data/LICENSE.txt +20 -0
- data/README.rdoc +63 -0
- data/Rakefile +57 -0
- data/lib/cielo/connection.rb +22 -0
- data/lib/cielo/transaction.rb +101 -0
- data/lib/cielo/version.rb +8 -0
- data/lib/cielo.rb +38 -0
- data/spec/cielo/connection_spec.rb +18 -0
- data/spec/cielo/transaction_spec.rb +102 -0
- data/spec/spec_helper.rb +2 -0
- metadata +171 -0
data/.document
ADDED
data/Gemfile
ADDED
@@ -0,0 +1,17 @@
|
|
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'
|
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 "shoulda", ">= 0"
|
12
|
+
gem "bundler", "~> 1.0.0"
|
13
|
+
gem "jeweler", "~> 1.6.0"
|
14
|
+
gem "rcov", ">= 0"
|
15
|
+
gem "rspec"
|
16
|
+
gem "fakeweb"
|
17
|
+
end
|
data/Gemfile.lock
ADDED
@@ -0,0 +1,38 @@
|
|
1
|
+
GEM
|
2
|
+
remote: http://rubygems.org/
|
3
|
+
specs:
|
4
|
+
activesupport (3.0.8)
|
5
|
+
builder (2.1.2)
|
6
|
+
diff-lcs (1.1.2)
|
7
|
+
fakeweb (1.3.0)
|
8
|
+
git (1.2.5)
|
9
|
+
i18n (0.6.0)
|
10
|
+
jeweler (1.6.2)
|
11
|
+
bundler (~> 1.0)
|
12
|
+
git (>= 1.2.5)
|
13
|
+
rake
|
14
|
+
rake (0.9.2)
|
15
|
+
rcov (0.9.9)
|
16
|
+
rspec (2.6.0)
|
17
|
+
rspec-core (~> 2.6.0)
|
18
|
+
rspec-expectations (~> 2.6.0)
|
19
|
+
rspec-mocks (~> 2.6.0)
|
20
|
+
rspec-core (2.6.4)
|
21
|
+
rspec-expectations (2.6.0)
|
22
|
+
diff-lcs (~> 1.1.2)
|
23
|
+
rspec-mocks (2.6.0)
|
24
|
+
shoulda (2.11.3)
|
25
|
+
|
26
|
+
PLATFORMS
|
27
|
+
ruby
|
28
|
+
|
29
|
+
DEPENDENCIES
|
30
|
+
activesupport (>= 3.0.7)
|
31
|
+
builder (~> 2.0)
|
32
|
+
bundler (~> 1.0.0)
|
33
|
+
fakeweb
|
34
|
+
i18n
|
35
|
+
jeweler (~> 1.6.0)
|
36
|
+
rcov
|
37
|
+
rspec
|
38
|
+
shoulda
|
data/LICENSE.txt
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2011 Crafters Software Studio
|
2
|
+
|
3
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
4
|
+
a copy of this software and associated documentation files (the
|
5
|
+
"Software"), to deal in the Software without restriction, including
|
6
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
7
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
8
|
+
permit persons to whom the Software is furnished to do so, subject to
|
9
|
+
the following conditions:
|
10
|
+
|
11
|
+
The above copyright notice and this permission notice shall be
|
12
|
+
included in all copies or substantial portions of the Software.
|
13
|
+
|
14
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
15
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
16
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
17
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
18
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
19
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
20
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.rdoc
ADDED
@@ -0,0 +1,63 @@
|
|
1
|
+
= cielo
|
2
|
+
|
3
|
+
Integração com a Cielo via WebServices
|
4
|
+
|
5
|
+
== Funcionalidades Implementadas
|
6
|
+
|
7
|
+
* Criaçao de transação
|
8
|
+
* Consulta de stauts de transação
|
9
|
+
* Caputra de transação
|
10
|
+
|
11
|
+
== USO
|
12
|
+
|
13
|
+
gem install cielo
|
14
|
+
|
15
|
+
=== Ambiente de teste (Homologação)
|
16
|
+
|
17
|
+
transaction = Cielo::Trasaction.new
|
18
|
+
transaction.create!(numero: "XXX", valor: "123123", moeda: "BRL", ...) #inicia uma nova transação
|
19
|
+
transaction.verify!("TID OF THE TRANSACTION") #verifica o status de uma transação
|
20
|
+
transaction.catch!("TID OF THE TRANSACTION") #captura a transação
|
21
|
+
|
22
|
+
=== Produção
|
23
|
+
|
24
|
+
É necessáio escrever sua classe production, os atributos de retorno e os numeros devem estar preenchidos
|
25
|
+
|
26
|
+
module Cielo
|
27
|
+
class Production
|
28
|
+
@@numero_afiliacao = "Vem com a afiliação"
|
29
|
+
@@chave_acesso="Deve ser pedido no suporte da cielo"
|
30
|
+
cattr_reader :numero_afiliacao, :chave_acesso
|
31
|
+
BASE_URL = "ecommerce.cbmp.com.br" # URL de produção da cielo
|
32
|
+
WS_PATH = "/servicos/ecommwsec.do" # Destino
|
33
|
+
DOMAIN_URL = "http://localhost:3000" # Seu site, é pra onde a cielo redirecionara após ter feito a transação
|
34
|
+
end
|
35
|
+
end
|
36
|
+
|
37
|
+
O restante do uso é igual homologação :P
|
38
|
+
|
39
|
+
== Avisos
|
40
|
+
|
41
|
+
* O retorno da cielo é convertido em um hash, então, atributos no xml como url-retorno ficam :"url-retorno", cuidado com esses detalhes.
|
42
|
+
* Foi desenvolvido e testado em ruby 1.9.2
|
43
|
+
|
44
|
+
== Contributing to cielo
|
45
|
+
|
46
|
+
* Check out the latest master to make sure the feature hasn't been implemented or the bug hasn't been fixed yet
|
47
|
+
* Check out the issue tracker to make sure someone already hasn't requested it and/or contributed it
|
48
|
+
* Fork the project
|
49
|
+
* Start a feature/bugfix branch
|
50
|
+
* Commit and push until you are happy with your contribution
|
51
|
+
* Make sure to add tests for it. This is important so I don't break it in a future version unintentionally.
|
52
|
+
* Please try not to mess with the Rakefile, version, or history. If you want to have your own version, or is otherwise necessary, that is fine, but please isolate to its own commit so I can cherry-pick around it.
|
53
|
+
|
54
|
+
== Colaboradores
|
55
|
+
|
56
|
+
* Felipe Rodrigues (@felipero)
|
57
|
+
* Rafael Felix (@fellix)
|
58
|
+
|
59
|
+
== Copyright
|
60
|
+
|
61
|
+
Copyright (c) 2011 Crafters Software Studio. See LICENSE.txt for
|
62
|
+
further details.
|
63
|
+
|
data/Rakefile
ADDED
@@ -0,0 +1,57 @@
|
|
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 = "felix.rafael@gmail.com"
|
26
|
+
gem.authors = ["Rafael Felix", "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
|
+
require 'rcov/rcovtask'
|
40
|
+
Rcov::RcovTask.new do |test|
|
41
|
+
test.libs << 'test'
|
42
|
+
test.pattern = 'test/**/test_*.rb'
|
43
|
+
test.verbose = true
|
44
|
+
test.rcov_opts << '--exclude "gems/*"'
|
45
|
+
end
|
46
|
+
|
47
|
+
task :default => :test
|
48
|
+
|
49
|
+
require 'rake/rdoctask'
|
50
|
+
Rake::RDocTask.new do |rdoc|
|
51
|
+
version = File.exist?('VERSION') ? File.read('VERSION') : ""
|
52
|
+
|
53
|
+
rdoc.rdoc_dir = 'rdoc'
|
54
|
+
rdoc.title = "cielo #{version}"
|
55
|
+
rdoc.rdoc_files.include('README*')
|
56
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
57
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
module Cielo
|
2
|
+
class Connection
|
3
|
+
attr_reader :environment
|
4
|
+
def initialize
|
5
|
+
@environment = eval(Cielo.environment.to_s.capitalize)
|
6
|
+
port = 443
|
7
|
+
@http = Net::HTTP.new(@environment::BASE_URL,port)
|
8
|
+
@http.use_ssl = true
|
9
|
+
@http.open_timeout = 10*1000
|
10
|
+
@http.read_timeout = 40*1000
|
11
|
+
end
|
12
|
+
|
13
|
+
def request!(params={})
|
14
|
+
str_params = ""
|
15
|
+
params.each do |key, value|
|
16
|
+
str_params+="&" unless str_params.empty?
|
17
|
+
str_params+="#{key}=#{value}"
|
18
|
+
end
|
19
|
+
@http.request_post(self.environment::WS_PATH, str_params)
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,101 @@
|
|
1
|
+
#encoding: utf-8
|
2
|
+
module Cielo
|
3
|
+
class Transaction
|
4
|
+
def initialize
|
5
|
+
@connection = Cielo::Connection.new
|
6
|
+
end
|
7
|
+
def create!(parameters={})
|
8
|
+
analysis_parameters(parameters)
|
9
|
+
message = xml_builder("requisicao-transacao") do |xml|
|
10
|
+
xml.send("dados-pedido") do
|
11
|
+
[:numero, :valor, :moeda, :"data-hora", :idioma].each do |key|
|
12
|
+
xml.send(key.to_s, parameters[key].to_s)
|
13
|
+
end
|
14
|
+
end
|
15
|
+
xml.send("forma-pagamento") do
|
16
|
+
[:bandeira, :produto, :parcelas].each do |key|
|
17
|
+
xml.send(key.to_s, parameters[key].to_s)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
xml.send("url-retorno", parameters[:"url-retorno"])
|
21
|
+
xml.autorizar parameters[:autorizar].to_s
|
22
|
+
xml.capturar parameters[:capturar].to_s
|
23
|
+
end
|
24
|
+
make_request! message
|
25
|
+
end
|
26
|
+
|
27
|
+
def verify!(cielo_tid)
|
28
|
+
return nil unless cielo_tid
|
29
|
+
message = xml_builder("requisicao-consulta", :before) do |xml|
|
30
|
+
xml.tid "#{cielo_tid}"
|
31
|
+
end
|
32
|
+
|
33
|
+
make_request! message
|
34
|
+
end
|
35
|
+
|
36
|
+
def catch!(cielo_tid)
|
37
|
+
return nil unless cielo_tid
|
38
|
+
message = xml_builder("requisicao-captura", :before) do |xml|
|
39
|
+
xml.tid "#{cielo_tid}"
|
40
|
+
end
|
41
|
+
make_request! message
|
42
|
+
end
|
43
|
+
|
44
|
+
private
|
45
|
+
def analysis_parameters(parameters={})
|
46
|
+
[:numero, :valor, :bandeira, :"url-retorno"].each do |parameter|
|
47
|
+
raise Cielo::MissingArgumentError, "Required parameter #{parameter} not found" unless parameters[parameter]
|
48
|
+
end
|
49
|
+
parameters.merge!(moeda: "986") unless parameters[:moeda]
|
50
|
+
parameters.merge!(:"data-hora" => Time.now.strftime("%Y-%m-%dT%H:%M:%S")) unless parameters[:"data-hora"]
|
51
|
+
parameters.merge!(idioma: "PT") unless parameters[:idioma]
|
52
|
+
parameters.merge!(produto: "1") unless parameters[:produto]
|
53
|
+
parameters.merge!(parcelas: "1") unless parameters[:parcelas]
|
54
|
+
parameters.merge!(autorizar: "2") unless parameters[:autorizar]
|
55
|
+
parameters.merge!(capturar: "true") unless parameters[:capturar]
|
56
|
+
parameters
|
57
|
+
end
|
58
|
+
|
59
|
+
def xml_builder(group_name, target=:after, &block)
|
60
|
+
xml = Builder::XmlMarkup.new
|
61
|
+
xml.instruct! :xml, :version=>"1.0", :encoding=>"ISO-8859-1"
|
62
|
+
xml.send(group_name, id: "#{Time.now.to_i}", versao: "1.1.0") do
|
63
|
+
block.call(xml) if target == :before
|
64
|
+
xml.send("dados-ec") do
|
65
|
+
xml.numero @connection.environment.numero_afiliacao
|
66
|
+
xml.chave @connection.environment.chave_acesso
|
67
|
+
end
|
68
|
+
block.call(xml) if target == :after
|
69
|
+
end
|
70
|
+
xml
|
71
|
+
end
|
72
|
+
|
73
|
+
def make_request!(message)
|
74
|
+
params = { mensagem: message.target! }
|
75
|
+
|
76
|
+
result = @connection.request! params
|
77
|
+
parse_response(result)
|
78
|
+
end
|
79
|
+
|
80
|
+
def parse_response(response)
|
81
|
+
case response
|
82
|
+
when Net::HTTPSuccess
|
83
|
+
document = REXML::Document.new(response.body)
|
84
|
+
parse_elements(document.elements)
|
85
|
+
else
|
86
|
+
{:erro => { :codigo => "000", :mensagem => "Impossível contactar o servidor"}}
|
87
|
+
end
|
88
|
+
end
|
89
|
+
def parse_elements(elements)
|
90
|
+
map={}
|
91
|
+
elements.each do |element|
|
92
|
+
element_map = {}
|
93
|
+
element_map = element.text if element.elements.empty? && element.attributes.empty?
|
94
|
+
element_map.merge!("value" => element.text) if element.elements.empty? && !element.attributes.empty?
|
95
|
+
element_map.merge!(parse_elements(element.elements)) unless element.elements.empty?
|
96
|
+
map.merge!(element.name => element_map)
|
97
|
+
end
|
98
|
+
map.symbolize_keys
|
99
|
+
end
|
100
|
+
end
|
101
|
+
end
|
data/lib/cielo.rb
ADDED
@@ -0,0 +1,38 @@
|
|
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 "rexml/document"
|
7
|
+
require "builder"
|
8
|
+
[:connection, :transaction].each { |lib| require "cielo/#{lib}" }
|
9
|
+
|
10
|
+
module Cielo
|
11
|
+
|
12
|
+
# Write your own production class
|
13
|
+
#class Production
|
14
|
+
# @@numero_afiliacao = "suporteweb@cielo.com.br"
|
15
|
+
# @@chave_acesso="suporteweb@cielo.com.br"
|
16
|
+
# cattr_reader :numero_afiliacao, :chave_acesso
|
17
|
+
# BASE_URL = "ecommerce.cbmp.com.br"
|
18
|
+
# WS_PATH = "/servicos/ecommwsec.do"
|
19
|
+
# DOMAIN_URL = "Your Web Site here"
|
20
|
+
#end
|
21
|
+
|
22
|
+
class Test
|
23
|
+
@@numero_afiliacao = "1001734898"
|
24
|
+
@@chave_acesso="e84827130b9837473681c2787007da5914d6359947015a5cdb2b8843db0fa832"
|
25
|
+
cattr_reader :numero_afiliacao, :chave_acesso
|
26
|
+
BASE_URL = "qasecommerce.cielo.com.br"
|
27
|
+
WS_PATH = "/servicos/ecommwsec.do"
|
28
|
+
DOMAIN_URL = "http://localhost:3000"
|
29
|
+
end
|
30
|
+
|
31
|
+
@@environment = :test
|
32
|
+
mattr_accessor :environment
|
33
|
+
|
34
|
+
def self.setup
|
35
|
+
yield self
|
36
|
+
end
|
37
|
+
class MissingArgumentError < StandardError; end
|
38
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
describe Cielo::Connection do
|
4
|
+
before do
|
5
|
+
@connection = Cielo::Connection.new
|
6
|
+
end
|
7
|
+
it "should estabilish connection when was created" do
|
8
|
+
@connection.environment.should_not be_nil
|
9
|
+
end
|
10
|
+
describe "making a request" do
|
11
|
+
it "should make a request" do
|
12
|
+
response = @connection.request! data: "Anything"
|
13
|
+
|
14
|
+
response.body.should_not be_nil
|
15
|
+
response.should be_kind_of Net::HTTPSuccess
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,102 @@
|
|
1
|
+
#encoding: utf-8
|
2
|
+
require 'spec_helper'
|
3
|
+
|
4
|
+
describe Cielo::Transaction do
|
5
|
+
before do
|
6
|
+
@transaction = Cielo::Transaction.new
|
7
|
+
end
|
8
|
+
|
9
|
+
describe "create a transaction" do
|
10
|
+
before do
|
11
|
+
@params = {:numero => "1", :valor => "100", :bandeira => "visa", :"url-retorno" => "http://some.thing.com"}
|
12
|
+
end
|
13
|
+
[:numero, :valor, :bandeira, :"url-retorno"].each do |parameter|
|
14
|
+
it "raises an error when #{parameter} isn't informed" do
|
15
|
+
lambda { @transaction.create! @params.except!(parameter) }.should raise_error(Cielo::MissingArgumentError)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
it "delivers an successful message" do
|
19
|
+
response = @transaction.create! @params
|
20
|
+
|
21
|
+
response[:transacao][:tid].should_not be_nil
|
22
|
+
response[:transacao][:"url-autenticacao"].should_not be_nil
|
23
|
+
|
24
|
+
response = @transaction.catch!("1001734898056B3C1001")
|
25
|
+
|
26
|
+
end
|
27
|
+
|
28
|
+
it "delivers a response with error message when status isn't 200" do
|
29
|
+
FakeWeb.register_uri(:any, "https://qasecommerce.cielo.com.br/servicos/ecommwsec.do",
|
30
|
+
:body => "Nothing to be found 'round here",
|
31
|
+
:status => ["404", "Not Found"])
|
32
|
+
response = @transaction.create! @params
|
33
|
+
|
34
|
+
response[:erro].should_not be_nil
|
35
|
+
response[:erro][:codigo].should be_eql("000")
|
36
|
+
end
|
37
|
+
|
38
|
+
it "delivers a response with error message when the server send" do
|
39
|
+
FakeWeb.register_uri(:any, "https://qasecommerce.cielo.com.br/servicos/ecommwsec.do",
|
40
|
+
: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")
|
41
|
+
response = @transaction.create! @params
|
42
|
+
|
43
|
+
response[:erro].should_not be_nil
|
44
|
+
response[:erro][:codigo].should be_eql("001")
|
45
|
+
end
|
46
|
+
|
47
|
+
end
|
48
|
+
|
49
|
+
describe "Verify a transaction status" do
|
50
|
+
it "returns null when no tid is informed" do
|
51
|
+
@transaction.verify!(nil).should be_nil
|
52
|
+
end
|
53
|
+
it "returns a successfull message" do
|
54
|
+
FakeWeb.register_uri(:any, "https://qasecommerce.cielo.com.br/servicos/ecommwsec.do",
|
55
|
+
: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")
|
56
|
+
|
57
|
+
response = @transaction.verify!("1001734898056B3C1001")
|
58
|
+
|
59
|
+
response[:transacao][:tid].should_not be_nil
|
60
|
+
response[:transacao][:status].should_not be_nil
|
61
|
+
end
|
62
|
+
end
|
63
|
+
|
64
|
+
describe "Catch a transaction" do
|
65
|
+
it "returns null when no tid is informed" do
|
66
|
+
@transaction.catch!(nil).should be_nil
|
67
|
+
end
|
68
|
+
it "returns a successfull message" do
|
69
|
+
FakeWeb.register_uri(:any, "https://qasecommerce.cielo.com.br/servicos/ecommwsec.do",
|
70
|
+
: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")
|
71
|
+
|
72
|
+
response = @transaction.catch!("1001734898056B3C1001")
|
73
|
+
|
74
|
+
response[:transacao][:tid].should_not be_nil
|
75
|
+
response[:transacao][:status].should_not be_nil
|
76
|
+
end
|
77
|
+
end
|
78
|
+
|
79
|
+
describe "Using a production environment" do
|
80
|
+
before do
|
81
|
+
module Cielo
|
82
|
+
class Production
|
83
|
+
@@numero_afiliacao = "1001734891"
|
84
|
+
@@chave_acesso="e84827130b9837473681c2787007da5914d6359947015a5cdb2b8843db0fa832"
|
85
|
+
cattr_reader :numero_afiliacao, :chave_acesso
|
86
|
+
BASE_URL = "ecommerce.cbmp.com.br"
|
87
|
+
WS_PATH = "/servicos/ecommwsec.do"
|
88
|
+
DOMAIN_URL = "http://localhost:3000"
|
89
|
+
end
|
90
|
+
end
|
91
|
+
|
92
|
+
Cielo.environment = :production
|
93
|
+
end
|
94
|
+
|
95
|
+
it "must use the production environment" do
|
96
|
+
con = Cielo::Connection.new
|
97
|
+
con.environment.numero_afiliacao.should be_eql "1001734891"
|
98
|
+
end
|
99
|
+
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
data/spec/spec_helper.rb
ADDED
metadata
ADDED
@@ -0,0 +1,171 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: cielo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: 6
|
5
|
+
version: 0.1.0.beta1
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Rafael Felix
|
9
|
+
- Felipe Rodrigues
|
10
|
+
autorequire:
|
11
|
+
bindir: bin
|
12
|
+
cert_chain: []
|
13
|
+
|
14
|
+
date: 2011-06-15 00:00:00 -03:00
|
15
|
+
default_executable:
|
16
|
+
dependencies:
|
17
|
+
- !ruby/object:Gem::Dependency
|
18
|
+
name: activesupport
|
19
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
20
|
+
none: false
|
21
|
+
requirements:
|
22
|
+
- - ">="
|
23
|
+
- !ruby/object:Gem::Version
|
24
|
+
version: 3.0.7
|
25
|
+
type: :runtime
|
26
|
+
prerelease: false
|
27
|
+
version_requirements: *id001
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: i18n
|
30
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
31
|
+
none: false
|
32
|
+
requirements:
|
33
|
+
- - ">="
|
34
|
+
- !ruby/object:Gem::Version
|
35
|
+
version: "0"
|
36
|
+
type: :runtime
|
37
|
+
prerelease: false
|
38
|
+
version_requirements: *id002
|
39
|
+
- !ruby/object:Gem::Dependency
|
40
|
+
name: builder
|
41
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
42
|
+
none: false
|
43
|
+
requirements:
|
44
|
+
- - ~>
|
45
|
+
- !ruby/object:Gem::Version
|
46
|
+
version: "2.0"
|
47
|
+
type: :runtime
|
48
|
+
prerelease: false
|
49
|
+
version_requirements: *id003
|
50
|
+
- !ruby/object:Gem::Dependency
|
51
|
+
name: shoulda
|
52
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
53
|
+
none: false
|
54
|
+
requirements:
|
55
|
+
- - ">="
|
56
|
+
- !ruby/object:Gem::Version
|
57
|
+
version: "0"
|
58
|
+
type: :development
|
59
|
+
prerelease: false
|
60
|
+
version_requirements: *id004
|
61
|
+
- !ruby/object:Gem::Dependency
|
62
|
+
name: bundler
|
63
|
+
requirement: &id005 !ruby/object:Gem::Requirement
|
64
|
+
none: false
|
65
|
+
requirements:
|
66
|
+
- - ~>
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: 1.0.0
|
69
|
+
type: :development
|
70
|
+
prerelease: false
|
71
|
+
version_requirements: *id005
|
72
|
+
- !ruby/object:Gem::Dependency
|
73
|
+
name: jeweler
|
74
|
+
requirement: &id006 !ruby/object:Gem::Requirement
|
75
|
+
none: false
|
76
|
+
requirements:
|
77
|
+
- - ~>
|
78
|
+
- !ruby/object:Gem::Version
|
79
|
+
version: 1.6.0
|
80
|
+
type: :development
|
81
|
+
prerelease: false
|
82
|
+
version_requirements: *id006
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: rcov
|
85
|
+
requirement: &id007 !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
87
|
+
requirements:
|
88
|
+
- - ">="
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: "0"
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: *id007
|
94
|
+
- !ruby/object:Gem::Dependency
|
95
|
+
name: rspec
|
96
|
+
requirement: &id008 !ruby/object:Gem::Requirement
|
97
|
+
none: false
|
98
|
+
requirements:
|
99
|
+
- - ">="
|
100
|
+
- !ruby/object:Gem::Version
|
101
|
+
version: "0"
|
102
|
+
type: :development
|
103
|
+
prerelease: false
|
104
|
+
version_requirements: *id008
|
105
|
+
- !ruby/object:Gem::Dependency
|
106
|
+
name: fakeweb
|
107
|
+
requirement: &id009 !ruby/object:Gem::Requirement
|
108
|
+
none: false
|
109
|
+
requirements:
|
110
|
+
- - ">="
|
111
|
+
- !ruby/object:Gem::Version
|
112
|
+
version: "0"
|
113
|
+
type: :development
|
114
|
+
prerelease: false
|
115
|
+
version_requirements: *id009
|
116
|
+
description: "Integra\xC3\xA7\xC3\xA3o com a cielo"
|
117
|
+
email: felix.rafael@gmail.com
|
118
|
+
executables: []
|
119
|
+
|
120
|
+
extensions: []
|
121
|
+
|
122
|
+
extra_rdoc_files:
|
123
|
+
- LICENSE.txt
|
124
|
+
- README.rdoc
|
125
|
+
files:
|
126
|
+
- .document
|
127
|
+
- Gemfile
|
128
|
+
- Gemfile.lock
|
129
|
+
- LICENSE.txt
|
130
|
+
- README.rdoc
|
131
|
+
- Rakefile
|
132
|
+
- lib/cielo.rb
|
133
|
+
- lib/cielo/connection.rb
|
134
|
+
- lib/cielo/transaction.rb
|
135
|
+
- lib/cielo/version.rb
|
136
|
+
- spec/cielo/connection_spec.rb
|
137
|
+
- spec/cielo/transaction_spec.rb
|
138
|
+
- spec/spec_helper.rb
|
139
|
+
has_rdoc: true
|
140
|
+
homepage: http://github.com/crafters/cielo
|
141
|
+
licenses:
|
142
|
+
- MIT
|
143
|
+
post_install_message:
|
144
|
+
rdoc_options: []
|
145
|
+
|
146
|
+
require_paths:
|
147
|
+
- lib
|
148
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
149
|
+
none: false
|
150
|
+
requirements:
|
151
|
+
- - ">="
|
152
|
+
- !ruby/object:Gem::Version
|
153
|
+
hash: 3648351556188948105
|
154
|
+
segments:
|
155
|
+
- 0
|
156
|
+
version: "0"
|
157
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
158
|
+
none: false
|
159
|
+
requirements:
|
160
|
+
- - ">"
|
161
|
+
- !ruby/object:Gem::Version
|
162
|
+
version: 1.3.1
|
163
|
+
requirements: []
|
164
|
+
|
165
|
+
rubyforge_project:
|
166
|
+
rubygems_version: 1.6.2
|
167
|
+
signing_key:
|
168
|
+
specification_version: 3
|
169
|
+
summary: "Integra\xC3\xA7\xC3\xA3o com a cielo"
|
170
|
+
test_files: []
|
171
|
+
|