pay 5.0.1 → 5.0.2
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/customer.rb +9 -8
- data/lib/pay/stripe/subscription.rb +9 -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: f7a284ee6da187cda76251887acb5192f351814f732b62708bec59ea1d016d80
|
|
4
|
+
data.tar.gz: a9838d32ccf610468681a707f69c14958e1838e49ed3ab7399e0ef6ffaa5a679
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: dc25980ecdfbeacdab79c0e5834a1c5c7c6932e693f1fb44f260d0ad0a468b0d8be34267d3eadd4a5cebe6d564bcf05c3b0bfc98c36cef749caa14bb76cf6406
|
|
7
|
+
data.tar.gz: 2654d78eeaddac5a8c923f895eab07619a0e960f19192a28e991b14bdb7d98a2963bed9e5d2bc54676e01c75d3ed5ea9e4a0c6c0f1cec52edaec31f6d89ce23e
|
data/app/models/pay/customer.rb
CHANGED
|
@@ -8,6 +8,7 @@ module Pay
|
|
|
8
8
|
|
|
9
9
|
scope :active, -> { where(deleted_at: nil) }
|
|
10
10
|
scope :deleted, -> { where.not(deleted_at: nil) }
|
|
11
|
+
scope :not_fake_processor, -> { where.not(processor: :fake_processor) }
|
|
11
12
|
|
|
12
13
|
validates :processor, presence: true
|
|
13
14
|
validates :processor_id, allow_blank: true, uniqueness: {scope: :processor, case_sensitive: true}
|
|
@@ -23,6 +24,14 @@ module Pay
|
|
|
23
24
|
delegate :email, to: :owner
|
|
24
25
|
delegate_missing_to :pay_processor
|
|
25
26
|
|
|
27
|
+
%w[stripe braintree paddle fake_processor].each do |processor_name|
|
|
28
|
+
scope processor_name, -> { where(processor: processor_name) }
|
|
29
|
+
|
|
30
|
+
define_method "#{processor_name}?" do
|
|
31
|
+
processor == processor_name
|
|
32
|
+
end
|
|
33
|
+
end
|
|
34
|
+
|
|
26
35
|
def self.pay_processor_for(name)
|
|
27
36
|
"Pay::#{name.to_s.classify}::Billable".constantize
|
|
28
37
|
end
|
|
@@ -83,13 +92,5 @@ module Pay
|
|
|
83
92
|
# If these match, consider it a generic trial
|
|
84
93
|
subscription.trial_ends_at == subscription.ends_at
|
|
85
94
|
end
|
|
86
|
-
|
|
87
|
-
%w[stripe braintree paddle fake_processor].each do |processor_name|
|
|
88
|
-
scope processor_name, -> { where(processor: processor_name) }
|
|
89
|
-
|
|
90
|
-
define_method "#{processor_name}?" do
|
|
91
|
-
processor == processor_name
|
|
92
|
-
end
|
|
93
|
-
end
|
|
94
95
|
end
|
|
95
96
|
end
|
|
@@ -240,16 +240,23 @@ module Pay
|
|
|
240
240
|
# create_usage_record(quantity: 4, action: :increment)
|
|
241
241
|
# create_usage_record(subscription_item_id: "si_1234", quantity: 100, action: :set)
|
|
242
242
|
def create_usage_record(**options)
|
|
243
|
-
subscription_item_id = options.fetch(:subscription_item_id,
|
|
243
|
+
subscription_item_id = options.fetch(:subscription_item_id, metered_subscription_item&.dig("id"))
|
|
244
244
|
::Stripe::SubscriptionItem.create_usage_record(subscription_item_id, options, stripe_options)
|
|
245
245
|
end
|
|
246
246
|
|
|
247
247
|
# Returns usage record summaries for a subscription item
|
|
248
248
|
def usage_record_summaries(**options)
|
|
249
|
-
subscription_item_id = options.fetch(:subscription_item_id,
|
|
249
|
+
subscription_item_id = options.fetch(:subscription_item_id, metered_subscription_item&.dig("id"))
|
|
250
250
|
::Stripe::SubscriptionItem.list_usage_record_summaries(subscription_item_id, options, stripe_options)
|
|
251
251
|
end
|
|
252
252
|
|
|
253
|
+
# Returns the first metered subscription item
|
|
254
|
+
def metered_subscription_item
|
|
255
|
+
subscription_items.find do |subscription_item|
|
|
256
|
+
subscription_item.dig("price", "recurring", "usage_type") == "metered"
|
|
257
|
+
end
|
|
258
|
+
end
|
|
259
|
+
|
|
253
260
|
# Returns an upcoming invoice for a subscription
|
|
254
261
|
def upcoming_invoice(**options)
|
|
255
262
|
::Stripe::Invoice.upcoming(options.merge(subscription: processor_id), stripe_options)
|
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: 5.0.
|
|
4
|
+
version: 5.0.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: 2022-08-
|
|
12
|
+
date: 2022-08-18 00:00:00.000000000 Z
|
|
13
13
|
dependencies:
|
|
14
14
|
- !ruby/object:Gem::Dependency
|
|
15
15
|
name: rails
|