pay 4.0.1 → 4.0.2

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of pay might be problematic. Click here for more details.

checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '09c79f10c2e9258ebfd7a54a58283d0d14eb33121b5f51f4a5b563088f672d41'
4
- data.tar.gz: 14af03dc31b7b65f9975c90876d1ffb764009e3cae1038abe2bce37822901c49
3
+ metadata.gz: cd5f149f88ae66352491ff4da889e6e252d491fa37467a1a7a05d635ef855f61
4
+ data.tar.gz: 970ca6f6183aba7795368d5b2b78c3ddb932498bd54af20567c467d126246e10
5
5
  SHA512:
6
- metadata.gz: bb583c78584c50bbf21d8d15f7a97449073864cb7064c6ae265639d3f75a97d528868d9db1b2b5d4a8e4e1036d19dd55a4ecdd49f96b9f24149f8e38c4cd4eab
7
- data.tar.gz: 95f41a1f851f09d9dae598a7d2f795668f4c1b5f28b0fec2ac05e7aed1fd95ad5aefdc5f1fab28f4cbf9a16b6385d55d40bb0f78562906335d8373eb4d76cdee
6
+ metadata.gz: e7fd623efada808362cef4f67d1a66919a2a74103c69cf16c859d854dc5e4ef8aed9e58cccd6addc1b2328b663824d7fa0830144ec44bceff3c2fde32a6f7131
7
+ data.tar.gz: 27cad2d3b9a1fb239c5dc68282f728fadf07451b2a9c9aa29d77274077d52b608865a39f90de5d3416f69c418f75493a545f4f41f00b58bccf722a52dcfabf3e
@@ -1,14 +1,7 @@
1
1
  module Pay
2
2
  module Stripe
3
3
  module Webhooks
4
- class CheckoutSessionAsyncPaymentSucceeded
5
- def call(event)
6
- # TODO: Also handle payment intents
7
-
8
- if event.data.object.subscription
9
- Pay::Stripe::Subscription.sync(event.data.object.subscription, stripe_account: event.try(:account))
10
- end
11
- end
4
+ class CheckoutSessionAsyncPaymentSucceeded < CheckoutSessionCompleted
12
5
  end
13
6
  end
14
7
  end
@@ -5,10 +5,29 @@ module Pay
5
5
  def call(event)
6
6
  # TODO: Also handle payment intents
7
7
 
8
- if event.data.object.subscription
9
- Pay::Stripe::Subscription.sync(event.data.object.subscription, stripe_account: event.try(:account))
8
+ locate_owner(event.data.object)
9
+
10
+ if (payment_intent_id = event.data.object.payment_intent)
11
+ payment_intent = ::Stripe::PaymentIntent.retrieve(payment_intent_id, {stripe_account: event.try(:account)}.compact)
12
+ payment_intent.charges.each do |charge|
13
+ Pay::Stripe::Charge.sync(charge.id, stripe_account: event.try(:account))
14
+ end
15
+ end
16
+
17
+ if (subscription_id = event.data.object.subscription)
18
+ Pay::Stripe::Subscription.sync(subscription_id, stripe_account: event.try(:account))
10
19
  end
11
20
  end
21
+
22
+ def locate_owner(object)
23
+ return if object.client_reference_id.nil?
24
+
25
+ # If there is a client reference ID, make sure we have a Pay::Customer record
26
+ owner = GlobalID::Locator.locate_signed(object.client_reference_id)
27
+ owner&.add_payment_processor(:stripe, processor_id: object.customer)
28
+ rescue
29
+ Rails.logger.debug "[Pay] Unable to locate record with SGID: #{object.client_reference_id}"
30
+ end
12
31
  end
13
32
  end
14
33
  end
data/lib/pay/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pay
2
- VERSION = "4.0.1"
2
+ VERSION = "4.0.2"
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: 4.0.1
4
+ version: 4.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Charnes
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2022-06-07 00:00:00.000000000 Z
12
+ date: 2022-07-27 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails