effective_orders 6.18.2 → 6.18.3

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 30573ea76732efc461d77ac72855675f2a8de7010a81e9d651fafaceb86c75c5
4
- data.tar.gz: 605bb5659cb3b7faf9e0940ed59367b3abfc09535f9f42dcb4048594f1408c09
3
+ metadata.gz: db369e138fd81a06777542fe77c48ac02e78afce689814c6e077e2d5dca7eb70
4
+ data.tar.gz: 3bf2190e5199a568bba9dd26900193f589cc5260ebf4a042192f72e0154b340d
5
5
  SHA512:
6
- metadata.gz: 4f14a09c4ea459f96eb727ac1b7bd8249e1fd42f087a1afca09e3c5705837ddb5ff7b859ab81e654a1e1607f5e4875a82ae8df58c846b50cef79b0296ce9e809
7
- data.tar.gz: c2863834450dad29c443746f3dc4c0db11115ffb03796dd4e35d99d707e12bc81c15cc7d609625dd9ae222f42e276e8d8aa046c089fb0572b66862efa23ceb61
6
+ metadata.gz: c7c3b27cecbb229a85f3dd4bb68e78869ac4fd7a9d25973fad201660efd9ce7af79b834c9ca4c19011a9c379ea4abcb01ceb84721f777ff4fb65ff3d8cbdf305
7
+ data.tar.gz: 470be08bf37435f36f12e31c7118f70545821f1a52357a9c7cc5e51143a50a73cff32b18497cbedb122d63fca021cabb1f2acfa27c62235c05f787ce8e8dcd5a
@@ -154,12 +154,13 @@ module Effective
154
154
  scope :pending_refunds, -> { not_purchased.where('total < ?', 0) }
155
155
 
156
156
  scope :delayed, -> { where(delayed_payment: true).where.not(delayed_payment_date: nil) }
157
+ scope :delayed_payment_provider, -> { where(payment_provider: EffectiveOrders.delayed_providers) }
157
158
  scope :delayed_payment_date_past, -> { delayed.where(arel_table[:delayed_payment_date].lteq(Time.zone.today)) }
158
159
  scope :delayed_payment_date_upcoming, -> { delayed.where(arel_table[:delayed_payment_date].gt(Time.zone.today)) }
159
160
 
160
161
  # Used by the rake effective_orders:purchase_delayed_orders task
161
162
  scope :delayed_ready_to_purchase, -> {
162
- delayed.deferred.delayed_payment_date_past.where(delayed_payment_purchase_ran_at: nil)
163
+ delayed.deferred.delayed_payment_provider.delayed_payment_date_past.where(delayed_payment_purchase_ran_at: nil)
163
164
  }
164
165
 
165
166
  # effective_reports
@@ -196,7 +197,8 @@ module Effective
196
197
  validates :delayed_payment_date, presence: true, if: -> { delayed_payment? }
197
198
  validates :delayed_payment_date, absence: true, unless: -> { delayed_payment? }
198
199
 
199
- with_options(if: -> { delayed? && deferred? }) do
200
+ # deluxe_delayed
201
+ with_options(if: -> { delayed? && deferred? && delayed_payment_provider? }) do
200
202
  validates :delayed_payment_intent, presence: { message: 'please provide your card information' }
201
203
  validates :delayed_payment_total, presence: true
202
204
  end
@@ -248,7 +250,7 @@ module Effective
248
250
  validates :payment_provider, presence: true
249
251
 
250
252
  validate do
251
- unless EffectiveOrders.deferred_providers.include?(payment_provider) || EffectiveOrders.delayed_providers.include?(payment_provider)
253
+ unless deferred_payment_provider? || delayed_payment_provider?
252
254
  errors.add(:payment_provider, "unknown deferred payment provider")
253
255
  end
254
256
  end
@@ -546,6 +548,14 @@ module Effective
546
548
  def refund?
547
549
  total.to_i < 0
548
550
  end
551
+
552
+ def delayed_payment_provider?
553
+ payment_provider.present? && EffectiveOrders.delayed_providers.include?(payment_provider)
554
+ end
555
+
556
+ def deferred_payment_provider?
557
+ payment_provider.present? && EffectiveOrders.deferred_providers.include?(payment_provider)
558
+ end
549
559
 
550
560
  # A new order is created.
551
561
  # If the delayed_payment and delayed_payment date are set, it's a delayed order
@@ -558,6 +568,7 @@ module Effective
558
568
  def delayed_ready_to_purchase?
559
569
  return false unless delayed?
560
570
  return false unless deferred?
571
+ return false unless delayed_payment_provider?
561
572
  return false unless delayed_payment_intent.present?
562
573
  return false if delayed_payment_date_upcoming?
563
574
  return false if delayed_payment_purchase_ran_at.present? # We ran before and probably failed
@@ -566,7 +577,7 @@ module Effective
566
577
  end
567
578
 
568
579
  def delayed_payment_info
569
- return unless delayed? && deferred?
580
+ return unless delayed? && deferred? && delayed_payment_provider?
570
581
  return unless delayed_payment_date_upcoming?
571
582
 
572
583
  "Your #{delayed_payment_method} will be charged $#{'%0.2f' % total_to_f} on #{delayed_payment_date.strftime('%F')}"
@@ -12,6 +12,10 @@
12
12
  - if EffectiveOrders.delayed? && order.delayed_payment_date_upcoming?
13
13
  = render partial: '/effective/orders/delayed/form', locals: provider_locals
14
14
 
15
+ - if EffectiveOrders.deferred? && !controller_path.include?('admin/') && !local_assigns[:skip_deferred]
16
+ %p.my-4.text-center - or -
17
+ = render partial: '/effective/orders/deferred/form', locals: provider_locals
18
+
15
19
  - elsif EffectiveOrders.free? && order.free?
16
20
  = render partial: '/effective/orders/free/form', locals: provider_locals
17
21
 
@@ -41,8 +45,8 @@
41
45
  %p.my-4.text-center - or -
42
46
  = render partial: '/effective/orders/deferred/form', locals: provider_locals
43
47
 
44
- - if EffectiveResources.authorized?(controller, :admin, :effective_orders) && controller_path.include?('admin/') && order.user != current_user
45
- - if EffectiveOrders.delayed? && order.delayed? && order.deferred?
48
+ - if EffectiveResources.authorized?(controller, :admin, :effective_orders) && controller_path.include?('admin/')
49
+ - if EffectiveOrders.delayed? && order.delayed? && order.deferred? && order.delayed_payment_provider?
46
50
  .effective-order-admin-purchase-actions
47
51
  = render partial: '/effective/orders/delayed/form_purchase', locals: provider_locals
48
52
 
@@ -7,7 +7,7 @@
7
7
  %tbody
8
8
  %tr
9
9
  %td
10
- - if order.delayed?
10
+ - if order.delayed? && order.delayed_payment_provider?
11
11
  %p Your #{order.delayed_payment_method} will be charged on #{order.delayed_payment_date.strftime('%F')}
12
12
  - else
13
13
  %p Waiting for payment by #{order.payment_provider}.
@@ -17,7 +17,7 @@
17
17
 
18
18
  - provider_locals = { order: order, deferred_url: deferred_url, declined_url: declined_url }
19
19
 
20
- - if order.deferred? && order.delayed?
20
+ - if order.deferred? && order.delayed? && order.delayed_payment_provider?
21
21
  %p Your existing #{order.delayed_payment_method} will be charged on the payment date.
22
22
 
23
23
  = collapse('Change my card info') do
@@ -1,3 +1,3 @@
1
1
  module EffectiveOrders
2
- VERSION = '6.18.2'.freeze
2
+ VERSION = '6.18.3'.freeze
3
3
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: effective_orders
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.18.2
4
+ version: 6.18.3
5
5
  platform: ruby
6
6
  authors:
7
7
  - Code and Effect
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2025-01-06 00:00:00.000000000 Z
11
+ date: 2025-01-14 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails