pay 4.1.1 → 5.0.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 +1 -1
- data/app/models/pay/subscription.rb +16 -2
- data/lib/pay/paddle/subscription.rb +2 -2
- data/lib/pay/stripe/billable.rb +1 -0
- data/lib/pay/stripe/subscription.rb +1 -1
- data/lib/pay/stripe.rb +2 -2
- 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: ac230e5bd9211a9ee883dad0d578c7aa26aed37d2ce09ad0dacccda4c7f544d1
|
4
|
+
data.tar.gz: eee27e8d56e29b7ad262b4fd12451f47e91778825f5359ae8d7b0ad39f03ebff
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: edffe8234d27e0d99b618a564ec46eaa3df44e8d8745b99c82506610f0786d916b6856afb4ba57c0d410d8c19c83b023b73c02ad7782f9d4f8f384554b8356ca
|
7
|
+
data.tar.gz: 6d19b7b841de05eaacfc616ab0d9ab197ccf0c0a251afeebdeecd183bcbade5e7ffb8344bc17e7379f5bc6bea14f4d370bcb39744a5b476498c4ad70dc29f7ec
|
data/README.md
CHANGED
@@ -20,7 +20,7 @@ Want to see how Pay works? Check out our video getting started guide.
|
|
20
20
|
|
21
21
|
Our supported payment processors are:
|
22
22
|
|
23
|
-
- Stripe ([SCA Compatible](https://stripe.com/docs/strong-customer-authentication) using API version `
|
23
|
+
- Stripe ([SCA Compatible](https://stripe.com/docs/strong-customer-authentication) using API version `2022-08-01`)
|
24
24
|
- Paddle (SCA Compatible & supports PayPal)
|
25
25
|
- Braintree (supports PayPal)
|
26
26
|
- [Fake Processor](docs/fake_processor/1_overview.md) (used for generic trials without cards, free subscriptions, testing, etc)
|
@@ -11,7 +11,9 @@ module Pay
|
|
11
11
|
scope :on_trial, -> { where.not(trial_ends_at: nil).where("#{table_name}.trial_ends_at > ?", Time.zone.now) }
|
12
12
|
scope :cancelled, -> { where.not(ends_at: nil) }
|
13
13
|
scope :on_grace_period, -> { cancelled.where("#{table_name}.ends_at > ?", Time.zone.now) }
|
14
|
-
|
14
|
+
# Stripe considers paused subscriptions to be active, therefore we reflect that in this scope and
|
15
|
+
# make it consistent across all processors
|
16
|
+
scope :active, -> { where(status: ["trialing", "active", "paused"], ends_at: nil).or(on_grace_period).or(on_trial) }
|
15
17
|
scope :incomplete, -> { where(status: :incomplete) }
|
16
18
|
scope :past_due, -> { where(status: :past_due) }
|
17
19
|
scope :with_active_customer, -> { joins(:customer).merge(Customer.active) }
|
@@ -49,6 +51,18 @@ module Pay
|
|
49
51
|
scope processor_name, -> { joins(:customer).where(pay_customers: {processor: processor_name}) }
|
50
52
|
end
|
51
53
|
|
54
|
+
def self.active_without_paused
|
55
|
+
case Pay::Adapter.current_adapter
|
56
|
+
when "postgresql", "postgis"
|
57
|
+
active.where("data->>'pause_behavior' IS NULL AND status != 'paused'")
|
58
|
+
when "mysql2"
|
59
|
+
active.where("data->>'$.pause_behavior' IS NULL AND status != 'paused'")
|
60
|
+
when "sqlite3"
|
61
|
+
# sqlite 3.38 supports ->> syntax, however, sqlite 3.37 is what ships with Ubuntu 22.04.
|
62
|
+
active.where("json_extract(data, '$.pause_behavior') IS NULL AND status != 'paused'")
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
52
66
|
def self.with_metered_items
|
53
67
|
case Pay::Adapter.current_adapter
|
54
68
|
when "sqlite3"
|
@@ -108,7 +122,7 @@ module Pay
|
|
108
122
|
end
|
109
123
|
|
110
124
|
def active?
|
111
|
-
["trialing", "active"].include?(status) && (ends_at.nil? || on_grace_period? || on_trial?)
|
125
|
+
["trialing", "active", "paused"].include?(status) && (ends_at.nil? || on_grace_period? || on_trial?)
|
112
126
|
end
|
113
127
|
|
114
128
|
def past_due?
|
@@ -107,13 +107,13 @@ module Pay
|
|
107
107
|
end
|
108
108
|
|
109
109
|
def paused?
|
110
|
-
|
110
|
+
pay_subscription.status == "paused"
|
111
111
|
end
|
112
112
|
|
113
113
|
def pause
|
114
114
|
attributes = {pause: true}
|
115
115
|
response = PaddlePay::Subscription::User.update(processor_id, attributes)
|
116
|
-
pay_subscription.update(paddle_paused_from: Time.zone.parse(response.dig(:next_payment, :date)))
|
116
|
+
pay_subscription.update(status: :paused, paddle_paused_from: Time.zone.parse(response.dig(:next_payment, :date)))
|
117
117
|
rescue ::PaddlePay::PaddlePayError => e
|
118
118
|
raise Pay::Paddle::Error, e
|
119
119
|
end
|
data/lib/pay/stripe/billable.rb
CHANGED
@@ -142,7 +142,7 @@ module Pay
|
|
142
142
|
# cancel_now!(prorate: true)
|
143
143
|
# cancel_now!(invoice_now: true)
|
144
144
|
def cancel_now!(**options)
|
145
|
-
@stripe_subscription = ::Stripe::Subscription.
|
145
|
+
@stripe_subscription = ::Stripe::Subscription.cancel(processor_id, options.merge(expand_options), stripe_options)
|
146
146
|
pay_subscription.update(ends_at: Time.current, status: :canceled)
|
147
147
|
rescue ::Stripe::StripeError => e
|
148
148
|
raise Pay::Stripe::Error, e
|
data/lib/pay/stripe.rb
CHANGED
@@ -31,12 +31,12 @@ module Pay
|
|
31
31
|
def self.enabled?
|
32
32
|
return false unless Pay.enabled_processors.include?(:stripe) && defined?(::Stripe)
|
33
33
|
|
34
|
-
Pay::Engine.version_matches?(required: "~>
|
34
|
+
Pay::Engine.version_matches?(required: "~> 7", current: ::Stripe::VERSION) || (raise "[Pay] stripe gem must be version ~> 7")
|
35
35
|
end
|
36
36
|
|
37
37
|
def self.setup
|
38
38
|
::Stripe.api_key = private_key
|
39
|
-
::Stripe.api_version = "
|
39
|
+
::Stripe.api_version = "2022-08-02"
|
40
40
|
|
41
41
|
# Used by Stripe to identify Pay for support
|
42
42
|
::Stripe.set_app_info("PayRails", partner_id: "pp_partner_IqhY0UExnJYLxg", version: Pay::VERSION, url: "https://github.com/pay-rails/pay")
|
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:
|
4
|
+
version: 5.0.0
|
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: 2022-
|
12
|
+
date: 2022-08-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|