pay 2.4.0 → 2.4.2
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/app/models/pay/subscription.rb +9 -17
- data/db/migrate/20200603134434_add_data_to_pay_models.rb +6 -1
- data/lib/pay/braintree/subscription.rb +12 -8
- data/lib/pay/paddle/subscription.rb +4 -6
- data/lib/pay/stripe/subscription.rb +12 -8
- data/lib/pay/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 4832547f758ca266af9bdb4e727dfec425fb7ace4cf6d3372f47dd0f73057ad4
|
4
|
+
data.tar.gz: 854f6d697267fe7e3c45799f036241266067140892d32470ee6be9d24f860e50
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7ca4679542933ddac4d75c5091dcc8653ffbe0f839d396aeec0d2aa0714117bb1a72e2b03d11f62e0d2508f1b7be71affd4f5703ec5c1da48462f35a7b194bf6
|
7
|
+
data.tar.gz: 62e21bae437f10db633efe35d993382a76c9b42e8cad661bed57f4a6cdc348889d7baae2b9c80d2f1219b050cc12d0c7e40c11dce4e87c613d077ed1005c7706
|
@@ -29,6 +29,15 @@ module Pay
|
|
29
29
|
|
30
30
|
attribute :prorate, :boolean, default: true
|
31
31
|
|
32
|
+
# Helpers for payment processors
|
33
|
+
%w[braintree stripe paddle].each do |processor_name|
|
34
|
+
define_method "#{processor_name}?" do
|
35
|
+
processor == processor_name
|
36
|
+
end
|
37
|
+
|
38
|
+
scope processor_name, -> { where(processor: processor_name) }
|
39
|
+
end
|
40
|
+
|
32
41
|
def no_prorate
|
33
42
|
self.prorate = false
|
34
43
|
end
|
@@ -71,12 +80,10 @@ module Pay
|
|
71
80
|
end
|
72
81
|
|
73
82
|
def paused?
|
74
|
-
return unless paddle?
|
75
83
|
send("#{processor}_paused?")
|
76
84
|
end
|
77
85
|
|
78
86
|
def pause
|
79
|
-
return unless paddle?
|
80
87
|
send("#{processor}_pause")
|
81
88
|
end
|
82
89
|
|
@@ -89,22 +96,7 @@ module Pay
|
|
89
96
|
end
|
90
97
|
|
91
98
|
def resume
|
92
|
-
unless on_grace_period?
|
93
|
-
unless paddle?
|
94
|
-
raise StandardError,
|
95
|
-
"You can only resume subscriptions within their grace period."
|
96
|
-
end
|
97
|
-
end
|
98
|
-
|
99
|
-
unless paused?
|
100
|
-
if paddle?
|
101
|
-
raise StandardError,
|
102
|
-
"You can only resume paused subscriptions."
|
103
|
-
end
|
104
|
-
end
|
105
|
-
|
106
99
|
send("#{processor}_resume")
|
107
|
-
|
108
100
|
update(ends_at: nil, status: "active")
|
109
101
|
self
|
110
102
|
end
|
@@ -5,7 +5,12 @@ class AddDataToPayModels < ActiveRecord::Migration[4.2]
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def data_column_type
|
8
|
-
|
8
|
+
default_hash = ActiveRecord::Base.configurations.default_hash
|
9
|
+
|
10
|
+
# Rails 6.1 uses a symbol key instead of a string
|
11
|
+
adapter = default_hash.dig(:adapter) || default_hash.dig("adapter")
|
12
|
+
|
13
|
+
case adapter
|
9
14
|
when "mysql2"
|
10
15
|
:json
|
11
16
|
when "postgresql"
|
@@ -3,14 +3,6 @@ module Pay
|
|
3
3
|
module Subscription
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
|
-
included do
|
7
|
-
scope :braintree, -> { where(processor: :braintree) }
|
8
|
-
end
|
9
|
-
|
10
|
-
def braintree?
|
11
|
-
processor == "braintree"
|
12
|
-
end
|
13
|
-
|
14
6
|
def braintree_cancel
|
15
7
|
subscription = processor_subscription
|
16
8
|
|
@@ -38,7 +30,19 @@ module Pay
|
|
38
30
|
canceled? && Time.zone.now < ends_at
|
39
31
|
end
|
40
32
|
|
33
|
+
def braintree_paused?
|
34
|
+
false
|
35
|
+
end
|
36
|
+
|
37
|
+
def braintree_pause
|
38
|
+
raise NotImplementedError, "Braintree does not support pausing subscriptions"
|
39
|
+
end
|
40
|
+
|
41
41
|
def braintree_resume
|
42
|
+
unless on_grace_period?
|
43
|
+
raise StandardError, "You can only resume subscriptions within their grace period."
|
44
|
+
end
|
45
|
+
|
42
46
|
if canceled? && on_trial?
|
43
47
|
duration = trial_ends_at.to_date - Date.today
|
44
48
|
|
@@ -4,17 +4,11 @@ module Pay
|
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
6
|
included do
|
7
|
-
scope :paddle, -> { where(processor: :paddle) }
|
8
|
-
|
9
7
|
store_accessor :data, :paddle_update_url
|
10
8
|
store_accessor :data, :paddle_cancel_url
|
11
9
|
store_accessor :data, :paddle_paused_from
|
12
10
|
end
|
13
11
|
|
14
|
-
def paddle?
|
15
|
-
processor == "paddle"
|
16
|
-
end
|
17
|
-
|
18
12
|
def paddle_cancel
|
19
13
|
subscription = processor_subscription
|
20
14
|
PaddlePay::Subscription::User.cancel(processor_id)
|
@@ -51,6 +45,10 @@ module Pay
|
|
51
45
|
end
|
52
46
|
|
53
47
|
def paddle_resume
|
48
|
+
unless paused?
|
49
|
+
raise StandardError, "You can only resume paused subscriptions."
|
50
|
+
end
|
51
|
+
|
54
52
|
attributes = {pause: false}
|
55
53
|
PaddlePay::Subscription::User.update(processor_id, attributes)
|
56
54
|
update(status: :active, paddle_paused_from: nil)
|
@@ -3,14 +3,6 @@ module Pay
|
|
3
3
|
module Subscription
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
|
-
included do
|
7
|
-
scope :stripe, -> { where(processor: :stripe) }
|
8
|
-
end
|
9
|
-
|
10
|
-
def stripe?
|
11
|
-
processor == "stripe"
|
12
|
-
end
|
13
|
-
|
14
6
|
def stripe_cancel
|
15
7
|
subscription = processor_subscription
|
16
8
|
subscription.cancel_at_period_end = true
|
@@ -33,7 +25,19 @@ module Pay
|
|
33
25
|
canceled? && Time.zone.now < ends_at
|
34
26
|
end
|
35
27
|
|
28
|
+
def stripe_paused?
|
29
|
+
false
|
30
|
+
end
|
31
|
+
|
32
|
+
def stripe_pause
|
33
|
+
raise NotImplementedError, "Stripe does not support pausing subscriptions"
|
34
|
+
end
|
35
|
+
|
36
36
|
def stripe_resume
|
37
|
+
unless on_grace_period?
|
38
|
+
raise StandardError, "You can only resume subscriptions within their grace period."
|
39
|
+
end
|
40
|
+
|
37
41
|
subscription = processor_subscription
|
38
42
|
subscription.plan = processor_plan
|
39
43
|
subscription.trial_end = on_trial? ? trial_ends_at.to_i : "now"
|
data/lib/pay/version.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: pay
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 2.4.
|
4
|
+
version: 2.4.2
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Charnes
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2021-01-
|
12
|
+
date: 2021-01-22 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|