catarse_pagarme 2.14.14 → 2.16.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile.lock +1 -1
- data/app/models/catarse_pagarme/antifraud_order_wrapper.rb +22 -22
- data/app/models/catarse_pagarme/credit_card_transaction.rb +2 -0
- data/app/models/catarse_pagarme/payment_delegator.rb +2 -3
- data/lib/catarse_pagarme/version.rb +1 -1
- metadata +4 -4
- data/app/models/catarse_pagarme/fee_calculator_concern.rb +0 -106
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 2548a2bfc6c26f6f079bd48daec8f8c43ecb8d34
|
4
|
+
data.tar.gz: fb599855e3ee3eb2781435a8a593646ac65c7323
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: bbe63f989ee9a0c6b0488b794cd7c74749f3e314f035e5e526b37e8a6940ee40343b6f9200211baa1a3956d28e033fa15d05c3066ac2523c24811af65bab9028
|
7
|
+
data.tar.gz: e8d539b1faf78690af42556e2a7b4b6440908b314b98213ff939717d9e86aeac4d117ca833c00278f254c17f657c740ac59968847f219cf7161af38a8b398e00
|
data/Gemfile.lock
CHANGED
@@ -59,9 +59,9 @@ module CatarsePagarme
|
|
59
59
|
|
60
60
|
def order_attributes
|
61
61
|
{
|
62
|
-
id: self.transaction.id.to_s,
|
62
|
+
id: self.transaction.id.to_s[0..99],
|
63
63
|
total_amount: self.attributes[:amount] / 100.0,
|
64
|
-
visitor: self.attributes.dig(:metadata, :contribution_id).to_s,
|
64
|
+
visitor: self.attributes.dig(:metadata, :contribution_id).to_s[0..40],
|
65
65
|
currency: 'BRL',
|
66
66
|
installments: self.attributes[:installments],
|
67
67
|
purchased_at: self.transaction.date_created,
|
@@ -74,10 +74,10 @@ module CatarsePagarme
|
|
74
74
|
tax_id = customer[:document_number].present? ? { tax_id: customer[:document_number] } : {}
|
75
75
|
|
76
76
|
{
|
77
|
-
id: customer[:id].to_s,
|
78
|
-
name: customer[:name],
|
79
|
-
email: customer[:email],
|
80
|
-
phone1: customer[:phone].to_h.values.join,
|
77
|
+
id: customer[:id].to_s[0..99],
|
78
|
+
name: customer[:name].to_s[0..99],
|
79
|
+
email: customer[:email].to_s[0..99],
|
80
|
+
phone1: customer[:phone].to_h.values.join.to_s[0..99],
|
81
81
|
created_at: self.attributes.dig(:antifraud_metadata, :register, :registered_at)
|
82
82
|
}.merge(tax_id)
|
83
83
|
end
|
@@ -95,33 +95,33 @@ module CatarsePagarme
|
|
95
95
|
def billing_address_attributes
|
96
96
|
billing_data = self.attributes.dig(:antifraud_metadata, :billing)
|
97
97
|
{
|
98
|
-
name: self.transaction.card.holder_name,
|
99
|
-
address1: billing_data.dig(:address, :street),
|
100
|
-
city: billing_data.dig(:address, :city),
|
101
|
-
state: billing_data.dig(:address, :state),
|
102
|
-
zip: billing_data.dig(:address, :zipcode),
|
103
|
-
country: billing_data.dig(:address, :country_code),
|
98
|
+
name: self.transaction.card.holder_name.to_s[0..99],
|
99
|
+
address1: billing_data.dig(:address, :street).to_s[0..254],
|
100
|
+
city: billing_data.dig(:address, :city).to_s[0..99],
|
101
|
+
state: billing_data.dig(:address, :state).to_s[0..99],
|
102
|
+
zip: billing_data.dig(:address, :zipcode).to_s[0..99],
|
103
|
+
country: billing_data.dig(:address, :country_code).to_s[0..1],
|
104
104
|
}
|
105
105
|
end
|
106
106
|
|
107
107
|
def shipping_address_attributes
|
108
108
|
shipping_data = self.attributes.dig(:antifraud_metadata, :shipping)
|
109
109
|
{
|
110
|
-
name: shipping_data.dig(:customer, :name),
|
111
|
-
address1: shipping_data.dig(:address, :street),
|
112
|
-
city: shipping_data.dig(:address, :city),
|
113
|
-
state: shipping_data.dig(:address, :state),
|
114
|
-
zip: shipping_data.dig(:address, :zipcode)
|
110
|
+
name: shipping_data.dig(:customer, :name).to_s[0..99],
|
111
|
+
address1: shipping_data.dig(:address, :street).to_s[0..254],
|
112
|
+
city: shipping_data.dig(:address, :city).to_s[0..99],
|
113
|
+
state: shipping_data.dig(:address, :state).to_s[0..99],
|
114
|
+
zip: shipping_data.dig(:address, :zipcode).to_s[0..99]
|
115
115
|
}
|
116
116
|
end
|
117
117
|
|
118
118
|
def item_attributes
|
119
119
|
shopping_cart_data = self.attributes.dig(:antifraud_metadata, :shopping_cart).first
|
120
120
|
{
|
121
|
-
sku: self.attributes.dig(:metadata, :contribution_id).to_s,
|
122
|
-
product_code: self.attributes.dig(:metadata, :contribution_id).to_s,
|
121
|
+
sku: self.attributes.dig(:metadata, :contribution_id).to_s[0..99],
|
122
|
+
product_code: self.attributes.dig(:metadata, :contribution_id).to_s[0..99],
|
123
123
|
category: 9999,
|
124
|
-
name: shopping_cart_data[:name],
|
124
|
+
name: shopping_cart_data[:name].to_s[0..99],
|
125
125
|
unit_cost: self.attributes[:amount] / 100.0,
|
126
126
|
quantity: 1,
|
127
127
|
created_at: self.attributes.dig(:metadata, :project_online).to_s[0..9]
|
@@ -131,8 +131,8 @@ module CatarsePagarme
|
|
131
131
|
def seller_attributes
|
132
132
|
event_data = self.attributes.dig(:antifraud_metadata, :events).first
|
133
133
|
{
|
134
|
-
id: event_data[:id],
|
135
|
-
name: event_data[:venue_name],
|
134
|
+
id: event_data[:id].to_s[0..99],
|
135
|
+
name: event_data[:venue_name].to_s[0..99],
|
136
136
|
created_at: event_data[:date]
|
137
137
|
}
|
138
138
|
end
|
@@ -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
|
@@ -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
|
-
|
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
|
34
|
+
PaymentEngines.import_payables(payment)
|
36
35
|
payment.save!
|
37
36
|
end
|
38
37
|
|
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
|
+
version: 2.16.3
|
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-
|
12
|
+
date: 2020-09-19 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
|
@@ -305,7 +304,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
305
304
|
- !ruby/object:Gem::Version
|
306
305
|
version: '0'
|
307
306
|
requirements: []
|
308
|
-
|
307
|
+
rubyforge_project:
|
308
|
+
rubygems_version: 2.6.14.1
|
309
309
|
signing_key:
|
310
310
|
specification_version: 4
|
311
311
|
summary: Integration with Pagar.me
|
@@ -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
|