catarse_pagarme 2.4.7 → 2.4.8
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ec4bf46c08fd53a8f3ad81da416096e0e563afa2
|
4
|
+
data.tar.gz: d9261190185e65ca22869256d2fb2acbe942bfd6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f7851fb114360c92a62791d1dba99df0fa520f7c6ffce0db2a61f8ae43fd514d5387345f851282568de9c054554763f09b918bc03dddc9f09b864b4157f40020
|
7
|
+
data.tar.gz: e46c9c5d8c1ae7d387d80728f60e7d4821f3cee9a4e4ab3b871a077d34a4fae6ddba5192931f883ffbf8e9ae0961d21ed5584ac16a9355191e8e375f72a21e54
|
data/Gemfile.lock
CHANGED
@@ -3,11 +3,13 @@ module CatarsePagarme::FeeCalculatorConcern
|
|
3
3
|
|
4
4
|
included do
|
5
5
|
|
6
|
-
def get_fee
|
7
|
-
if
|
6
|
+
def get_fee
|
7
|
+
return nil if self.contribution.payment_choice.blank? # We always depend on the payment_choice
|
8
|
+
if self.contribution.payment_choice == ::CatarsePagarme::PaymentType::SLIP
|
8
9
|
CatarsePagarme.configuration.slip_tax.to_f
|
9
10
|
else
|
10
|
-
if acquirer_name
|
11
|
+
return nil if self.contribution.acquirer_name.blank? # Here we depend on the acquirer name
|
12
|
+
if self.contribution.acquirer_name == 'stone'
|
11
13
|
self.contribution.installments > 1 ? tax_calc_for_installment(stone_tax) : tax_calc(stone_tax)
|
12
14
|
else
|
13
15
|
if self.contribution.card_brand == 'amex'
|
@@ -34,14 +34,15 @@ module CatarsePagarme
|
|
34
34
|
}
|
35
35
|
end
|
36
36
|
|
37
|
+
def delegator
|
38
|
+
self.contribution.pagarme_delegator
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
37
42
|
def update_fee
|
38
43
|
self.contribution.update_attributes({
|
39
|
-
payment_service_fee: delegator.get_fee
|
44
|
+
payment_service_fee: delegator.get_fee,
|
40
45
|
})
|
41
46
|
end
|
42
|
-
|
43
|
-
def delegator
|
44
|
-
self.contribution.pagarme_delegator
|
45
|
-
end
|
46
47
|
end
|
47
48
|
end
|
@@ -44,18 +44,33 @@ describe CatarsePagarme::ContributionDelegator do
|
|
44
44
|
CatarsePagarme.configuration.stub(:pagarme_tax).and_return(0.0063)
|
45
45
|
CatarsePagarme.configuration.stub(:cielo_tax).and_return(0.038)
|
46
46
|
CatarsePagarme.configuration.stub(:stone_tax).and_return(0.0307)
|
47
|
+
CatarsePagarme.configuration.stub(:credit_card_cents_fee).and_return(0.39)
|
47
48
|
|
48
49
|
delegator.stub(:transaction).and_return(fake_transaction)
|
49
50
|
end
|
50
51
|
|
52
|
+
context 'when choice is nil' do
|
53
|
+
let(:contribution) { create(:contribution, value: 10, payment_choice: nil) }
|
54
|
+
subject { delegator.get_fee }
|
55
|
+
it { expect(subject).to eq(nil) }
|
56
|
+
end
|
57
|
+
|
58
|
+
context 'when choice is credit card and acquirer_name is nil' do
|
59
|
+
let(:contribution) { create(:contribution, value: 10, payment_choice: CatarsePagarme::PaymentType::CREDIT_CARD, acquirer_name: nil) }
|
60
|
+
subject { delegator.get_fee }
|
61
|
+
it { expect(subject).to eq(nil) }
|
62
|
+
end
|
63
|
+
|
51
64
|
context 'when choice is slip' do
|
52
|
-
|
65
|
+
let(:contribution) { create(:contribution, value: 10, payment_choice: CatarsePagarme::PaymentType::SLIP, acquirer_name: nil) }
|
66
|
+
subject { delegator.get_fee }
|
53
67
|
it { expect(subject).to eq(2.00) }
|
54
68
|
end
|
55
69
|
|
56
70
|
context 'when choice is credit card' do
|
57
|
-
|
58
|
-
|
71
|
+
let(:contribution) { create(:contribution, value: 10, payment_choice: CatarsePagarme::PaymentType::CREDIT_CARD, acquirer_name: 'stone', card_brand: 'visa', installments: 1) }
|
72
|
+
subject { delegator.get_fee }
|
73
|
+
it { expect(subject).to eq(0.76) }
|
59
74
|
end
|
60
75
|
end
|
61
76
|
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: catarse_pagarme
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.4.
|
4
|
+
version: 2.4.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Antônio Roberto Silva
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-02
|
12
|
+
date: 2015-03-02 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|