pagseguro-transparente 0.2.3 → 0.2.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile.lock +1 -1
- data/lib/pagseguro/document.rb +8 -4
- data/lib/pagseguro/payment/serializer.rb +10 -1
- data/lib/pagseguro/version.rb +1 -1
- data/spec/pagseguro/document_spec.rb +17 -0
- data/spec/pagseguro/payment/serializer_spec.rb +6 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 234a60fab82229142db4d62ea008209a61e4999b
|
4
|
+
data.tar.gz: d46919e9d88378d712bae935c342a88b0f839cc0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: dbd8b9392b49ef932faccce27cf2a35f57b06a708229c1bdee6863af8683849a71bd1882d715a11bc3e878ea21e102e81fefc11ddaf400d1c4ebdb4ad78980fe
|
7
|
+
data.tar.gz: 9cca0d91346a11e90882a3f347c23f1e94165eb0d6f68673980e383fb65258510176ce951d06c6d5bb28595ada58b3a99570c3ed75c1d9d171538a64d683f6ab
|
data/Gemfile.lock
CHANGED
data/lib/pagseguro/document.rb
CHANGED
@@ -3,18 +3,22 @@ module PagSeguro
|
|
3
3
|
include ActiveModel::Validations
|
4
4
|
|
5
5
|
validates_presence_of :type, :value
|
6
|
+
validates_inclusion_of :type, in: %w(CPF CNPJ)
|
6
7
|
|
7
8
|
# Set the document type
|
8
|
-
#
|
9
|
+
# CPF or CNPJ is acceptable
|
9
10
|
attr_accessor :type
|
10
11
|
|
11
12
|
# Set the document number.
|
12
|
-
# Must have 7-9 numbers.
|
13
13
|
attr_accessor :value
|
14
14
|
|
15
|
-
def initialize(value)
|
16
|
-
@type =
|
15
|
+
def initialize(value, type = 'CPF')
|
16
|
+
@type = type
|
17
17
|
@value = value
|
18
18
|
end
|
19
|
+
|
20
|
+
def cpf?
|
21
|
+
type == "CPF"
|
22
|
+
end
|
19
23
|
end
|
20
24
|
end
|
@@ -67,13 +67,21 @@ module PagSeguro
|
|
67
67
|
return unless sender
|
68
68
|
|
69
69
|
params[:senderName] = sender.name
|
70
|
-
params[:senderCPF] = sender.document.value
|
71
70
|
params[:senderEmail] = sender.email
|
72
71
|
params[:senderHash] = sender.hash_id
|
73
72
|
|
73
|
+
serialize_document(sender.document)
|
74
74
|
serialize_phone(sender.phone)
|
75
75
|
end
|
76
76
|
|
77
|
+
def serialize_document(document)
|
78
|
+
if document.cpf?
|
79
|
+
params[:senderCPF] = document.value
|
80
|
+
else
|
81
|
+
params[:senderCNPJ] = document.value
|
82
|
+
end
|
83
|
+
end
|
84
|
+
|
77
85
|
def serialize_phone(phone)
|
78
86
|
return unless phone
|
79
87
|
|
@@ -81,6 +89,7 @@ module PagSeguro
|
|
81
89
|
params[:senderPhone] = phone.number
|
82
90
|
end
|
83
91
|
|
92
|
+
|
84
93
|
def serialize_bank(bank)
|
85
94
|
return unless bank
|
86
95
|
|
data/lib/pagseguro/version.rb
CHANGED
@@ -6,6 +6,7 @@ describe PagSeguro::Document do
|
|
6
6
|
|
7
7
|
it { should respond_to(:type) }
|
8
8
|
it { should respond_to(:value) }
|
9
|
+
it { should respond_to(:cpf?) }
|
9
10
|
|
10
11
|
describe 'presence validations' do
|
11
12
|
it { should validate_presence_of(:type) }
|
@@ -15,4 +16,20 @@ describe PagSeguro::Document do
|
|
15
16
|
describe 'set default country' do
|
16
17
|
its(:type) { should eq('CPF') }
|
17
18
|
end
|
19
|
+
|
20
|
+
describe 'inclusion validations' do
|
21
|
+
let(:types) { %w(CPF CNPJ) }
|
22
|
+
it { should ensure_inclusion_of(:type).in_array(types) }
|
23
|
+
end
|
24
|
+
|
25
|
+
describe '#cpf' do
|
26
|
+
context 'with CPF' do
|
27
|
+
its(:cpf?) { should be_true }
|
28
|
+
end
|
29
|
+
|
30
|
+
context 'with CNPJ' do
|
31
|
+
let(:document) { PagSeguro::Document.new('017.345.345-00', 'CNPJ') }
|
32
|
+
its(:cpf?) { should be_false }
|
33
|
+
end
|
34
|
+
end
|
18
35
|
end
|
@@ -144,4 +144,10 @@ describe PagSeguro::Payment::Serializer do
|
|
144
144
|
|
145
145
|
it { subject[:creditCardHolderBirthDate].should eq(nil) }
|
146
146
|
end
|
147
|
+
|
148
|
+
context 'with CNPJ' do
|
149
|
+
let(:document) { PagSeguro::Document.new('22111944785', 'CNPJ') }
|
150
|
+
|
151
|
+
it { subject[:senderCNPJ].should eq('22111944785') }
|
152
|
+
end
|
147
153
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pagseguro-transparente
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.2.
|
4
|
+
version: 0.2.4
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cirdes Henrique
|
@@ -277,7 +277,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
277
277
|
version: '0'
|
278
278
|
requirements: []
|
279
279
|
rubyforge_project:
|
280
|
-
rubygems_version: 2.
|
280
|
+
rubygems_version: 2.4.3
|
281
281
|
signing_key:
|
282
282
|
specification_version: 4
|
283
283
|
summary: Integração com o novo checkout transparente do Pagseguro.
|