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: 5d100fe3b67eb40c0099ad4875c9aed063da3a57d6ddd84f7d3ccd572d53bbcd
4
- data.tar.gz: 8c62540416d2089e12dabb3cb5b2780201088d7c793bad92adfa839e14363c06
3
+ metadata.gz: a2c55cf9e768d0706c1ea9cb6efa042bd4988655ff64ef8692950b2333352238
4
+ data.tar.gz: 33eefe08c1f201a4a58bee3d80705a2677aa6a064c4a00a1bf391965819e81be
5
5
  SHA512:
6
- metadata.gz: 3ab2f514dcb11ffcdfac4dbeef8ef88673c2ba9f63d6fe47927953ce9508dd1eabc337dcc47224264a7a843242af830a921cc090c892860edbf972bca877e388
7
- data.tar.gz: 69c039a1ad0732ee7f62113515ee8d1f7d351766a859ccf5a457fb1c8fabde8d06531ea1682f7ff42102cb85956c36971db0aff571b8b30ab4caa47e8e6ca451
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
- object = event.data.object
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, object.subscription)
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: event.data.object.payment_intent,
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
- object = event.data.object
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, object.subscription)
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: object
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, event.data.object.subscription)
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 = event.data.object.lines.data.first.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 = event.data.object.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
@@ -1,3 +1,3 @@
1
1
  module Pay
2
- VERSION = "10.0.2"
2
+ VERSION = "10.0.4"
3
3
  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: 10.0.2
4
+ version: 10.0.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Charnes