catarse_pagarme 2.7.6 → 2.7.7
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/app/models/catarse_pagarme/fee_calculator_concern.rb +1 -1
- data/app/models/catarse_pagarme/payment_delegator.rb +9 -6
- data/lib/catarse_pagarme/version.rb +1 -1
- data/spec/controllers/catarse_pagarme/notifications_controller_spec.rb +3 -3
- data/spec/models/catarse_pagarme/payment_delegator_spec.rb +38 -1
- 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: 8e8bbb31e0174af0ee3e4de0efaea4c10fb0384b
|
4
|
+
data.tar.gz: 75c632f18a64aceddbad27ce548ec4550f5bb048
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 517aed8b6eb577a19a2d7d35d9f35c6049b0bf95b896c83da29f3e023fc73c4d15095d367faf5e2e9cb3c07b596a871250f58c813b8a4e6d20566c880a7edb90
|
7
|
+
data.tar.gz: b50189ff5a90b837c01f5b4db758f95b308be91c32c7f8cec04c865d71a89291ce2657c001f9e153b1492749612c300dc16df4a8f17c7e99a70e4a894524126e
|
data/Gemfile.lock
CHANGED
@@ -19,7 +19,7 @@ module CatarsePagarme::FeeCalculatorConcern
|
|
19
19
|
|
20
20
|
def get_card_fee
|
21
21
|
return nil if self.payment.gateway_data["acquirer_name"].blank? # Here we depend on the acquirer name
|
22
|
-
if self.payment.gateway_data["acquirer_name"]
|
22
|
+
if %w(stone pagarme).include? self.payment.gateway_data["acquirer_name"]
|
23
23
|
get_stone_fee
|
24
24
|
else
|
25
25
|
get_cielo_fee
|
@@ -69,12 +69,15 @@ module CatarsePagarme
|
|
69
69
|
end
|
70
70
|
|
71
71
|
def transaction
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
72
|
+
gateway_id = self.payment.gateway_id
|
73
|
+
raise "no gateway_id present" unless gateway_id.present?
|
74
|
+
|
75
|
+
@transaction ||= ::PagarMe::Transaction.find_by_id(gateway_id)
|
76
|
+
_transaction = @transaction.kind_of?(Array) ? @transaction.last : @transaction
|
77
|
+
|
78
|
+
raise "transaction gateway not match" unless _transaction.id == gateway_id
|
79
|
+
|
80
|
+
_transaction
|
78
81
|
end
|
79
82
|
|
80
83
|
def get_installment(installment_number)
|
@@ -1,7 +1,7 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
3
|
describe CatarsePagarme::NotificationsController do
|
4
|
-
let(:fake_transaction) { double("fake transaction", card_brand: 'visa', acquirer_name: 'stone', tid: '404040404', installments: 2) }
|
4
|
+
let(:fake_transaction) { double("fake transaction", id: payment.gateway_id, card_brand: 'visa', acquirer_name: 'stone', tid: '404040404', installments: 2) }
|
5
5
|
|
6
6
|
before do
|
7
7
|
PagarMe.stub(:validate_fingerprint).and_return(true)
|
@@ -10,8 +10,8 @@ describe CatarsePagarme::NotificationsController do
|
|
10
10
|
|
11
11
|
let(:project) { create(:project, goal: 10_000, state: 'online') }
|
12
12
|
let(:contribution) { create(:contribution, value: 10, project: project) }
|
13
|
-
let(:payment) {
|
14
|
-
p = contribution.payments.first
|
13
|
+
let(:payment) {
|
14
|
+
p = contribution.payments.first
|
15
15
|
p.update_attributes gateway_id: 'abcd'
|
16
16
|
p
|
17
17
|
}
|
@@ -4,7 +4,7 @@ describe CatarsePagarme::PaymentDelegator do
|
|
4
4
|
let(:contribution) { create(:contribution, value: 10) }
|
5
5
|
let(:payment) { contribution.payments.first }
|
6
6
|
let(:delegator) { payment.pagarme_delegator }
|
7
|
-
let(:fake_transaction) { double("fake transaction", card_brand: 'visa', acquirer_name: 'stone', tid: '404040404', installments: 2) }
|
7
|
+
let(:fake_transaction) { double("fake transaction", id: payment.gateway_id, card_brand: 'visa', acquirer_name: 'stone', tid: '404040404', installments: 2) }
|
8
8
|
|
9
9
|
before do
|
10
10
|
CatarsePagarme.configuration.stub(:slip_tax).and_return(2.00)
|
@@ -100,6 +100,43 @@ describe CatarsePagarme::PaymentDelegator do
|
|
100
100
|
end
|
101
101
|
end
|
102
102
|
|
103
|
+
describe "#transaction" do
|
104
|
+
before do
|
105
|
+
delegator.unstub(:transaction)#.and_return(fake_transaction)
|
106
|
+
allow(PagarMe::Transaction).to receive(:find_by_id).and_return(fake_transaction)
|
107
|
+
end
|
108
|
+
|
109
|
+
context "when payment.gateway id is null" do
|
110
|
+
before do
|
111
|
+
allow(payment).to receive(:gateway_id).and_return(nil)
|
112
|
+
end
|
113
|
+
|
114
|
+
it "expect to raises an error" do
|
115
|
+
expect {
|
116
|
+
delegator.transaction
|
117
|
+
}.to raise_error("no gateway_id present")
|
118
|
+
end
|
119
|
+
end
|
120
|
+
|
121
|
+
context "when transaction.id dont match with gateway_id" do
|
122
|
+
before do
|
123
|
+
allow(fake_transaction).to receive(:id).and_return("123")
|
124
|
+
end
|
125
|
+
|
126
|
+
it "expect to raises an error" do
|
127
|
+
expect {
|
128
|
+
delegator.transaction
|
129
|
+
}.to raise_error("transaction gateway not match")
|
130
|
+
end
|
131
|
+
end
|
132
|
+
|
133
|
+
context "when have correct transaction" do
|
134
|
+
it "should return the transaction object" do
|
135
|
+
expect(delegator.transaction).to eq(fake_transaction)
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
|
103
140
|
describe "#transfer_funds" do
|
104
141
|
let(:admin_user) { create(:user, admin: true) }
|
105
142
|
let(:transfer_mock) {
|
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.7.
|
4
|
+
version: 2.7.7
|
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-08-
|
12
|
+
date: 2015-08-12 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|