catarse_pagarme 2.14.13 → 2.16.2

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
  SHA256:
3
- metadata.gz: 49e29b96cb90884167e704aac825c48f4af388a557a2ff1f99f3075d600e2644
4
- data.tar.gz: 151e7effa7cf9dda5f58b64e3a597061857e3fce1e63baa5572be02b2bbe46d4
3
+ metadata.gz: adc06f64a7c86fb2853d12401bda4179708cd5eb65a7f73073c817fb14af08e8
4
+ data.tar.gz: 061fc971048552be99c8df628d3b29318179f8a915a50c6bdf26ebca4889b6a4
5
5
  SHA512:
6
- metadata.gz: b1c50a2cdee1962128500137b884eaa6f107cbad2c1339a1974d2f81e04b398817939b567eb512560f029cf6878681a098f53c5a20e8fcf86ded5d695a915a0e
7
- data.tar.gz: 630d6a3d226133e85f19af98ae6243f604fb850f4144e01048440e7ebc2ba95fd0166341f1a2b3c999abe2aa6a15a47a9921bf0bd948d49cf3b5628be438fb53
6
+ metadata.gz: ca30ba89cd28bc1746098958298faf8a2eda6bda1561af7d4b3708f1d24684de3f3d97336755cdeec18357f3897523f27329eb6cad8940acbad9fc7158865869
7
+ data.tar.gz: e070ac29be02557a7fb7b509dce0d5e8620ccc7611020bfcdaa012a3b096fbd45b5bac9f7ea36e1bca1b2b0c9cea968d17c9503e06cd165941f4983df914a780
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- catarse_pagarme (2.14.13)
4
+ catarse_pagarme (2.16.2)
5
5
  countries (= 3.0.0)
6
6
  konduto-ruby (= 2.1.0)
7
7
  pagarme (= 2.1.4)
@@ -19,20 +19,24 @@ module CatarsePagarme
19
19
  payment_method: payment.payment_method
20
20
  }
21
21
  )
22
- ::Raven.capture_exception(exception)
22
+ ::Raven.capture_exception(exception, level: 'fatal')
23
23
  ::Raven.user_context({})
24
24
  end
25
25
 
26
26
  def metadata_attributes
27
27
  {
28
28
  key: payment.generate_key,
29
- contribution_id: payment.contribution.id,
29
+ contribution_id: payment.contribution.id.to_s,
30
+ project_id: payment.project.id.to_s,
30
31
  project_name: payment.project.name,
31
32
  permalink: payment.project.permalink,
32
33
  project_online: payment.project.online_at,
33
34
  project_expires: payment.project.expires_at,
34
35
  user_total_contributions: payment.user.contributions.was_confirmed.count,
35
- user_id: payment.user.id
36
+ user_id: payment.user.id,
37
+ common_user_id: payment.user.common_id.to_s,
38
+ user_name: payment.user.name,
39
+ user_email: payment.user.email
36
40
  }
37
41
  end
38
42
 
@@ -46,7 +46,7 @@ module CatarsePagarme
46
46
  number: document_number
47
47
  }],
48
48
  },
49
- metadata: metadata_attributes
49
+ metadata: metadata_attributes.merge({ second_slip: payment.generating_second_slip.to_s })
50
50
  }
51
51
  end
52
52
 
@@ -8,6 +8,8 @@ module CatarsePagarme
8
8
  else
9
9
  antifraud_outcome = process_antifraud
10
10
 
11
+ self.payment.create_antifraud_analysis!(cost: CatarsePagarme.configuration.antifraud_tax)
12
+
11
13
  if antifraud_outcome.recommendation == :APPROVE
12
14
  self.transaction.capture
13
15
  elsif antifraud_outcome.recommendation == :DECLINE
@@ -33,7 +35,8 @@ module CatarsePagarme
33
35
  async: false,
34
36
  postback_url: self.attributes[:postback_url],
35
37
  installments: self.attributes[:installments],
36
- soft_descriptor: self.attributes[:soft_descriptor]
38
+ soft_descriptor: self.attributes[:soft_descriptor],
39
+ metadata: self.attributes[:metadata]
37
40
  }.merge(credit_card_identifier)
38
41
  )
39
42
 
@@ -1,14 +1,13 @@
1
1
  module CatarsePagarme
2
2
  class PaymentDelegator
3
3
  attr_accessor :payment, :transaction
4
- include FeeCalculatorConcern
5
4
 
6
5
  def initialize(payment)
7
6
  configure_pagarme
8
7
  self.payment = payment
9
8
  end
10
9
 
11
- def change_status_by_transaction(transaction_status)
10
+ def change_status_by_transaction(transaction_status)
12
11
  case transaction_status
13
12
  when 'pending_review' then
14
13
  self.payment.try(:notify_about_pending_review)
@@ -32,7 +31,7 @@ module CatarsePagarme
32
31
  def update_transaction
33
32
  fill_acquirer_data
34
33
  payment.installment_value = (value_for_installment / 100.0).to_f
35
- payment.gateway_fee = get_fee
34
+ PaymentEngines.import_payables(payment)
36
35
  payment.save!
37
36
  end
38
37
 
@@ -1,3 +1,3 @@
1
1
  module CatarsePagarme
2
- VERSION = "2.14.13"
2
+ VERSION = "2.16.2"
3
3
  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.14.13
4
+ version: 2.16.2
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: 2020-04-13 00:00:00.000000000 Z
12
+ date: 2020-07-16 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: countries
@@ -194,7 +194,6 @@ files:
194
194
  - app/models/catarse_pagarme/balance_transfer_delegator.rb
195
195
  - app/models/catarse_pagarme/bank_account_concern.rb
196
196
  - app/models/catarse_pagarme/credit_card_transaction.rb
197
- - app/models/catarse_pagarme/fee_calculator_concern.rb
198
197
  - app/models/catarse_pagarme/payment_concern.rb
199
198
  - app/models/catarse_pagarme/payment_delegator.rb
200
199
  - app/models/catarse_pagarme/payment_type.rb
@@ -1,106 +0,0 @@
1
- module CatarsePagarme::FeeCalculatorConcern
2
- extend ActiveSupport::Concern
3
-
4
- included do
5
-
6
- def get_fee
7
- return nil if self.payment.payment_method.blank? # We always depend on the payment_choice
8
- if self.payment.payment_method == ::CatarsePagarme::PaymentType::SLIP
9
- get_slip_fee
10
- else
11
- get_card_fee
12
- end
13
- end
14
-
15
- protected
16
- def get_slip_fee
17
- CatarsePagarme.configuration.slip_tax.to_f
18
- end
19
-
20
- def get_card_fee
21
- return nil if self.payment.gateway_data["acquirer_name"].blank? # Here we depend on the acquirer name
22
- fee = if %w(stone pagarme).include? self.payment.gateway_data["acquirer_name"]
23
- get_stone_fee
24
- else
25
- get_cielo_fee
26
- end
27
-
28
- fee + payment_cost
29
- end
30
-
31
- def payment_cost
32
- self.payment.gateway_data["cost"] / 100.0
33
- end
34
-
35
- def get_stone_fee
36
- self.payment.installments > 1 ? tax_calc_for_installment(stone_installment_tax) : tax_calc(stone_tax)
37
- end
38
-
39
- def get_cielo_fee
40
- return nil if self.payment.gateway_data["card_brand"].blank? # Here we depend on the card_brand
41
- if self.payment.gateway_data["card_brand"] == 'amex'
42
- get_cielo_fee_for_amex
43
- else
44
- get_cielo_fee_for_non_amex
45
- end
46
- end
47
-
48
- def get_cielo_fee_for_amex
49
- self.payment.installments > 1 ? tax_calc_for_installment(cielo_installment_amex_tax) : tax_calc(cielo_installment_not_amex_tax)
50
- end
51
-
52
- def get_cielo_fee_for_non_amex
53
- current_tax = self.payment.gateway_data["card_brand"] == 'diners' ? installment_diners_tax : installment_not_diners_tax
54
- self.payment.installments > 1 ? tax_calc_for_installment(current_tax) : tax_calc(cielo_tax)
55
- end
56
-
57
- def tax_calc acquirer_tax
58
- ((self.payment.value * pagarme_tax) + cents_fee).round(2) + (self.payment.value * acquirer_tax).round(2)
59
- end
60
-
61
- def tax_calc_for_installment acquirer_tax
62
- (((self.payment.installment_value * self.payment.installments) * pagarme_tax) + cents_fee).round(2) + ((self.payment.installment_value * acquirer_tax).round(2) * self.payment.installments)
63
- end
64
-
65
- def antifraud_tax
66
- CatarsePagarme.configuration.antifraud_tax.to_f
67
- end
68
-
69
- def cents_fee
70
- CatarsePagarme.configuration.credit_card_cents_fee.to_f
71
- end
72
-
73
- def pagarme_tax
74
- CatarsePagarme.configuration.pagarme_tax.to_f
75
- end
76
-
77
- def cielo_tax
78
- CatarsePagarme.configuration.cielo_tax.to_f
79
- end
80
-
81
- def stone_tax
82
- CatarsePagarme.configuration.stone_tax.to_f
83
- end
84
-
85
- def stone_installment_tax
86
- CatarsePagarme.configuration.stone_installment_tax.to_f
87
- end
88
-
89
- def installment_diners_tax
90
- CatarsePagarme.configuration.cielo_installment_diners_tax.to_f
91
- end
92
-
93
- def installment_not_diners_tax
94
- CatarsePagarme.configuration.cielo_installment_not_diners_tax.to_f
95
- end
96
-
97
- def cielo_installment_amex_tax
98
- CatarsePagarme.configuration.cielo_installment_amex_tax.to_f
99
- end
100
-
101
- def cielo_installment_not_amex_tax
102
- CatarsePagarme.configuration.cielo_installment_not_amex_tax.to_f
103
- end
104
-
105
- end
106
- end