pay 2.1.2 → 2.3.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of pay might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/README.md +168 -14
- data/Rakefile +15 -17
- data/app/controllers/pay/payments_controller.rb +3 -0
- data/app/controllers/pay/webhooks/paddle_controller.rb +36 -0
- data/app/mailers/pay/user_mailer.rb +2 -2
- data/app/models/pay/application_record.rb +6 -1
- data/app/models/pay/charge.rb +7 -0
- data/app/models/pay/subscription.rb +24 -3
- data/app/views/pay/payments/show.html.erb +1 -1
- data/config/routes.rb +1 -0
- data/db/migrate/20170205020145_create_pay_subscriptions.rb +2 -1
- data/db/migrate/20170727235816_create_pay_charges.rb +1 -0
- data/db/migrate/20200603134434_add_data_to_pay_models.rb +17 -0
- data/lib/generators/active_record/pay_generator.rb +1 -1
- data/lib/generators/pay/orm_helpers.rb +1 -2
- data/lib/pay.rb +11 -2
- data/lib/pay/billable.rb +7 -2
- data/lib/pay/braintree.rb +1 -1
- data/lib/pay/braintree/billable.rb +18 -4
- data/lib/pay/braintree/charge.rb +4 -0
- data/lib/pay/braintree/subscription.rb +6 -0
- data/lib/pay/engine.rb +7 -0
- data/lib/pay/paddle.rb +38 -0
- data/lib/pay/paddle/billable.rb +66 -0
- data/lib/pay/paddle/charge.rb +39 -0
- data/lib/pay/paddle/subscription.rb +59 -0
- data/lib/pay/paddle/webhooks.rb +1 -0
- data/lib/pay/paddle/webhooks/signature_verifier.rb +115 -0
- data/lib/pay/paddle/webhooks/subscription_cancelled.rb +18 -0
- data/lib/pay/paddle/webhooks/subscription_created.rb +59 -0
- data/lib/pay/paddle/webhooks/subscription_payment_refunded.rb +21 -0
- data/lib/pay/paddle/webhooks/subscription_payment_succeeded.rb +64 -0
- data/lib/pay/paddle/webhooks/subscription_updated.rb +34 -0
- data/lib/pay/stripe.rb +1 -0
- data/lib/pay/stripe/billable.rb +14 -5
- data/lib/pay/stripe/charge.rb +4 -0
- data/lib/pay/stripe/subscription.rb +7 -1
- data/lib/pay/stripe/webhooks/charge_succeeded.rb +7 -7
- data/lib/pay/stripe/webhooks/payment_action_required.rb +7 -8
- data/lib/pay/stripe/webhooks/subscription_created.rb +1 -1
- data/lib/pay/version.rb +1 -1
- metadata +63 -8
data/lib/pay/stripe/charge.rb
CHANGED
@@ -1,6 +1,12 @@
|
|
1
1
|
module Pay
|
2
2
|
module Stripe
|
3
3
|
module Subscription
|
4
|
+
extend ActiveSupport::Concern
|
5
|
+
|
6
|
+
included do
|
7
|
+
scope :stripe, -> { where(processor: :stripe) }
|
8
|
+
end
|
9
|
+
|
4
10
|
def stripe?
|
5
11
|
processor == "stripe"
|
6
12
|
end
|
@@ -37,7 +43,7 @@ module Pay
|
|
37
43
|
subscription = processor_subscription
|
38
44
|
subscription.cancel_at_period_end = false
|
39
45
|
subscription.plan = plan
|
40
|
-
subscription.
|
46
|
+
subscription.proration_behavior = (prorate ? "create_prorations" : "none")
|
41
47
|
subscription.trial_end = on_trial? ? trial_ends_at.to_i : "now"
|
42
48
|
subscription.quantity = quantity if quantity?
|
43
49
|
subscription.save
|
@@ -9,13 +9,11 @@ module Pay
|
|
9
9
|
return unless billable.present?
|
10
10
|
return if billable.charges.where(processor_id: object.id).any?
|
11
11
|
|
12
|
-
|
13
|
-
notify_user(billable, charge)
|
14
|
-
charge
|
12
|
+
create_charge(billable, object)
|
15
13
|
end
|
16
14
|
|
17
|
-
def create_charge(
|
18
|
-
charge =
|
15
|
+
def create_charge(billable, object)
|
16
|
+
charge = billable.charges.find_or_initialize_by(
|
19
17
|
processor: :stripe,
|
20
18
|
processor_id: object.id
|
21
19
|
)
|
@@ -29,12 +27,14 @@ module Pay
|
|
29
27
|
created_at: Time.zone.at(object.created)
|
30
28
|
)
|
31
29
|
|
30
|
+
notify_user(billable, charge)
|
31
|
+
|
32
32
|
charge
|
33
33
|
end
|
34
34
|
|
35
|
-
def notify_user(
|
35
|
+
def notify_user(billable, charge)
|
36
36
|
if Pay.send_emails && charge.respond_to?(:receipt)
|
37
|
-
Pay::UserMailer.receipt(
|
37
|
+
Pay::UserMailer.receipt(billable, charge).deliver_later
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
@@ -6,19 +6,18 @@ module Pay
|
|
6
6
|
# Event is of type "invoice" see:
|
7
7
|
# https://stripe.com/docs/api/invoices/object
|
8
8
|
|
9
|
-
|
9
|
+
object = event.data.object
|
10
10
|
|
11
|
-
subscription = Pay.subscription_model.find_by(
|
12
|
-
|
13
|
-
|
14
|
-
)
|
11
|
+
subscription = Pay.subscription_model.find_by(processor: :stripe, processor_id: object.subscription)
|
12
|
+
return if subscription.nil?
|
13
|
+
billable = subscription.owner
|
15
14
|
|
16
|
-
notify_user(
|
15
|
+
notify_user(billable, event.data.object.payment_intent, subscription)
|
17
16
|
end
|
18
17
|
|
19
|
-
def notify_user(
|
18
|
+
def notify_user(billable, payment_intent_id, subscription)
|
20
19
|
if Pay.send_emails
|
21
|
-
Pay::UserMailer.payment_action_required(
|
20
|
+
Pay::UserMailer.payment_action_required(billable, payment_intent_id, subscription).deliver_later
|
22
21
|
end
|
23
22
|
end
|
24
23
|
end
|
@@ -18,7 +18,7 @@ module Pay
|
|
18
18
|
return
|
19
19
|
end
|
20
20
|
|
21
|
-
subscription = Pay.subscription_model.new(owner: owner)
|
21
|
+
subscription = Pay.subscription_model.new(name: "default", owner: owner, processor: :stripe, processor_id: object.id)
|
22
22
|
end
|
23
23
|
|
24
24
|
subscription.quantity = object.quantity
|
data/lib/pay/version.rb
CHANGED
metadata
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.
|
4
|
+
version: 2.3.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Charnes
|
8
8
|
- Chris Oliver
|
9
|
-
autorequire:
|
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
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -34,7 +34,7 @@ dependencies:
|
|
34
34
|
version: 2.92.0
|
35
35
|
- - "<"
|
36
36
|
- !ruby/object:Gem::Version
|
37
|
-
version: '
|
37
|
+
version: '4.0'
|
38
38
|
type: :development
|
39
39
|
prerelease: false
|
40
40
|
version_requirements: !ruby/object:Gem::Requirement
|
@@ -44,7 +44,7 @@ dependencies:
|
|
44
44
|
version: 2.92.0
|
45
45
|
- - "<"
|
46
46
|
- !ruby/object:Gem::Version
|
47
|
-
version: '
|
47
|
+
version: '4.0'
|
48
48
|
- !ruby/object:Gem::Dependency
|
49
49
|
name: stripe
|
50
50
|
requirement: !ruby/object:Gem::Requirement
|
@@ -73,6 +73,20 @@ dependencies:
|
|
73
73
|
- - "~>"
|
74
74
|
- !ruby/object:Gem::Version
|
75
75
|
version: '2.3'
|
76
|
+
- !ruby/object:Gem::Dependency
|
77
|
+
name: paddle_pay
|
78
|
+
requirement: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - "~>"
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 0.0.1
|
83
|
+
type: :development
|
84
|
+
prerelease: false
|
85
|
+
version_requirements: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - "~>"
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: 0.0.1
|
76
90
|
- !ruby/object:Gem::Dependency
|
77
91
|
name: byebug
|
78
92
|
requirement: !ruby/object:Gem::Requirement
|
@@ -157,6 +171,34 @@ dependencies:
|
|
157
171
|
- - "~>"
|
158
172
|
- !ruby/object:Gem::Version
|
159
173
|
version: '1.4'
|
174
|
+
- !ruby/object:Gem::Dependency
|
175
|
+
name: mysql2
|
176
|
+
requirement: !ruby/object:Gem::Requirement
|
177
|
+
requirements:
|
178
|
+
- - ">="
|
179
|
+
- !ruby/object:Gem::Version
|
180
|
+
version: '0'
|
181
|
+
type: :development
|
182
|
+
prerelease: false
|
183
|
+
version_requirements: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - ">="
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: '0'
|
188
|
+
- !ruby/object:Gem::Dependency
|
189
|
+
name: pg
|
190
|
+
requirement: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - ">="
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: '0'
|
195
|
+
type: :development
|
196
|
+
prerelease: false
|
197
|
+
version_requirements: !ruby/object:Gem::Requirement
|
198
|
+
requirements:
|
199
|
+
- - ">="
|
200
|
+
- !ruby/object:Gem::Version
|
201
|
+
version: '0'
|
160
202
|
- !ruby/object:Gem::Dependency
|
161
203
|
name: vcr
|
162
204
|
requirement: !ruby/object:Gem::Requirement
|
@@ -202,6 +244,7 @@ files:
|
|
202
244
|
- app/controllers/pay/application_controller.rb
|
203
245
|
- app/controllers/pay/payments_controller.rb
|
204
246
|
- app/controllers/pay/webhooks/braintree_controller.rb
|
247
|
+
- app/controllers/pay/webhooks/paddle_controller.rb
|
205
248
|
- app/helpers/pay/application_helper.rb
|
206
249
|
- app/jobs/pay/application_job.rb
|
207
250
|
- app/jobs/pay/email_sync_job.rb
|
@@ -221,6 +264,7 @@ files:
|
|
221
264
|
- db/migrate/20170205020145_create_pay_subscriptions.rb
|
222
265
|
- db/migrate/20170727235816_create_pay_charges.rb
|
223
266
|
- db/migrate/20190816015720_add_status_to_pay_subscriptions.rb
|
267
|
+
- db/migrate/20200603134434_add_data_to_pay_models.rb
|
224
268
|
- lib/generators/active_record/pay_generator.rb
|
225
269
|
- lib/generators/active_record/templates/migration.rb
|
226
270
|
- lib/generators/pay/email_views_generator.rb
|
@@ -236,6 +280,17 @@ files:
|
|
236
280
|
- lib/pay/braintree/subscription.rb
|
237
281
|
- lib/pay/engine.rb
|
238
282
|
- lib/pay/env.rb
|
283
|
+
- lib/pay/paddle.rb
|
284
|
+
- lib/pay/paddle/billable.rb
|
285
|
+
- lib/pay/paddle/charge.rb
|
286
|
+
- lib/pay/paddle/subscription.rb
|
287
|
+
- lib/pay/paddle/webhooks.rb
|
288
|
+
- lib/pay/paddle/webhooks/signature_verifier.rb
|
289
|
+
- lib/pay/paddle/webhooks/subscription_cancelled.rb
|
290
|
+
- lib/pay/paddle/webhooks/subscription_created.rb
|
291
|
+
- lib/pay/paddle/webhooks/subscription_payment_refunded.rb
|
292
|
+
- lib/pay/paddle/webhooks/subscription_payment_succeeded.rb
|
293
|
+
- lib/pay/paddle/webhooks/subscription_updated.rb
|
239
294
|
- lib/pay/payment.rb
|
240
295
|
- lib/pay/receipts.rb
|
241
296
|
- lib/pay/stripe.rb
|
@@ -258,7 +313,7 @@ homepage: https://github.com/jasoncharnes/pay
|
|
258
313
|
licenses:
|
259
314
|
- MIT
|
260
315
|
metadata: {}
|
261
|
-
post_install_message:
|
316
|
+
post_install_message:
|
262
317
|
rdoc_options: []
|
263
318
|
require_paths:
|
264
319
|
- lib
|
@@ -273,8 +328,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
273
328
|
- !ruby/object:Gem::Version
|
274
329
|
version: '0'
|
275
330
|
requirements: []
|
276
|
-
rubygems_version: 3.1.
|
277
|
-
signing_key:
|
331
|
+
rubygems_version: 3.1.4
|
332
|
+
signing_key:
|
278
333
|
specification_version: 4
|
279
334
|
summary: A Ruby on Rails subscription engine.
|
280
335
|
test_files: []
|