pagseguro-transparente 0.2.5 → 1.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/Gemfile.lock +49 -46
- data/lib/pagseguro.rb +5 -4
- data/lib/pagseguro/notification.rb +1 -1
- data/lib/pagseguro/payment.rb +1 -5
- data/lib/pagseguro/query.rb +1 -1
- data/lib/pagseguro/refund.rb +1 -1
- data/lib/pagseguro/request.rb +5 -4
- data/lib/pagseguro/session.rb +1 -1
- data/lib/pagseguro/transaction.rb +11 -7
- data/lib/pagseguro/transaction/creditor_fees.rb +27 -0
- data/lib/pagseguro/transaction/payment_method.rb +1 -1
- data/lib/pagseguro/version.rb +1 -1
- data/pagseguro-transparente.gemspec +8 -7
- data/spec/pagseguro/address_spec.rb +1 -1
- data/spec/pagseguro/document_spec.rb +3 -3
- data/spec/pagseguro/item_spec.rb +1 -1
- data/spec/pagseguro/notification_spec.rb +2 -2
- data/spec/pagseguro/pagseguro_spec.rb +18 -5
- data/spec/pagseguro/query_spec.rb +2 -2
- data/spec/pagseguro/refund_spec.rb +4 -4
- data/spec/pagseguro/transaction/creditor_fees_spec.rb +24 -0
- data/spec/pagseguro/transaction_spec.rb +31 -22
- metadata +33 -16
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 50b6c3781ffdbe907acfcbbe270e64fbf62a04c0
|
4
|
+
data.tar.gz: bf8eaa4feb3fdb20515e3ab76c9b3f5d77047ca9
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 55f19a7f2d74fc5c05c04efff644dac7d386a0f1b7e9cd00473ac3ddb6b121c3de436cc602e5e906d471cf8d83dd256a6c0a0a57fc47c99df252f3425de5d2fb
|
7
|
+
data.tar.gz: 8460ec3591ad1e8c7ec7d86fcf91763302227736bd8e4a8a8eab62f7fa2235cbbb5014addc7e5c030407803d9e6aede29dceddcdb55815bbd8f20adc07f00e67
|
data/Gemfile.lock
CHANGED
@@ -1,76 +1,79 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
pagseguro-transparente (0.
|
4
|
+
pagseguro-transparente (1.0.0)
|
5
5
|
activemodel
|
6
6
|
httparty (~> 0.13)
|
7
|
-
i18n (~> 0.
|
8
|
-
json (~> 1.8)
|
7
|
+
i18n (~> 0.7)
|
8
|
+
json (~> 1.8.2)
|
9
9
|
nokogiri (~> 1.6)
|
10
|
+
safe_yaml (~> 1.0.4)
|
10
11
|
|
11
12
|
GEM
|
12
13
|
remote: https://rubygems.org/
|
13
14
|
specs:
|
14
|
-
activemodel (4.
|
15
|
-
activesupport (= 4.
|
15
|
+
activemodel (4.2.0)
|
16
|
+
activesupport (= 4.2.0)
|
16
17
|
builder (~> 3.1)
|
17
|
-
activesupport (4.
|
18
|
-
i18n (~> 0.
|
18
|
+
activesupport (4.2.0)
|
19
|
+
i18n (~> 0.7)
|
19
20
|
json (~> 1.7, >= 1.7.7)
|
20
21
|
minitest (~> 5.1)
|
21
|
-
thread_safe (~> 0.
|
22
|
+
thread_safe (~> 0.3, >= 0.3.4)
|
22
23
|
tzinfo (~> 1.1)
|
23
|
-
addressable (2.3.
|
24
|
+
addressable (2.3.7)
|
24
25
|
builder (3.2.2)
|
25
|
-
coveralls (0.7.
|
26
|
-
multi_json (~> 1.
|
27
|
-
rest-client
|
28
|
-
simplecov (
|
29
|
-
term-ansicolor
|
30
|
-
thor
|
26
|
+
coveralls (0.7.11)
|
27
|
+
multi_json (~> 1.10)
|
28
|
+
rest-client (>= 1.6.8, < 2)
|
29
|
+
simplecov (~> 0.9.1)
|
30
|
+
term-ansicolor (~> 1.3)
|
31
|
+
thor (~> 0.19.1)
|
31
32
|
crack (0.4.2)
|
32
33
|
safe_yaml (~> 1.0.0)
|
33
34
|
diff-lcs (1.2.5)
|
34
|
-
docile (1.1.
|
35
|
+
docile (1.1.5)
|
35
36
|
httparty (0.13.3)
|
36
37
|
json (~> 1.8)
|
37
38
|
multi_xml (>= 0.5.2)
|
38
|
-
i18n (0.
|
39
|
-
json (1.8.
|
40
|
-
mime-types (2.
|
41
|
-
mini_portile (0.6.
|
42
|
-
minitest (5.
|
43
|
-
multi_json (1.
|
39
|
+
i18n (0.7.0)
|
40
|
+
json (1.8.2)
|
41
|
+
mime-types (2.4.3)
|
42
|
+
mini_portile (0.6.2)
|
43
|
+
minitest (5.5.1)
|
44
|
+
multi_json (1.11.0)
|
44
45
|
multi_xml (0.5.5)
|
45
|
-
|
46
|
+
netrc (0.10.3)
|
47
|
+
nokogiri (1.6.6.2)
|
46
48
|
mini_portile (~> 0.6.0)
|
47
|
-
rake (10.
|
48
|
-
rest-client (1.
|
49
|
-
mime-types (>= 1.16)
|
50
|
-
|
51
|
-
|
52
|
-
rspec-
|
53
|
-
rspec-
|
54
|
-
|
55
|
-
rspec-
|
49
|
+
rake (10.4.2)
|
50
|
+
rest-client (1.7.3)
|
51
|
+
mime-types (>= 1.16, < 3.0)
|
52
|
+
netrc (~> 0.7)
|
53
|
+
rspec (2.99.0)
|
54
|
+
rspec-core (~> 2.99.0)
|
55
|
+
rspec-expectations (~> 2.99.0)
|
56
|
+
rspec-mocks (~> 2.99.0)
|
57
|
+
rspec-core (2.99.2)
|
58
|
+
rspec-expectations (2.99.2)
|
56
59
|
diff-lcs (>= 1.1.3, < 2.0)
|
57
|
-
rspec-mocks (2.
|
58
|
-
safe_yaml (1.0.
|
60
|
+
rspec-mocks (2.99.3)
|
61
|
+
safe_yaml (1.0.4)
|
59
62
|
shoulda-matchers (2.5.0)
|
60
63
|
activesupport (>= 3.0.0)
|
61
|
-
simplecov (0.
|
64
|
+
simplecov (0.9.2)
|
62
65
|
docile (~> 1.1.0)
|
63
|
-
multi_json
|
64
|
-
simplecov-html (~> 0.
|
65
|
-
simplecov-html (0.
|
66
|
+
multi_json (~> 1.0)
|
67
|
+
simplecov-html (~> 0.9.0)
|
68
|
+
simplecov-html (0.9.0)
|
66
69
|
term-ansicolor (1.3.0)
|
67
70
|
tins (~> 1.0)
|
68
71
|
thor (0.19.1)
|
69
|
-
thread_safe (0.3.
|
70
|
-
tins (1.3.
|
71
|
-
tzinfo (1.
|
72
|
+
thread_safe (0.3.4)
|
73
|
+
tins (1.3.5)
|
74
|
+
tzinfo (1.2.2)
|
72
75
|
thread_safe (~> 0.1)
|
73
|
-
webmock (1.
|
76
|
+
webmock (1.20.4)
|
74
77
|
addressable (>= 2.3.6)
|
75
78
|
crack (>= 0.3.2)
|
76
79
|
|
@@ -78,11 +81,11 @@ PLATFORMS
|
|
78
81
|
ruby
|
79
82
|
|
80
83
|
DEPENDENCIES
|
81
|
-
bundler (~> 1.
|
84
|
+
bundler (~> 1.8)
|
82
85
|
coveralls (~> 0.7)
|
83
86
|
pagseguro-transparente!
|
84
|
-
rake (~> 10.
|
85
|
-
rspec (~> 2.
|
87
|
+
rake (~> 10.4)
|
88
|
+
rspec (~> 2.99)
|
86
89
|
shoulda-matchers (= 2.5)
|
87
|
-
thread_safe (~> 0.
|
90
|
+
thread_safe (~> 0.3)
|
88
91
|
webmock (~> 1.18)
|
data/lib/pagseguro.rb
CHANGED
@@ -15,6 +15,7 @@ require "pagseguro/transaction/payment_method"
|
|
15
15
|
require "pagseguro/transaction/phone"
|
16
16
|
require "pagseguro/transaction/sender"
|
17
17
|
require "pagseguro/transaction/shipping"
|
18
|
+
require "pagseguro/transaction/creditor_fees"
|
18
19
|
require "pagseguro/notification"
|
19
20
|
require "pagseguro/query"
|
20
21
|
require "pagseguro/sender"
|
@@ -52,15 +53,15 @@ module PagSeguro
|
|
52
53
|
# Timeout value in seconds for requests.
|
53
54
|
attr_accessor :timeout
|
54
55
|
|
55
|
-
def api_url
|
56
|
-
uris.fetch(environment)
|
56
|
+
def api_url(version)
|
57
|
+
uris.fetch(environment) + version
|
57
58
|
end
|
58
59
|
|
59
60
|
private
|
60
61
|
def uris
|
61
62
|
@uris ||= {
|
62
|
-
production: 'https://ws.pagseguro.uol.com.br/
|
63
|
-
sandbox: 'https://ws.sandbox.pagseguro.uol.com.br/
|
63
|
+
production: 'https://ws.pagseguro.uol.com.br/',
|
64
|
+
sandbox: 'https://ws.sandbox.pagseguro.uol.com.br/'
|
64
65
|
}
|
65
66
|
end
|
66
67
|
end
|
data/lib/pagseguro/payment.rb
CHANGED
@@ -66,7 +66,7 @@ module PagSeguro
|
|
66
66
|
# Calls the PagSeguro web service and register this request for payment.
|
67
67
|
def transaction(account = nil)
|
68
68
|
params = Serializer.new(self).to_params
|
69
|
-
PagSeguro::Transaction.new post('/transactions', account, params).parsed_response
|
69
|
+
PagSeguro::Transaction.new post('/transactions', API_V2 ,account, params).parsed_response
|
70
70
|
end
|
71
71
|
|
72
72
|
def initialize(options = {})
|
@@ -80,10 +80,6 @@ module PagSeguro
|
|
80
80
|
end
|
81
81
|
|
82
82
|
private
|
83
|
-
def endpoint
|
84
|
-
PagSeguro.api_url("checkout")
|
85
|
-
end
|
86
|
-
|
87
83
|
def paid_with_card?
|
88
84
|
payment_method == "creditCard"
|
89
85
|
end
|
data/lib/pagseguro/query.rb
CHANGED
data/lib/pagseguro/refund.rb
CHANGED
@@ -8,7 +8,7 @@ module PagSeguro
|
|
8
8
|
end
|
9
9
|
|
10
10
|
def request(account = nil)
|
11
|
-
@request = post("/transactions/refunds", account, transactionCode: @transaction_code)
|
11
|
+
@request = post("/transactions/refunds", API_V2, account, transactionCode: @transaction_code)
|
12
12
|
@request.response.code == '200'
|
13
13
|
end
|
14
14
|
|
data/lib/pagseguro/request.rb
CHANGED
@@ -4,15 +4,16 @@ module PagSeguro
|
|
4
4
|
class Request
|
5
5
|
include HTTParty
|
6
6
|
debug_output $stderr
|
7
|
+
API_VERSIONS = [API_V2 = 'v2', API_V3 = 'v3']
|
7
8
|
|
8
|
-
def get(path, account = "default")
|
9
|
-
self.class.base_uri PagSeguro.api_url
|
9
|
+
def get(path, version, account = "default")
|
10
|
+
self.class.base_uri PagSeguro.api_url(version)
|
10
11
|
options = { query: add_credencials(account) }
|
11
12
|
self.class.get(path, options)
|
12
13
|
end
|
13
14
|
|
14
|
-
def post(path, account = "default", params = {})
|
15
|
-
self.class.base_uri PagSeguro.api_url
|
15
|
+
def post(path, version, account = "default", params = {})
|
16
|
+
self.class.base_uri PagSeguro.api_url(version)
|
16
17
|
options = { body: add_credencials(account) }
|
17
18
|
options[:body].merge!(params)
|
18
19
|
options[:timeout] = PagSeguro.timeout unless PagSeguro.timeout.blank?
|
data/lib/pagseguro/session.rb
CHANGED
@@ -1,9 +1,14 @@
|
|
1
1
|
module PagSeguro
|
2
2
|
class Transaction
|
3
|
+
extend Forwardable
|
3
4
|
attr_reader :response
|
4
5
|
|
6
|
+
def_delegators :creditor_fees, :installment_fee_amount,
|
7
|
+
:intermediation_rate_amount, :intermediation_fee_amount, :fee_amount
|
8
|
+
|
5
9
|
PAYMENT_STATUS = { '1' => :awaiting_payment, '2' => :pending, '3' => :paid,
|
6
|
-
'4' => :available, '5' => :in_dispute, '6' => :refunded, '7' => :canceled
|
10
|
+
'4' => :available, '5' => :in_dispute, '6' => :refunded, '7' => :canceled,
|
11
|
+
'8' => :chargeback, '9' => :plea }
|
7
12
|
|
8
13
|
def initialize(response)
|
9
14
|
@response = response
|
@@ -57,10 +62,6 @@ module PagSeguro
|
|
57
62
|
transaction['discountAmount']
|
58
63
|
end
|
59
64
|
|
60
|
-
def fee_amount
|
61
|
-
transaction['feeAmount']
|
62
|
-
end
|
63
|
-
|
64
65
|
def escrow_end_date
|
65
66
|
transaction['escrowEndDate']
|
66
67
|
end
|
@@ -100,9 +101,12 @@ module PagSeguro
|
|
100
101
|
end
|
101
102
|
|
102
103
|
private
|
103
|
-
|
104
104
|
def transaction
|
105
|
-
response['transaction']
|
105
|
+
@transaction ||= response['transaction']
|
106
|
+
end
|
107
|
+
|
108
|
+
def creditor_fees
|
109
|
+
@creditor_fees ||= CreditorFees.new(transaction['creditorFees'])
|
106
110
|
end
|
107
111
|
end
|
108
112
|
end
|
@@ -0,0 +1,27 @@
|
|
1
|
+
module PagSeguro
|
2
|
+
class Transaction
|
3
|
+
class CreditorFees
|
4
|
+
attr_accessor :creditor_fees
|
5
|
+
|
6
|
+
def initialize(creditor_fees)
|
7
|
+
@creditor_fees = creditor_fees
|
8
|
+
end
|
9
|
+
|
10
|
+
def installment_fee_amount
|
11
|
+
@installment_fee_amount ||= creditor_fees['installmentFeeAmount'].to_f
|
12
|
+
end
|
13
|
+
|
14
|
+
def intermediation_rate_amount
|
15
|
+
@intermediation_rate_amount ||= creditor_fees['intermediationRateAmount'].to_f
|
16
|
+
end
|
17
|
+
|
18
|
+
def intermediation_fee_amount
|
19
|
+
@intermediation_fee_amount ||= creditor_fees['intermediationFeeAmount'].to_f
|
20
|
+
end
|
21
|
+
|
22
|
+
def fee_amount
|
23
|
+
@fee_amount ||= installment_fee_amount + intermediation_rate_amount + intermediation_fee_amount
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -4,7 +4,7 @@ module PagSeguro
|
|
4
4
|
attr_reader :payment_method
|
5
5
|
|
6
6
|
PAYMENT_TYPE = { '1' => :credit_card, '2' => :boleto, '3' => :tef,
|
7
|
-
'4' => :pagseguro_balance, '5' => :io_paggo, '
|
7
|
+
'4' => :pagseguro_balance, '5' => :io_paggo, '7' => :deposit }
|
8
8
|
|
9
9
|
def initialize(payment_method)
|
10
10
|
@payment_method = payment_method
|
data/lib/pagseguro/version.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
require "./lib/pagseguro/version"
|
3
3
|
|
4
4
|
Gem::Specification.new do |spec|
|
5
|
-
spec.required_ruby_version = ">=
|
5
|
+
spec.required_ruby_version = ">= 2.0.0"
|
6
6
|
spec.name = "pagseguro-transparente"
|
7
7
|
spec.version = PagSeguro::VERSION
|
8
8
|
spec.authors = ["Cirdes Henrique", "Bruno Luigi"]
|
@@ -20,14 +20,15 @@ Gem::Specification.new do |spec|
|
|
20
20
|
spec.add_dependency "activemodel"
|
21
21
|
spec.add_dependency "httparty", '~> 0.13'
|
22
22
|
spec.add_dependency "nokogiri", '~> 1.6'
|
23
|
-
spec.add_dependency "json", '~> 1.8'
|
24
|
-
spec.add_dependency "i18n", '~> 0.
|
23
|
+
spec.add_dependency "json", '~> 1.8.2'
|
24
|
+
spec.add_dependency "i18n", '~> 0.7'
|
25
|
+
spec.add_dependency "safe_yaml", '~> 1.0.4'
|
25
26
|
|
26
|
-
spec.add_development_dependency "bundler", '~> 1.
|
27
|
-
spec.add_development_dependency "rake", '~> 10.
|
28
|
-
spec.add_development_dependency "rspec", '~> 2.
|
27
|
+
spec.add_development_dependency "bundler", '~> 1.8'
|
28
|
+
spec.add_development_dependency "rake", '~> 10.4'
|
29
|
+
spec.add_development_dependency "rspec", '~> 2.99'
|
29
30
|
spec.add_development_dependency "shoulda-matchers", '2.5'
|
30
31
|
spec.add_development_dependency "coveralls", '~> 0.7'
|
31
32
|
spec.add_development_dependency "webmock", '~> 1.18'
|
32
|
-
spec.add_development_dependency 'thread_safe', '~> 0.
|
33
|
+
spec.add_development_dependency 'thread_safe', '~> 0.3'
|
33
34
|
end
|
@@ -14,7 +14,7 @@ describe PagSeguro::Document do
|
|
14
14
|
end
|
15
15
|
|
16
16
|
describe 'set default country' do
|
17
|
-
|
17
|
+
it { expect(subject.type).to eq('CPF') }
|
18
18
|
end
|
19
19
|
|
20
20
|
describe 'inclusion validations' do
|
@@ -24,12 +24,12 @@ describe PagSeguro::Document do
|
|
24
24
|
|
25
25
|
describe '#cpf' do
|
26
26
|
context 'with CPF' do
|
27
|
-
|
27
|
+
it { expect(subject.cpf?).to be_truthy }
|
28
28
|
end
|
29
29
|
|
30
30
|
context 'with CNPJ' do
|
31
31
|
let(:document) { PagSeguro::Document.new('017.345.345-00', 'CNPJ') }
|
32
|
-
|
32
|
+
it { expect(subject.cpf?).to be_falsey }
|
33
33
|
end
|
34
34
|
end
|
35
35
|
end
|
data/spec/pagseguro/item_spec.rb
CHANGED
@@ -20,7 +20,7 @@ describe PagSeguro::Notification do
|
|
20
20
|
context "with default credencials" do
|
21
21
|
subject { notification.transaction }
|
22
22
|
before do
|
23
|
-
stub_request(:get, "https://ws.pagseguro.uol.com.br/
|
23
|
+
stub_request(:get, "https://ws.pagseguro.uol.com.br/v3/transactions/notifications/766B9C-AD4B044B04DA-77742F5FA653-E1AB24?email=mail&token=token").
|
24
24
|
to_return(:status => 200, :body => "", :headers => {})
|
25
25
|
end
|
26
26
|
|
@@ -30,7 +30,7 @@ describe PagSeguro::Notification do
|
|
30
30
|
context "with secondary credencials" do
|
31
31
|
subject { notification.transaction("alternative") }
|
32
32
|
before do
|
33
|
-
stub_request(:get, "https://ws.pagseguro.uol.com.br/
|
33
|
+
stub_request(:get, "https://ws.pagseguro.uol.com.br/v3/transactions/notifications/766B9C-AD4B044B04DA-77742F5FA653-E1AB24?email=alt_mail&token=alt_token").
|
34
34
|
to_return(:status => 200, :body => "", :headers => {})
|
35
35
|
end
|
36
36
|
|
@@ -24,13 +24,26 @@ describe PagSeguro do
|
|
24
24
|
end
|
25
25
|
|
26
26
|
describe ".api_url" do
|
27
|
-
context
|
28
|
-
|
27
|
+
context 'api v2' do
|
28
|
+
context "production" do
|
29
|
+
it { expect(PagSeguro.api_url(PagSeguro::Request::API_V2)).to eq('https://ws.pagseguro.uol.com.br/v2') }
|
30
|
+
end
|
31
|
+
|
32
|
+
context "sandbox" do
|
33
|
+
before { PagSeguro.environment = :sandbox }
|
34
|
+
it { expect(PagSeguro.api_url(PagSeguro::Request::API_V2)).to eq('https://ws.sandbox.pagseguro.uol.com.br/v2') }
|
35
|
+
end
|
29
36
|
end
|
30
37
|
|
31
|
-
context
|
32
|
-
|
33
|
-
|
38
|
+
context 'api v3' do
|
39
|
+
context "production" do
|
40
|
+
it { expect(PagSeguro.api_url(PagSeguro::Request::API_V3)).to eq('https://ws.pagseguro.uol.com.br/v3') }
|
41
|
+
end
|
42
|
+
|
43
|
+
context "sandbox" do
|
44
|
+
before { PagSeguro.environment = :sandbox }
|
45
|
+
it { expect(PagSeguro.api_url(PagSeguro::Request::API_V3)).to eq('https://ws.sandbox.pagseguro.uol.com.br/v3') }
|
46
|
+
end
|
34
47
|
end
|
35
48
|
end
|
36
49
|
end
|
@@ -18,7 +18,7 @@ describe PagSeguro::Query do
|
|
18
18
|
describe "#transaction" do
|
19
19
|
subject { query.transaction }
|
20
20
|
before do
|
21
|
-
stub_request(:get, "https://ws.pagseguro.uol.com.br/
|
21
|
+
stub_request(:get, "https://ws.pagseguro.uol.com.br/v3/transactions/64C4CB1E-5FF2-4092-BE17-CACE271D789E?email=mail&token=token").
|
22
22
|
to_return(:status => 200, :body => "", :headers => {})
|
23
23
|
end
|
24
24
|
|
@@ -28,7 +28,7 @@ describe PagSeguro::Query do
|
|
28
28
|
describe "with secondary credencials" do
|
29
29
|
subject { query.transaction("alternative") }
|
30
30
|
before do
|
31
|
-
stub_request(:get, "https://ws.pagseguro.uol.com.br/
|
31
|
+
stub_request(:get, "https://ws.pagseguro.uol.com.br/v3/transactions/64C4CB1E-5FF2-4092-BE17-CACE271D789E?email=alt_mail&token=alt_token").
|
32
32
|
to_return(:status => 200, :body => "", :headers => {})
|
33
33
|
end
|
34
34
|
|
@@ -28,7 +28,7 @@ describe PagSeguro::Refund do
|
|
28
28
|
to_return(:status => 200, :body => "<?xml version='1.0' encoding='ISO-8859-1' standalone='yes'?> <result>OK</result>", :headers => {'Content-Type' => 'application/xml;charset=ISO-8859-1'})
|
29
29
|
end
|
30
30
|
|
31
|
-
it { expect(subject).to
|
31
|
+
it { expect(subject).to be_truthy }
|
32
32
|
end
|
33
33
|
|
34
34
|
context "alternative successful refund" do
|
@@ -40,7 +40,7 @@ describe PagSeguro::Refund do
|
|
40
40
|
to_return(:status => 200, :body => "<?xml version='1.0' encoding='ISO-8859-1' standalone='yes'?> <result>OK</result>", :headers => {'Content-Type' => 'application/xml;charset=ISO-8859-1'})
|
41
41
|
end
|
42
42
|
|
43
|
-
it { expect(subject).to
|
43
|
+
it { expect(subject).to be_truthy }
|
44
44
|
end
|
45
45
|
|
46
46
|
context "unsuccessfull refund" do
|
@@ -60,7 +60,7 @@ describe PagSeguro::Refund do
|
|
60
60
|
context "request return" do
|
61
61
|
subject { refund.request }
|
62
62
|
|
63
|
-
it { expect(subject).to
|
63
|
+
it { expect(subject).to be_falsey }
|
64
64
|
end
|
65
65
|
|
66
66
|
context "error format" do
|
@@ -77,7 +77,7 @@ describe PagSeguro::Refund do
|
|
77
77
|
context "request return" do
|
78
78
|
subject { refund.request }
|
79
79
|
|
80
|
-
it { expect(subject).to
|
80
|
+
it { expect(subject).to be_falsey }
|
81
81
|
end
|
82
82
|
|
83
83
|
context "error format" do
|
@@ -0,0 +1,24 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe PagSeguro::Transaction::CreditorFees do
|
4
|
+
let(:xml) { MultiXml.parse(xml_file) }
|
5
|
+
|
6
|
+
let(:creditor_fee) do
|
7
|
+
PagSeguro::Transaction::CreditorFees.new(xml['creditorFees'])
|
8
|
+
end
|
9
|
+
|
10
|
+
subject { creditor_fee }
|
11
|
+
|
12
|
+
its(:installment_fee_amount) { should eq(1.00) }
|
13
|
+
its(:intermediation_rate_amount) { should eq(2.00) }
|
14
|
+
its(:intermediation_fee_amount) { should eq(27.15) }
|
15
|
+
its(:fee_amount) { should eq(30.15) }
|
16
|
+
|
17
|
+
let(:xml_file) {
|
18
|
+
"<creditorFees>
|
19
|
+
<installmentFeeAmount>1.00</installmentFeeAmount>
|
20
|
+
<intermediationRateAmount>2.00</intermediationRateAmount>
|
21
|
+
<intermediationFeeAmount>27.15</intermediationFeeAmount>
|
22
|
+
</creditorFees>"
|
23
|
+
}
|
24
|
+
end
|
@@ -3,32 +3,35 @@ require "spec_helper"
|
|
3
3
|
describe PagSeguro::Transaction do
|
4
4
|
let(:xml) { MultiXml.parse(xml_file) }
|
5
5
|
|
6
|
+
let(:xml_file) {
|
7
|
+
"<transaction>
|
8
|
+
<date>2011-02-05T15:46:12.000-02:00</date>
|
9
|
+
<lastEventDate>2011-02-15T17:39:14.000-03:00</lastEventDate>
|
10
|
+
<code>9E884542-81B3-4419-9A75-BCC6FB495EF1</code>
|
11
|
+
<reference>REF1234</reference>
|
12
|
+
<type>1</type>
|
13
|
+
<status>3</status>
|
14
|
+
<paymentLink>https://pagseguro.uol.com.br/checkout/imprimeBoleto.jhtml</paymentLink>
|
15
|
+
<grossAmount>49900.00</grossAmount>
|
16
|
+
<discountAmount>0.00</discountAmount>
|
17
|
+
<creditorFees>
|
18
|
+
<installmentFeeAmount>0.00</installmentFeeAmount>
|
19
|
+
<intermediationRateAmount>0.00</intermediationRateAmount>
|
20
|
+
<intermediationFeeAmount>27.15</intermediationFeeAmount>
|
21
|
+
</creditorFees>
|
22
|
+
<netAmount>49900.50</netAmount>
|
23
|
+
<extraAmount>0.00</extraAmount>
|
24
|
+
<installmentCount>1</installmentCount>
|
25
|
+
<escrowEndDate>2011-02-05T15:46:12.000-02:00</escrowEndDate>
|
26
|
+
<cancellationSource>INTERNAL</cancellationSource>
|
27
|
+
</transaction>"
|
28
|
+
}
|
29
|
+
|
6
30
|
let(:response) { PagSeguro::Transaction.new(xml) }
|
7
31
|
|
8
32
|
subject { response }
|
9
33
|
|
10
34
|
context "successful transaction" do
|
11
|
-
|
12
|
-
let(:xml_file) {
|
13
|
-
"<transaction>
|
14
|
-
<date>2011-02-05T15:46:12.000-02:00</date>
|
15
|
-
<lastEventDate>2011-02-15T17:39:14.000-03:00</lastEventDate>
|
16
|
-
<code>9E884542-81B3-4419-9A75-BCC6FB495EF1</code>
|
17
|
-
<reference>REF1234</reference>
|
18
|
-
<type>1</type>
|
19
|
-
<status>3</status>
|
20
|
-
<paymentLink>https://pagseguro.uol.com.br/checkout/imprimeBoleto.jhtml</paymentLink>
|
21
|
-
<grossAmount>49900.00</grossAmount>
|
22
|
-
<discountAmount>0.00</discountAmount>
|
23
|
-
<feeAmount>0.00</feeAmount>
|
24
|
-
<netAmount>49900.50</netAmount>
|
25
|
-
<extraAmount>0.00</extraAmount>
|
26
|
-
<installmentCount>1</installmentCount>
|
27
|
-
<escrowEndDate>2011-02-05T15:46:12.000-02:00</escrowEndDate>
|
28
|
-
<cancellationSource>INTERNAL</cancellationSource>
|
29
|
-
</transaction>"
|
30
|
-
}
|
31
|
-
|
32
35
|
it { should be_valid }
|
33
36
|
its(:date) { should eq('2011-02-05T15:46:12.000-02:00') }
|
34
37
|
its(:last_event_date) { should eq('2011-02-15T17:39:14.000-03:00') }
|
@@ -40,7 +43,7 @@ describe PagSeguro::Transaction do
|
|
40
43
|
its(:payment_link) { should eq('https://pagseguro.uol.com.br/checkout/imprimeBoleto.jhtml') }
|
41
44
|
its(:gross_amount) { should eq('49900.00') }
|
42
45
|
its(:discount_amount) { should eq("0.00") }
|
43
|
-
its(:fee_amount) { should eq(
|
46
|
+
its(:fee_amount) { should eq(27.15) }
|
44
47
|
its(:net_amount) { should eq('49900.50') }
|
45
48
|
its(:extra_amount) { should eq('0.00') }
|
46
49
|
its(:installment_count) { should eq("1") }
|
@@ -51,7 +54,13 @@ describe PagSeguro::Transaction do
|
|
51
54
|
its(:escrow_end_date) { should eq('2011-02-05T15:46:12.000-02:00') }
|
52
55
|
its(:cancellation_source) { should eq('INTERNAL') }
|
53
56
|
its(:errors) { should eq([]) }
|
57
|
+
end
|
54
58
|
|
59
|
+
context 'creditor_fees' do
|
60
|
+
it { expect(subject).to respond_to(:installment_fee_amount) }
|
61
|
+
it { expect(subject).to respond_to(:intermediation_rate_amount) }
|
62
|
+
it { expect(subject).to respond_to(:intermediation_fee_amount) }
|
63
|
+
it { expect(subject).to respond_to(:fee_amount) }
|
55
64
|
end
|
56
65
|
|
57
66
|
context "unsuccessfull transaction" do
|
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.
|
4
|
+
version: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Cirdes Henrique
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-03-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: activemodel
|
@@ -59,70 +59,84 @@ dependencies:
|
|
59
59
|
requirements:
|
60
60
|
- - "~>"
|
61
61
|
- !ruby/object:Gem::Version
|
62
|
-
version:
|
62
|
+
version: 1.8.2
|
63
63
|
type: :runtime
|
64
64
|
prerelease: false
|
65
65
|
version_requirements: !ruby/object:Gem::Requirement
|
66
66
|
requirements:
|
67
67
|
- - "~>"
|
68
68
|
- !ruby/object:Gem::Version
|
69
|
-
version:
|
69
|
+
version: 1.8.2
|
70
70
|
- !ruby/object:Gem::Dependency
|
71
71
|
name: i18n
|
72
72
|
requirement: !ruby/object:Gem::Requirement
|
73
73
|
requirements:
|
74
74
|
- - "~>"
|
75
75
|
- !ruby/object:Gem::Version
|
76
|
-
version: '0.
|
76
|
+
version: '0.7'
|
77
77
|
type: :runtime
|
78
78
|
prerelease: false
|
79
79
|
version_requirements: !ruby/object:Gem::Requirement
|
80
80
|
requirements:
|
81
81
|
- - "~>"
|
82
82
|
- !ruby/object:Gem::Version
|
83
|
-
version: '0.
|
83
|
+
version: '0.7'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: safe_yaml
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: 1.0.4
|
91
|
+
type: :runtime
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: 1.0.4
|
84
98
|
- !ruby/object:Gem::Dependency
|
85
99
|
name: bundler
|
86
100
|
requirement: !ruby/object:Gem::Requirement
|
87
101
|
requirements:
|
88
102
|
- - "~>"
|
89
103
|
- !ruby/object:Gem::Version
|
90
|
-
version: '1.
|
104
|
+
version: '1.8'
|
91
105
|
type: :development
|
92
106
|
prerelease: false
|
93
107
|
version_requirements: !ruby/object:Gem::Requirement
|
94
108
|
requirements:
|
95
109
|
- - "~>"
|
96
110
|
- !ruby/object:Gem::Version
|
97
|
-
version: '1.
|
111
|
+
version: '1.8'
|
98
112
|
- !ruby/object:Gem::Dependency
|
99
113
|
name: rake
|
100
114
|
requirement: !ruby/object:Gem::Requirement
|
101
115
|
requirements:
|
102
116
|
- - "~>"
|
103
117
|
- !ruby/object:Gem::Version
|
104
|
-
version: '10.
|
118
|
+
version: '10.4'
|
105
119
|
type: :development
|
106
120
|
prerelease: false
|
107
121
|
version_requirements: !ruby/object:Gem::Requirement
|
108
122
|
requirements:
|
109
123
|
- - "~>"
|
110
124
|
- !ruby/object:Gem::Version
|
111
|
-
version: '10.
|
125
|
+
version: '10.4'
|
112
126
|
- !ruby/object:Gem::Dependency
|
113
127
|
name: rspec
|
114
128
|
requirement: !ruby/object:Gem::Requirement
|
115
129
|
requirements:
|
116
130
|
- - "~>"
|
117
131
|
- !ruby/object:Gem::Version
|
118
|
-
version: '2.
|
132
|
+
version: '2.99'
|
119
133
|
type: :development
|
120
134
|
prerelease: false
|
121
135
|
version_requirements: !ruby/object:Gem::Requirement
|
122
136
|
requirements:
|
123
137
|
- - "~>"
|
124
138
|
- !ruby/object:Gem::Version
|
125
|
-
version: '2.
|
139
|
+
version: '2.99'
|
126
140
|
- !ruby/object:Gem::Dependency
|
127
141
|
name: shoulda-matchers
|
128
142
|
requirement: !ruby/object:Gem::Requirement
|
@@ -171,14 +185,14 @@ dependencies:
|
|
171
185
|
requirements:
|
172
186
|
- - "~>"
|
173
187
|
- !ruby/object:Gem::Version
|
174
|
-
version: '0.
|
188
|
+
version: '0.3'
|
175
189
|
type: :development
|
176
190
|
prerelease: false
|
177
191
|
version_requirements: !ruby/object:Gem::Requirement
|
178
192
|
requirements:
|
179
193
|
- - "~>"
|
180
194
|
- !ruby/object:Gem::Version
|
181
|
-
version: '0.
|
195
|
+
version: '0.3'
|
182
196
|
description: Integração com o novo checkout transparente do Pagseguro.
|
183
197
|
email:
|
184
198
|
- cirdes@gmail.com
|
@@ -221,6 +235,7 @@ files:
|
|
221
235
|
- lib/pagseguro/shipping.rb
|
222
236
|
- lib/pagseguro/transaction.rb
|
223
237
|
- lib/pagseguro/transaction/address.rb
|
238
|
+
- lib/pagseguro/transaction/creditor_fees.rb
|
224
239
|
- lib/pagseguro/transaction/item.rb
|
225
240
|
- lib/pagseguro/transaction/items.rb
|
226
241
|
- lib/pagseguro/transaction/payment_method.rb
|
@@ -249,6 +264,7 @@ files:
|
|
249
264
|
- spec/pagseguro/session_spec.rb
|
250
265
|
- spec/pagseguro/shipping_spec.rb
|
251
266
|
- spec/pagseguro/transaction/address_spec.rb
|
267
|
+
- spec/pagseguro/transaction/creditor_fees_spec.rb
|
252
268
|
- spec/pagseguro/transaction/item_spec.rb
|
253
269
|
- spec/pagseguro/transaction/items_spec.rb
|
254
270
|
- spec/pagseguro/transaction/payment_method_spec.rb
|
@@ -269,7 +285,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
269
285
|
requirements:
|
270
286
|
- - ">="
|
271
287
|
- !ruby/object:Gem::Version
|
272
|
-
version:
|
288
|
+
version: 2.0.0
|
273
289
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
274
290
|
requirements:
|
275
291
|
- - ">="
|
@@ -277,7 +293,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
277
293
|
version: '0'
|
278
294
|
requirements: []
|
279
295
|
rubyforge_project:
|
280
|
-
rubygems_version: 2.
|
296
|
+
rubygems_version: 2.4.5
|
281
297
|
signing_key:
|
282
298
|
specification_version: 4
|
283
299
|
summary: Integração com o novo checkout transparente do Pagseguro.
|
@@ -302,6 +318,7 @@ test_files:
|
|
302
318
|
- spec/pagseguro/session_spec.rb
|
303
319
|
- spec/pagseguro/shipping_spec.rb
|
304
320
|
- spec/pagseguro/transaction/address_spec.rb
|
321
|
+
- spec/pagseguro/transaction/creditor_fees_spec.rb
|
305
322
|
- spec/pagseguro/transaction/item_spec.rb
|
306
323
|
- spec/pagseguro/transaction/items_spec.rb
|
307
324
|
- spec/pagseguro/transaction/payment_method_spec.rb
|