catarse_pagarme 2.10.2 → 2.10.4

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: d92cef6d2e2207c5f2085a2608ae8fb391fc70eb
4
- data.tar.gz: 7e8c3e743cf8a0de16c60911ced7b2737645d885
3
+ metadata.gz: 6ef478d781c5314e5ea06725a0464fa6b8a61c5f
4
+ data.tar.gz: 415e0282212a4049794b59eae0eb2f709019aaa9
5
5
  SHA512:
6
- metadata.gz: 04070141b9c6c38b6424ca80767db10bcbe02775447c32b3de6eee58ae5077378e56581ae18df0d677857662e15d6f23c153ee9f037304cb4c72d8bf51e827f7
7
- data.tar.gz: 0043c6adc7d3782e8dac4a05b5508dad456b79ed771bcefd168c38b5122666a3af2ff1fe32ed6edbf78fdbbf9d4fa24e34dc72d604c44ada6b1b02b10458ff21
6
+ metadata.gz: 46a0cdbeb6b608be866b4f9b8f89cc0d89be53c4271bf0349024347827bde4d3078b6f207aeb10b0a37ee9d7f056c1015ed9206828a43c5b70b14567ebcc5d9e
7
+ data.tar.gz: e0da1d06e2b7e5c55904b2b9488088e666078a739107731ac970f07fcd91cd685d2b4f492612063a27db8421dccf1e049c48fecc894bc5ef71bbc233b63c89fd
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- catarse_pagarme (2.10.2)
4
+ catarse_pagarme (2.10.4)
5
5
  pagarme (= 2.1.4)
6
6
  rails (~> 4.0)
7
7
  sentry-raven
@@ -53,7 +53,7 @@ GEM
53
53
  connection_pool (2.2.1)
54
54
  database_cleaner (1.5.0)
55
55
  diff-lcs (1.2.5)
56
- domain_name (0.5.20161129)
56
+ domain_name (0.5.20170223)
57
57
  unf (>= 0.0.5, < 1.0.0)
58
58
  erubis (2.7.0)
59
59
  factory_girl (4.5.0)
@@ -123,7 +123,7 @@ GEM
123
123
  thor (>= 0.18.1, < 2.0)
124
124
  rake (10.4.2)
125
125
  redis (3.3.2)
126
- rest-client (2.0.0)
126
+ rest-client (2.0.1)
127
127
  http-cookie (>= 1.0.2, < 2.0)
128
128
  mime-types (>= 1.16, < 4.0)
129
129
  netrc (~> 0.8)
@@ -142,7 +142,6 @@ module CatarsePagarme
142
142
  def af_metadata
143
143
  return {} unless CatarsePagarme.configuration.use_simility
144
144
  project = contribution.project
145
- project_account = project.account
146
145
  user = contribution.user
147
146
 
148
147
  {
@@ -235,16 +234,16 @@ module CatarsePagarme
235
234
  name: contribution.project.name,
236
235
  type: contribution.project.mode == 'flex' ? 'flex' : 'full',
237
236
  date: contribution.project.expires_at.to_s,
238
- venue_name: project_account.try(:owner_name),
237
+ venue_name: project.user.name,
239
238
  address: {
240
239
  country: "Brasil",
241
- state: project_account.address_state,
242
- city: project_account.address_city,
243
- zipcode: project_account.address_zip_code,
244
- neighborhood: project_account.address_neighbourhood,
245
- street: project_account.address_street,
246
- street_number: project_account.address_number,
247
- complementary: project_account.address_complement,
240
+ state: project.user.address_state,
241
+ city: project.user.address_city,
242
+ zipcode: project.user.address_zip_code,
243
+ neighborhood: project.user.address_neighbourhood,
244
+ street: project.user.address_street,
245
+ street_number: project.user.address_number,
246
+ complementary: project.user.address_complement,
248
247
  latitude: 0.0,
249
248
  longitude: 0.0
250
249
  },
@@ -29,7 +29,8 @@ module CatarsePagarme
29
29
  end
30
30
 
31
31
  def bank_account_attributes
32
- account = balance_transfer.project.account
32
+ user = balance_transfer.user
33
+ account = user.bank_account
33
34
 
34
35
  bank_account_attrs = {
35
36
  bank_account: {
@@ -38,8 +39,9 @@ module CatarsePagarme
38
39
  agencia_dv: account.agency_digit,
39
40
  conta: account.account,
40
41
  conta_dv: account.account_digit,
41
- legal_name: account.owner_name[0..29],
42
- document_number: account.owner_document
42
+ legal_name: user.name[0..29],
43
+ document_number: user.cpf,
44
+ type: account.account_type
43
45
  }
44
46
  }
45
47
 
@@ -33,8 +33,9 @@ module CatarsePagarme::BankAccountConcern
33
33
  agencia: self.agency,
34
34
  conta: self.account,
35
35
  conta_dv: self.account_digit,
36
- legal_name: self.owner_name,
37
- document_number: self.owner_document
36
+ legal_name: self.user.name,
37
+ document_number: self.user.cpf,
38
+ type: self.account_type
38
39
  }
39
40
  pagarme_params[:agencia_dv] = self.agency_digit unless self.agency_digit.blank?
40
41
  pagarme_params
@@ -48,7 +49,8 @@ module CatarsePagarme::BankAccountConcern
48
49
  conta: :account,
49
50
  conta_dv: :account_digit,
50
51
  legal_name: :owner_name,
51
- document_number: :owner_document
52
+ document_number: :owner_document,
53
+ type: :account_type
52
54
  }
53
55
  end
54
56
 
@@ -120,7 +120,8 @@ module CatarsePagarme
120
120
  protected
121
121
 
122
122
  def bank_account_attributes
123
- bank = payment.user.bank_account
123
+ user = payment.user
124
+ bank = user.bank_account
124
125
 
125
126
  bank_account_attrs = {
126
127
  bank_account: {
@@ -129,8 +130,9 @@ module CatarsePagarme
129
130
  agencia_dv: bank.agency_digit,
130
131
  conta: bank.account,
131
132
  conta_dv: bank.account_digit,
132
- legal_name: bank.owner_name,
133
- document_number: bank.owner_document
133
+ legal_name: user.name[0..29],
134
+ document_number: user.cpf,
135
+ type: bank.account_type
134
136
  }
135
137
  }
136
138
 
@@ -5,7 +5,6 @@ module CatarsePagarme
5
5
  config.to_prepare do
6
6
  ::Payment.send(:include, CatarsePagarme::PaymentConcern)
7
7
  ::BalanceTransfer.send(:include, CatarsePagarme::BalanceTransferConcern)
8
- ::BalanceTransferPing.send(:include, CatarsePagarme::BalanceTransferPingConcern)
9
8
  end
10
9
  end
11
10
  end
@@ -1,3 +1,3 @@
1
1
  module CatarsePagarme
2
- VERSION = "2.10.2"
2
+ VERSION = "2.10.4"
3
3
  end
@@ -3,6 +3,8 @@ require 'spec_helper'
3
3
  describe CatarsePagarme::BalanceTransferDelegator do
4
4
  let(:project) { create(:project, state: 'successful') }
5
5
  let(:project_acc) { create(:project_account, project: project) }
6
+ let(:bank) { create(:bank) }
7
+ let!(:bank_account) { create(:bank_account, user: project.user)}
6
8
  let(:balance_transfer) { create(:balance_transfer, amount: 10, user: project.user, project: project)}
7
9
  let(:delegator) { balance_transfer.pagarme_delegator }
8
10
 
@@ -5,10 +5,11 @@ class FakeBankAccount < BankAccount
5
5
  end
6
6
 
7
7
  describe FakeBankAccount do
8
+ let(:user) { create(:user) }
8
9
  let(:bank) { create(:bank) }
9
10
 
10
11
  let(:valid_attr) do
11
- vb = build(:bank_account, bank: bank, owner_name: 'fo')
12
+ vb = build(:bank_account, bank: bank, owner_name: 'fo', user: user)
12
13
  vb.attributes
13
14
  end
14
15
 
@@ -21,6 +21,7 @@ FactoryGirl.define do
21
21
 
22
22
  factory :user do |f|
23
23
  f.name "Foo bar"
24
+ f.public_name "Foo bar"
24
25
  f.cpf "111.111.111-11"
25
26
  f.email { generate(:email) }
26
27
  end
@@ -62,6 +63,7 @@ FactoryGirl.define do
62
63
  f.agency_digit '2'
63
64
  f.owner_name 'Lorem amenori'
64
65
  f.owner_document '11111111111'
66
+ f.account_type 'conta_corrente'
65
67
  end
66
68
 
67
69
  factory :project do |f|
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.10.2
4
+ version: 2.10.4
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: 2017-02-13 00:00:00.000000000 Z
12
+ date: 2017-03-03 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -162,8 +162,6 @@ files:
162
162
  - app/helpers/catarse_pagarme/application_helper.rb
163
163
  - app/models/catarse_pagarme/balance_transfer_concern.rb
164
164
  - app/models/catarse_pagarme/balance_transfer_delegator.rb
165
- - app/models/catarse_pagarme/balance_transfer_ping_concern.rb
166
- - app/models/catarse_pagarme/balance_transfer_ping_delegator.rb
167
165
  - app/models/catarse_pagarme/bank_account_concern.rb
168
166
  - app/models/catarse_pagarme/credit_card_transaction.rb
169
167
  - app/models/catarse_pagarme/fee_calculator_concern.rb
@@ -199,7 +197,6 @@ files:
199
197
  - spec/dummy/app/mailers/.keep
200
198
  - spec/dummy/app/models/.keep
201
199
  - spec/dummy/app/models/balance_transfer.rb
202
- - spec/dummy/app/models/balance_transfer_ping.rb
203
200
  - spec/dummy/app/models/bank.rb
204
201
  - spec/dummy/app/models/bank_account.rb
205
202
  - spec/dummy/app/models/category.rb
@@ -298,7 +295,6 @@ test_files:
298
295
  - spec/dummy/app/mailers/.keep
299
296
  - spec/dummy/app/models/.keep
300
297
  - spec/dummy/app/models/balance_transfer.rb
301
- - spec/dummy/app/models/balance_transfer_ping.rb
302
298
  - spec/dummy/app/models/bank.rb
303
299
  - spec/dummy/app/models/bank_account.rb
304
300
  - spec/dummy/app/models/category.rb
@@ -1,9 +0,0 @@
1
- module CatarsePagarme::BalanceTransferPingConcern
2
- extend ActiveSupport::Concern
3
-
4
- included do
5
- def pagarme_delegator
6
- CatarsePagarme::BalanceTransferPingDelegator.new(self)
7
- end
8
- end
9
- end
@@ -1,59 +0,0 @@
1
- module CatarsePagarme
2
- class BalanceTransferPingDelegator
3
- attr_accessor :balance_transfer_ping, :transfer
4
-
5
- def initialize(balance_transfer_ping)
6
- configure_pagarme
7
- self.balance_transfer_ping = balance_transfer_ping
8
- end
9
-
10
- def transfer_funds
11
- ActiveRecord::Base.transaction do
12
- raise "unable to create transfer ping, need to be authorized" if !balance_transfer_ping.authorized?
13
-
14
- bank_account = PagarMe::BankAccount.new(bank_account_attributes.delete(:bank_account))
15
- bank_account.create
16
- raise "unable to create an bank account" unless bank_account.id.present?
17
-
18
- transfer = PagarMe::Transfer.new({
19
- bank_account_id: bank_account.id,
20
- amount: value_for_transaction
21
- })
22
- transfer.create
23
- raise "unable to create a transfer ping" unless transfer.id.present?
24
-
25
- balance_transfer_ping.update_attributes(transfer_id: transfer.id,
26
- metadata: transfer.to_hash,
27
- state: 'processing')
28
- balance_transfer_ping
29
- end
30
- end
31
-
32
- def bank_account_attributes
33
- account = balance_transfer_ping.balance_transfer.project.account
34
-
35
- bank_account_attrs = {
36
- bank_account: {
37
- bank_code: (account.bank.code || account.bank.name),
38
- agencia: account.agency,
39
- agencia_dv: account.agency_digit,
40
- conta: account.account,
41
- conta_dv: account.account_digit,
42
- legal_name: account.owner_name[0..29],
43
- document_number: account.owner_document
44
- }
45
- }
46
-
47
- bank_account_attrs[:bank_account].delete(:agencia_dv) if account.agency_digit.blank?
48
- return bank_account_attrs
49
- end
50
-
51
- def configure_pagarme
52
- ::PagarMe.api_key = CatarsePagarme.configuration.api_key
53
- end
54
-
55
- def value_for_transaction
56
- (self.balance_transfer_ping.amount * 100).to_i
57
- end
58
- end
59
- end
@@ -1,2 +0,0 @@
1
- class BalanceTransferPing < ActiveRecord::Base
2
- end