pay 8.1.2 → 8.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/models/pay/braintree/subscription.rb +1 -1
- data/app/models/pay/fake_processor/subscription.rb +1 -1
- data/app/models/pay/lemon_squeezy/subscription.rb +3 -3
- data/app/models/pay/paddle_billing/charge.rb +8 -0
- data/app/models/pay/paddle_billing/payment_method.rb +9 -1
- data/app/models/pay/paddle_billing/subscription.rb +10 -2
- data/app/models/pay/paddle_classic/subscription.rb +1 -1
- data/app/models/pay/stripe/subscription.rb +1 -1
- data/lib/pay/version.rb +1 -1
- metadata +3 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9c203986ec600312090922863e206b2136fc040e68cdab530575aa521501563b
|
4
|
+
data.tar.gz: 9b0f5220d53a014148a3d7a58fc4c2f7fefd5b04fe92ced36c65decfabb4fd34
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 60caf2d4f344da6c2581636ee8d03991ecf0462fb0a7e7c7c502031b733228499c58da2ff47b746401115798a760e2ca759909b9b33d76379c92fdc5168b3666
|
7
|
+
data.tar.gz: b530d41e9f0b4ff493575c3b3b74e8af07ff27557f2bf090eefee9b175862e4b05c1b6c9f9515bf38291946074841bfdfcd4e1c2cf0e093a467773a74931e7ec
|
@@ -37,7 +37,7 @@ module Pay
|
|
37
37
|
|
38
38
|
def resume
|
39
39
|
unless resumable?
|
40
|
-
raise
|
40
|
+
raise Error, "You can only resume subscriptions within their grace period."
|
41
41
|
end
|
42
42
|
|
43
43
|
update(status: :active, trial_ends_at: nil, ends_at: nil)
|
@@ -100,7 +100,7 @@ module Pay
|
|
100
100
|
|
101
101
|
def resume
|
102
102
|
unless resumable?
|
103
|
-
raise
|
103
|
+
raise Error, "You can only resume paused or cancelled subscriptions"
|
104
104
|
end
|
105
105
|
|
106
106
|
if paused? && pause_starts_at? && Time.current < pause_starts_at
|
@@ -117,8 +117,8 @@ module Pay
|
|
117
117
|
# Lemon Squeezy requires both the Product ID and Variant ID.
|
118
118
|
# The Variant ID will be saved as the processor_plan
|
119
119
|
def swap(plan, **options)
|
120
|
-
raise
|
121
|
-
raise
|
120
|
+
raise Error, "A plan_id is required to swap a subscription" unless plan
|
121
|
+
raise Error, "A variant_id is required to swap a subscription" unless options[:variant_id]
|
122
122
|
|
123
123
|
::LemonSqueezy::Subscription.change_plan id: processor_id, plan_id: plan, variant_id: options[:variant_id]
|
124
124
|
|
@@ -56,6 +56,14 @@ module Pay
|
|
56
56
|
else
|
57
57
|
pay_customer.charges.create!(attrs.merge(processor_id: object.id))
|
58
58
|
end
|
59
|
+
rescue ActiveRecord::RecordInvalid, ActiveRecord::RecordNotUnique
|
60
|
+
try += 1
|
61
|
+
if try <= retries
|
62
|
+
sleep 0.1
|
63
|
+
retry
|
64
|
+
else
|
65
|
+
raise
|
66
|
+
end
|
59
67
|
end
|
60
68
|
end
|
61
69
|
end
|
@@ -8,7 +8,7 @@ module Pay
|
|
8
8
|
sync(pay_customer: pay_customer, attributes: transaction.payments.first)
|
9
9
|
end
|
10
10
|
|
11
|
-
def self.sync(pay_customer:, attributes:)
|
11
|
+
def self.sync(pay_customer:, attributes:, try: 0, retries: 1)
|
12
12
|
details = attributes.method_details
|
13
13
|
attrs = {
|
14
14
|
payment_method_type: details.type.downcase
|
@@ -25,6 +25,14 @@ module Pay
|
|
25
25
|
payment_method = pay_customer.payment_methods.find_or_initialize_by(processor_id: attributes.payment_method_id)
|
26
26
|
payment_method.update!(attrs)
|
27
27
|
payment_method
|
28
|
+
rescue ActiveRecord::RecordInvalid, ActiveRecord::RecordNotUnique
|
29
|
+
try += 1
|
30
|
+
if try <= retries
|
31
|
+
sleep 0.1
|
32
|
+
retry
|
33
|
+
else
|
34
|
+
raise
|
35
|
+
end
|
28
36
|
end
|
29
37
|
|
30
38
|
def make_default!
|
@@ -6,7 +6,7 @@ module Pay
|
|
6
6
|
sync(transaction.subscription_id) if transaction.subscription_id
|
7
7
|
end
|
8
8
|
|
9
|
-
def self.sync(subscription_id, object: nil, name: Pay.default_product_name)
|
9
|
+
def self.sync(subscription_id, object: nil, name: Pay.default_product_name, try: 0, retries: 1)
|
10
10
|
# Passthrough is not return from this API, so we can't use that
|
11
11
|
object ||= ::Paddle::Subscription.retrieve(id: subscription_id)
|
12
12
|
|
@@ -62,6 +62,14 @@ module Pay
|
|
62
62
|
else
|
63
63
|
pay_customer.subscriptions.create!(attributes.merge(name: name, processor_id: subscription_id))
|
64
64
|
end
|
65
|
+
rescue ActiveRecord::RecordInvalid, ActiveRecord::RecordNotUnique
|
66
|
+
try += 1
|
67
|
+
if try <= retries
|
68
|
+
sleep 0.1
|
69
|
+
retry
|
70
|
+
else
|
71
|
+
raise
|
72
|
+
end
|
65
73
|
end
|
66
74
|
|
67
75
|
def api_record(**options)
|
@@ -135,7 +143,7 @@ module Pay
|
|
135
143
|
|
136
144
|
def resume
|
137
145
|
unless resumable?
|
138
|
-
raise
|
146
|
+
raise Error, "You can only resume paused subscriptions."
|
139
147
|
end
|
140
148
|
|
141
149
|
# Paddle Billing API only allows "resuming" subscriptions when they are paused
|
@@ -116,7 +116,7 @@ module Pay
|
|
116
116
|
|
117
117
|
def resume
|
118
118
|
unless resumable?
|
119
|
-
raise
|
119
|
+
raise Error, "You can only resume paused subscriptions."
|
120
120
|
end
|
121
121
|
|
122
122
|
PaddleClassic.client.users.unpause(subscription_id: processor_id)
|
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: 8.1.
|
4
|
+
version: 8.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Jason Charnes
|
@@ -10,7 +10,7 @@ authors:
|
|
10
10
|
autorequire:
|
11
11
|
bindir: bin
|
12
12
|
cert_chain: []
|
13
|
-
date: 2024-10-
|
13
|
+
date: 2024-10-29 00:00:00.000000000 Z
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|
16
16
|
name: rails
|
@@ -180,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
180
180
|
- !ruby/object:Gem::Version
|
181
181
|
version: '0'
|
182
182
|
requirements: []
|
183
|
-
rubygems_version: 3.5.
|
183
|
+
rubygems_version: 3.5.18
|
184
184
|
signing_key:
|
185
185
|
specification_version: 4
|
186
186
|
summary: Payments engine for Ruby on Rails
|