pay 10.0.2 → 10.0.4
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
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: a2c55cf9e768d0706c1ea9cb6efa042bd4988655ff64ef8692950b2333352238
|
4
|
+
data.tar.gz: 33eefe08c1f201a4a58bee3d80705a2677aa6a064c4a00a1bf391965819e81be
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b136aa767deaa1ea0c37cc6d7e9e340e588005ba14d5b23c6ff7043e86b408720a9f86efc8e850308c52a665aa8d11182261d63a3c98f326243cffa1f26f9303
|
7
|
+
data.tar.gz: b9b7336acd10e8a956fc3d3911e81bf002d5003cf0f1283c21cee24fd79bef7b43cc331cdc6988ce0551ec8eb5fe99da976741595c939ad7e4a4c27c8d0aad55
|
@@ -6,16 +6,17 @@ module Pay
|
|
6
6
|
# Event is of type "invoice" see:
|
7
7
|
# https://stripe.com/docs/api/invoices/object
|
8
8
|
|
9
|
-
|
9
|
+
invoice = event.data.object
|
10
|
+
subscription_id = invoice.parent.try(:subscription_details).try(:subscription)
|
10
11
|
|
11
12
|
# Don't send email on incomplete Stripe subscriptions since they're just getting created and the JavaScript will handle SCA
|
12
|
-
pay_subscription = Pay::Subscription.find_by_processor_and_id(:stripe,
|
13
|
+
pay_subscription = Pay::Subscription.find_by_processor_and_id(:stripe, subscription_id)
|
13
14
|
return if pay_subscription.nil? || pay_subscription.status == "incomplete"
|
14
15
|
|
15
16
|
if Pay.send_email?(:payment_action_required, pay_subscription)
|
16
17
|
Pay.mailer.with(
|
17
18
|
pay_customer: pay_subscription.customer,
|
18
|
-
payment_intent_id:
|
19
|
+
payment_intent_id: invoice.payment_intent,
|
19
20
|
pay_subscription: pay_subscription
|
20
21
|
).payment_action_required.deliver_later
|
21
22
|
end
|
@@ -6,16 +6,17 @@ module Pay
|
|
6
6
|
# Event is of type "invoice" see:
|
7
7
|
# https://stripe.com/docs/api/invoices/object
|
8
8
|
|
9
|
-
|
9
|
+
invoice = event.data.object
|
10
|
+
subscription_id = invoice.parent.try(:subscription_details).try(:subscription)
|
10
11
|
|
11
12
|
# Don't send email on incomplete Stripe subscriptions since they're just getting created and the JavaScript will handle SCA
|
12
|
-
pay_subscription = Pay::Subscription.find_by_processor_and_id(:stripe,
|
13
|
+
pay_subscription = Pay::Subscription.find_by_processor_and_id(:stripe, subscription_id)
|
13
14
|
return if pay_subscription.nil? || pay_subscription.status == "incomplete"
|
14
15
|
|
15
16
|
if Pay.send_email?(:payment_failed, pay_subscription)
|
16
17
|
Pay.mailer.with(
|
17
18
|
pay_customer: pay_subscription.customer,
|
18
|
-
stripe_invoice:
|
19
|
+
stripe_invoice: invoice
|
19
20
|
).payment_failed.deliver_now
|
20
21
|
end
|
21
22
|
end
|
@@ -6,17 +6,20 @@ module Pay
|
|
6
6
|
# Occurs X number of days before a subscription is scheduled to create an invoice that is automatically charged—where X is determined by your subscriptions settings. Note: The received Invoice object will not have an invoice ID.
|
7
7
|
|
8
8
|
def call(event)
|
9
|
+
invoice = event.data.object
|
10
|
+
subscription_id = invoice.parent.try(:subscription_details).try(:subscription)
|
11
|
+
|
9
12
|
# Event is of type "invoice" see:
|
10
13
|
# https://stripe.com/docs/api/invoices/object
|
11
|
-
pay_subscription = Pay::Subscription.find_by_processor_and_id(:stripe,
|
14
|
+
pay_subscription = Pay::Subscription.find_by_processor_and_id(:stripe, subscription_id)
|
12
15
|
return unless pay_subscription
|
13
16
|
|
14
17
|
# Stripe subscription items all have the same interval
|
15
|
-
price =
|
18
|
+
price = ::Stripe::Price.retrieve(invoice.lines.first.pricing.price_details.price)
|
16
19
|
|
17
20
|
# For collection_method=send_invoice, Stripe will send an email and next_payment_attempt will be null
|
18
21
|
# https://docs.stripe.com/api/invoices/object#invoice_object-collection_method
|
19
|
-
if Pay.send_email?(:subscription_renewing, pay_subscription, price) && (next_payment_attempt =
|
22
|
+
if Pay.send_email?(:subscription_renewing, pay_subscription, price) && (next_payment_attempt = invoice.next_payment_attempt)
|
20
23
|
Pay.mailer.with(
|
21
24
|
pay_customer: pay_subscription.customer,
|
22
25
|
pay_subscription: pay_subscription,
|
data/lib/pay/version.rb
CHANGED