catarse_pagarme 2.7.13 → 2.7.14

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: 956cfd4d934cd4d2f5b60cd7f0477b5d59c8a447
4
- data.tar.gz: ca3fc2602768ed56c32fe2c9e3d4181998024d53
3
+ metadata.gz: 64917b88fa785e17b6a46b2fffe652e543e49658
4
+ data.tar.gz: d523792d29cd7f16899fa93aa25ecef903aaa122
5
5
  SHA512:
6
- metadata.gz: fc97dc2ffe2d9a191d64ea7a83cd051df9f63086ba336f7b1181022d25a75c36a19affe4e442101b0a4aa79293b0b9786bedd8f4cb5bb91eeb90f93e92196741
7
- data.tar.gz: d5d5b29730b43e8b9a27c6e706db54d1cc391e957cce9c459a4a116d2997fc6037b6ec921b0236eedf131c5c9c939fe769b8110d262df6917f72a1e2ad54260c
6
+ metadata.gz: d9572cf6e8483a30f8c920869405a93608985feb34ffd8acfa9e3f9a863cbc96a830d0979eb5e613f6ed8bc360ab5d68ce345f0f2286d9ad8d6df56d41f729ac
7
+ data.tar.gz: fbccfc7e54dc617e1c4a049837265d2b76c4200fbeb9579da5c7e80c10cdf3d72cf6fe9121765549fd7a9fa5069bf4449ea78042fd8e00037b2a26d58ff8faf1
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- catarse_pagarme (2.7.13)
4
+ catarse_pagarme (2.7.14)
5
5
  pagarme (= 1.10.0)
6
6
  rails (~> 4.0)
7
7
  sidekiq
@@ -96,10 +96,8 @@ module CatarsePagarme
96
96
  end
97
97
 
98
98
  # Transfer payment amount to payer bank account via transfers API
99
- # Params:
100
- # +authorized_by+:: +User+ object that authorize this transfer
101
- def transfer_funds(authorized_by)
102
- raise 'must be admin to perform this action' unless authorized_by.try(:admin?)
99
+ def transfer_funds
100
+ raise "payment must be paid" if !payment.paid?
103
101
 
104
102
  bank_account = PagarMe::BankAccount.new(bank_account_attributes.delete(:bank_account))
105
103
  bank_account.create
@@ -112,10 +110,12 @@ module CatarsePagarme
112
110
  transfer.create
113
111
 
114
112
  payment.payment_transfers.create!({
115
- user: authorized_by,
113
+ user: payment.user,
116
114
  transfer_id: transfer.id,
117
115
  transfer_data: transfer.to_json
118
116
  })
117
+ #avoid sending notification
118
+ payment.update_attributes(state: 'pending_refund')
119
119
  end
120
120
 
121
121
  protected
@@ -20,6 +20,10 @@ module CatarsePagarme
20
20
  contribution.pagarme_delegator.refund
21
21
  end
22
22
 
23
+ def transfer contribution
24
+ contribution.pagarme_delegator.transfer_funds
25
+ end
26
+
23
27
  def can_generate_second_slip?
24
28
  true
25
29
  end
@@ -36,3 +40,4 @@ module CatarsePagarme
36
40
  end
37
41
  end
38
42
  end
43
+
@@ -1,3 +1,3 @@
1
1
  module CatarsePagarme
2
- VERSION = "2.7.13"
2
+ VERSION = "2.7.14"
3
3
  end
@@ -139,20 +139,18 @@ describe CatarsePagarme::PaymentDelegator do
139
139
  end
140
140
 
141
141
  describe "#transfer_funds" do
142
- let(:admin_user) { create(:user, admin: true) }
143
142
  let(:transfer_mock) { double(create: true, id: "123", to_json: {id: '123'}.to_json) }
144
143
  before do
145
144
  allow(PagarMe::Transfer).to receive(:new).and_return(transfer_mock)
146
145
  create(:bank_account, user: payment.user)
147
- allow(payment.user).to receive(:admin?).and_return(true)
148
146
  end
149
147
 
150
148
  it do
151
- transfer = delegator.transfer_funds(admin_user)
149
+ transfer = delegator.transfer_funds
152
150
 
153
151
  expect(payment.payment_transfers.count).to eq(1)
154
152
  expect(transfer.payment).to eq(payment)
155
- expect(transfer.user).to eq(admin_user)
153
+ expect(transfer.user).to eq(payment.user)
156
154
  expect(transfer.transfer_id).to eq(transfer.transfer_data["id"])
157
155
  end
158
156
  end
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.13
4
+ version: 2.7.14
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-10-06 00:00:00.000000000 Z
12
+ date: 2015-10-08 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails