pay 5.0.3 → 5.0.4

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: c607f5486ae4c1dfbf46b492e1a369e89e763e03e43bb25596882396285a416a
4
- data.tar.gz: cbe12e5104c4cc18c9edc0a3d2ecf99f2d9d3adad431e4868747625f4934e6ec
3
+ metadata.gz: 9bebc5ba3aec0992dd2000bd4f7102043bf19de8f71895b8e0179cf268e411bf
4
+ data.tar.gz: 783e8e0465b562f8a3d285bef1e8675a002ffa8543795711a13df15f2ee5ea9c
5
5
  SHA512:
6
- metadata.gz: ae0b3f32f96f2efcc5618df5b158397e1d6d1c6c79ee2109bb806628da2c53d998d8090fb7c9d7b2055a7ba660960b8ae4a36a6e6c4da54a943b4cd7020adae2
7
- data.tar.gz: 356ba70d14722f9b083f366a957c26809082ce14193d7e4ec09350cf4c232de8dd215736b8c5968166d5659a8d9235df90104cc9367654b94e8905a09cfcdb77
6
+ metadata.gz: edb6ebdfc2950926fe868ba0d812bd440ca9501b57139d7d1024c72e849f2c7349eeb6b21446626e59a0cfad51e70c5ae7d0b00af5a81ee7e3eab9aa76e72463
7
+ data.tar.gz: de25718ebbea2ede5fbd05e65ec8bf29b7eb687b6e9725369cb6bc5b620055170f2ce29b397da739148ad26f0258c5639dbf3f62d4b3f9f96c93f3f667607f4b
@@ -46,7 +46,7 @@ module Pay
46
46
  end
47
47
 
48
48
  def subscription(name: Pay.default_product_name)
49
- subscriptions.loaded? ? subscriptions.reverse.detect { |s| s.name == name } : subscriptions.for_name(name).last
49
+ subscriptions.order(id: :desc).for_name(name).first
50
50
  end
51
51
 
52
52
  def subscribed?(name: Pay.default_product_name, processor_plan: nil)
data/lib/pay/engine.rb CHANGED
@@ -17,7 +17,9 @@ module Pay
17
17
  end
18
18
  end
19
19
 
20
- initializer "pay.webhooks" do
20
+ # Add webhook subscribers before app initializers define extras
21
+ # This keeps the processing in order so that changes have happened before user-defined webhook processors
22
+ config.before_initialize do
21
23
  Pay::Stripe.configure_webhooks if Pay::Stripe.enabled?
22
24
  Pay::Braintree.configure_webhooks if Pay::Braintree.enabled?
23
25
  Pay::Paddle.configure_webhooks if Pay::Paddle.enabled?
@@ -109,9 +109,6 @@ module Pay
109
109
  off_session: true
110
110
  }.merge(options)
111
111
 
112
- # Inherit trial from plan unless trial override was specified
113
- opts[:trial_from_plan] = true unless opts[:trial_period_days]
114
-
115
112
  # Load the Stripe customer to verify it exists and update payment method if needed
116
113
  opts[:customer] = customer.id
117
114
 
@@ -190,9 +187,10 @@ module Pay
190
187
  stripe_sub.trial_end.present? ? Time.at(stripe_sub.trial_end) : nil
191
188
  end
192
189
 
193
- # Syncs a customer's subscriptions from Stripe to the database
194
- def sync_subscriptions
195
- subscriptions = ::Stripe::Subscription.list({customer: customer}, stripe_options)
190
+ # Syncs a customer's subscriptions from Stripe to the database.
191
+ # Note that by default canceled subscriptions are NOT returned by Stripe. In order to include them, use `sync_subscriptions(status: "all")`.
192
+ def sync_subscriptions(**options)
193
+ subscriptions = ::Stripe::Subscription.list(options.merge(customer: customer), stripe_options)
196
194
  subscriptions.map do |subscription|
197
195
  Pay::Stripe::Subscription.sync(subscription.id)
198
196
  end
data/lib/pay/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pay
2
- VERSION = "5.0.3"
2
+ VERSION = "5.0.4"
3
3
  end
@@ -27,7 +27,7 @@ module Pay
27
27
 
28
28
  # Unsubscribe
29
29
  def unsubscribe(name)
30
- backend.unsubscribe name
30
+ backend.unsubscribe name_with_namespace(name)
31
31
  end
32
32
 
33
33
  # Called to process an event
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.3
4
+ version: 5.0.4
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-19 00:00:00.000000000 Z
12
+ date: 2022-09-29 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails