catarse_pagarme 2.16.0 → 3.0.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/Gemfile.lock +117 -109
- data/app/controllers/catarse_pagarme/application_controller.rb +2 -2
- data/app/controllers/catarse_pagarme/notifications_controller.rb +1 -1
- data/app/models/catarse_pagarme/antifraud_order_wrapper.rb +22 -22
- data/app/models/catarse_pagarme/balance_transfer_delegator.rb +1 -1
- data/app/models/catarse_pagarme/credit_card_transaction.rb +1 -1
- data/app/models/catarse_pagarme/payment_delegator.rb +3 -4
- data/app/models/catarse_pagarme/slip_transaction.rb +3 -2
- data/app/models/catarse_pagarme/transaction_base.rb +1 -1
- data/app/workers/catarse_pagarme/verify_pagarme_worker.rb +1 -1
- data/catarse_pagarme.gemspec +1 -2
- data/lib/catarse_pagarme.rb +0 -1
- data/lib/catarse_pagarme/version.rb +1 -1
- data/spec/controllers/catarse_pagarme/credit_cards_controller_spec.rb +1 -1
- data/spec/controllers/catarse_pagarme/notifications_controller_spec.rb +1 -2
- data/spec/models/catarse_pagarme/slip_transaction_spec.rb +1 -1
- data/spec/support/factories.rb +1 -3
- data/spec/workers/catarse_pagarme/verify_pagarme_worker_spec.rb +1 -2
- metadata +8 -22
- data/app/models/catarse_pagarme/fee_calculator_concern.rb +0 -21
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA1:
|
3
|
+
metadata.gz: 0e7be854657adedb16a5144be548f82a1d4afb2a
|
4
|
+
data.tar.gz: fcc26b9e7c29296a0f0718fb763714446a1b0ad7
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: be12e118913110b6a09a4003c7e1d7721c78e235b4453868f8b8e2ade9742939999223fb8f4df1e14b7d3714666efd361ebe96089ef3866569fe71c24104a9da
|
7
|
+
data.tar.gz: 744fc8c23ccfb2e2e65bc2f21c8ca6a1e43e1a1cdf1309161a1bea1b3b22118d131c258c4436d8c91a1eed9c2f27d769f5456c005f6cf5c1c13c1dce5922aa03
|
data/Gemfile.lock
CHANGED
@@ -1,11 +1,10 @@
|
|
1
1
|
PATH
|
2
2
|
remote: .
|
3
3
|
specs:
|
4
|
-
catarse_pagarme (
|
5
|
-
countries (= 3.0.0)
|
4
|
+
catarse_pagarme (3.0.1)
|
6
5
|
konduto-ruby (= 2.1.0)
|
7
6
|
pagarme (= 2.1.4)
|
8
|
-
rails
|
7
|
+
rails
|
9
8
|
sentry-raven
|
10
9
|
sidekiq
|
11
10
|
weekdays (>= 1.0.2)
|
@@ -13,171 +12,180 @@ PATH
|
|
13
12
|
GEM
|
14
13
|
remote: https://rubygems.org/
|
15
14
|
specs:
|
16
|
-
|
17
|
-
actionpack (=
|
18
|
-
|
19
|
-
|
15
|
+
actioncable (5.2.4.3)
|
16
|
+
actionpack (= 5.2.4.3)
|
17
|
+
nio4r (~> 2.0)
|
18
|
+
websocket-driver (>= 0.6.1)
|
19
|
+
actionmailer (5.2.4.3)
|
20
|
+
actionpack (= 5.2.4.3)
|
21
|
+
actionview (= 5.2.4.3)
|
22
|
+
activejob (= 5.2.4.3)
|
20
23
|
mail (~> 2.5, >= 2.5.4)
|
21
|
-
rails-dom-testing (~>
|
22
|
-
actionpack (
|
23
|
-
actionview (=
|
24
|
-
activesupport (=
|
25
|
-
rack (~>
|
26
|
-
rack-test (
|
27
|
-
rails-dom-testing (~>
|
24
|
+
rails-dom-testing (~> 2.0)
|
25
|
+
actionpack (5.2.4.3)
|
26
|
+
actionview (= 5.2.4.3)
|
27
|
+
activesupport (= 5.2.4.3)
|
28
|
+
rack (~> 2.0, >= 2.0.8)
|
29
|
+
rack-test (>= 0.6.3)
|
30
|
+
rails-dom-testing (~> 2.0)
|
28
31
|
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
29
|
-
actionview (
|
30
|
-
activesupport (=
|
32
|
+
actionview (5.2.4.3)
|
33
|
+
activesupport (= 5.2.4.3)
|
31
34
|
builder (~> 3.1)
|
32
|
-
|
33
|
-
rails-dom-testing (~>
|
35
|
+
erubi (~> 1.4)
|
36
|
+
rails-dom-testing (~> 2.0)
|
34
37
|
rails-html-sanitizer (~> 1.0, >= 1.0.3)
|
35
|
-
activejob (
|
36
|
-
activesupport (=
|
37
|
-
globalid (>= 0.3.
|
38
|
-
activemodel (
|
39
|
-
activesupport (=
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
38
|
+
activejob (5.2.4.3)
|
39
|
+
activesupport (= 5.2.4.3)
|
40
|
+
globalid (>= 0.3.6)
|
41
|
+
activemodel (5.2.4.3)
|
42
|
+
activesupport (= 5.2.4.3)
|
43
|
+
activerecord (5.2.4.3)
|
44
|
+
activemodel (= 5.2.4.3)
|
45
|
+
activesupport (= 5.2.4.3)
|
46
|
+
arel (>= 9.0)
|
47
|
+
activestorage (5.2.4.3)
|
48
|
+
actionpack (= 5.2.4.3)
|
49
|
+
activerecord (= 5.2.4.3)
|
50
|
+
marcel (~> 0.3.1)
|
51
|
+
activesupport (5.2.4.3)
|
52
|
+
concurrent-ruby (~> 1.0, >= 1.0.2)
|
53
|
+
i18n (>= 0.7, < 2)
|
47
54
|
minitest (~> 5.1)
|
48
|
-
thread_safe (~> 0.3, >= 0.3.4)
|
49
55
|
tzinfo (~> 1.1)
|
50
|
-
arel (
|
51
|
-
builder (3.2.
|
52
|
-
coderay (1.1.
|
53
|
-
concurrent-ruby (1.
|
54
|
-
connection_pool (2.2.
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
unicode_utils (~> 1.4)
|
59
|
-
crass (1.0.4)
|
60
|
-
database_cleaner (1.7.0)
|
61
|
-
diff-lcs (1.3)
|
56
|
+
arel (9.0.0)
|
57
|
+
builder (3.2.4)
|
58
|
+
coderay (1.1.3)
|
59
|
+
concurrent-ruby (1.1.6)
|
60
|
+
connection_pool (2.2.3)
|
61
|
+
crass (1.0.6)
|
62
|
+
database_cleaner (1.8.5)
|
63
|
+
diff-lcs (1.4.4)
|
62
64
|
domain_name (0.5.20190701)
|
63
65
|
unf (>= 0.0.5, < 1.0.0)
|
64
|
-
|
66
|
+
erubi (1.9.0)
|
65
67
|
factory_girl (4.9.0)
|
66
68
|
activesupport (>= 3.0.0)
|
67
69
|
factory_girl_rails (4.9.0)
|
68
70
|
factory_girl (~> 4.9.0)
|
69
71
|
railties (>= 3.0.0)
|
70
|
-
faraday (1.0
|
72
|
+
faraday (1.1.0)
|
71
73
|
multipart-post (>= 1.2, < 3)
|
74
|
+
ruby2_keywords
|
72
75
|
globalid (0.4.2)
|
73
76
|
activesupport (>= 4.2.0)
|
74
77
|
http-accept (1.7.0)
|
75
78
|
http-cookie (1.0.3)
|
76
79
|
domain_name (~> 0.5)
|
77
|
-
i18n (
|
80
|
+
i18n (1.8.3)
|
78
81
|
concurrent-ruby (~> 1.0)
|
79
|
-
i18n_data (0.8.0)
|
80
82
|
konduto-ruby (2.1.0)
|
81
|
-
loofah (2.
|
83
|
+
loofah (2.6.0)
|
82
84
|
crass (~> 1.0.2)
|
83
85
|
nokogiri (>= 1.5.9)
|
84
86
|
mail (2.7.1)
|
85
87
|
mini_mime (>= 0.1.1)
|
86
|
-
|
88
|
+
marcel (0.3.3)
|
89
|
+
mimemagic (~> 0.3.2)
|
90
|
+
method_source (1.0.0)
|
87
91
|
mime-types (3.3.1)
|
88
92
|
mime-types-data (~> 3.2015)
|
89
|
-
mime-types-data (3.
|
93
|
+
mime-types-data (3.2020.0512)
|
94
|
+
mimemagic (0.3.5)
|
90
95
|
mini_mime (1.0.2)
|
91
|
-
mini_portile2 (2.
|
92
|
-
minitest (5.
|
93
|
-
multi_json (1.
|
96
|
+
mini_portile2 (2.4.0)
|
97
|
+
minitest (5.14.1)
|
98
|
+
multi_json (1.15.0)
|
94
99
|
multipart-post (2.1.1)
|
95
100
|
netrc (0.11.0)
|
96
|
-
|
97
|
-
|
101
|
+
nio4r (2.5.4)
|
102
|
+
nokogiri (1.10.9)
|
103
|
+
mini_portile2 (~> 2.4.0)
|
98
104
|
pagarme (2.1.4)
|
99
105
|
multi_json
|
100
106
|
rest-client
|
101
|
-
pg (
|
102
|
-
pry (0.
|
103
|
-
coderay (~> 1.1
|
104
|
-
method_source (~>
|
105
|
-
rack (
|
106
|
-
rack-protection (2.0
|
107
|
+
pg (1.2.3)
|
108
|
+
pry (0.13.1)
|
109
|
+
coderay (~> 1.1)
|
110
|
+
method_source (~> 1.0)
|
111
|
+
rack (2.2.3)
|
112
|
+
rack-protection (2.1.0)
|
107
113
|
rack
|
108
|
-
rack-test (
|
109
|
-
rack (>= 1.0)
|
110
|
-
rails (
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
|
116
|
-
|
117
|
-
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
122
|
-
|
123
|
-
rails-dom-testing (
|
124
|
-
activesupport (>= 4.2.0
|
125
|
-
nokogiri (
|
126
|
-
|
127
|
-
|
128
|
-
|
129
|
-
|
130
|
-
|
131
|
-
|
114
|
+
rack-test (1.1.0)
|
115
|
+
rack (>= 1.0, < 3)
|
116
|
+
rails (5.2.4.3)
|
117
|
+
actioncable (= 5.2.4.3)
|
118
|
+
actionmailer (= 5.2.4.3)
|
119
|
+
actionpack (= 5.2.4.3)
|
120
|
+
actionview (= 5.2.4.3)
|
121
|
+
activejob (= 5.2.4.3)
|
122
|
+
activemodel (= 5.2.4.3)
|
123
|
+
activerecord (= 5.2.4.3)
|
124
|
+
activestorage (= 5.2.4.3)
|
125
|
+
activesupport (= 5.2.4.3)
|
126
|
+
bundler (>= 1.3.0)
|
127
|
+
railties (= 5.2.4.3)
|
128
|
+
sprockets-rails (>= 2.0.0)
|
129
|
+
rails-dom-testing (2.0.3)
|
130
|
+
activesupport (>= 4.2.0)
|
131
|
+
nokogiri (>= 1.6)
|
132
|
+
rails-html-sanitizer (1.3.0)
|
133
|
+
loofah (~> 2.3)
|
134
|
+
railties (5.2.4.3)
|
135
|
+
actionpack (= 5.2.4.3)
|
136
|
+
activesupport (= 5.2.4.3)
|
137
|
+
method_source
|
132
138
|
rake (>= 0.8.7)
|
133
|
-
thor (>= 0.
|
134
|
-
rake (
|
135
|
-
redis (4.1.
|
139
|
+
thor (>= 0.19.0, < 2.0)
|
140
|
+
rake (13.0.1)
|
141
|
+
redis (4.1.4)
|
136
142
|
rest-client (2.1.0)
|
137
143
|
http-accept (>= 1.7.0, < 2.0)
|
138
144
|
http-cookie (>= 1.0.2, < 2.0)
|
139
145
|
mime-types (>= 1.16, < 4.0)
|
140
146
|
netrc (~> 0.8)
|
141
|
-
rspec-core (3.
|
142
|
-
rspec-support (~> 3.
|
143
|
-
rspec-expectations (3.
|
147
|
+
rspec-core (3.9.2)
|
148
|
+
rspec-support (~> 3.9.3)
|
149
|
+
rspec-expectations (3.9.2)
|
144
150
|
diff-lcs (>= 1.2.0, < 2.0)
|
145
|
-
rspec-support (~> 3.
|
146
|
-
rspec-mocks (3.
|
151
|
+
rspec-support (~> 3.9.0)
|
152
|
+
rspec-mocks (3.9.1)
|
147
153
|
diff-lcs (>= 1.2.0, < 2.0)
|
148
|
-
rspec-support (~> 3.
|
149
|
-
rspec-rails (3.
|
154
|
+
rspec-support (~> 3.9.0)
|
155
|
+
rspec-rails (3.9.1)
|
150
156
|
actionpack (>= 3.0)
|
151
157
|
activesupport (>= 3.0)
|
152
158
|
railties (>= 3.0)
|
153
|
-
rspec-core (~> 3.
|
154
|
-
rspec-expectations (~> 3.
|
155
|
-
rspec-mocks (~> 3.
|
156
|
-
rspec-support (~> 3.
|
157
|
-
rspec-support (3.
|
158
|
-
|
159
|
+
rspec-core (~> 3.9.0)
|
160
|
+
rspec-expectations (~> 3.9.0)
|
161
|
+
rspec-mocks (~> 3.9.0)
|
162
|
+
rspec-support (~> 3.9.0)
|
163
|
+
rspec-support (3.9.3)
|
164
|
+
ruby2_keywords (0.0.2)
|
165
|
+
sentry-raven (3.1.1)
|
159
166
|
faraday (>= 1.0)
|
160
|
-
sidekiq (5.2.
|
167
|
+
sidekiq (5.2.9)
|
161
168
|
connection_pool (~> 2.2, >= 2.2.2)
|
162
|
-
rack (
|
169
|
+
rack (~> 2.0)
|
163
170
|
rack-protection (>= 1.5.0)
|
164
|
-
redis (>= 3.3.5, <
|
165
|
-
sixarm_ruby_unaccent (1.2.0)
|
171
|
+
redis (>= 3.3.5, < 4.2)
|
166
172
|
sprockets (3.7.2)
|
167
173
|
concurrent-ruby (~> 1.0)
|
168
174
|
rack (> 1, < 3)
|
169
|
-
sprockets-rails (3.2.
|
175
|
+
sprockets-rails (3.2.2)
|
170
176
|
actionpack (>= 4.0)
|
171
177
|
activesupport (>= 4.0)
|
172
178
|
sprockets (>= 3.0.0)
|
173
|
-
thor (0.
|
179
|
+
thor (1.0.1)
|
174
180
|
thread_safe (0.3.6)
|
175
|
-
tzinfo (1.2.
|
181
|
+
tzinfo (1.2.7)
|
176
182
|
thread_safe (~> 0.1)
|
177
183
|
unf (0.1.4)
|
178
184
|
unf_ext
|
179
185
|
unf_ext (0.0.7.7)
|
180
|
-
|
186
|
+
websocket-driver (0.7.3)
|
187
|
+
websocket-extensions (>= 0.1.0)
|
188
|
+
websocket-extensions (0.1.5)
|
181
189
|
weekdays (1.0.2)
|
182
190
|
|
183
191
|
PLATFORMS
|
@@ -3,8 +3,8 @@ require "pagarme"
|
|
3
3
|
module CatarsePagarme
|
4
4
|
class ApplicationController < ActionController::Base
|
5
5
|
|
6
|
-
|
7
|
-
|
6
|
+
before_action :authenticate_user!
|
7
|
+
before_action :configure_pagarme
|
8
8
|
helper_method :payment
|
9
9
|
layout :false
|
10
10
|
|
@@ -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
|
@@ -26,7 +26,7 @@ module CatarsePagarme
|
|
26
26
|
transfer.create
|
27
27
|
raise "unable to create a transfer" unless transfer.id.present?
|
28
28
|
|
29
|
-
balance_transfer.
|
29
|
+
balance_transfer.update(transfer_id: transfer.id)
|
30
30
|
balance_transfer.transition_to(:processing, transfer_data: transfer.to_hash)
|
31
31
|
balance_transfer
|
32
32
|
end
|
@@ -40,7 +40,7 @@ module CatarsePagarme
|
|
40
40
|
}.merge(credit_card_identifier)
|
41
41
|
)
|
42
42
|
|
43
|
-
unless payment.
|
43
|
+
unless payment.update(gateway: 'Pagarme', payment_method: payment_method)
|
44
44
|
raise ::PagarMe::PagarMeError.new(payment.errors.messages.values.flatten.to_sentence)
|
45
45
|
end
|
46
46
|
|
@@ -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
|
|
@@ -128,7 +127,7 @@ module CatarsePagarme
|
|
128
127
|
raise "unable to create a transfer" unless transfer.id.present?
|
129
128
|
|
130
129
|
#avoid sending notification
|
131
|
-
payment.
|
130
|
+
payment.update(state: 'pending_refund')
|
132
131
|
payment.payment_transfers.create!({
|
133
132
|
user: payment.user,
|
134
133
|
transfer_id: transfer.id,
|
@@ -1,9 +1,10 @@
|
|
1
1
|
module CatarsePagarme
|
2
2
|
class SlipTransaction < TransactionBase
|
3
3
|
def charge!
|
4
|
-
unless payment.
|
4
|
+
unless payment.update(
|
5
5
|
gateway: 'Pagarme',
|
6
|
-
payment_method: payment_method
|
6
|
+
payment_method: payment_method
|
7
|
+
)
|
7
8
|
|
8
9
|
raise ::PagarMe::PagarMeError.new(
|
9
10
|
payment.errors.messages.values.flatten.to_sentence)
|
@@ -10,7 +10,7 @@ module CatarsePagarme
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def change_payment_state
|
13
|
-
self.payment.
|
13
|
+
self.payment.update(attributes_to_payment)
|
14
14
|
self.payment.save!
|
15
15
|
delegator.update_transaction
|
16
16
|
self.payment.payment_notifications.create(contribution_id: self.payment.contribution_id, extra_data: self.transaction.to_json)
|
@@ -9,7 +9,7 @@ class CatarsePagarme::VerifyPagarmeWorker
|
|
9
9
|
raise "payment not found" unless payment.present?
|
10
10
|
raise "source not found" unless source.present? && source.try(:[], "metadata").try(:[], "key") == key
|
11
11
|
|
12
|
-
payment.
|
12
|
+
payment.update(gateway_id: source["id"])
|
13
13
|
payment.pagarme_delegator.update_transaction
|
14
14
|
payment.pagarme_delegator.change_status_by_transaction source["status"]
|
15
15
|
end
|
data/catarse_pagarme.gemspec
CHANGED
@@ -17,8 +17,7 @@ Gem::Specification.new do |s|
|
|
17
17
|
s.files = `git ls-files`.split($\)
|
18
18
|
s.test_files = s.files.grep(%r{^(test|spec|features)/})
|
19
19
|
|
20
|
-
s.add_dependency "
|
21
|
-
s.add_dependency "rails", "~> 4.0"
|
20
|
+
s.add_dependency "rails"
|
22
21
|
s.add_dependency "pagarme", "2.1.4"
|
23
22
|
s.add_dependency "konduto-ruby", "2.1.0"
|
24
23
|
s.add_dependency "weekdays", ">= 1.0.2"
|
data/lib/catarse_pagarme.rb
CHANGED
@@ -11,7 +11,7 @@ describe CatarsePagarme::CreditCardsController, type: :controller do
|
|
11
11
|
let(:payment) do
|
12
12
|
contribution.reload
|
13
13
|
p = contribution.payments.first
|
14
|
-
#p.
|
14
|
+
#p.update(state: 'pending', gateway_id: nil)
|
15
15
|
p
|
16
16
|
end
|
17
17
|
|
@@ -13,7 +13,7 @@ describe CatarsePagarme::NotificationsController, type: :controller do
|
|
13
13
|
let(:contribution) { create(:contribution, value: 10, project: project) }
|
14
14
|
let(:payment) {
|
15
15
|
p = contribution.payments.first
|
16
|
-
p.
|
16
|
+
p.update gateway_id: 'abcd'
|
17
17
|
p
|
18
18
|
}
|
19
19
|
let(:credit_card) { create(:credit_card, subscription_id: '1542')}
|
@@ -48,4 +48,3 @@ describe CatarsePagarme::NotificationsController, type: :controller do
|
|
48
48
|
end
|
49
49
|
|
50
50
|
end
|
51
|
-
|
@@ -66,7 +66,7 @@ describe CatarsePagarme::SlipTransaction do
|
|
66
66
|
|
67
67
|
context "with valid attributes" do
|
68
68
|
before do
|
69
|
-
payment.should_receive(:
|
69
|
+
payment.should_receive(:update).at_least(1).and_call_original
|
70
70
|
PagarMe::Transaction.should_receive(:find_by_id).with(pagarme_transaction.id).and_return(pagarme_transaction)
|
71
71
|
CatarsePagarme::PaymentDelegator.any_instance.should_receive(:change_status_by_transaction).with('paid')
|
72
72
|
|
data/spec/support/factories.rb
CHANGED
@@ -70,7 +70,7 @@ FactoryGirl.define do
|
|
70
70
|
#after(:create) do |project|
|
71
71
|
# create(:reward, project: project)
|
72
72
|
# if project.state == 'change_to_online_after_create'
|
73
|
-
# project.
|
73
|
+
# project.update(state: 'online')
|
74
74
|
# end
|
75
75
|
#end
|
76
76
|
f.name "Foo bar"
|
@@ -190,5 +190,3 @@ FactoryGirl.define do
|
|
190
190
|
f.name "foo"
|
191
191
|
end
|
192
192
|
end
|
193
|
-
|
194
|
-
|
@@ -23,7 +23,7 @@ describe CatarsePagarme::VerifyPagarmeWorker do
|
|
23
23
|
allow_any_instance_of(CatarsePagarme::PaymentDelegator).to receive(:update_transaction)
|
24
24
|
allow_any_instance_of(CatarsePagarme::PaymentDelegator).to receive(:change_status_by_transaction)
|
25
25
|
|
26
|
-
expect_any_instance_of(Payment).to receive(:
|
26
|
+
expect_any_instance_of(Payment).to receive(:update).with({gateway_id: fake_transaction["id"]})
|
27
27
|
expect_any_instance_of(CatarsePagarme::PaymentDelegator).to receive(:update_transaction)
|
28
28
|
expect_any_instance_of(CatarsePagarme::PaymentDelegator).to receive(:change_status_by_transaction).with(fake_transaction["status"])
|
29
29
|
end
|
@@ -65,4 +65,3 @@ describe CatarsePagarme::VerifyPagarmeWorker do
|
|
65
65
|
end
|
66
66
|
end
|
67
67
|
end
|
68
|
-
|
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:
|
4
|
+
version: 3.0.1
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Antônio Roberto Silva
|
@@ -9,36 +9,22 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2020-
|
12
|
+
date: 2020-12-11 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
|
-
- !ruby/object:Gem::Dependency
|
15
|
-
name: countries
|
16
|
-
requirement: !ruby/object:Gem::Requirement
|
17
|
-
requirements:
|
18
|
-
- - '='
|
19
|
-
- !ruby/object:Gem::Version
|
20
|
-
version: 3.0.0
|
21
|
-
type: :runtime
|
22
|
-
prerelease: false
|
23
|
-
version_requirements: !ruby/object:Gem::Requirement
|
24
|
-
requirements:
|
25
|
-
- - '='
|
26
|
-
- !ruby/object:Gem::Version
|
27
|
-
version: 3.0.0
|
28
14
|
- !ruby/object:Gem::Dependency
|
29
15
|
name: rails
|
30
16
|
requirement: !ruby/object:Gem::Requirement
|
31
17
|
requirements:
|
32
|
-
- - "
|
18
|
+
- - ">="
|
33
19
|
- !ruby/object:Gem::Version
|
34
|
-
version: '
|
20
|
+
version: '0'
|
35
21
|
type: :runtime
|
36
22
|
prerelease: false
|
37
23
|
version_requirements: !ruby/object:Gem::Requirement
|
38
24
|
requirements:
|
39
|
-
- - "
|
25
|
+
- - ">="
|
40
26
|
- !ruby/object:Gem::Version
|
41
|
-
version: '
|
27
|
+
version: '0'
|
42
28
|
- !ruby/object:Gem::Dependency
|
43
29
|
name: pagarme
|
44
30
|
requirement: !ruby/object:Gem::Requirement
|
@@ -194,7 +180,6 @@ files:
|
|
194
180
|
- app/models/catarse_pagarme/balance_transfer_delegator.rb
|
195
181
|
- app/models/catarse_pagarme/bank_account_concern.rb
|
196
182
|
- app/models/catarse_pagarme/credit_card_transaction.rb
|
197
|
-
- app/models/catarse_pagarme/fee_calculator_concern.rb
|
198
183
|
- app/models/catarse_pagarme/payment_concern.rb
|
199
184
|
- app/models/catarse_pagarme/payment_delegator.rb
|
200
185
|
- app/models/catarse_pagarme/payment_type.rb
|
@@ -305,7 +290,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
305
290
|
- !ruby/object:Gem::Version
|
306
291
|
version: '0'
|
307
292
|
requirements: []
|
308
|
-
|
293
|
+
rubyforge_project:
|
294
|
+
rubygems_version: 2.6.14.1
|
309
295
|
signing_key:
|
310
296
|
specification_version: 4
|
311
297
|
summary: Integration with Pagar.me
|
@@ -1,21 +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
|
-
|
9
|
-
transaction = PagarMe::Transaction.find(self.payment.gateway_id)
|
10
|
-
payables = transaction.payables
|
11
|
-
cost = transaction.cost.to_f / 100.00
|
12
|
-
payables_fee = payables.to_a.sum(&:fee).to_f / 100.00
|
13
|
-
|
14
|
-
if self.payment.payment_method == ::CatarsePagarme::PaymentType::SLIP
|
15
|
-
cost + payables_fee
|
16
|
-
else
|
17
|
-
payables_fee == 0 ? cost : payables_fee
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|