pay 3.0.2 → 3.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: 72854ccf4950082b24ff854f6c20b9dfd27ed606af82032ac57edef72c5722a5
4
- data.tar.gz: dfe726cedf8ac7afd9ff5b4fa87cd96563244f493f1e3f399c749b3492c534d7
3
+ metadata.gz: ef0b3b501b5c25692a192c44b7bac08fe9980a7764f11d17332ae0c5db27b37a
4
+ data.tar.gz: 9be9f1a40979bf0ec042c536bae0b93654902b9c33625cb58da3dabc0e6c448e
5
5
  SHA512:
6
- metadata.gz: acadc8b9c2de89ff113ef75550fb6f82dc79cb3a4bca20834bdfa6ed47e81397405782cef60462248e98a68ab9833ab4bf61429dbd92b0891642e35825b98348
7
- data.tar.gz: 709dd5387de015deb67eaaf7a770bd6b23ff2b70159c8f22ee5b2063c0bbda4326af67b24effcc19280604dc98373894b42260e728b00ec1b42c480c3bb27a67
6
+ metadata.gz: 1adeb3e84b859998c32c943e00cace51cf2014496c836919d7258761d7c782cb5088f3a53454aed7bfda75e1d47dac7786404f4077ccdaab5d928e5479b500a3
7
+ data.tar.gz: 62dc7337b2dd15ec65ec2ca685cb4e0af650b79977e9f6465291887b07c598a33bde25d9af9bdfd091bf960982dc00cb9d2bceebf53243a1ca18f1a1fe623495
@@ -76,6 +76,16 @@ module Pay
76
76
  deleted_at.present?
77
77
  end
78
78
 
79
+ def on_generic_trial?
80
+ return false unless fake_processor?
81
+
82
+ subscription = subscriptions.active.last
83
+ return false unless subscription
84
+
85
+ # If these match, consider it a generic trial
86
+ subscription.trial_ends_at == subscription.ends_at
87
+ end
88
+
79
89
  %w[stripe braintree paddle fake_processor].each do |processor_name|
80
90
  scope processor_name, -> { where(processor: processor_name) }
81
91
 
data/lib/pay/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pay
2
- VERSION = "3.0.2"
2
+ VERSION = "3.0.4"
3
3
  end
data/lib/tasks/pay.rake CHANGED
@@ -3,18 +3,29 @@ namespace :pay do
3
3
  desc "Sync default payment methods for Pay::Customers"
4
4
  task sync_default: :environment do
5
5
  Pay::Customer.find_each do |pay_customer|
6
- puts "Syncing Pay::Customer ##{pay_customer.id}: #{pay_customer.processor.titleize} #{pay_customer.processor_id}"
7
- case pay_customer.processor
8
- when "braintree"
9
- payment_method = pay_customer.customer.payment_methods.find(&:default?)
10
- Pay::Braintree::PaymentMethod.sync(payment_method.token, object: payment_method) if payment_method
11
- when "stripe"
12
- payment_method_id = pay_customer.customer.invoice_settings.default_payment_method
13
- Pay::Stripe::PaymentMethod.sync(payment_method_id) if payment_method_id
14
- when "paddle"
15
- Pay::Paddle::PaymentMethod.sync(pay_customer)
16
- end
6
+ sync_default_payment_method(pay_customer)
17
7
  end
18
8
  end
19
9
  end
20
10
  end
11
+
12
+ def sync_default_payment_method(pay_customer, retries: 2)
13
+ try = 0
14
+ begin
15
+ puts "Syncing Pay::Customer ##{pay_customer.id} attempt #{try + 1}: #{pay_customer.processor.titleize} #{pay_customer.processor_id}"
16
+ case pay_customer.processor
17
+ when "braintree"
18
+ payment_method = pay_customer.customer.payment_methods.find(&:default?)
19
+ Pay::Braintree::PaymentMethod.sync(payment_method.token, object: payment_method) if payment_method
20
+ when "stripe"
21
+ payment_method_id = pay_customer.customer.invoice_settings.default_payment_method
22
+ Pay::Stripe::PaymentMethod.sync(payment_method_id) if payment_method_id
23
+ when "paddle"
24
+ Pay::Paddle::PaymentMethod.sync(pay_customer)
25
+ end
26
+ rescue
27
+ sleep 0.5
28
+ try += 1
29
+ try <= retries ? retry : raise
30
+ end
31
+ 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: 3.0.2
4
+ version: 3.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Charnes