pay 10.1.3 → 10.1.4

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: fddeba44df77f083b49b253a9df62cbf96b131f1e6909307ebda05d97182067a
4
- data.tar.gz: a688da09f393dd5979c733218d9532f905a4f8770b24349f9743617752d80e34
3
+ metadata.gz: 873e2e915a42da4de0b3769bd1292cca73e243adce75ffcfe4acc25e8a4752af
4
+ data.tar.gz: a59cc532c1b4a53de674ce5e8aebd7b3ffabb5e171b5619260141b24d59be97c
5
5
  SHA512:
6
- metadata.gz: fbd0cde3b1c9633b4b5648d7e92b4542bd9235a03e808ef8344afc85a08d9a8c66447cd814f7604199c74e26c12124d4a075eb2f1ef7e96c5b3b100f145f0a7d
7
- data.tar.gz: daa632f8f37b54b528e025ce8d8ce6ba294b52457d743ce1360bb0438e5d985ee96b08ab8f72b8c6920f8d295e18d2324edc64e1d8b4999e7523153ddb7e6cb0
6
+ metadata.gz: 4a6a4991279f47d23adcb01c7fe976847114dc99330f635e878cb9e7ea3bbb14c492a330bb37f4d1d63bc87ef006d1e951c36253dcb29e94836a9ff02b7834b3
7
+ data.tar.gz: 5d7d82b1061c9cdb8d6b1d29bc9cb04db2083b83d4ad833717c562a95a3926e0192ff952e2d4509adc97d38220dfdcf989eeaa70ba56c69918eee582c14fc6b4
@@ -20,7 +20,7 @@ module Pay
20
20
  store_accessor :data, :invoice_credit_balance
21
21
  store_accessor :data, :currency
22
22
 
23
- delegate :email, to: :owner
23
+ delegate :email, to: :owner, allow_nil: true
24
24
 
25
25
  %w[stripe braintree paddle_billing paddle_classic lemon_squeezy fake_processor].each do |processor_name|
26
26
  scope processor_name, -> { where(processor: processor_name) }
@@ -55,6 +55,10 @@ module Pay
55
55
  subscriptions.create!(attributes)
56
56
  end
57
57
 
58
+ def sync_subscriptions(**options)
59
+ []
60
+ end
61
+
58
62
  def add_payment_method(payment_method_id, default: false)
59
63
  # Make to generate a processor_id
60
64
  api_record
@@ -297,7 +297,7 @@ module Pay
297
297
  )
298
298
 
299
299
  # Validate that swap was successful and handle SCA if needed
300
- if (payment_intent_id = @api_record.latest_invoice.payments.first.payment.payment_intent)
300
+ if (payment_intent_id = @api_record.latest_invoice.payments.first&.payment&.payment_intent)
301
301
  Pay::Payment.from_id(payment_intent_id).validate
302
302
  end
303
303
 
@@ -35,7 +35,7 @@ module Pay
35
35
  klass = "Pay::#{processor_name.to_s.classify}::Customer".constantize
36
36
  raise ArgumentError, "not a valid payment processor" if klass.ancestors.exclude?(Pay::Customer)
37
37
 
38
- ActiveRecord::Base.transaction do
38
+ with_lock do
39
39
  pay_customers.update_all(default: false)
40
40
  pay_customer = pay_customers.active.where(processor: processor_name, type: klass.name).first_or_initialize
41
41
  pay_customer.update!(attributes.merge(default: true))
@@ -81,7 +81,7 @@ module Pay
81
81
  end
82
82
 
83
83
  def set_merchant_processor(processor_name, **attributes)
84
- ActiveRecord::Base.transaction do
84
+ with_lock do
85
85
  pay_merchants.update_all(default: false)
86
86
  pay_merchant = pay_merchants.where(processor: processor_name, type: "Pay::#{processor_name.to_s.classify}::Merchant").first_or_initialize
87
87
  pay_merchant.update!(attributes.merge(default: true))
@@ -13,11 +13,13 @@ module Pay
13
13
  pay_subscription = Pay::Subscription.find_by_processor_and_id(:stripe, subscription_id)
14
14
  return if pay_subscription.nil? || pay_subscription.status == "incomplete"
15
15
 
16
- if Pay.send_email?(:payment_action_required, pay_subscription)
16
+ invoice_payment = ::Stripe::InvoicePayment.list({invoice: invoice.id, status: :open}).first
17
+
18
+ if invoice_payment && Pay.send_email?(:payment_action_required, pay_subscription)
17
19
  Pay.mailer.with(
18
20
  pay_customer: pay_subscription.customer,
19
- payment_intent_id: invoice.payment_intent,
20
- pay_subscription: pay_subscription
21
+ pay_subscription: pay_subscription,
22
+ payment_intent_id: invoice_payment.payment.payment_intent
21
23
  ).payment_action_required.deliver_later
22
24
  end
23
25
  end
data/lib/pay/version.rb CHANGED
@@ -1,3 +1,3 @@
1
1
  module Pay
2
- VERSION = "10.1.3"
2
+ VERSION = "10.1.4"
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.1.3
4
+ version: 10.1.4
5
5
  platform: ruby
6
6
  authors:
7
7
  - Jason Charnes
@@ -180,7 +180,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
180
180
  - !ruby/object:Gem::Version
181
181
  version: '0'
182
182
  requirements: []
183
- rubygems_version: 3.6.8
183
+ rubygems_version: 3.6.9
184
184
  specification_version: 4
185
185
  summary: Payments engine for Ruby on Rails
186
186
  test_files: []