effective_orders 5.8.1 → 5.9.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/effective/providers/refund.rb +1 -0
- data/app/datatables/admin/effective_orders_datatable.rb +3 -1
- data/app/models/effective/order.rb +17 -3
- data/app/views/admin/orders/_datatable_actions.html.haml +1 -1
- data/app/views/effective/orders/_order_actions.html.haml +4 -3
- data/app/views/effective/orders/mark_as_paid/_form.html.haml +12 -9
- data/app/views/effective/orders/refund/_form.html.haml +9 -4
- data/config/effective_orders.rb +22 -4
- data/lib/effective_orders/version.rb +1 -1
- data/lib/effective_orders.rb +6 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 03a959b70b778d7a61499dcaec401c812b0fda1685fbbf9593fb75dd12aa21b6
|
4
|
+
data.tar.gz: 79f227bd79c340bfe03e37db465dc85addeecf36ab33c3b4977e85ad8bc46a53
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 10f7edcd5aa36dfcc1a37802453c781e6e40818747818e14a09994ded71d53021fb4e0218dc5302c15ff952fe4f9272ae846d0b5dce5d897bba530c1e561e51a
|
7
|
+
data.tar.gz: 7450d630b12ae7755093f99239e759f88d0b3ff077bd04cf1a7eb9c9c740dd3d62c5d22db5649d6f594e6299d7162d7936ede470de24a3648008bf11bc9ecdd6
|
@@ -19,6 +19,8 @@ class Admin::EffectiveOrdersDatatable < Effective::Datatable
|
|
19
19
|
scope :purchased
|
20
20
|
|
21
21
|
scope :deferred if EffectiveOrders.deferred_providers.present?
|
22
|
+
|
23
|
+
scope :pending_refunds if EffectiveOrders.refund && !EffectiveOrders.buyer_purchases_refund?
|
22
24
|
scope :refunds if EffectiveOrders.refund
|
23
25
|
|
24
26
|
scope :not_purchased
|
@@ -38,7 +40,7 @@ class Admin::EffectiveOrdersDatatable < Effective::Datatable
|
|
38
40
|
end
|
39
41
|
|
40
42
|
col :purchased_at do |order|
|
41
|
-
order.purchased_at&.strftime('%F %H:%M') || 'not purchased'
|
43
|
+
order.purchased_at&.strftime('%F %H:%M') || ('pending refund' if order.pending_refund?) || 'not purchased'
|
42
44
|
end
|
43
45
|
|
44
46
|
if attributes[:user_id].blank?
|
@@ -75,7 +75,9 @@ module Effective
|
|
75
75
|
scope :deferred, -> { where(state: EffectiveOrders::DEFERRED) }
|
76
76
|
scope :declined, -> { where(state: EffectiveOrders::DECLINED) }
|
77
77
|
scope :abandoned, -> { where(state: EffectiveOrders::ABANDONED) }
|
78
|
+
|
78
79
|
scope :refunds, -> { purchased.where('total < ?', 0) }
|
80
|
+
scope :pending_refunds, -> { not_purchased.where('total < ?', 0) }
|
79
81
|
|
80
82
|
before_validation do
|
81
83
|
self.state ||= EffectiveOrders::PENDING
|
@@ -445,6 +447,13 @@ module Effective
|
|
445
447
|
total.to_i < 0
|
446
448
|
end
|
447
449
|
|
450
|
+
def pending_refund?
|
451
|
+
return false if EffectiveOrders.buyer_purchases_refund?
|
452
|
+
return false if purchased?
|
453
|
+
|
454
|
+
refund?
|
455
|
+
end
|
456
|
+
|
448
457
|
def num_items
|
449
458
|
present_order_items.map { |oi| oi.quantity }.sum
|
450
459
|
end
|
@@ -466,6 +475,11 @@ module Effective
|
|
466
475
|
EffectiveResources.truthy?(send_payment_request_to_buyer)
|
467
476
|
end
|
468
477
|
|
478
|
+
def send_refund_notification_to_admin?
|
479
|
+
return false unless refund?
|
480
|
+
EffectiveOrders.send_refund_notification_to_admin
|
481
|
+
end
|
482
|
+
|
469
483
|
def send_mark_as_paid_email_to_buyer?
|
470
484
|
EffectiveResources.truthy?(send_mark_as_paid_email_to_buyer)
|
471
485
|
end
|
@@ -524,7 +538,7 @@ module Effective
|
|
524
538
|
|
525
539
|
payment_provider: provider,
|
526
540
|
payment_card: (card.presence || 'none'),
|
527
|
-
purchased_at: Time.zone.now,
|
541
|
+
purchased_at: (purchased_at.presence || Time.zone.now),
|
528
542
|
payment: payment_to_h(payment)
|
529
543
|
)
|
530
544
|
|
@@ -622,7 +636,7 @@ module Effective
|
|
622
636
|
def send_order_receipts!
|
623
637
|
send_order_receipt_to_admin! if send_order_receipt_to_admin?
|
624
638
|
send_order_receipt_to_buyer! if send_order_receipt_to_buyer?
|
625
|
-
send_refund_notification! if
|
639
|
+
send_refund_notification! if send_refund_notification_to_admin?
|
626
640
|
end
|
627
641
|
|
628
642
|
def send_order_receipt_to_admin!
|
@@ -642,7 +656,7 @@ module Effective
|
|
642
656
|
end
|
643
657
|
|
644
658
|
def send_refund_notification!
|
645
|
-
EffectiveOrders.send_email(:refund_notification_to_admin, self) if
|
659
|
+
EffectiveOrders.send_email(:refund_notification_to_admin, self) if refund?
|
646
660
|
end
|
647
661
|
|
648
662
|
protected
|
@@ -8,7 +8,7 @@
|
|
8
8
|
= dropdown_link_to 'Email receipt to buyer', effective_orders.send_buyer_receipt_order_path(order),
|
9
9
|
data: { method: :post, confirm: "Send receipt to #{order.emails_send_to}?" }
|
10
10
|
|
11
|
-
- if order.pending? || order.confirmed? || order.deferred?
|
11
|
+
- if (order.pending? || order.confirmed? || order.deferred?) && !order.refund?
|
12
12
|
= dropdown_link_to 'Email request for payment to buyer', effective_orders.send_payment_request_admin_order_path(order),
|
13
13
|
data: { method: :post, confirm: "Send request for payment to #{order.emails_send_to}?" }
|
14
14
|
|
@@ -15,9 +15,10 @@
|
|
15
15
|
- if params[:action] == 'edit'
|
16
16
|
= link_to('Show', effective_orders.admin_order_path(order), class: 'btn btn-primary')
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
- unless order.refund?
|
19
|
+
= link_to 'Email request for payment to buyer', effective_orders.send_payment_request_admin_order_path(order),
|
20
|
+
class: 'btn btn-secondary',
|
21
|
+
data: { method: :post, confirm: "Send request for payment to #{order.emails_send_to}?" }
|
21
22
|
|
22
23
|
= link_to 'Delete', effective_orders.admin_order_path(order),
|
23
24
|
class: 'btn btn-danger',
|
@@ -5,17 +5,19 @@
|
|
5
5
|
= order.refund? ? 'Complete Refund' : 'Mark as Paid'
|
6
6
|
|
7
7
|
= effective_form_with(model: order, url: effective_orders.mark_as_paid_order_path(order), method: :post) do |f|
|
8
|
-
|
8
|
+
.row
|
9
|
+
.col-6
|
10
|
+
= f.select :payment_provider, EffectiveOrders.admin_payment_providers, required: true
|
9
11
|
|
10
|
-
|
12
|
+
= f.text_field :payment_card,
|
13
|
+
label: 'Payment card type, cheque, e-transfer or transaction number',
|
14
|
+
hint: 'Do not enter credit card numbers here, or anywhere.'
|
11
15
|
|
12
|
-
|
13
|
-
label: 'Payment card type, cheque, e-transfer or transaction number',
|
14
|
-
hint: 'Do not enter credit card numbers here, or anywhere.'
|
16
|
+
= f.datetime_field :purchased_at, label: 'Purchased or completed'
|
15
17
|
|
16
|
-
|
17
|
-
|
18
|
-
|
18
|
+
= f.check_box :send_mark_as_paid_email_to_buyer,
|
19
|
+
label: 'Yes, send a receipt email to the buyer.',
|
20
|
+
input_html: { checked: (f.object.send_mark_as_paid_email_to_buyer.nil? ? EffectiveOrders.send_order_receipts_when_mark_as_paid : f.object.send_mark_as_paid_email_to_buyer?) }
|
19
21
|
|
20
22
|
.row
|
21
23
|
.col
|
@@ -23,4 +25,5 @@
|
|
23
25
|
.col
|
24
26
|
= f.text_area :note_internal, hint: 'For or internal admin use only. This note will never be displayed to the buyer.'
|
25
27
|
|
26
|
-
= f.submit
|
28
|
+
= f.submit(center: true) do
|
29
|
+
= f.save(order.refund? ? 'Complete Refund' : 'Mark as Paid')
|
@@ -1,5 +1,10 @@
|
|
1
|
-
|
2
|
-
=
|
3
|
-
|
1
|
+
- if EffectiveOrders.buyer_purchases_refund?
|
2
|
+
= effective_form_with(scope: :refund, url: effective_orders.refund_order_path(order), method: :post) do |f|
|
3
|
+
= f.hidden_field :purchased_url, value: purchased_url
|
4
|
+
= f.hidden_field :declined_url, value: declined_url
|
4
5
|
|
5
|
-
|
6
|
+
= f.submit order_checkout_label(:refund), center: true, border: false
|
7
|
+
|
8
|
+
- else
|
9
|
+
.text-center
|
10
|
+
= EffectiveOrders.refund[:pending].presence || 'Refund pending'
|
data/config/effective_orders.rb
CHANGED
@@ -95,6 +95,8 @@ EffectiveOrders.setup do |config|
|
|
95
95
|
config.send_payment_request_to_buyer = true
|
96
96
|
config.send_pending_order_invoice_to_buyer = true
|
97
97
|
|
98
|
+
config.send_refund_notification_to_admin = true
|
99
|
+
|
98
100
|
config.send_order_receipts_when_mark_as_paid = true
|
99
101
|
config.send_order_receipts_when_free = true
|
100
102
|
|
@@ -201,17 +203,33 @@ EffectiveOrders.setup do |config|
|
|
201
203
|
# success: 'Thank you! You have indicated that this order will be purchased by phone. Please give us a call at your earliest convenience.'
|
202
204
|
# }
|
203
205
|
|
204
|
-
|
205
206
|
# Refunds
|
206
207
|
# This does not issue a refund with the payment processor at all.
|
207
|
-
#
|
208
|
-
#
|
208
|
+
#
|
209
|
+
# The historic way of doing refunds was the user would click Accept Refund
|
210
|
+
# Which marks the order as purchased and sends an admin the notification to issue a refund with processor
|
211
|
+
# To support this, set:
|
212
|
+
# config.buyer_purchases_refund = true
|
213
|
+
# config.send_refund_notification_to_admin = true
|
214
|
+
#
|
215
|
+
# The newer way of doing refunds is driven by the admin
|
216
|
+
# The user just sees a pending refund and cannot purchase the order
|
217
|
+
# The admin does the refund with processor, then uses Admin: Mark as Paid to mark order as purchased thereby completing the refund
|
218
|
+
# To support this, set:
|
219
|
+
# config.buyer_purchases_refund = false
|
220
|
+
# config.send_refund_notification_to_admin = false
|
221
|
+
#
|
222
|
+
# You can call order.send_refund_notification! directly or implement a better one in your app
|
209
223
|
config.refund = false
|
210
224
|
|
211
225
|
# config.refund = {
|
212
|
-
# success: 'Thank you! Your refund will be processed in the next few business days.'
|
226
|
+
# success: 'Thank you! Your refund will be processed in the next few business days.',
|
227
|
+
# pending: 'Thank you! Your refund will be processed in the next few business days.'
|
213
228
|
# }
|
214
229
|
|
230
|
+
config.buyer_purchases_refund = true
|
231
|
+
config.send_refund_notification_to_admin = true # On Purchase
|
232
|
+
|
215
233
|
# Stripe
|
216
234
|
config.stripe = false
|
217
235
|
|
data/lib/effective_orders.rb
CHANGED
@@ -48,9 +48,10 @@ module EffectiveOrders
|
|
48
48
|
:send_order_receipts_when_mark_as_paid, :send_order_receipts_when_free,
|
49
49
|
:send_subscription_events,
|
50
50
|
:send_subscription_trialing, :send_subscription_trial_expired,
|
51
|
+
:send_refund_notification_to_admin,
|
51
52
|
|
52
53
|
# Features
|
53
|
-
:free_enabled, :mark_as_paid_enabled, :pretend_enabled, :pretend_message,
|
54
|
+
:free_enabled, :mark_as_paid_enabled, :pretend_enabled, :pretend_message, :buyer_purchases_refund,
|
54
55
|
|
55
56
|
# Payment processors. false or Hash
|
56
57
|
:cheque, :etransfer, :moneris, :moneris_checkout, :paypal, :phone, :refund, :stripe, :subscriptions, :trial
|
@@ -112,6 +113,10 @@ module EffectiveOrders
|
|
112
113
|
refund.kind_of?(Hash)
|
113
114
|
end
|
114
115
|
|
116
|
+
def self.buyer_purchases_refund?
|
117
|
+
buyer_purchases_refund == true
|
118
|
+
end
|
119
|
+
|
115
120
|
def self.stripe?
|
116
121
|
stripe.kind_of?(Hash)
|
117
122
|
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: 5.
|
4
|
+
version: 5.9.0
|
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: 2022-
|
11
|
+
date: 2022-10-06 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|