pay 11.3.0 → 11.4.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/Rakefile +0 -2
- data/app/models/pay/braintree/payment_method.rb +7 -1
- data/app/models/pay/fake_processor/payment_method.rb +4 -0
- data/app/models/pay/lemon_squeezy/payment_method.rb +4 -0
- data/app/models/pay/paddle_billing/payment_method.rb +4 -0
- data/app/models/pay/paddle_classic/payment_method.rb +4 -0
- data/app/models/pay/payment_method.rb +0 -13
- data/app/models/pay/stripe/charge.rb +3 -2
- data/app/models/pay/stripe/payment_method.rb +5 -0
- data/app/models/pay/stripe/subscription.rb +1 -0
- data/lib/pay/receipts.rb +2 -2
- 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: 91779791c74af77a8ab63818f20a4edc7793cf6c1aab3fbf579448d417ae15e9
|
|
4
|
+
data.tar.gz: f85d015b0ff83469bdec0157c72cc35345459eb7ae919c8459de553d9edfc60c
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 735bd7fe2149a54795de3f60fbbcacaa8597bbdced88e7f4ae7f03d9051fe6e0af600aa9cce321f6554b98d996a75a8b9cda1da58f7ac8fe29d82d37079b8281
|
|
7
|
+
data.tar.gz: 266b0aa2699a0bbfff739937032f7692dd616ee976d50e2b56aaadf3bb281093146aceab949c3c3af474ead2322c0b0e2d790f30f5bedb3de37cef5a6c15ce22
|
data/Rakefile
CHANGED
|
@@ -10,10 +10,16 @@ module Pay
|
|
|
10
10
|
pay_customer.save_payment_method(object, default: object.default?)
|
|
11
11
|
end
|
|
12
12
|
|
|
13
|
-
# Sets payment method as default
|
|
13
|
+
# Sets payment method as default
|
|
14
14
|
def make_default!
|
|
15
|
+
return if default?
|
|
16
|
+
|
|
15
17
|
result = gateway.customer.update(customer.processor_id, default_payment_method_token: processor_id)
|
|
16
18
|
raise Pay::Braintree::Error, result unless result.success?
|
|
19
|
+
|
|
20
|
+
customer.payment_methods.update_all(default: false)
|
|
21
|
+
update!(default: true)
|
|
22
|
+
|
|
17
23
|
result.success?
|
|
18
24
|
end
|
|
19
25
|
|
|
@@ -21,19 +21,6 @@ module Pay
|
|
|
21
21
|
def self.pay_processor_for(name)
|
|
22
22
|
"Pay::#{name.to_s.classify}::PaymentMethod".constantize
|
|
23
23
|
end
|
|
24
|
-
|
|
25
|
-
def payment_processor
|
|
26
|
-
@payment_processor ||= self.class.pay_processor_for(customer.processor).new(self)
|
|
27
|
-
end
|
|
28
|
-
|
|
29
|
-
def make_default!
|
|
30
|
-
return if default?
|
|
31
|
-
|
|
32
|
-
payment_processor.make_default!
|
|
33
|
-
|
|
34
|
-
customer.payment_methods.update_all(default: false)
|
|
35
|
-
update!(default: true)
|
|
36
|
-
end
|
|
37
24
|
end
|
|
38
25
|
end
|
|
39
26
|
|
|
@@ -48,8 +48,9 @@ module Pay
|
|
|
48
48
|
|
|
49
49
|
# Associate charge with subscription if we can
|
|
50
50
|
if object.payment_intent.present?
|
|
51
|
-
invoice_payments = ::Stripe::InvoicePayment.list({payment: {type: :payment_intent, payment_intent: object.payment_intent}, status: :paid
|
|
52
|
-
if invoice_payments.any?
|
|
51
|
+
invoice_payments = ::Stripe::InvoicePayment.list({payment: {type: :payment_intent, payment_intent: object.payment_intent}, status: :paid}, {stripe_account: stripe_account}.compact)
|
|
52
|
+
if invoice_payments.any?
|
|
53
|
+
invoice = ::Stripe::Invoice.retrieve({id: invoice_payments.first.invoice, expand: ["total_discount_amounts.discount.source.coupon"]}, {stripe_account: stripe_account}.compact)
|
|
53
54
|
attrs[:stripe_invoice] = invoice.to_hash
|
|
54
55
|
attrs[:subtotal] = invoice.subtotal
|
|
55
56
|
attrs[:tax] = invoice.total - invoice.total_excluding_tax.to_i
|
|
@@ -67,7 +67,12 @@ module Pay
|
|
|
67
67
|
|
|
68
68
|
# Sets payment method as default
|
|
69
69
|
def make_default!
|
|
70
|
+
return if default?
|
|
71
|
+
|
|
70
72
|
::Stripe::Customer.update(customer.processor_id, {invoice_settings: {default_payment_method: processor_id}}, stripe_options)
|
|
73
|
+
|
|
74
|
+
customer.payment_methods.update_all(default: false)
|
|
75
|
+
update!(default: true)
|
|
71
76
|
end
|
|
72
77
|
|
|
73
78
|
# Remove payment method
|
data/lib/pay/receipts.rb
CHANGED
|
@@ -70,8 +70,8 @@ module Pay
|
|
|
70
70
|
items
|
|
71
71
|
end
|
|
72
72
|
|
|
73
|
-
def discount_description(
|
|
74
|
-
coupon = discount.discount.coupon
|
|
73
|
+
def discount_description(total_discount_amount)
|
|
74
|
+
coupon = total_discount_amount.discount.try(:source).try(:coupon) || total_discount_amount.discount.try(:coupon)
|
|
75
75
|
name = coupon.name
|
|
76
76
|
|
|
77
77
|
if (percent = coupon.percent_off)
|
data/lib/pay/stripe.rb
CHANGED
data/lib/pay/version.rb
CHANGED