catarse_pagarme 2.4.7 → 2.4.8

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 8b2dc18b893178e919d89e94cafdb79e61593f88
4
- data.tar.gz: c6d160bb2125ec861ffb382960dfb51d470341fe
3
+ metadata.gz: ec4bf46c08fd53a8f3ad81da416096e0e563afa2
4
+ data.tar.gz: d9261190185e65ca22869256d2fb2acbe942bfd6
5
5
  SHA512:
6
- metadata.gz: ed09efce5d14df55bf3fc7f7047802df835a1b2f62b3212b84d902d5ca7a2222ae90e2656817cb1dd2f09922c80dcb46c41882cc41851989374fd7ee3a79bf19
7
- data.tar.gz: 77fc5db5f5c615713915e45f12f55039c2e6dd2163617f05f756a811f2c2ac81ab4eceb1eb865f62b59de07649230025b8d711a064e4cd9b9af4f63b8f515f12
6
+ metadata.gz: f7851fb114360c92a62791d1dba99df0fa520f7c6ffce0db2a61f8ae43fd514d5387345f851282568de9c054554763f09b918bc03dddc9f09b864b4157f40020
7
+ data.tar.gz: e46c9c5d8c1ae7d387d80728f60e7d4821f3cee9a4e4ab3b871a077d34a4fae6ddba5192931f883ffbf8e9ae0961d21ed5584ac16a9355191e8e375f72a21e54
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- catarse_pagarme (2.4.7)
4
+ catarse_pagarme (2.4.8)
5
5
  pagarme (~> 1.9.8)
6
6
  rails (~> 4.0)
7
7
 
@@ -3,11 +3,13 @@ module CatarsePagarme::FeeCalculatorConcern
3
3
 
4
4
  included do
5
5
 
6
- def get_fee(payment_method, acquirer_name = nil)
7
- if payment_method == ::CatarsePagarme::PaymentType::SLIP
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 == 'stone'
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(payment_method, self.transaction.acquirer_name),
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
@@ -1,3 +1,3 @@
1
1
  module CatarsePagarme
2
- VERSION = "2.4.7"
2
+ VERSION = "2.4.8"
3
3
  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
- subject { delegator.get_fee(CatarsePagarme::PaymentType::SLIP).to_f }
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
- subject { delegator.get_fee(CatarsePagarme::PaymentType::CREDIT_CARD).to_f }
58
- it { expect(subject).to eq(0.83) }
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.7
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-23 00:00:00.000000000 Z
12
+ date: 2015-03-02 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails