pay 10.0.1 → 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: 97c43263ab73cd849da8c65e8a4f1235aabb28b6f35c56c5441c077838374186
4
- data.tar.gz: c0161223fdbd12eee31ef928639bba40e9af1a63e2e6cdeee3e2a69fce106de4
3
+ metadata.gz: e9a03557a1292cbb8dcd8b3c8b43533b3c2f9a0cfc53481f99976579e1009dba
4
+ data.tar.gz: f1d085db81f5132db3abb62bf07306ae7c4703343d46a39279fbef9eaf7692f7
5
5
  SHA512:
6
- metadata.gz: 1fd5fdc16c976d6d33e908210c54de32cdbfcea6e0d641b58eb5f6e52fb5ff217bb59ac6ae3bb7118f8e59f5f6bcc2f2bd88fd61736d01c9fff386ebf24937ef
7
- data.tar.gz: ffee6759b0bae293ffadb173158a57bac35e9f10150a38846499e2ffe635380a64606847098303a9422addd23e7e372d08669929b973c4135df2f2f81a3a0d2c
6
+ metadata.gz: c8af553a1fffd442ed1bc19399b4e19df35404a41af7546a48737d45af2b9cb9aa7906b71ad9c2abd3b119d72048608afe9a4506ba7dc75f606eff89adc803d5
7
+ data.tar.gz: b1de35982f96be48e20e8d514c0d14ccda50bcc25beb1f5238405931f8a4cc0331edad92160ab664b9a4031b5f9e3533fad3c1d2f529184cebc5bc4311ad19aa
@@ -89,7 +89,7 @@ module Pay
89
89
 
90
90
  response = ::Paddle::Subscription.cancel(
91
91
  id: processor_id,
92
- effective_from: options.fetch(:effective_from, (paused? ? "immediately" : "next_billing_period"))
92
+ effective_from: options.fetch(:effective_from, paused? ? "immediately" : "next_billing_period")
93
93
  )
94
94
  update(
95
95
  status: response.status,
data/lib/pay/receipts.rb CHANGED
@@ -31,7 +31,7 @@ module Pay
31
31
  ]
32
32
  ]
33
33
 
34
- if stripe_invoice
34
+ if try(:stripe_invoice)
35
35
  stripe_invoice.lines.auto_paging_each do |line|
36
36
  items << [line.description, line.quantity, Pay::Currency.format(line.pricing.unit_amount_decimal, currency: line.currency), Pay::Currency.format(line.amount, currency: line.currency)]
37
37
 
@@ -45,21 +45,21 @@ module Pay
45
45
  end
46
46
 
47
47
  # If no subtotal, we will display the total
48
- items << [nil, nil, I18n.t("pay.line_items.subtotal"), Pay::Currency.format(stripe_invoice&.subtotal || amount, currency: currency)]
48
+ items << [nil, nil, I18n.t("pay.line_items.subtotal"), Pay::Currency.format(try(:stripe_invoice)&.subtotal || amount, currency: currency)]
49
49
 
50
50
  # Discounts on the invoice
51
- stripe_invoice&.discounts&.each do |discount_id|
51
+ try(:stripe_invoice)&.discounts&.each do |discount_id|
52
52
  discount = stripe_invoice.total_discount_amounts.find { |d| d.discount.id == discount_id }
53
53
  items << [nil, nil, discount_description(discount), Pay::Currency.format(-discount.amount, currency: currency)]
54
54
  end
55
55
 
56
56
  # Total excluding tax
57
- if stripe_invoice
57
+ if try(:stripe_invoice)
58
58
  items << [nil, nil, I18n.t("pay.line_items.total"), Pay::Currency.format(stripe_invoice.total_excluding_tax, currency: currency)]
59
59
  end
60
60
 
61
61
  # Tax rates
62
- stripe_invoice&.total_taxes&.each do |tax|
62
+ try(:stripe_invoice)&.total_taxes&.each do |tax|
63
63
  next if tax.amount.zero?
64
64
  # tax_rate = ::Stripe::TaxRate.retrieve(tax.tax_rate_details.tax_rate)
65
65
  items << [nil, nil, I18n.t("pay.line_items.tax"), Pay::Currency.format(tax.amount, currency: currency)]
@@ -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.1"
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.1
4
+ version: 10.0.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Charnes