pay 4.1.1 → 4.2.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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: e9178fdc2803ccfa6b8552a26e34a3849702c5f0ea7143a00773dc8d51b7f373
4
- data.tar.gz: c8da4c71a2317213e3e23b4be9651eafc4ce3df5848b4ac918d89fab916d731e
3
+ metadata.gz: 21dbf64c59853ff5226ba4896f3d25c29625182637cc4ac43f9eaffb60433ec7
4
+ data.tar.gz: e0cd4bfa462306aa0ddf15244a2d536c36a97e45b2d4acb2564cee9c8143351b
5
5
  SHA512:
6
- metadata.gz: fff2d403ce33d8fe02b869b4387d164a8f50ec5b2bdfdb7d747e11987ba586e14958dc220e77379e5649340b44a12352b61e2862395ccf0991c4b3597b7261f0
7
- data.tar.gz: 9a98e720f18f9e2572410c52d86ea3b46c08490a1a7749ea627bc7cb4ee8fe717ac7d45c90e58c8799a92d602d8b91712d08eea7ccfec7d0ec1a93b7c20af004
6
+ metadata.gz: e3b007b3190cb534dec8953486a21fca0b9fe82d26a1caa80dc27a405f835bbb8424c034508e8adc5f36ce3d9ae526a4334d1a5a315b43ebba472dc60f0772f1
7
+ data.tar.gz: 0f0390f51f53fad304ceb5866d1f68a3a5af7272ce33403c27b0362e916d0ad20de756f77a3375f466ec8866d0d2a97e006a15c6dd3f18ac221fb4fc10d3f467
@@ -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
- scope :active, -> { where(status: ["trialing", "active"], ends_at: nil).or(on_grace_period).or(on_trial) }
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
- paddle_paused_from.present?
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/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pay
2
- VERSION = "4.1.1"
2
+ VERSION = "4.2.0"
3
3
  end
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.1.1
4
+ version: 4.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Charnes