pay 11.2.2 → 11.3.0
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/stripe/payment_method.rb +1 -1
- data/app/models/pay/stripe/subscription.rb +2 -4
- data/lib/pay/attributes.rb +4 -4
- data/lib/pay/stripe.rb +1 -1
- data/lib/pay/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 9edcf51b1a6346022cd5d504b2d6e730dadeb31580ae60da69b3f5c5414b97d8
|
|
4
|
+
data.tar.gz: 9cd3ea459bdd0f853efab3a72f32af739125740f22e78f756da1e6ea2a059a5e
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 3e92c7fd1cd767d5d67160abd1bda24d1d9a9c56a4ea3ea883a1be04e65bdaf21fc5a2ad4c9268cad9d37747e6927f79bfcc4beadecbf3f6c79e499d7c890c64
|
|
7
|
+
data.tar.gz: ca5742925df0d3f6aaae8ed148a9710f5c1be43394c0918eb2f0afcba9cf3968546e9388768b98ff3181df8c8e9ddb83ad7ae8d27a5d1266100863e4dcb0b2d8
|
|
@@ -31,7 +31,7 @@ module Pay
|
|
|
31
31
|
return
|
|
32
32
|
end
|
|
33
33
|
|
|
34
|
-
default_payment_method_id = pay_customer.api_record.invoice_settings
|
|
34
|
+
default_payment_method_id = pay_customer.api_record.invoice_settings&.default_payment_method
|
|
35
35
|
default = (id == default_payment_method_id)
|
|
36
36
|
|
|
37
37
|
attributes = extract_attributes(object).merge(default: default, stripe_account: stripe_account)
|
|
@@ -279,7 +279,6 @@ module Pay
|
|
|
279
279
|
unpause
|
|
280
280
|
else
|
|
281
281
|
@api_record = ::Stripe::Subscription.update(processor_id, {
|
|
282
|
-
plan: processor_plan,
|
|
283
282
|
trial_end: (on_trial? ? trial_ends_at.to_i : "now"),
|
|
284
283
|
cancel_at_period_end: false
|
|
285
284
|
}.merge(expand_options),
|
|
@@ -300,10 +299,9 @@ module Pay
|
|
|
300
299
|
processor_id,
|
|
301
300
|
{
|
|
302
301
|
cancel_at_period_end: false,
|
|
303
|
-
plan: plan,
|
|
302
|
+
items: [{id: subscription_items.first.id, plan: plan, quantity: quantity}],
|
|
304
303
|
proration_behavior: proration_behavior,
|
|
305
|
-
trial_end: (on_trial? ? trial_ends_at.to_i : "now")
|
|
306
|
-
quantity: quantity
|
|
304
|
+
trial_end: (on_trial? ? trial_ends_at.to_i : "now")
|
|
307
305
|
}.merge(expand_options).merge(options),
|
|
308
306
|
stripe_options
|
|
309
307
|
)
|
data/lib/pay/attributes.rb
CHANGED
|
@@ -28,7 +28,7 @@ module Pay
|
|
|
28
28
|
# - Finds or creates a Pay::Customer for the process and marks it as default
|
|
29
29
|
# - Removes the default flag from all other Pay::Customers
|
|
30
30
|
# - Removes the default flag from all Pay::PaymentMethods
|
|
31
|
-
def set_payment_processor(processor_name, allow_fake: false, **attributes)
|
|
31
|
+
def set_payment_processor(processor_name, allow_fake: false, stripe_account: nil, **attributes)
|
|
32
32
|
raise Pay::Error, "Processor `#{processor_name}` is not allowed" if processor_name.to_s == "fake_processor" && !allow_fake
|
|
33
33
|
|
|
34
34
|
# Safety check to make sure this is a valid Pay processor
|
|
@@ -37,7 +37,7 @@ module Pay
|
|
|
37
37
|
|
|
38
38
|
with_lock do
|
|
39
39
|
pay_customers.update_all(default: false)
|
|
40
|
-
pay_customer = pay_customers.active.where(processor: processor_name, type: klass.name).first_or_initialize
|
|
40
|
+
pay_customer = pay_customers.active.where(processor: processor_name, type: klass.name, stripe_account: stripe_account).first_or_initialize
|
|
41
41
|
pay_customer.update!(attributes.merge(default: true))
|
|
42
42
|
end
|
|
43
43
|
|
|
@@ -45,14 +45,14 @@ module Pay
|
|
|
45
45
|
reload_payment_processor
|
|
46
46
|
end
|
|
47
47
|
|
|
48
|
-
def add_payment_processor(processor_name, allow_fake: false, **attributes)
|
|
48
|
+
def add_payment_processor(processor_name, allow_fake: false, stripe_account: nil, **attributes)
|
|
49
49
|
raise Pay::Error, "Processor `#{processor_name}` is not allowed" if processor_name.to_s == "fake_processor" && !allow_fake
|
|
50
50
|
|
|
51
51
|
# Safety check to make sure this is a valid Pay processor
|
|
52
52
|
klass = "Pay::#{processor_name.to_s.classify}::Customer".constantize
|
|
53
53
|
raise ArgumentError, "not a valid payment processor" if klass.ancestors.exclude?(Pay::Customer)
|
|
54
54
|
|
|
55
|
-
pay_customer = pay_customers.active.where(processor: processor_name, type: klass.name).first_or_initialize
|
|
55
|
+
pay_customer = pay_customers.active.where(processor: processor_name, type: klass.name, stripe_account: stripe_account).first_or_initialize
|
|
56
56
|
pay_customer.update!(attributes)
|
|
57
57
|
pay_customer
|
|
58
58
|
end
|
data/lib/pay/stripe.rb
CHANGED
data/lib/pay/version.rb
CHANGED