cielox 0.0.1a → 0.0.2a
Sign up to get free protection for your applications and to get access to all the features.
- data/lib/cielo/authorization_request.rb +1 -16
- data/lib/cielo/cancelation.rb +11 -0
- data/lib/cielo/cancelation_request.rb +12 -0
- data/lib/cielo/capture_request.rb +1 -16
- data/lib/cielo/card/validity.rb +21 -0
- data/lib/cielo/card.rb +2 -0
- data/lib/cielo/error.rb +9 -0
- data/lib/cielo/http.rb +21 -0
- data/lib/cielo/info_request.rb +12 -0
- data/lib/cielo/transaction.rb +1 -0
- data/lib/cielo/transaction_request.rb +1 -18
- data/lib/cielo/version.rb +1 -1
- data/lib/cielo.rb +7 -1
- data/spec/cielo/authorization_request_spec.rb +4 -4
- data/spec/cielo/cancelation_request_spec.rb +49 -0
- data/spec/cielo/capture_request_spec.rb +3 -3
- data/spec/cielo/card_spec.rb +1 -1
- data/spec/cielo/info_request_spec.rb +58 -0
- data/spec/cielo/transaction_request_spec.rb +8 -5
- data/spec/cielo/validity_spec.rb +25 -4
- data/spec/fixtures/cancelation_request.xml +8 -0
- data/spec/fixtures/info_request/error_request.xml +8 -0
- data/spec/fixtures/info_request/error_response.xml +5 -0
- data/spec/fixtures/info_request/request.xml +8 -0
- data/spec/fixtures/info_request/response.xml +18 -0
- data/spec/fixtures/transaction_1.xml +1 -1
- data/spec/fixtures/transaction_2.xml +1 -1
- data/spec/fixtures/transaction_3.xml +12 -0
- data/spec/fixtures/transaction_request/request.xml +29 -0
- data/spec/fixtures/transaction_request/response.xml +18 -0
- metadata +36 -11
- data/lib/cielo/validity.rb +0 -19
@@ -1,27 +1,12 @@
|
|
1
1
|
module Cielo
|
2
2
|
class AuthorizationRequest
|
3
3
|
include HappyMapper
|
4
|
+
include HTTP
|
4
5
|
|
5
6
|
tag "requisicao-autorizacao-tid"
|
6
7
|
attribute :id, Integer, :on_save => proc { |value| value.to_s }
|
7
8
|
attribute :version, String, :tag => "versao", :on_save => proc { |value| value ? value : "1.1.1" }
|
8
9
|
element :tid, String
|
9
10
|
has_one :shop, Shop
|
10
|
-
|
11
|
-
def authorize
|
12
|
-
http = Net::HTTP.new(Cielo.configuration.host, Cielo.configuration.port)
|
13
|
-
http.use_ssl = true
|
14
|
-
http.open_timeout = 10 * 1000
|
15
|
-
http.read_timeout = 40 * 1000
|
16
|
-
Cielo.logger.info(http.inspect)
|
17
|
-
|
18
|
-
post_body = "mensagem=#{to_xml}"
|
19
|
-
Cielo.logger.info(post_body)
|
20
|
-
|
21
|
-
response = http.request_post(Cielo.configuration.path, post_body)
|
22
|
-
Cielo.logger.info(response.body)
|
23
|
-
|
24
|
-
Transaction.parse(response.body, :single => true)
|
25
|
-
end
|
26
11
|
end
|
27
12
|
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
module Cielo
|
2
|
+
class Cancelation
|
3
|
+
include HappyMapper
|
4
|
+
|
5
|
+
tag "cancelamento"
|
6
|
+
element :code, Integer, :tag => "codigo"
|
7
|
+
element :message, String, :tag => "mensagem"
|
8
|
+
element :time, Time, :tag => "data-hora"
|
9
|
+
element :total, Integer, :tag => "valor"
|
10
|
+
end
|
11
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Cielo
|
2
|
+
class CancelationRequest
|
3
|
+
include HappyMapper
|
4
|
+
include HTTP
|
5
|
+
|
6
|
+
tag "requisicao-cancelamento"
|
7
|
+
attribute :id, Integer, :on_save => proc { |value| value.to_s }
|
8
|
+
attribute :version, String, :tag => "versao", :on_save => proc { |value| value ? value : "1.1.1" }
|
9
|
+
element :tid, String
|
10
|
+
has_one :shop, Shop
|
11
|
+
end
|
12
|
+
end
|
@@ -1,27 +1,12 @@
|
|
1
1
|
module Cielo
|
2
2
|
class CaptureRequest
|
3
3
|
include HappyMapper
|
4
|
+
include HTTP
|
4
5
|
|
5
6
|
tag "requisicao-captura"
|
6
7
|
attribute :id, Integer, :on_save => proc { |value| value.to_s }
|
7
8
|
attribute :version, String, :tag => "versao", :on_save => proc { |value| value ? value : "1.1.1" }
|
8
9
|
element :tid, String
|
9
10
|
has_one :shop, Shop
|
10
|
-
|
11
|
-
def capture
|
12
|
-
http = Net::HTTP.new(Cielo.configuration.host, Cielo.configuration.port)
|
13
|
-
http.use_ssl = true
|
14
|
-
http.open_timeout = 10 * 1000
|
15
|
-
http.read_timeout = 40 * 1000
|
16
|
-
Cielo.logger.info(http.inspect)
|
17
|
-
|
18
|
-
post_body = "mensagem=#{to_xml}"
|
19
|
-
Cielo.logger.info(post_body)
|
20
|
-
|
21
|
-
response = http.request_post(Cielo.configuration.path, post_body)
|
22
|
-
Cielo.logger.info(response.body)
|
23
|
-
|
24
|
-
Transaction.parse(response.body, :single => true)
|
25
|
-
end
|
26
11
|
end
|
27
12
|
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
module Cielo
|
2
|
+
class Card
|
3
|
+
class Validity
|
4
|
+
class InvalidDate < StandardError; end
|
5
|
+
|
6
|
+
def initialize(year, month)
|
7
|
+
@year = year.to_i
|
8
|
+
@month = month.to_i
|
9
|
+
|
10
|
+
now = Time.now
|
11
|
+
if @year < now.year || (@year == now.year && @month < now.month)
|
12
|
+
raise InvalidDate, "#{@month}/#{@year} is not valid"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_s
|
17
|
+
[@year, "%02d" % @month].join
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
data/lib/cielo/card.rb
CHANGED
data/lib/cielo/error.rb
ADDED
data/lib/cielo/http.rb
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
require "net/http"
|
2
|
+
|
3
|
+
module Cielo
|
4
|
+
module HTTP
|
5
|
+
def request
|
6
|
+
http = Net::HTTP.new(Cielo.configuration.host, Cielo.configuration.port)
|
7
|
+
http.use_ssl = true
|
8
|
+
http.open_timeout = 10 * 1000
|
9
|
+
http.read_timeout = 40 * 1000
|
10
|
+
Cielo.logger.info(http.inspect)
|
11
|
+
|
12
|
+
post_body = "mensagem=#{to_xml}"
|
13
|
+
Cielo.logger.info(post_body)
|
14
|
+
|
15
|
+
response = http.request_post(Cielo.configuration.path, post_body)
|
16
|
+
Cielo.logger.info(response.body)
|
17
|
+
|
18
|
+
Transaction.parse(response.body, :single => true) || Error.parse(response.body, :single => true)
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,12 @@
|
|
1
|
+
module Cielo
|
2
|
+
class InfoRequest
|
3
|
+
include HappyMapper
|
4
|
+
include HTTP
|
5
|
+
|
6
|
+
tag "requisicao-consulta"
|
7
|
+
attribute :id, Integer, :on_save => proc { |value| value.to_s }
|
8
|
+
attribute :version, String, :tag => "versao", :on_save => proc { |value| value ? value : "1.1.1" }
|
9
|
+
element :tid, String
|
10
|
+
has_one :shop, Shop
|
11
|
+
end
|
12
|
+
end
|
data/lib/cielo/transaction.rb
CHANGED
@@ -1,8 +1,7 @@
|
|
1
|
-
require "net/http"
|
2
|
-
|
3
1
|
module Cielo
|
4
2
|
class TransactionRequest
|
5
3
|
include HappyMapper
|
4
|
+
include HTTP
|
6
5
|
|
7
6
|
tag "requisicao-transacao"
|
8
7
|
attribute :id, Integer, :on_save => proc { |value| value.to_s }
|
@@ -14,21 +13,5 @@ module Cielo
|
|
14
13
|
element :return_url, String, :tag => "url-retorno"
|
15
14
|
element :authorize, Integer, :tag => "autorizar"
|
16
15
|
element :capture, Boolean, :tag => "capturar", :on_save => proc { |value| value.to_s }
|
17
|
-
|
18
|
-
def create
|
19
|
-
http = Net::HTTP.new(Cielo.configuration.host, Cielo.configuration.port)
|
20
|
-
http.use_ssl = true
|
21
|
-
http.open_timeout = 10 * 1000
|
22
|
-
http.read_timeout = 40 * 1000
|
23
|
-
Cielo.logger.info(http.inspect)
|
24
|
-
|
25
|
-
post_body = "mensagem=#{to_xml}"
|
26
|
-
Cielo.logger.info(post_body)
|
27
|
-
|
28
|
-
response = http.request_post(Cielo.configuration.path, post_body)
|
29
|
-
Cielo.logger.info(response.body)
|
30
|
-
|
31
|
-
Transaction.parse(response.body, :single => true)
|
32
|
-
end
|
33
16
|
end
|
34
17
|
end
|
data/lib/cielo/version.rb
CHANGED
data/lib/cielo.rb
CHANGED
@@ -3,11 +3,12 @@ require "happymapper"
|
|
3
3
|
|
4
4
|
module Cielo
|
5
5
|
autoload :Configuration, "cielo/configuration"
|
6
|
+
autoload :HTTP, "cielo/http"
|
7
|
+
autoload :Error, "cielo/error"
|
6
8
|
|
7
9
|
autoload :Shop, "cielo/shop"
|
8
10
|
autoload :Order, "cielo/order"
|
9
11
|
autoload :Payment, "cielo/payment"
|
10
|
-
autoload :Validity, "cielo/validity"
|
11
12
|
autoload :Card, "cielo/card"
|
12
13
|
|
13
14
|
autoload :TransactionRequest, "cielo/transaction_request"
|
@@ -19,6 +20,11 @@ module Cielo
|
|
19
20
|
autoload :CaptureRequest, "cielo/capture_request"
|
20
21
|
autoload :Capture, "cielo/capture"
|
21
22
|
|
23
|
+
autoload :CancelationRequest, "cielo/cancelation_request"
|
24
|
+
autoload :Cancelation, "cielo/cancelation"
|
25
|
+
|
26
|
+
autoload :InfoRequest, "cielo/info_request"
|
27
|
+
|
22
28
|
class << self
|
23
29
|
def configuration
|
24
30
|
@configuration ||= Configuration.new
|
@@ -25,7 +25,7 @@ describe Cielo::AuthorizationRequest do
|
|
25
25
|
it "#authorize" do
|
26
26
|
stub_request(:post, "https://qasecommerce.cielo.com.br/servicos/ecommwsec.do").
|
27
27
|
with(
|
28
|
-
:body => "mensagem=<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<requisicao-autorizacao-tid id=\"1\" versao=\"1.1.1\">\n <tid>100699306904CC7E1001</tid>\n <dados-ec>\n <numero>1006993069</numero>\n <chave>25fbb99741c739dd84d7b06ec78c9bac718838630f30b112d033ce2e621b34f3</chave>\n </dados-ec>\n</requisicao-autorizacao-tid>\n"
|
28
|
+
:body => "mensagem=<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<requisicao-autorizacao-tid id=\"1\" versao=\"1.1.1\">\n <tid>100699306904CC7E1001</tid>\n <dados-ec>\n <numero>1006993069</numero>\n <chave>25fbb99741c739dd84d7b06ec78c9bac718838630f30b112d033ce2e621b34f3</chave>\n </dados-ec>\n</requisicao-autorizacao-tid>\n"
|
29
29
|
).
|
30
30
|
to_return(
|
31
31
|
:status => 200,
|
@@ -36,11 +36,11 @@ describe Cielo::AuthorizationRequest do
|
|
36
36
|
subject.shop = shop
|
37
37
|
subject.id = 1
|
38
38
|
subject.tid = "100699306904CC7E1001"
|
39
|
-
transaction = subject.
|
39
|
+
transaction = subject.request
|
40
40
|
|
41
|
-
transaction.authorization.code.should ==
|
41
|
+
transaction.authorization.code.should == 6
|
42
42
|
transaction.authorization.message.should == "Transação autorizada"
|
43
|
-
transaction.authorization.time.should == Time.
|
43
|
+
transaction.authorization.time.should == Time.parse("2010-07-14 13:56:12")
|
44
44
|
transaction.authorization.total.should == 100
|
45
45
|
transaction.authorization.lr.should == 1
|
46
46
|
transaction.authorization.arp.should == "a1b2c3"
|
@@ -0,0 +1,49 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
require "spec_helper"
|
3
|
+
|
4
|
+
describe Cielo::CancelationRequest do
|
5
|
+
subject { described_class.new }
|
6
|
+
|
7
|
+
let(:shop) do
|
8
|
+
Cielo::Shop.new.tap do |s|
|
9
|
+
s.number = 1006993069
|
10
|
+
s.key = "25fbb99741c739dd84d7b06ec78c9bac718838630f30b112d033ce2e621b34f3"
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
let(:request_xml) { File.read(File.expand_path("../../fixtures/cancelation_request.xml", __FILE__)) }
|
15
|
+
|
16
|
+
it "#to_xml" do
|
17
|
+
subject.shop = shop
|
18
|
+
subject.id = 1
|
19
|
+
subject.tid = "100699306904CC7E1001"
|
20
|
+
xml = subject.to_xml
|
21
|
+
|
22
|
+
xml.should == request_xml
|
23
|
+
end
|
24
|
+
|
25
|
+
it "#cancel" do
|
26
|
+
stub_request(:post, "https://qasecommerce.cielo.com.br/servicos/ecommwsec.do").
|
27
|
+
with(
|
28
|
+
:body => "mensagem=#{request_xml}"
|
29
|
+
).
|
30
|
+
to_return(
|
31
|
+
:status => 200,
|
32
|
+
:body => File.read(File.expand_path("../../fixtures/transaction_3.xml", __FILE__)),
|
33
|
+
:headers => { "Content-Type" => "text/xml" }
|
34
|
+
)
|
35
|
+
|
36
|
+
subject.shop = shop
|
37
|
+
subject.id = 1
|
38
|
+
subject.tid = "100699306904CC7E1001"
|
39
|
+
transaction = subject.request
|
40
|
+
|
41
|
+
transaction.tid.should == "100699306904CC7E1001"
|
42
|
+
transaction.pan.should == "IqVz7P9zaIgTYdU41HaW/OB/d7Idwttqwb2vaTt8MT0="
|
43
|
+
transaction.status.should == 9
|
44
|
+
transaction.cancelation.code.should == 9
|
45
|
+
transaction.cancelation.message.should == "Transacao cancelada com sucesso"
|
46
|
+
transaction.cancelation.time.should == Time.parse("2012-05-14 09:52:14")
|
47
|
+
transaction.cancelation.total.should == 100
|
48
|
+
end
|
49
|
+
end
|
@@ -36,14 +36,14 @@ describe Cielo::CaptureRequest do
|
|
36
36
|
subject.shop = shop
|
37
37
|
subject.id = 1
|
38
38
|
subject.tid = "100699306904CC7E1001"
|
39
|
-
transaction = subject.
|
39
|
+
transaction = subject.request
|
40
40
|
|
41
41
|
transaction.tid.should == "100699306904CC7E1001"
|
42
42
|
transaction.pan.should == "IqVz7P9zaIgTYdU41HaW/OB/d7Idwttqwb2vaTt8MT0="
|
43
43
|
transaction.status.should == 6
|
44
|
-
transaction.capture.code.should ==
|
44
|
+
transaction.capture.code.should == 6
|
45
45
|
transaction.capture.message.should == "Transação capturada"
|
46
|
-
transaction.capture.time.should == Time.
|
46
|
+
transaction.capture.time.should == Time.parse("2010-07-14 13:56:12")
|
47
47
|
transaction.capture.total.should == 100
|
48
48
|
end
|
49
49
|
end
|
data/spec/cielo/card_spec.rb
CHANGED
@@ -5,7 +5,7 @@ describe Cielo::Card do
|
|
5
5
|
|
6
6
|
it "#to_xml" do
|
7
7
|
subject.number = "4012001037141112"
|
8
|
-
subject.validity = Cielo::Validity.new(2015, 11)
|
8
|
+
subject.validity = Cielo::Card::Validity.new(2015, 11)
|
9
9
|
subject.indicator = 1
|
10
10
|
subject.security_code = 371
|
11
11
|
subject.owner = "FULANO DE TAL"
|
@@ -0,0 +1,58 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe Cielo::InfoRequest do
|
4
|
+
let(:shop) do
|
5
|
+
Cielo::Shop.new.tap do |s|
|
6
|
+
s.number = 1006993069
|
7
|
+
s.key = "25fbb99741c739dd84d7b06ec78c9bac718838630f30b112d033ce2e621b34f3"
|
8
|
+
end
|
9
|
+
end
|
10
|
+
|
11
|
+
subject { described_class.new }
|
12
|
+
|
13
|
+
it "returns transaction information of a given tid" do
|
14
|
+
request = File.read(File.expand_path("../../fixtures/info_request/request.xml", __FILE__))
|
15
|
+
response = File.read(File.expand_path("../../fixtures/info_request/response.xml", __FILE__))
|
16
|
+
|
17
|
+
stub_request(:post, "https://qasecommerce.cielo.com.br/servicos/ecommwsec.do").
|
18
|
+
with(
|
19
|
+
:body => "mensagem=#{request}"
|
20
|
+
).
|
21
|
+
to_return(
|
22
|
+
:status => 200,
|
23
|
+
:body => response,
|
24
|
+
:headers => { "Content-Type" => "text/xml" }
|
25
|
+
)
|
26
|
+
|
27
|
+
subject.id = 1
|
28
|
+
subject.tid = "100699306904CC7E1001"
|
29
|
+
subject.shop = shop
|
30
|
+
|
31
|
+
transaction = subject.request
|
32
|
+
transaction.tid.should == "100699306904CC7E1001"
|
33
|
+
end
|
34
|
+
|
35
|
+
it "returns an error with wrong tid" do
|
36
|
+
request = File.read(File.expand_path("../../fixtures/info_request/error_request.xml", __FILE__))
|
37
|
+
response = File.read(File.expand_path("../../fixtures/info_request/error_response.xml", __FILE__))
|
38
|
+
|
39
|
+
stub_request(:post, "https://qasecommerce.cielo.com.br/servicos/ecommwsec.do").
|
40
|
+
with(
|
41
|
+
:body => "mensagem=#{request}"
|
42
|
+
).
|
43
|
+
to_return(
|
44
|
+
:status => 200,
|
45
|
+
:body => response,
|
46
|
+
:headers => { "Content-Type" => "text/xml" }
|
47
|
+
)
|
48
|
+
|
49
|
+
subject.id = 1
|
50
|
+
subject.tid = "103760993800001E1001"
|
51
|
+
subject.shop = shop
|
52
|
+
|
53
|
+
error = subject.request
|
54
|
+
error.should be_instance_of(Cielo::Error)
|
55
|
+
error.code.should == 3
|
56
|
+
error.message.should_not be_empty
|
57
|
+
end
|
58
|
+
end
|
@@ -60,14 +60,17 @@ describe Cielo::TransactionRequest do
|
|
60
60
|
end
|
61
61
|
|
62
62
|
it "#create" do
|
63
|
+
request = File.read(File.expand_path("../../fixtures/transaction_request/request.xml", __FILE__))
|
64
|
+
response = File.read(File.expand_path("../../fixtures/transaction_request/response.xml", __FILE__))
|
65
|
+
|
63
66
|
stub_request(:post, "https://qasecommerce.cielo.com.br/servicos/ecommwsec.do").
|
64
67
|
with(
|
65
|
-
:body => "mensagem
|
68
|
+
:body => "mensagem=#{request}"
|
66
69
|
).
|
67
70
|
to_return(
|
68
71
|
:status => 200,
|
69
|
-
:body =>
|
70
|
-
:headers => {}
|
72
|
+
:body => response,
|
73
|
+
:headers => { "Content-Type" => "text/xml" }
|
71
74
|
)
|
72
75
|
|
73
76
|
subject.id = "1"
|
@@ -78,9 +81,9 @@ describe Cielo::TransactionRequest do
|
|
78
81
|
subject.return_url = "http://minha.loja.com/pedido/285813768"
|
79
82
|
subject.authorize = 2
|
80
83
|
subject.capture = false
|
81
|
-
transaction = subject.
|
84
|
+
transaction = subject.request
|
82
85
|
|
83
|
-
transaction.tid.should
|
86
|
+
transaction.tid.should have(20).chars
|
84
87
|
transaction.pan.should == "IqVz7P9zaIgTYdU41HaW/OB/d7Idwttqwb2vaTt8MT0="
|
85
88
|
transaction.status.should == 0
|
86
89
|
transaction.authentication_url = "https://qasecommerce.cielo.com.br/web/index.cbmp?id=4c0476919b9ea10d11f761bd3158bde0"
|
data/spec/cielo/validity_spec.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
require "spec_helper"
|
2
2
|
|
3
|
-
describe Cielo::Validity do
|
3
|
+
describe Cielo::Card::Validity do
|
4
4
|
before do
|
5
5
|
Timecop.freeze(Time.parse("2012-05-14 09:23:00"))
|
6
6
|
end
|
@@ -17,8 +17,29 @@ describe Cielo::Validity do
|
|
17
17
|
expect { described_class.new(Time.now.year, Time.now.month - 1) }.should raise_error(described_class::InvalidDate)
|
18
18
|
end
|
19
19
|
|
20
|
-
it "
|
21
|
-
|
22
|
-
|
20
|
+
it "raises an exception if both year and month are not valid" do
|
21
|
+
expect { described_class.new(Time.now.year - 1, Time.now.month - 1) }.should raise_error(described_class::InvalidDate)
|
22
|
+
end
|
23
|
+
|
24
|
+
describe "#to_s" do
|
25
|
+
it "works with current year and month" do
|
26
|
+
validity = described_class.new(Time.now.year, Time.now.month)
|
27
|
+
validity.to_s.should == "201205"
|
28
|
+
end
|
29
|
+
|
30
|
+
it "works with next year but current month" do
|
31
|
+
validity = described_class.new(Time.now.year + 1, Time.now.month)
|
32
|
+
validity.to_s.should == "201305"
|
33
|
+
end
|
34
|
+
|
35
|
+
it "works with next year and next month" do
|
36
|
+
validity = described_class.new(Time.now.year + 1, Time.now.month + 1)
|
37
|
+
validity.to_s.should == "201306"
|
38
|
+
end
|
39
|
+
|
40
|
+
it "works with two-digits month" do
|
41
|
+
validity = described_class.new(Time.now.year + 1, 12)
|
42
|
+
validity.to_s.should == "201312"
|
43
|
+
end
|
23
44
|
end
|
24
45
|
end
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<requisicao-cancelamento id="1" versao="1.1.1">
|
3
|
+
<tid>100699306904CC7E1001</tid>
|
4
|
+
<dados-ec>
|
5
|
+
<numero>1006993069</numero>
|
6
|
+
<chave>25fbb99741c739dd84d7b06ec78c9bac718838630f30b112d033ce2e621b34f3</chave>
|
7
|
+
</dados-ec>
|
8
|
+
</requisicao-cancelamento>
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<requisicao-consulta id="1" versao="1.1.1">
|
3
|
+
<tid>103760993800001E1001</tid>
|
4
|
+
<dados-ec>
|
5
|
+
<numero>1006993069</numero>
|
6
|
+
<chave>25fbb99741c739dd84d7b06ec78c9bac718838630f30b112d033ce2e621b34f3</chave>
|
7
|
+
</dados-ec>
|
8
|
+
</requisicao-consulta>
|
@@ -0,0 +1,8 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<requisicao-consulta id="1" versao="1.1.1">
|
3
|
+
<tid>100699306904CC7E1001</tid>
|
4
|
+
<dados-ec>
|
5
|
+
<numero>1006993069</numero>
|
6
|
+
<chave>25fbb99741c739dd84d7b06ec78c9bac718838630f30b112d033ce2e621b34f3</chave>
|
7
|
+
</dados-ec>
|
8
|
+
</requisicao-consulta>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<?xml version="1.0" encoding="ISO-8859-1"?>
|
2
|
+
<transacao versao="1.1.1" id="1" xmlns="http://ecommerce.cbmp.com.br">
|
3
|
+
<tid>100699306904CC7E1001</tid>
|
4
|
+
<pan>IqVz7P9zaIgTYdU41HaW/OB/d7Idwttqwb2vaTt8MT0=</pan>
|
5
|
+
<dados-pedido>
|
6
|
+
<numero>285813768</numero>
|
7
|
+
<valor>100</valor>
|
8
|
+
<moeda>986</moeda>
|
9
|
+
<data-hora>2012-04-30T08:30:15.358-03:00</data-hora>
|
10
|
+
<idioma>PT</idioma>
|
11
|
+
</dados-pedido>
|
12
|
+
<forma-pagamento>
|
13
|
+
<bandeira>visa</bandeira>
|
14
|
+
<produto>1</produto>
|
15
|
+
<parcelas>1</parcelas>
|
16
|
+
</forma-pagamento>
|
17
|
+
<status>0</status>
|
18
|
+
</transacao>
|
@@ -0,0 +1,12 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<transacao versao="1.1.1" id="1" xmlns="http://ecommerce.cbmp.com.br">
|
3
|
+
<tid>100699306904CC7E1001</tid>
|
4
|
+
<pan>IqVz7P9zaIgTYdU41HaW/OB/d7Idwttqwb2vaTt8MT0=</pan>
|
5
|
+
<status>9</status>
|
6
|
+
<cancelamento>
|
7
|
+
<codigo>9</codigo>
|
8
|
+
<mensagem>Transacao cancelada com sucesso</mensagem>
|
9
|
+
<data-hora>2012-05-14T09:52:14</data-hora>
|
10
|
+
<valor>100</valor>
|
11
|
+
</cancelamento>
|
12
|
+
</transacao>
|
@@ -0,0 +1,29 @@
|
|
1
|
+
<?xml version="1.0" encoding="UTF-8"?>
|
2
|
+
<requisicao-transacao id="1" versao="1.1.1">
|
3
|
+
<dados-ec>
|
4
|
+
<numero>1006993069</numero>
|
5
|
+
<chave>25fbb99741c739dd84d7b06ec78c9bac718838630f30b112d033ce2e621b34f3</chave>
|
6
|
+
</dados-ec>
|
7
|
+
<dados-portador>
|
8
|
+
<numero>4012001037141112</numero>
|
9
|
+
<validade>201511</validade>
|
10
|
+
<indicador>1</indicador>
|
11
|
+
<codigo-seguranca>371</codigo-seguranca>
|
12
|
+
<nome-portador>FULANO DE TAL</nome-portador>
|
13
|
+
</dados-portador>
|
14
|
+
<dados-pedido>
|
15
|
+
<numero>285813768</numero>
|
16
|
+
<valor>100</valor>
|
17
|
+
<moeda>986</moeda>
|
18
|
+
<data-hora>2010-07-14T13:56:12</data-hora>
|
19
|
+
<idioma>PT</idioma>
|
20
|
+
</dados-pedido>
|
21
|
+
<forma-pagamento>
|
22
|
+
<bandeira>visa</bandeira>
|
23
|
+
<produto>1</produto>
|
24
|
+
<parcelas>1</parcelas>
|
25
|
+
</forma-pagamento>
|
26
|
+
<url-retorno>http://minha.loja.com/pedido/285813768</url-retorno>
|
27
|
+
<autorizar>2</autorizar>
|
28
|
+
<capturar>false</capturar>
|
29
|
+
</requisicao-transacao>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<transacao versao="1.1.1" id="1" xmlns="http://ecommerce.cbmp.com.br">
|
2
|
+
<tid>100699306905519A1001</tid>
|
3
|
+
<pan>IqVz7P9zaIgTYdU41HaW/OB/d7Idwttqwb2vaTt8MT0=</pan>
|
4
|
+
<dados-pedido>
|
5
|
+
<numero>285813768</numero>
|
6
|
+
<valor>100</valor>
|
7
|
+
<moeda>986</moeda>
|
8
|
+
<data-hora>2012-05-23T09:14:11.922-03:00</data-hora>
|
9
|
+
<idioma>PT</idioma>
|
10
|
+
</dados-pedido>
|
11
|
+
<forma-pagamento>
|
12
|
+
<bandeira>visa</bandeira>
|
13
|
+
<produto>1</produto>
|
14
|
+
<parcelas>1</parcelas>
|
15
|
+
</forma-pagamento>
|
16
|
+
<status>0</status>
|
17
|
+
<url-autenticacao>https://qasecommerce.cielo.com.br/web/index.cbmp?id=18beb3bf46e4ee2a3407eafd94d382ca</url-autenticacao>
|
18
|
+
</transacao>
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: cielox
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.2a
|
5
5
|
prerelease: 5
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,11 +9,11 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-05-
|
12
|
+
date: 2012-05-23 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: happymapper
|
16
|
-
requirement: &
|
16
|
+
requirement: &70150121511440 !ruby/object:Gem::Requirement
|
17
17
|
none: false
|
18
18
|
requirements:
|
19
19
|
- - ~>
|
@@ -21,10 +21,10 @@ dependencies:
|
|
21
21
|
version: 0.4.0
|
22
22
|
type: :runtime
|
23
23
|
prerelease: false
|
24
|
-
version_requirements: *
|
24
|
+
version_requirements: *70150121511440
|
25
25
|
- !ruby/object:Gem::Dependency
|
26
26
|
name: rspec
|
27
|
-
requirement: &
|
27
|
+
requirement: &70150121510940 !ruby/object:Gem::Requirement
|
28
28
|
none: false
|
29
29
|
requirements:
|
30
30
|
- - ~>
|
@@ -32,10 +32,10 @@ dependencies:
|
|
32
32
|
version: 2.9.0
|
33
33
|
type: :development
|
34
34
|
prerelease: false
|
35
|
-
version_requirements: *
|
35
|
+
version_requirements: *70150121510940
|
36
36
|
- !ruby/object:Gem::Dependency
|
37
37
|
name: timecop
|
38
|
-
requirement: &
|
38
|
+
requirement: &70150121510480 !ruby/object:Gem::Requirement
|
39
39
|
none: false
|
40
40
|
requirements:
|
41
41
|
- - ~>
|
@@ -43,10 +43,10 @@ dependencies:
|
|
43
43
|
version: 0.3.5
|
44
44
|
type: :development
|
45
45
|
prerelease: false
|
46
|
-
version_requirements: *
|
46
|
+
version_requirements: *70150121510480
|
47
47
|
- !ruby/object:Gem::Dependency
|
48
48
|
name: webmock
|
49
|
-
requirement: &
|
49
|
+
requirement: &70150121510020 !ruby/object:Gem::Requirement
|
50
50
|
none: false
|
51
51
|
requirements:
|
52
52
|
- - ~>
|
@@ -54,7 +54,7 @@ dependencies:
|
|
54
54
|
version: 1.8.6
|
55
55
|
type: :development
|
56
56
|
prerelease: false
|
57
|
-
version_requirements: *
|
57
|
+
version_requirements: *70150121510020
|
58
58
|
description: Gem for integration with Cielo
|
59
59
|
email:
|
60
60
|
- me@rafaelss.com
|
@@ -73,22 +73,29 @@ files:
|
|
73
73
|
- lib/cielo.rb
|
74
74
|
- lib/cielo/authorization.rb
|
75
75
|
- lib/cielo/authorization_request.rb
|
76
|
+
- lib/cielo/cancelation.rb
|
77
|
+
- lib/cielo/cancelation_request.rb
|
76
78
|
- lib/cielo/capture.rb
|
77
79
|
- lib/cielo/capture_request.rb
|
78
80
|
- lib/cielo/card.rb
|
81
|
+
- lib/cielo/card/validity.rb
|
79
82
|
- lib/cielo/configuration.rb
|
83
|
+
- lib/cielo/error.rb
|
84
|
+
- lib/cielo/http.rb
|
85
|
+
- lib/cielo/info_request.rb
|
80
86
|
- lib/cielo/order.rb
|
81
87
|
- lib/cielo/payment.rb
|
82
88
|
- lib/cielo/shop.rb
|
83
89
|
- lib/cielo/transaction.rb
|
84
90
|
- lib/cielo/transaction_request.rb
|
85
|
-
- lib/cielo/validity.rb
|
86
91
|
- lib/cielo/version.rb
|
87
92
|
- lib/cielox.rb
|
88
93
|
- spec/cielo/authorization_request_spec.rb
|
94
|
+
- spec/cielo/cancelation_request_spec.rb
|
89
95
|
- spec/cielo/capture_request_spec.rb
|
90
96
|
- spec/cielo/card_spec.rb
|
91
97
|
- spec/cielo/configuration_spec.rb
|
98
|
+
- spec/cielo/info_request_spec.rb
|
92
99
|
- spec/cielo/order_spec.rb
|
93
100
|
- spec/cielo/payment_spec.rb
|
94
101
|
- spec/cielo/shop_spec.rb
|
@@ -97,15 +104,23 @@ files:
|
|
97
104
|
- spec/cielo/validity_spec.rb
|
98
105
|
- spec/cielo_spec.rb
|
99
106
|
- spec/fixtures/authorization_request.xml
|
107
|
+
- spec/fixtures/cancelation_request.xml
|
100
108
|
- spec/fixtures/capture_request.xml
|
101
109
|
- spec/fixtures/card.xml
|
110
|
+
- spec/fixtures/info_request/error_request.xml
|
111
|
+
- spec/fixtures/info_request/error_response.xml
|
112
|
+
- spec/fixtures/info_request/request.xml
|
113
|
+
- spec/fixtures/info_request/response.xml
|
102
114
|
- spec/fixtures/order.xml
|
103
115
|
- spec/fixtures/payment.xml
|
104
116
|
- spec/fixtures/shop.xml
|
105
117
|
- spec/fixtures/transaction.xml
|
106
118
|
- spec/fixtures/transaction_1.xml
|
107
119
|
- spec/fixtures/transaction_2.xml
|
120
|
+
- spec/fixtures/transaction_3.xml
|
108
121
|
- spec/fixtures/transaction_request.xml
|
122
|
+
- spec/fixtures/transaction_request/request.xml
|
123
|
+
- spec/fixtures/transaction_request/response.xml
|
109
124
|
- spec/spec_helper.rb
|
110
125
|
homepage: http://github.com/rafaelss/cielo
|
111
126
|
licenses: []
|
@@ -133,9 +148,11 @@ specification_version: 3
|
|
133
148
|
summary: Gem for integration with Cielo
|
134
149
|
test_files:
|
135
150
|
- spec/cielo/authorization_request_spec.rb
|
151
|
+
- spec/cielo/cancelation_request_spec.rb
|
136
152
|
- spec/cielo/capture_request_spec.rb
|
137
153
|
- spec/cielo/card_spec.rb
|
138
154
|
- spec/cielo/configuration_spec.rb
|
155
|
+
- spec/cielo/info_request_spec.rb
|
139
156
|
- spec/cielo/order_spec.rb
|
140
157
|
- spec/cielo/payment_spec.rb
|
141
158
|
- spec/cielo/shop_spec.rb
|
@@ -144,14 +161,22 @@ test_files:
|
|
144
161
|
- spec/cielo/validity_spec.rb
|
145
162
|
- spec/cielo_spec.rb
|
146
163
|
- spec/fixtures/authorization_request.xml
|
164
|
+
- spec/fixtures/cancelation_request.xml
|
147
165
|
- spec/fixtures/capture_request.xml
|
148
166
|
- spec/fixtures/card.xml
|
167
|
+
- spec/fixtures/info_request/error_request.xml
|
168
|
+
- spec/fixtures/info_request/error_response.xml
|
169
|
+
- spec/fixtures/info_request/request.xml
|
170
|
+
- spec/fixtures/info_request/response.xml
|
149
171
|
- spec/fixtures/order.xml
|
150
172
|
- spec/fixtures/payment.xml
|
151
173
|
- spec/fixtures/shop.xml
|
152
174
|
- spec/fixtures/transaction.xml
|
153
175
|
- spec/fixtures/transaction_1.xml
|
154
176
|
- spec/fixtures/transaction_2.xml
|
177
|
+
- spec/fixtures/transaction_3.xml
|
155
178
|
- spec/fixtures/transaction_request.xml
|
179
|
+
- spec/fixtures/transaction_request/request.xml
|
180
|
+
- spec/fixtures/transaction_request/response.xml
|
156
181
|
- spec/spec_helper.rb
|
157
182
|
has_rdoc:
|
data/lib/cielo/validity.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
module Cielo
|
2
|
-
class Validity
|
3
|
-
class InvalidDate < StandardError; end
|
4
|
-
|
5
|
-
def initialize(year, month)
|
6
|
-
@year = year.to_i
|
7
|
-
@month = month.to_i
|
8
|
-
|
9
|
-
now = Time.now
|
10
|
-
if @year < now.year || @month < now.month
|
11
|
-
raise InvalidDate, "#{@month}/#{@year} is not valid"
|
12
|
-
end
|
13
|
-
end
|
14
|
-
|
15
|
-
def to_s
|
16
|
-
[@year, "%02d" % @month].join
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|