effective_orders 6.12.3 → 6.12.4

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: 4f5fbabf9c4012193962576f7ef67838e17e382740ad3860ab9c9f527ce86787
4
- data.tar.gz: 71f6af17259b5b62ee66b2fd993bb085dc8411ad8040c21fa0a3bc639381c655
3
+ metadata.gz: 6d365ebd0599f72ed9c5bbf7e9e9f26284647135153befe60799452b87fc1e0c
4
+ data.tar.gz: 913c9fa4e2d528382652c297d6806fb827c79974baebb9890ddd1854449f98d1
5
5
  SHA512:
6
- metadata.gz: 60eff8ba4e046b46575a23c98daf14b0ba07cf548041826590ac49c3bf193cde6632437baeae38bfe011f37a3cae0e7d3d5d444aeeb0340a0990d1c93a88ce2b
7
- data.tar.gz: 9b91126b76b01d50fefc86b31d1a163dfe8164c523f69a2c3a523a827c632faaf0b0b5e13e0174b01450078dd32754a76157b5c4338b39b16b47a10ca1d25c59
6
+ metadata.gz: d5fde239931a219f5e15a29a085dd4f056f12174fb4e6331b5b05369d8798518781e7eddae549edb3d3e8d34a9a8a18896a6a271fa0883a15161f75766cad95b
7
+ data.tar.gz: 2b0daaa3d6a0b0111efe48cac3db3d2b0073a3a8ed3b51ec5e9beaeaadaee604ae515cdc5c309b33c8a4ad28598bfcbdd3c6f345aa95052543588f31dcc1a6bc
@@ -45,7 +45,7 @@ module EffectiveOrdersHelper
45
45
  when :deluxe
46
46
  'Pay Now'
47
47
  when :deluxe_delayed
48
- 'Save now and charge me later'
48
+ 'Save card and charge me later'
49
49
  when :etransfer
50
50
  'Pay by E-transfer'
51
51
  when :free
@@ -39,8 +39,19 @@ module ActsAsPurchasableParent
39
39
  end
40
40
 
41
41
  included do
42
- has_many :orders, -> { order(:id) }, as: :parent, class_name: 'Effective::Order', dependent: :nullify
42
+ has_many :orders, -> { order(:id) }, as: :parent, class_name: 'Effective::Order'
43
+
43
44
  accepts_nested_attributes_for :orders
45
+
46
+ before_destroy do
47
+ orders.each do |order|
48
+ raise('unable to destroy a purchasable_parent with purchased orders') if order.purchased?
49
+ order.voided? ? order.save! : order.void!
50
+ end
51
+
52
+ true
53
+ end
54
+
44
55
  end
45
56
 
46
57
  end
@@ -548,13 +548,20 @@ module Effective
548
548
  return false unless delayed?
549
549
  return false unless deferred?
550
550
  return false unless delayed_payment_intent.present?
551
- return false if delayed_payment_date_future?
551
+ return false if delayed_payment_date_upcoming?
552
552
  return false if delayed_payment_purchase_ran_at.present? # We ran before and probably failed
553
553
 
554
554
  true
555
555
  end
556
556
 
557
- def delayed_payment_date_future?
557
+ def delayed_payment_info
558
+ return unless delayed? && deferred?
559
+ return unless delayed_payment_date_upcoming?
560
+
561
+ "Your #{delayed_payment_method} will be charged on #{delayed_payment_date.strftime('%F')} for the full amount of $#{'%0.2f' % total_to_f}"
562
+ end
563
+
564
+ def delayed_payment_date_upcoming?
558
565
  return false unless delayed?
559
566
  delayed_payment_date > Time.zone.now.to_date
560
567
  end
@@ -832,6 +839,15 @@ module Effective
832
839
  unvoided!(skip_buyer_validations: true)
833
840
  end
834
841
 
842
+ def deluxe_delayed_purchase!
843
+ raise('expected a delayed order') unless delayed?
844
+ raise('expected a deferred order') unless deferred?
845
+ raise('expected delayed payment intent') unless delayed_payment_intent.present?
846
+ raise('expected a deluxe_delayed payment provider') unless payment_provider == 'deluxe_delayed'
847
+
848
+ Effective::DeluxeApi.new().purchase_delayed_orders!(self)
849
+ end
850
+
835
851
  # These are all the emails we send all notifications to
836
852
  def emails
837
853
  ([purchased_by.try(:email)] + [email] + [user.try(:email)] + Array(organization.try(:billing_emails))).map(&:presence).compact.uniq
@@ -8,6 +8,6 @@
8
8
  %tr
9
9
  %td
10
10
  - if order.delayed?
11
- Your #{order.delayed_payment_method} will be charged on #{order.delayed_payment_date.strftime('%F')} for the full amount
11
+ Your #{order.delayed_payment_method} will be charged on #{order.delayed_payment_date.strftime('%F')}
12
12
  - else
13
13
  Waiting for payment by #{order.payment_provider}
@@ -8,18 +8,24 @@
8
8
 
9
9
  The payment date for this order
10
10
 
11
- - if order.delayed_payment_date_future?
11
+ - if order.delayed_payment_date_upcoming?
12
12
  is in #{distance} from now on #{order.delayed_payment_date.strftime('%F')}
13
13
  - elsif order.delayed_payment_date_today?
14
14
  was today
15
15
  - else
16
16
  was #{distance} ago on #{order.delayed_payment_date.strftime('%F')}
17
+
18
+ - provider_locals = { order: order, deferred_url: deferred_url, declined_url: declined_url }
17
19
 
18
- %p
19
- Instead of charging your card right away, the following action will securely save a token
20
- representing your card information. The full amount will be charged on the payment date.
20
+ - if order.deferred? && order.delayed?
21
+ %p Your existing #{order.delayed_payment_method} will be charged on the payment date.
21
22
 
22
- - provider_locals = { order: order, deferred_url: deferred_url, declined_url: declined_url }
23
+ = collapse('Change my card info') do
24
+ - EffectiveOrders.delayed_providers.each do |provider|
25
+ = render partial: "/effective/orders/#{provider}/form", locals: provider_locals
26
+ - else
27
+ %p
28
+ Please enter your card information so it can be charged on the payment date.
23
29
 
24
- - EffectiveOrders.delayed_providers.each do |provider|
25
- = render partial: "/effective/orders/#{provider}/form", locals: provider_locals
30
+ - EffectiveOrders.delayed_providers.each do |provider|
31
+ = render partial: "/effective/orders/#{provider}/form", locals: provider_locals
@@ -13,7 +13,7 @@
13
13
 
14
14
  The payment date for this order
15
15
 
16
- - if order.delayed_payment_date_future?
16
+ - if order.delayed_payment_date_upcoming?
17
17
  is in #{distance} from now on #{order.delayed_payment_date.strftime('%F')}
18
18
  - elsif order.delayed_payment_date_today?
19
19
  was today
@@ -1,3 +1,3 @@
1
1
  module EffectiveOrders
2
- VERSION = '6.12.3'.freeze
2
+ VERSION = '6.12.4'.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.12.3
4
+ version: 6.12.4
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: 2024-05-31 00:00:00.000000000 Z
11
+ date: 2024-06-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: rails