pay 10.0.2 → 10.0.3

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: e9a03557a1292cbb8dcd8b3c8b43533b3c2f9a0cfc53481f99976579e1009dba
4
+ data.tar.gz: f1d085db81f5132db3abb62bf07306ae7c4703343d46a39279fbef9eaf7692f7
5
5
  SHA512:
6
- metadata.gz: 3ab2f514dcb11ffcdfac4dbeef8ef88673c2ba9f63d6fe47927953ce9508dd1eabc337dcc47224264a7a843242af830a921cc090c892860edbf972bca877e388
7
- data.tar.gz: 69c039a1ad0732ee7f62113515ee8d1f7d351766a859ccf5a457fb1c8fabde8d06531ea1682f7ff42102cb85956c36971db0aff571b8b30ab4caa47e8e6ca451
6
+ metadata.gz: c8af553a1fffd442ed1bc19399b4e19df35404a41af7546a48737d45af2b9cb9aa7906b71ad9c2abd3b119d72048608afe9a4506ba7dc75f606eff89adc803d5
7
+ data.tar.gz: b1de35982f96be48e20e8d514c0d14ccda50bcc25beb1f5238405931f8a4cc0331edad92160ab664b9a4031b5f9e3533fad3c1d2f529184cebc5bc4311ad19aa
@@ -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.3"
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.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Charnes