pay 11.5.0 → 11.6.1

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: bcb89cdb780ab408b8944ee8fa69c4c08d478a61d81c63b7d76a46a95be2c30f
4
- data.tar.gz: 7a099fbc3c7322c94b7924dce3a39b82e610c86c48a4e62ffc2c785931e42244
3
+ metadata.gz: b562e4a4f9648149c46c4932ad4c770cb6c9f93bc424b84ba8619cb7282170bc
4
+ data.tar.gz: c8328e7c5b1d4770131515d56fcd8b8a6170f6d427bbda29159d00d8dd8244f3
5
5
  SHA512:
6
- metadata.gz: 10ea989771b7f383b15276ebb647630f4657aa4ba6cb0ae335f31d87b8a5bc6033e35c81c76cec112b4a3d35992c5d6345d0275f329c8ee72fce3a2215598927
7
- data.tar.gz: ea3ce066533ef2a84ce2feda0c5e58f6232f43d44c5581a51ce936a4d2f170ad17ee6432068b78649bf11df8c4601592a9600430590494007490291d880414d0
6
+ metadata.gz: 272d38c42d2be1bfaf55929c429b15164c2dd2f64eca8571f4d868a0df0262f8599b5ac81c23539cf24c8a263b5bc8670b7f075871d79abdae1fa4983474ded4
7
+ data.tar.gz: d56318ddb06905b38bf3869b8dea5415ff8159b0a1b70d0e228389e1f23cc060a8fbe153028f682e7b6775688aae82a7d2514b560ea965e089b6076a339acb16
@@ -0,0 +1,34 @@
1
+ module Pay
2
+ module Stripe
3
+ module Webhooks
4
+ class InvoiceUpdated
5
+ def call(event)
6
+ # Grab the invoice from the event
7
+ invoice = event.data.object
8
+
9
+ # Find the corresponding subscription_id
10
+ subscription_id = invoice.parent.try(:subscription_details).try(:subscription)
11
+
12
+ # Not all invoices have a subscription - could be a one-time or manual payment
13
+ return if subscription_id.blank?
14
+
15
+ # Grab the local subscription
16
+ subscription = Pay::Subscription.find_by_processor_and_id(:stripe, subscription_id)
17
+
18
+ # Return if we don't have a corresponding subscription
19
+ return unless subscription
20
+
21
+ # Grab the local latest_invoice from the subscription stripe_object
22
+ latest_invoice = subscription.stripe_object.try(:latest_invoice)
23
+
24
+ # Compare the local invoice id to the event invoice id and sync if they are the same
25
+ if latest_invoice.id.to_s == invoice.id.to_s
26
+ Pay::Stripe::Subscription.sync(subscription_id, stripe_account: event.try(:account))
27
+ end
28
+ rescue ::Stripe::StripeError => e
29
+ Rails.logger.error "Stripe Webhook Error (InvoiceUpdated): #{e.message}"
30
+ end
31
+ end
32
+ end
33
+ end
34
+ end
data/lib/pay/stripe.rb CHANGED
@@ -12,6 +12,7 @@ module Pay
12
12
  autoload :CheckoutSessionAsyncPaymentSucceeded, "pay/stripe/webhooks/checkout_session_async_payment_succeeded"
13
13
  autoload :CustomerDeleted, "pay/stripe/webhooks/customer_deleted"
14
14
  autoload :CustomerUpdated, "pay/stripe/webhooks/customer_updated"
15
+ autoload :InvoiceUpdated, "pay/stripe/webhooks/invoice_updated"
15
16
  autoload :PaymentActionRequired, "pay/stripe/webhooks/payment_action_required"
16
17
  autoload :PaymentFailed, "pay/stripe/webhooks/payment_failed"
17
18
  autoload :PaymentIntentSucceeded, "pay/stripe/webhooks/payment_intent_succeeded"
@@ -84,6 +85,9 @@ module Pay
84
85
  # This probably should be ignored for monthly subscriptions.
85
86
  events.subscribe "stripe.invoice.upcoming", Pay::Stripe::Webhooks::SubscriptionRenewing.new
86
87
 
88
+ # Ensures the local stripe_object is up-to-date anytime the API's record is updated.
89
+ events.subscribe "stripe.invoice.updated", Pay::Stripe::Webhooks::InvoiceUpdated.new
90
+
87
91
  # Payment action is required to process an invoice
88
92
  events.subscribe "stripe.invoice.payment_action_required", Pay::Stripe::Webhooks::PaymentActionRequired.new
89
93
 
data/lib/pay/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pay
2
- VERSION = "11.5.0"
2
+ VERSION = "11.6.1"
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: 11.5.0
4
+ version: 11.6.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Charnes
@@ -153,6 +153,7 @@ files:
153
153
  - lib/pay/stripe/webhooks/checkout_session_completed.rb
154
154
  - lib/pay/stripe/webhooks/customer_deleted.rb
155
155
  - lib/pay/stripe/webhooks/customer_updated.rb
156
+ - lib/pay/stripe/webhooks/invoice_updated.rb
156
157
  - lib/pay/stripe/webhooks/payment_action_required.rb
157
158
  - lib/pay/stripe/webhooks/payment_failed.rb
158
159
  - lib/pay/stripe/webhooks/payment_intent_succeeded.rb
@@ -172,7 +173,8 @@ files:
172
173
  homepage: https://github.com/pay-rails/pay
173
174
  licenses:
174
175
  - MIT
175
- metadata: {}
176
+ metadata:
177
+ rubygems_mfa_required: 'true'
176
178
  rdoc_options: []
177
179
  require_paths:
178
180
  - lib
@@ -187,7 +189,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
187
189
  - !ruby/object:Gem::Version
188
190
  version: '0'
189
191
  requirements: []
190
- rubygems_version: 4.0.9
192
+ rubygems_version: 4.0.3
191
193
  specification_version: 4
192
194
  summary: Payments engine for Ruby on Rails
193
195
  test_files: []