pay 3.0.1 → 3.0.6
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.
Potentially problematic release.
This version of pay might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/app/models/pay/charge.rb +25 -1
- data/app/models/pay/customer.rb +10 -0
- data/app/models/pay/subscription.rb +1 -1
- data/app/views/pay/payments/show.html.erb +0 -1
- data/lib/pay/stripe/webhooks/customer_updated.rb +1 -1
- data/lib/pay/version.rb +1 -1
- data/lib/tasks/pay.rake +22 -11
- 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: 2a5f1e8f94af3893db2d70bfd6f7b153213c0fc6bcc8c73b5d58465f94a35ea9
|
4
|
+
data.tar.gz: 14cc1b16d5a6cfc1ff4b220cef61c4910da17bd6e896719e8ecda7284894b848
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a2b2164b3af965a2598c1c9257ded5741c2e0631d08f36198b32a981b3a4e7edc0fb83e6dc7bc9de00c796a9dc8bdafab2a36f385e3bb47511aa7376924a5be3
|
7
|
+
data.tar.gz: 6550e82d22748167fa820dbfa48bf2db33e8f98369bb37ac654492a7ea37578b8d8ccd77ab93354e677f1ef94b788afb52f3d537e52dc7fd39084356fa2d3047
|
data/app/models/pay/charge.rb
CHANGED
@@ -63,9 +63,33 @@ module Pay
|
|
63
63
|
def charged_to
|
64
64
|
case payment_method_type
|
65
65
|
when "card"
|
66
|
-
"#{brand} (**** **** **** #{last4})"
|
66
|
+
"#{brand.titleize} (**** **** **** #{last4})"
|
67
67
|
when "paypal"
|
68
68
|
"#{brand} (#{email})"
|
69
|
+
|
70
|
+
# Braintree
|
71
|
+
when "venmo"
|
72
|
+
"#{brand.titleize} #{username}"
|
73
|
+
when "us_bank_account"
|
74
|
+
"#{bank} #{last4}"
|
75
|
+
|
76
|
+
# Stripe
|
77
|
+
when "acss_debit"
|
78
|
+
"#{bank} #{last4}"
|
79
|
+
when "eps", "fpx", "ideal", "p24"
|
80
|
+
bank
|
81
|
+
|
82
|
+
when "au_becs_debit"
|
83
|
+
"BECS Debit #{last4}"
|
84
|
+
|
85
|
+
when "bacs_debit"
|
86
|
+
"Bacs Debit #{last4}"
|
87
|
+
|
88
|
+
when "sepa_debit"
|
89
|
+
"SEPA Debit #{last4}"
|
90
|
+
|
91
|
+
else
|
92
|
+
payment_method_type&.titleize
|
69
93
|
end
|
70
94
|
end
|
71
95
|
end
|
data/app/models/pay/customer.rb
CHANGED
@@ -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
|
|
@@ -110,7 +110,7 @@ module Pay
|
|
110
110
|
end
|
111
111
|
|
112
112
|
def swap(plan)
|
113
|
-
raise ArgumentError, "plan must be a string" unless plan.is_a?(String)
|
113
|
+
raise ArgumentError, "plan must be a string. Got `#{plan.inspect}` instead." unless plan.is_a?(String)
|
114
114
|
payment_processor.swap(plan)
|
115
115
|
update(processor_plan: plan, ends_at: nil, status: :active)
|
116
116
|
end
|
@@ -11,7 +11,7 @@ module Pay
|
|
11
11
|
|
12
12
|
# Sync default card
|
13
13
|
if (payment_method_id = pay_customer.customer.invoice_settings.default_payment_method)
|
14
|
-
Pay::Stripe::PaymentMethod.sync(payment_method_id,
|
14
|
+
Pay::Stripe::PaymentMethod.sync(payment_method_id, stripe_account: event.try(:account))
|
15
15
|
|
16
16
|
else
|
17
17
|
# No default payment method set
|
data/lib/pay/version.rb
CHANGED
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
|
-
|
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.
|
4
|
+
version: 3.0.6
|
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: 2021-09-
|
12
|
+
date: 2021-09-04 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|