clearsale 0.1.0 → 0.1.1
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +1 -0
- data/Gemfile.lock +1 -1
- data/README.rdoc +3 -0
- data/lib/clearsale/order.rb +2 -2
- data/lib/clearsale/version.rb +1 -1
- data/spec/order_spec.rb +33 -5
- metadata +2 -2
data/.gitignore
CHANGED
data/Gemfile.lock
CHANGED
data/README.rdoc
CHANGED
@@ -4,6 +4,9 @@
|
|
4
4
|
Defina a variavél de ambiente CLEARSALE_ENTITYCODE
|
5
5
|
export CLEARSALE_ENTITYCODE=03524C82-F434-4A32-8D34-EFFF2023341B
|
6
6
|
|
7
|
+
Defina a variavél de ambiente CLEARSALE_ENV
|
8
|
+
export CLEARSALE_ENV=production
|
9
|
+
|
7
10
|
Adicione no seu Gemfile
|
8
11
|
gem 'clearsale', :github => 'Baby-com-br/clearsale'
|
9
12
|
|
data/lib/clearsale/order.rb
CHANGED
@@ -52,7 +52,7 @@ module Clearsale
|
|
52
52
|
builder.tag!('Type', 1) # Pessoa Física
|
53
53
|
builder.tag!('LegalDocument1', user.cpf.gsub(/[\.\-]*/, '').strip)
|
54
54
|
builder.tag!('Name', user.full_name)
|
55
|
-
builder.tag!('BirthDate', user.birthdate.to_time.strftime("%Y-%m-%dT%H:%M:%S"))
|
55
|
+
builder.tag!('BirthDate', user.birthdate.to_time.strftime("%Y-%m-%dT%H:%M:%S")) if user.birthdate.present?
|
56
56
|
builder.tag!('Email', user.email)
|
57
57
|
builder.tag!('Genre', user.gender.downcase)
|
58
58
|
build_address(builder, billing_address)
|
@@ -99,7 +99,7 @@ module Clearsale
|
|
99
99
|
|
100
100
|
b.tag!('CardNumber', payment.card_number)
|
101
101
|
b.tag!('CardBin', payment.card_number[0..5])
|
102
|
-
b.tag!('CardType', CARD_TYPE_MAP.fetch(payment.acquirer, 4)) # Failover is 'outros'
|
102
|
+
b.tag!('CardType', CARD_TYPE_MAP.fetch(payment.acquirer.to_sym, 4)) # Failover is 'outros'
|
103
103
|
b.tag!('CardExpirationDate', payment.card_expiration)
|
104
104
|
b.tag!('Name', payment.customer_name)
|
105
105
|
b.tag!('LegalDocument', user.cpf.gsub(/[\.\-]*/, '').strip)
|
data/lib/clearsale/version.rb
CHANGED
data/spec/order_spec.rb
CHANGED
@@ -4,13 +4,41 @@ require 'timecop'
|
|
4
4
|
|
5
5
|
module Clearsale
|
6
6
|
describe Order do
|
7
|
+
before :each do
|
8
|
+
Timecop.freeze Time.parse('2012-07-01 11:13')
|
9
|
+
end
|
10
|
+
|
11
|
+
let(:_order) { Object.new(order) }
|
12
|
+
let(:_payment) { Object.new(payment) }
|
13
|
+
let(:_user) { Object.new(user) }
|
14
|
+
|
7
15
|
describe ".to_xml" do
|
8
16
|
it "converts the order to xml successfully" do
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
17
|
+
described_class.to_xml(_order, _payment, _user).should eq '<ClearSale><Orders><Order><ID>1234</ID><Date>2012-07-01T11:13:00</Date><Email>petergriffin@abc.com</Email><TotalItens>20.0</TotalItens><TotalOrder>25.0</TotalOrder><QtyInstallments>3</QtyInstallments><QtyItems>3</QtyItems><IP>127.0.0.1</IP><CollectionData><ID>8888</ID><Type>1</Type><LegalDocument1>24878346337</LegalDocument1><Name>Peter Löwenbräu Griffin</Name><BirthDate>1972-07-01T11:13:00</BirthDate><Email>petergriffin@abc.com</Email><Genre>m</Genre><Address><Street>Billing Street</Street><Number>123</Number><Comp></Comp><County>Rhode Island</County><City>Mayland</City><State>Maryland</State><ZipCode>00100-011</ZipCode></Address><Phones><Phone><Type>0</Type><DDD>11</DDD><Number>80011002</Number></Phone></Phones></CollectionData><ShippingData><ID>8888</ID><Type>1</Type><LegalDocument1>24878346337</LegalDocument1><Name>Peter Löwenbräu Griffin</Name><BirthDate>1972-07-01T11:13:00</BirthDate><Email>petergriffin@abc.com</Email><Genre>m</Genre><Address><Street>Shipping Street</Street><Number>123</Number><Comp></Comp><County>Rhode Island</County><City>Mayland</City><State>Maryland</State><ZipCode>00100-011</ZipCode></Address><Phones><Phone><Type>0</Type><DDD>11</DDD><Number>80011002</Number></Phone></Phones></ShippingData><Payments><Payment><Date>2012-07-01T11:12:58</Date><Amount>50.0</Amount><PaymentTypeID>1</PaymentTypeID><QtyInstallments>3</QtyInstallments><CardNumber>1234432111112222</CardNumber><CardBin>123443</CardBin><CardType>3</CardType><CardExpirationDate>05/2012</CardExpirationDate><Name></Name><LegalDocument>24878346337</LegalDocument><Address><Street>Billing Street</Street><Number>123</Number><Comp></Comp><County>Rhode Island</County><City>Mayland</City><State>Maryland</State><ZipCode>00100-011</ZipCode></Address></Payment></Payments><Items><Item><ID>5555</ID><Name>Pogobol</Name><ItemValue>5.0</ItemValue><Qty>2</Qty><CategoryID>7777</CategoryID><CategoryName>Disney</CategoryName></Item><Item><ID>5555</ID><Name>Pogobol</Name><ItemValue>5.0</ItemValue><Qty>2</Qty><CategoryID>7777</CategoryID><CategoryName>Disney</CategoryName></Item></Items></Order></Orders></ClearSale>'
|
18
|
+
end
|
19
|
+
|
20
|
+
context "about credit card acquirer" do
|
21
|
+
it "should accept symbol" do
|
22
|
+
_payment.acquirer = :amex
|
23
|
+
described_class.to_xml(_order, _payment, _user).should include "<CardType>#{Clearsale::Order::CARD_TYPE_MAP[:amex]}</CardType>"
|
24
|
+
end
|
25
|
+
|
26
|
+
it "should accept string" do
|
27
|
+
_payment.acquirer = 'amex'
|
28
|
+
described_class.to_xml(_order, _payment, _user).should include "<CardType>#{Clearsale::Order::CARD_TYPE_MAP[:amex]}</CardType>"
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
32
|
+
context "when birthdate is empty" do
|
33
|
+
it "should not send birthdate" do
|
34
|
+
_user.birthdate = nil
|
35
|
+
described_class.to_xml(_order, _payment, _user).should_not include "<BirthDate>"
|
36
|
+
end
|
37
|
+
|
38
|
+
it "should not send birthdate" do
|
39
|
+
_user.birthdate = nil
|
40
|
+
expect{ described_class.to_xml(_order, _payment, _user) }.to_not raise_error
|
41
|
+
end
|
14
42
|
end
|
15
43
|
end
|
16
44
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: clearsale
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-
|
12
|
+
date: 2012-08-03 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: builder
|