pay 11.4.3 → 11.6.0
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 +4 -4
- data/app/models/pay/braintree/customer.rb +1 -1
- data/lib/pay/errors.rb +1 -1
- data/lib/pay/stripe/webhooks/invoice_updated.rb +34 -0
- data/lib/pay/stripe.rb +5 -1
- data/lib/pay/version.rb +1 -1
- metadata +3 -2
checksums.yaml
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
---
|
|
2
2
|
SHA256:
|
|
3
|
-
metadata.gz:
|
|
4
|
-
data.tar.gz:
|
|
3
|
+
metadata.gz: 503a2d20ce3d8163cac35c916673cc1cc56d252fc895a292694eaba7dfab2924
|
|
4
|
+
data.tar.gz: 03630e69b4b412963703a8bc2649552867de46be58c394885868e330203ef723
|
|
5
5
|
SHA512:
|
|
6
|
-
metadata.gz:
|
|
7
|
-
data.tar.gz:
|
|
6
|
+
metadata.gz: 4dde8d6ebbbe1b4b212f971491843a3dce19f9335a47e9e3ad85364f1229c3cd93c1e148b36e3f3f37c634fae51212199ca1616619d1ed48fac4fdea9681bf51
|
|
7
|
+
data.tar.gz: 67a37ea6b91b289d9f11a1a1258c9e8715d2b80082605810bc48e710f3a0cf1f2e765de4e89b9e151c032094294b4e561ef4ce6d69ac45d7a3961cb18d7b7401
|
|
@@ -158,7 +158,7 @@ module Pay
|
|
|
158
158
|
|
|
159
159
|
def save_payment_method(payment_method, default:)
|
|
160
160
|
attributes = case payment_method
|
|
161
|
-
when ::Braintree::CreditCard, ::Braintree::ApplePayCard, ::Braintree::GooglePayCard, ::Braintree::SamsungPayCard
|
|
161
|
+
when ::Braintree::CreditCard, ::Braintree::ApplePayCard, ::Braintree::GooglePayCard, ::Braintree::SamsungPayCard
|
|
162
162
|
{
|
|
163
163
|
payment_method_type: :card,
|
|
164
164
|
brand: payment_method.card_type,
|
data/lib/pay/errors.rb
CHANGED
|
@@ -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"
|
|
@@ -27,7 +28,7 @@ module Pay
|
|
|
27
28
|
|
|
28
29
|
extend Env
|
|
29
30
|
|
|
30
|
-
REQUIRED_VERSION = "~>
|
|
31
|
+
REQUIRED_VERSION = "~> 19"
|
|
31
32
|
|
|
32
33
|
# A list of database model names that include Pay
|
|
33
34
|
# Used for safely looking up models with client_reference_id
|
|
@@ -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
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.
|
|
4
|
+
version: 11.6.0
|
|
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
|
|
@@ -187,7 +188,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
|
187
188
|
- !ruby/object:Gem::Version
|
|
188
189
|
version: '0'
|
|
189
190
|
requirements: []
|
|
190
|
-
rubygems_version: 4.0.
|
|
191
|
+
rubygems_version: 4.0.9
|
|
191
192
|
specification_version: 4
|
|
192
193
|
summary: Payments engine for Ruby on Rails
|
|
193
194
|
test_files: []
|