effective_orders 6.19.7 → 6.20.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/concerns/purchase.rb +2 -2
- data/app/controllers/effective/providers/mark_as_paid.rb +1 -1
- data/app/datatables/admin/effective_orders_datatable.rb +3 -3
- data/app/mailers/effective/orders_mailer.rb +18 -55
- data/app/models/effective/order.rb +25 -73
- data/app/models/effective/order_email.rb +98 -0
- data/app/views/effective/order_emails/_header.html.haml +16 -0
- data/app/views/effective/order_emails/_info.html.haml +70 -0
- data/app/views/effective/order_emails/_items.html.haml +1 -0
- data/app/views/effective/order_emails/_order_email.html.haml +6 -0
- data/app/views/effective/order_emails/_signature.html.haml +12 -0
- data/app/views/effective/orders/_order_deferred.html.haml +1 -1
- data/app/views/effective/orders/_order_items.html.haml +15 -23
- data/app/views/effective/orders/delayed/_form.html.haml +2 -2
- data/app/views/effective/orders_mailer/order_email.html.haml +1 -0
- data/app/views/effective/orders_mailer/order_email_to_admin.html.haml +1 -0
- data/config/locales/effective_orders.en.yml +2 -2
- data/config/routes.rb +3 -3
- data/lib/effective_orders/version.rb +1 -1
- metadata +9 -7
- data/app/views/effective/orders_mailer/order_declined_to_admin.html.haml +0 -2
- data/app/views/effective/orders_mailer/order_declined_to_buyer.html.haml +0 -2
- data/app/views/effective/orders_mailer/order_receipt_to_admin.html.haml +0 -2
- data/app/views/effective/orders_mailer/order_receipt_to_buyer.html.haml +0 -2
- data/app/views/effective/orders_mailer/payment_request_to_buyer.html.haml +0 -13
- data/app/views/effective/orders_mailer/pending_order_invoice_to_buyer.html.haml +0 -23
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5266c20d5867e006a46275ad40820436f7401b7355f9ed5fb196aedee94180d3
|
4
|
+
data.tar.gz: 5469f434c36294e847718c1bcdbd92d04778ab1dd658784819fb21e99bc02902
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 38b74f58fe8cd5ec06a8eadeecaa8bfc115aa16190f642ba9b6e0893f86261e022625e0bc800282bf95eb0cb6c9ec8eeb93b17c40838a97f28c62c25b671d08b
|
7
|
+
data.tar.gz: 6eb685f21f1b99a421831b5cf188650b2e7447149fcf1f8d799c5ebb203b42f5868e9519102d6cf4aa1ffbdea66dc679121e435c7aebcd2300715df9a6fcca6e
|
@@ -21,7 +21,7 @@ module Effective
|
|
21
21
|
Effective::Cart.where(user: @order.current_user).destroy_all if @order.current_user.present?
|
22
22
|
|
23
23
|
if flash[:success].blank?
|
24
|
-
if email &&
|
24
|
+
if email && EffectiveOrders.send_order_receipt_to_buyer
|
25
25
|
flash[:success] = "Payment successful! A receipt has been sent to #{@order.email}"
|
26
26
|
else
|
27
27
|
flash[:success] = "Payment successful! An email receipt has not been sent."
|
@@ -49,7 +49,7 @@ module Effective
|
|
49
49
|
redirect_to deferred_url.gsub(':id', @order.to_param.to_s)
|
50
50
|
end
|
51
51
|
|
52
|
-
def order_delayed(payment:, payment_intent:, provider:, card: 'none', email:
|
52
|
+
def order_delayed(payment:, payment_intent:, provider:, card: 'none', email: true, deferred_url: nil)
|
53
53
|
@order.delay!(payment: payment, payment_intent: payment_intent, provider: provider, card: card, email: email)
|
54
54
|
|
55
55
|
Effective::Cart.where(user: @order.current_user).destroy_all if @order.current_user.present?
|
@@ -18,7 +18,7 @@ module Effective
|
|
18
18
|
payment: 'mark as paid',
|
19
19
|
provider: mark_as_paid_params[:payment_provider],
|
20
20
|
card: mark_as_paid_params[:payment_card],
|
21
|
-
email:
|
21
|
+
email: EffectiveResources.truthy?(mark_as_paid_params[:send_mark_as_paid_email_to_buyer]),
|
22
22
|
skip_buyer_validations: true,
|
23
23
|
purchased_url: effective_orders.admin_order_path(@order)
|
24
24
|
)
|
@@ -8,9 +8,9 @@ module Admin
|
|
8
8
|
)
|
9
9
|
|
10
10
|
bulk_action(
|
11
|
-
|
12
|
-
effective_orders.
|
13
|
-
data: { confirm: 'Send
|
11
|
+
'Send invoice email to selected purchased orders',
|
12
|
+
effective_orders.bulk_send_order_email_to_buyer_orders_path,
|
13
|
+
data: { confirm: 'Send invoice emails?' }
|
14
14
|
)
|
15
15
|
end
|
16
16
|
|
@@ -3,74 +3,35 @@ module Effective
|
|
3
3
|
include EffectiveMailer
|
4
4
|
|
5
5
|
helper EffectiveOrdersHelper
|
6
|
+
helper EffectiveEventsHelper if defined?(EffectiveEventsHelper)
|
6
7
|
|
7
|
-
|
8
|
+
# This is the new order email
|
9
|
+
# It's sent from like 15 different places in 15 different ways
|
10
|
+
# Has to be aware of events and registrations, applicants, renewals, etc
|
11
|
+
# Has to be aware of deferred payments, delayed payments, requests for payment, purchased, declined etc
|
12
|
+
def order_email(resource, opts = {})
|
8
13
|
raise('expected an Effective::Order') unless resource.kind_of?(Effective::Order)
|
9
14
|
|
10
15
|
@order = resource
|
11
|
-
|
12
|
-
headers = headers_for(resource, opts)
|
13
|
-
|
14
|
-
mail(to: mailer_admin, subject: subject, **headers)
|
15
|
-
end
|
16
|
-
|
17
|
-
def order_receipt_to_buyer(resource, opts = {})
|
18
|
-
raise('expected an Effective::Order') unless resource.kind_of?(Effective::Order)
|
19
|
-
|
20
|
-
@order = resource
|
21
|
-
subject = subject_for(__method__, "Order Receipt: ##{@order.to_param}", resource, opts)
|
22
|
-
headers = headers_for(resource, opts)
|
16
|
+
@order_email = Effective::OrderEmail.new(resource, opts)
|
23
17
|
|
24
|
-
|
25
|
-
|
26
|
-
end
|
27
|
-
|
28
|
-
def order_declined_to_admin(resource, opts = {})
|
29
|
-
raise('expected an Effective::Order') unless resource.kind_of?(Effective::Order)
|
30
|
-
|
31
|
-
@order = resource
|
32
|
-
subject = subject_for(__method__, "Declined Order: ##{@order.to_param}", resource, opts)
|
33
|
-
headers = headers_for(resource, opts)
|
34
|
-
|
35
|
-
mail(to: mailer_admin, subject: subject, **headers)
|
36
|
-
end
|
37
|
-
|
38
|
-
def order_declined_to_buyer(resource, opts = {})
|
39
|
-
raise('expected an Effective::Order') unless resource.kind_of?(Effective::Order)
|
40
|
-
|
41
|
-
@order = resource
|
42
|
-
subject = subject_for(__method__, "Declined Order: ##{@order.to_param}", resource, opts)
|
43
|
-
headers = headers_for(resource, opts)
|
44
|
-
|
45
|
-
# Just to the purchaser. Not everyone.
|
46
|
-
mail(to: @order.emails.first, cc: @order.cc.presence, subject: subject, **headers)
|
47
|
-
end
|
48
|
-
|
49
|
-
# This is sent when an admin creates a new order or /admin/orders/new
|
50
|
-
# Or when Pay by Cheque or Pay by Phone (deferred payments)
|
51
|
-
# Or uses the order action Send Payment Request
|
52
|
-
def payment_request_to_buyer(resource, opts = {})
|
53
|
-
raise('expected an Effective::Order') unless resource.kind_of?(Effective::Order)
|
54
|
-
|
55
|
-
@order = resource
|
56
|
-
subject = subject_for(__method__, "Payment request - Order ##{@order.to_param}", resource, opts)
|
57
|
-
headers = headers_for(resource, opts)
|
18
|
+
subject = subject_for(__method__, @order_email.subject, @order, opts)
|
19
|
+
headers = headers_for(@order, opts)
|
58
20
|
|
59
|
-
mail(to: @
|
21
|
+
mail(to: @order_email.to, cc: @order_email.cc, subject: subject, **headers)
|
60
22
|
end
|
61
23
|
|
62
|
-
#
|
63
|
-
|
64
|
-
def pending_order_invoice_to_buyer(resource, opts = {})
|
24
|
+
# Same as above but sent to admin
|
25
|
+
def order_email_to_admin(resource, opts = {})
|
65
26
|
raise('expected an Effective::Order') unless resource.kind_of?(Effective::Order)
|
66
27
|
|
67
28
|
@order = resource
|
68
|
-
|
69
|
-
headers = headers_for(resource, opts)
|
29
|
+
@order_email = Effective::OrderEmail.new(resource)
|
70
30
|
|
71
|
-
|
31
|
+
subject = subject_for(__method__, @order_email.subject, @order, opts)
|
32
|
+
headers = headers_for(@order, opts)
|
72
33
|
|
73
|
-
mail(to:
|
34
|
+
mail(to: mailer_admin, subject: subject, **headers)
|
74
35
|
end
|
75
36
|
|
76
37
|
# This is sent to admin when someone Accepts Refund
|
@@ -84,6 +45,8 @@ module Effective
|
|
84
45
|
mail(to: mailer_admin, subject: subject, **headers)
|
85
46
|
end
|
86
47
|
|
48
|
+
#### OLD EMAILS ####
|
49
|
+
|
87
50
|
# Sent by the invoice.payment_succeeded webhook event
|
88
51
|
def subscription_payment_succeeded(resource, opts = {})
|
89
52
|
raise('expected an Effective::Customer') unless resource.kind_of?(Effective::Customer)
|
@@ -46,6 +46,7 @@ module Effective
|
|
46
46
|
attr_accessor :send_payment_request_to_buyer # Set by Admin::Orders#new. Should the payment request email be sent after creating an order?
|
47
47
|
attr_accessor :send_mark_as_paid_email_to_buyer # Set by Admin::Orders#mark_as_paid
|
48
48
|
attr_accessor :skip_buyer_validations # Set by Admin::Orders#create
|
49
|
+
attr_accessor :mailer_preview # Set by the mailer preview. Disabled delayed payment validations
|
49
50
|
|
50
51
|
# If we want to use orders in a has_many way
|
51
52
|
belongs_to :parent, polymorphic: true, optional: true
|
@@ -251,7 +252,7 @@ module Effective
|
|
251
252
|
validates :payment_provider, presence: true
|
252
253
|
|
253
254
|
validate do
|
254
|
-
unless deferred_payment_provider? || delayed_payment_provider?
|
255
|
+
unless deferred_payment_provider? || delayed_payment_provider? || mailer_preview
|
255
256
|
errors.add(:payment_provider, "unknown deferred payment provider")
|
256
257
|
end
|
257
258
|
end
|
@@ -611,41 +612,6 @@ module Effective
|
|
611
612
|
present_order_items.map { |oi| oi.quantity }.sum
|
612
613
|
end
|
613
614
|
|
614
|
-
def send_order_receipt_to_admin?
|
615
|
-
return false if free? && !EffectiveOrders.send_order_receipts_when_free
|
616
|
-
EffectiveOrders.send_order_receipt_to_admin
|
617
|
-
end
|
618
|
-
|
619
|
-
def send_order_receipt_to_buyer?
|
620
|
-
return false if free? && !EffectiveOrders.send_order_receipts_when_free
|
621
|
-
EffectiveOrders.send_order_receipt_to_buyer
|
622
|
-
end
|
623
|
-
|
624
|
-
def send_order_declined_to_admin?
|
625
|
-
return false if free? && !EffectiveOrders.send_order_receipts_when_free
|
626
|
-
EffectiveOrders.send_order_declined_to_admin
|
627
|
-
end
|
628
|
-
|
629
|
-
def send_order_declined_to_buyer?
|
630
|
-
return false if free? && !EffectiveOrders.send_order_receipts_when_free
|
631
|
-
EffectiveOrders.send_order_declined_to_buyer
|
632
|
-
end
|
633
|
-
|
634
|
-
def send_payment_request_to_buyer?
|
635
|
-
return false if free? && !EffectiveOrders.send_order_receipts_when_free
|
636
|
-
return false if refund?
|
637
|
-
|
638
|
-
EffectiveResources.truthy?(send_payment_request_to_buyer)
|
639
|
-
end
|
640
|
-
|
641
|
-
def send_refund_notification_to_admin?
|
642
|
-
return false unless refund?
|
643
|
-
EffectiveOrders.send_refund_notification_to_admin
|
644
|
-
end
|
645
|
-
|
646
|
-
def send_mark_as_paid_email_to_buyer?
|
647
|
-
EffectiveResources.truthy?(send_mark_as_paid_email_to_buyer)
|
648
|
-
end
|
649
615
|
|
650
616
|
def skip_buyer_validations?
|
651
617
|
EffectiveResources.truthy?(skip_buyer_validations)
|
@@ -662,7 +628,7 @@ module Effective
|
|
662
628
|
self.addresses.clear if addresses.any? { |address| address.valid? == false }
|
663
629
|
save!
|
664
630
|
|
665
|
-
if send_payment_request_to_buyer
|
631
|
+
if EffectiveResources.truthy?(send_payment_request_to_buyer)
|
666
632
|
after_commit { send_payment_request_to_buyer! }
|
667
633
|
end
|
668
634
|
|
@@ -752,7 +718,7 @@ module Effective
|
|
752
718
|
raise(e)
|
753
719
|
end
|
754
720
|
|
755
|
-
|
721
|
+
send_order_emails! if email
|
756
722
|
after_commit { sync_quickbooks!(skip: skip_quickbooks) }
|
757
723
|
|
758
724
|
true
|
@@ -777,9 +743,9 @@ module Effective
|
|
777
743
|
|
778
744
|
# This was submitted via the deluxe_delayed provider checkout
|
779
745
|
# This is a special case of a deferred provider. We require the payment_intent and payment info
|
780
|
-
def delay!(payment:, payment_intent:, provider:, card:, email:
|
746
|
+
def delay!(payment:, payment_intent:, provider:, card:, email: true, validate: true)
|
781
747
|
raise('expected payment intent to be a String') unless payment_intent.kind_of?(String)
|
782
|
-
raise('expected a delayed payment provider') unless EffectiveOrders.delayed_providers.include?(provider)
|
748
|
+
raise('expected a delayed payment provider') unless EffectiveOrders.delayed_providers.include?(provider) || mailer_preview
|
783
749
|
raise('expected a delayed payment order with a delayed_payment_date') unless delayed_payment? && delayed_payment_date.present?
|
784
750
|
|
785
751
|
assign_attributes(
|
@@ -832,7 +798,7 @@ module Effective
|
|
832
798
|
|
833
799
|
raise "Failed to defer order: #{error || errors.full_messages.to_sentence}" unless error.nil?
|
834
800
|
|
835
|
-
|
801
|
+
send_order_emails! if email
|
836
802
|
|
837
803
|
true
|
838
804
|
end
|
@@ -873,7 +839,7 @@ module Effective
|
|
873
839
|
|
874
840
|
raise "Failed to decline order: #{error || errors.full_messages.to_sentence}" unless error.nil?
|
875
841
|
|
876
|
-
|
842
|
+
send_order_emails! if email
|
877
843
|
|
878
844
|
true
|
879
845
|
end
|
@@ -913,44 +879,30 @@ module Effective
|
|
913
879
|
(emails + [cc.presence]).compact.uniq.to_sentence
|
914
880
|
end
|
915
881
|
|
916
|
-
def
|
917
|
-
|
918
|
-
|
919
|
-
|
920
|
-
|
921
|
-
|
922
|
-
def send_declined_notifications!
|
923
|
-
send_order_declined_to_admin! if send_order_declined_to_admin?
|
924
|
-
send_order_declined_to_buyer! if send_order_declined_to_buyer?
|
925
|
-
end
|
926
|
-
|
927
|
-
def send_order_declined_to_admin!
|
928
|
-
EffectiveOrders.send_email(:order_declined_to_admin, self) if declined?
|
929
|
-
end
|
930
|
-
|
931
|
-
def send_order_declined_to_buyer!
|
932
|
-
EffectiveOrders.send_email(:order_declined_to_buyer, self) if declined?
|
933
|
-
end
|
882
|
+
def send_order_emails!
|
883
|
+
if purchased_or_deferred? && (!free? || EffectiveOrders.send_order_receipts_when_free)
|
884
|
+
EffectiveOrders.send_email(:order_email, self) if EffectiveOrders.send_order_receipt_to_buyer
|
885
|
+
EffectiveOrders.send_email(:order_email_to_admin, self) if EffectiveOrders.send_order_receipt_to_admin
|
886
|
+
end
|
934
887
|
|
935
|
-
|
936
|
-
|
937
|
-
|
888
|
+
if declined?
|
889
|
+
EffectiveOrders.send_email(:order_email, self) if EffectiveOrders.send_order_declined_to_buyer
|
890
|
+
EffectiveOrders.send_email(:order_email_to_admin, self) if EffectiveOrders.send_order_declined_to_admin
|
891
|
+
end
|
938
892
|
|
939
|
-
|
940
|
-
|
893
|
+
if refund?
|
894
|
+
EffectiveOrders.send_email(:refund_notification_to_admin, self) if EffectiveOrders.send_refund_notification_to_admin
|
895
|
+
end
|
941
896
|
end
|
942
|
-
alias_method :send_buyer_receipt!, :send_order_receipt_to_buyer!
|
943
897
|
|
898
|
+
# Admin datatable action
|
944
899
|
def send_payment_request_to_buyer!
|
945
|
-
EffectiveOrders.send_email(:
|
946
|
-
end
|
947
|
-
|
948
|
-
def send_pending_order_invoice_to_buyer!
|
949
|
-
EffectiveOrders.send_email(:pending_order_invoice_to_buyer, self) unless purchased?
|
900
|
+
EffectiveOrders.send_email(:order_email, self, payment_request: true) unless (purchased? || refund?)
|
950
901
|
end
|
951
902
|
|
952
|
-
|
953
|
-
|
903
|
+
# Admin datatable action
|
904
|
+
def send_order_email_to_buyer!
|
905
|
+
EffectiveOrders.send_email(:order_email, self) if purchased_or_deferred?
|
954
906
|
end
|
955
907
|
|
956
908
|
protected
|
@@ -0,0 +1,98 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
# a PORO to handle all the email logic for an order
|
3
|
+
|
4
|
+
module Effective
|
5
|
+
class OrderEmail
|
6
|
+
attr_accessor :order
|
7
|
+
attr_accessor :opts
|
8
|
+
|
9
|
+
def initialize(order, opts = {})
|
10
|
+
raise('expected an Effective::Order') unless order.kind_of?(Effective::Order)
|
11
|
+
raise('expected a Hash of options') unless opts.kind_of?(Hash)
|
12
|
+
|
13
|
+
@order = order
|
14
|
+
@opts = opts
|
15
|
+
end
|
16
|
+
|
17
|
+
# Just to the purchaser. Not everyone.
|
18
|
+
def to
|
19
|
+
return order.emails if payment_request?
|
20
|
+
order.emails.first
|
21
|
+
end
|
22
|
+
|
23
|
+
def cc
|
24
|
+
order.cc.presence
|
25
|
+
end
|
26
|
+
|
27
|
+
# The very first line of the email body
|
28
|
+
def header
|
29
|
+
if event.present? && order.purchased_or_deferred?
|
30
|
+
return "Your tickets have been confirmed" if event_none_waitlisted?
|
31
|
+
return "Some of your tickets have been confirmed, but some are on the waitlist" if event_some_waitlisted?
|
32
|
+
return "Your tickets are on the waitlist" if event_all_waitlisted?
|
33
|
+
end
|
34
|
+
|
35
|
+
return "Request for Payment" if payment_request?
|
36
|
+
return "Pending order created" if order.deferred?
|
37
|
+
return "Your order has been successfully purchased" if order.purchased?
|
38
|
+
return "Your order was declined by the payment processor" if order.declined?
|
39
|
+
|
40
|
+
# Fallback
|
41
|
+
"Order: ##{order.to_param}"
|
42
|
+
end
|
43
|
+
|
44
|
+
def subject
|
45
|
+
if event.present? && order.purchased_or_deferred?
|
46
|
+
return "Confirmation - #{event}" if event_none_waitlisted?
|
47
|
+
return "Confirmation + Waitlist - #{event}" if event_some_waitlisted?
|
48
|
+
return "Waitlist - #{event}" if event_all_waitlisted?
|
49
|
+
end
|
50
|
+
|
51
|
+
return "Payment Request - Order: ##{order.to_param}" if payment_request?
|
52
|
+
return "Pending Order: ##{order.to_param}" if order.deferred?
|
53
|
+
return "Declined Order: ##{order.to_param}" if order.declined?
|
54
|
+
return "Order Receipt: ##{order.to_param}" if order.purchased?
|
55
|
+
|
56
|
+
# Fallback
|
57
|
+
"Order: ##{order.to_param}"
|
58
|
+
end
|
59
|
+
|
60
|
+
def payment_request?
|
61
|
+
opts[:payment_request] == true
|
62
|
+
end
|
63
|
+
|
64
|
+
def event
|
65
|
+
order.purchasables.find { |purchasable| purchasable.class.name == "Effective::EventRegistrant" }.try(:event)
|
66
|
+
end
|
67
|
+
|
68
|
+
def event_registration
|
69
|
+
order.purchasables.find { |purchasable| purchasable.class.name == "Effective::EventRegistrant" }.try(:event_registration)
|
70
|
+
end
|
71
|
+
|
72
|
+
def event_registrants
|
73
|
+
order.purchasables.select { |purchasable| purchasable.class.name == "Effective::EventRegistrant" }
|
74
|
+
end
|
75
|
+
|
76
|
+
def event_addons
|
77
|
+
order.purchasables.select { |purchasable| purchasable.class.name == "Effective::EventAddon" }
|
78
|
+
end
|
79
|
+
|
80
|
+
def event_none_waitlisted?
|
81
|
+
return false unless event_registrants.present?
|
82
|
+
event_registrants.none? { |er| er.waitlisted_not_promoted? }
|
83
|
+
end
|
84
|
+
|
85
|
+
def event_some_waitlisted?
|
86
|
+
return false unless event_registrants.present?
|
87
|
+
|
88
|
+
event_registrants.find { |er| er.waitlisted_not_promoted? }.present? &&
|
89
|
+
event_registrants.find { |er| !er.waitlisted_not_promoted? }.present?
|
90
|
+
end
|
91
|
+
|
92
|
+
def event_all_waitlisted?
|
93
|
+
return false unless event_registrants.present?
|
94
|
+
event_registrants.all? { |er| er.waitlisted_not_promoted? }
|
95
|
+
end
|
96
|
+
|
97
|
+
end
|
98
|
+
end
|
@@ -0,0 +1,16 @@
|
|
1
|
+
%h1{style: "text-align: center"}= order_email.header
|
2
|
+
|
3
|
+
- if order.purchased?
|
4
|
+
%p{style: "margin-bottom: 14px; font-weight: bold; text-align: center;"} Thank you!
|
5
|
+
- elsif order.declined?
|
6
|
+
%p{style: "margin-bottom: 14px; font-weight: bold; text-align: center;"}= order.declined_reason
|
7
|
+
|
8
|
+
- if (event = order_email.event).present?
|
9
|
+
%p{style: "text-align: center"}
|
10
|
+
%strong{style: "font-size: 18px"}= event.title
|
11
|
+
%br
|
12
|
+
#{effective_events_event_schedule(event)}
|
13
|
+
|
14
|
+
- if event.rich_text_confirmation_email.present?
|
15
|
+
%hr
|
16
|
+
= event.rich_text_confirmation_email.to_s.html_safe
|
@@ -0,0 +1,70 @@
|
|
1
|
+
- if order.delayed? && order.deferred? && order.delayed_payment_date_upcoming?
|
2
|
+
%hr
|
3
|
+
%p{style: "margin-bottom: 4px; font-weight: bold;"} Please note:
|
4
|
+
|
5
|
+
- if order.payment_provider == 'deluxe_delayed'
|
6
|
+
%ul{style: "margin-top: 0;"}
|
7
|
+
%li Your credit card will be charged on <strong>#{order.delayed_payment_date.strftime("%A, %B %d, %Y")}</strong>.
|
8
|
+
%li Changes and cancellations must be made before this date.
|
9
|
+
%li A receipt will be sent after the transaction is completed.
|
10
|
+
- elsif order.payment_provider == 'cheque'
|
11
|
+
%ul{style: "margin-top: 0;"}
|
12
|
+
%li Please submit a cheque at your earliest convience.
|
13
|
+
%li You have until payment is received or until <strong>#{order.delayed_payment_date.strftime("%A, %B %d, %Y")}</strong>, whichever is first, to make changes and cancellations.
|
14
|
+
%li A receipt will be sent after payment has been received.
|
15
|
+
- elsif order.payment_provider == 'phone'
|
16
|
+
%ul{style: "margin-top: 0;"}
|
17
|
+
%li Please phone us at your earliest convience.
|
18
|
+
%li You have until payment is received or until <strong>#{order.delayed_payment_date.strftime("%A, %B %d, %Y")}</strong>, whichever is first, to make changes and cancellations.
|
19
|
+
%li A receipt will be sent after payment has been received.
|
20
|
+
- elsif order.payment_provider == 'etransfer'
|
21
|
+
%ul{style: "margin-top: 0;"}
|
22
|
+
%li Please submit an etransfer at your earliest convience.
|
23
|
+
%li You have until payment is received or until <strong>#{order.delayed_payment_date.strftime("%A, %B %d, %Y")}</strong>, whichever is first, to make changes and cancellations.
|
24
|
+
%li A receipt will be sent after payment has been received.
|
25
|
+
- else
|
26
|
+
- providers = EffectiveOrders.deferred_providers.to_sentence(last_word_connector: ', or', two_words_connector: ' or ')
|
27
|
+
%ul{style: "margin-top: 0;"}
|
28
|
+
- if providers.present?
|
29
|
+
%li When we receive your #{providers} we will mark your order paid.
|
30
|
+
%li You have until payment is received or until <strong>#{order.delayed_payment_date.strftime("%A, %B %d, %Y")}</strong>, whichever is first, to make changes and cancellations.
|
31
|
+
%li A receipt will be sent after payment has been received.
|
32
|
+
|
33
|
+
- elsif order.deferred?
|
34
|
+
%hr
|
35
|
+
%p{style: "margin-bottom: 4px; font-weight: bold;"} Please remit payment at your earliest convenience.
|
36
|
+
|
37
|
+
- if order.payment_provider == 'deluxe_delayed'
|
38
|
+
%ul{style: "margin-top: 0;"}
|
39
|
+
%li Your credit card will be automatically charged.
|
40
|
+
%li A receipt will be sent after the transaction is completed.
|
41
|
+
- elsif order.payment_provider == 'cheque'
|
42
|
+
%ul{style: "margin-top: 0;"}
|
43
|
+
%li Please submit a cheque at your earliest convience.
|
44
|
+
%li A receipt will be sent after payment has been received.
|
45
|
+
- elsif order.payment_provider == 'phone'
|
46
|
+
%ul{style: "margin-top: 0;"}
|
47
|
+
%li Please phone us at your earliest convience.
|
48
|
+
%li A receipt will be sent after payment has been received.
|
49
|
+
- elsif order.payment_provider == 'etransfer'
|
50
|
+
%ul{style: "margin-top: 0;"}
|
51
|
+
%li Please submit an etransfer at your earliest convience.
|
52
|
+
%li A receipt will be sent after payment has been received.
|
53
|
+
- else
|
54
|
+
- providers = EffectiveOrders.deferred_providers.to_sentence(last_word_connector: ', or', two_words_connector: ' or ')
|
55
|
+
%ul{style: "margin-top: 0;"}
|
56
|
+
- if providers.present?
|
57
|
+
%li When we receive your #{providers} we will mark your order paid.
|
58
|
+
%li A receipt will be sent after payment has been received.
|
59
|
+
|
60
|
+
- elsif order_email.payment_request?
|
61
|
+
%hr
|
62
|
+
%p{style: "margin-bottom: 4px; font-weight: bold;"} An order has been created on your behalf for the following items.
|
63
|
+
%p{style: "margin-bottom: 4px; font-weight: bold;"} Please remit payment at your earliest convenience.
|
64
|
+
|
65
|
+
- providers = EffectiveOrders.deferred_providers.to_sentence(last_word_connector: ', or', two_words_connector: ' or ')
|
66
|
+
%ul{style: "margin-top: 0;"}
|
67
|
+
%li #{link_to('Click here', effective_orders.order_url(@order))} to review your order and pay online with a credit card.
|
68
|
+
- if providers.present?
|
69
|
+
%li We also accept #{providers}.
|
70
|
+
%li A receipt will be sent after payment has been received.
|
@@ -0,0 +1 @@
|
|
1
|
+
= render(order, no_order_actions: true)
|
@@ -0,0 +1,6 @@
|
|
1
|
+
- # This is the order email
|
2
|
+
= render('effective/order_emails/header', order_email: order_email, order: order)
|
3
|
+
= render('effective/order_emails/info', order_email: order_email, order: order)
|
4
|
+
= render('effective/order_emails/items', order_email: order_email, order: order)
|
5
|
+
= render('effective/order_emails/signature', order_email: order_email, order: order)
|
6
|
+
|
@@ -0,0 +1,12 @@
|
|
1
|
+
%hr
|
2
|
+
|
3
|
+
- event = order_email.event
|
4
|
+
- event_registration = order_email.event_registration
|
5
|
+
|
6
|
+
%p{style: "text-align: center;"}
|
7
|
+
- if event.present? && event_registration.present? && order.delayed_payment_date_upcoming? && order.deferred?
|
8
|
+
= link_to('View or modify your registration', effective_events.event_event_registration_url(event, event_registration))
|
9
|
+
- elsif event.present? && event_registration.present?
|
10
|
+
= link_to('View your registration', effective_events.event_event_registration_url(event, event_registration))
|
11
|
+
- else
|
12
|
+
= link_to('View your order', effective_orders.order_url(order))
|
@@ -8,7 +8,7 @@
|
|
8
8
|
%tr
|
9
9
|
%td
|
10
10
|
- if order.delayed? && order.delayed_payment_provider?
|
11
|
-
%p Your #{order.delayed_payment_method} will be charged on #{order.delayed_payment_date.strftime(
|
11
|
+
%p Your #{order.delayed_payment_method} will be charged on #{order.delayed_payment_date.strftime("%A, %B %d, %Y")}
|
12
12
|
- else
|
13
13
|
%p Waiting for payment by #{order.payment_provider}.
|
14
14
|
|
@@ -1,5 +1,5 @@
|
|
1
1
|
.effective-order-items
|
2
|
-
%table.table
|
2
|
+
%table.table{style: "margin-bottom: 20px;"}
|
3
3
|
%thead
|
4
4
|
%tr
|
5
5
|
%th.quantity Qty
|
@@ -14,16 +14,20 @@
|
|
14
14
|
%td.item
|
15
15
|
= item.name.html_safe
|
16
16
|
|
17
|
+
- if item.purchasable.class.name == 'Effective::EventRegistrant'
|
18
|
+
= item.purchasable.try(:responses) || item.purchasable.try(:notes)
|
19
|
+
|
17
20
|
- if order.purchased? && item.purchased_download_url.present?
|
18
21
|
= link_to 'Download', item.purchased_download_url
|
19
22
|
|
20
23
|
%td.price= price_to_currency(item.subtotal)
|
21
24
|
|
22
|
-
%table.table
|
23
25
|
%tfoot
|
24
26
|
%tr
|
25
|
-
%
|
26
|
-
|
27
|
+
%td{colspan: 3}= " ".html_safe
|
28
|
+
|
29
|
+
%tr
|
30
|
+
%th.subtotal{colspan: 2} Subtotal
|
27
31
|
%td.price.subtotal-price= price_to_currency(order.subtotal)
|
28
32
|
|
29
33
|
- if order.tax_rate.blank?
|
@@ -31,42 +35,30 @@
|
|
31
35
|
|
32
36
|
- elsif order.tax_rate.present? && order.surcharge_percent.to_f > 0.0
|
33
37
|
%tr
|
34
|
-
%th
|
35
|
-
%td.tax #{EffectiveOrders.tax_label} (#{rate_to_percentage(order.tax_rate)})
|
38
|
+
%th.tax{colspan: 2} #{EffectiveOrders.tax_label} (#{rate_to_percentage(order.tax_rate)})
|
36
39
|
%td.price.tax-price= price_to_currency(order.tax)
|
37
40
|
|
38
41
|
%tr.single-line
|
39
|
-
%th
|
40
|
-
%td.amount-owing Amount owing before Credit Card Processing Fee
|
42
|
+
%th.amount-owing{colspan: 2} Amount owing before Credit Card Processing Fee
|
41
43
|
%td.price.amount-owing-price= price_to_currency(order.amount_owing)
|
42
44
|
|
43
45
|
%tr
|
44
|
-
%th
|
45
|
-
%td
|
46
|
-
%td
|
47
|
-
|
48
|
-
%tr
|
49
|
-
%th
|
50
|
-
%td.surcharge Credit Card Processing Fee (#{rate_to_percentage(order.surcharge_percent)}) on #{price_to_currency(order.amount_owing)}
|
46
|
+
%th.surcharge{colspan: 2} Credit Card Processing Fee (#{rate_to_percentage(order.surcharge_percent)}) on #{price_to_currency(order.amount_owing)}
|
51
47
|
%td.price.surcharge-price= price_to_currency(order.surcharge)
|
52
48
|
|
53
49
|
%tr
|
54
|
-
%th
|
55
|
-
%td.surcharge-tax #{EffectiveOrders.tax_label} (#{rate_to_percentage(order.tax_rate)}) on Credit Card Processing Fee
|
50
|
+
%th.surcharge-tax{colspan: 2} #{EffectiveOrders.tax_label} (#{rate_to_percentage(order.tax_rate)}) on Credit Card Processing Fee
|
56
51
|
%td.price.surcharge-tax-price= price_to_currency(order.surcharge_tax)
|
57
52
|
|
58
53
|
%tr.double-line
|
59
|
-
%th
|
60
|
-
%td.total Total amount charged to credit card
|
54
|
+
%th.total{colspan: 2} Total amount charged to credit card
|
61
55
|
%td.price.total-price= price_to_currency(order.total)
|
62
56
|
|
63
57
|
- elsif order.tax_rate.present? && !(order.surcharge_percent.to_f > 0.0)
|
64
58
|
%tr
|
65
|
-
%th
|
66
|
-
%td.tax #{EffectiveOrders.tax_label} (#{rate_to_percentage(order.tax_rate)})
|
59
|
+
%th.tax{colspan: 2} #{EffectiveOrders.tax_label} (#{rate_to_percentage(order.tax_rate)})
|
67
60
|
%td.price.tax-price= price_to_currency(order.tax)
|
68
61
|
|
69
62
|
%tr.single-line
|
70
|
-
%th
|
71
|
-
%td.total= order.total_label
|
63
|
+
%th.total{colspan: 2}= order.total_label
|
72
64
|
%td.price.total-price= price_to_currency(order.total)
|
@@ -9,11 +9,11 @@
|
|
9
9
|
The payment date for this order
|
10
10
|
|
11
11
|
- if order.delayed_payment_date_upcoming?
|
12
|
-
is in #{distance} from now on #{order.delayed_payment_date.strftime(
|
12
|
+
is in #{distance} from now on #{order.delayed_payment_date.strftime("%A, %B %d, %Y")}
|
13
13
|
- elsif order.delayed_payment_date_today?
|
14
14
|
was today
|
15
15
|
- else
|
16
|
-
was #{distance} ago on #{order.delayed_payment_date.strftime(
|
16
|
+
was #{distance} ago on #{order.delayed_payment_date.strftime("%A, %B %d, %Y")}
|
17
17
|
|
18
18
|
- provider_locals = { order: order, deferred_url: deferred_url, declined_url: declined_url }
|
19
19
|
|
@@ -0,0 +1 @@
|
|
1
|
+
= render('effective/order_emails/order_email', order_email: @order_email, order: @order)
|
@@ -0,0 +1 @@
|
|
1
|
+
= render('effective/order_emails/order_email', order_email: @order_email, order: @order)
|
@@ -6,8 +6,8 @@ en:
|
|
6
6
|
activerecord:
|
7
7
|
actions:
|
8
8
|
effective/order:
|
9
|
-
|
10
|
-
|
9
|
+
send_order_email_to_buyer: 'Send order email'
|
10
|
+
send_order_email_to_buyer_confirm: 'Send order email to @resource.emails_send_to?'
|
11
11
|
|
12
12
|
datatables:
|
13
13
|
admin/report_transactions_datatable: 'Report: Individual Transactions'
|
data/config/routes.rb
CHANGED
@@ -7,7 +7,7 @@ EffectiveOrders::Engine.routes.draw do
|
|
7
7
|
get :purchased
|
8
8
|
get :deferred
|
9
9
|
get :declined
|
10
|
-
post :
|
10
|
+
post :send_order_email_to_buyer
|
11
11
|
|
12
12
|
post :cheque
|
13
13
|
post :deluxe # 1-off payment and purchase
|
@@ -25,7 +25,7 @@ EffectiveOrders::Engine.routes.draw do
|
|
25
25
|
end
|
26
26
|
|
27
27
|
collection do
|
28
|
-
post :
|
28
|
+
post :bulk_send_order_email_to_buyer
|
29
29
|
|
30
30
|
post :moneris_postback
|
31
31
|
post :paypal_postback
|
@@ -56,7 +56,7 @@ EffectiveOrders::Engine.routes.draw do
|
|
56
56
|
resources :orders do
|
57
57
|
member do
|
58
58
|
post :send_payment_request
|
59
|
-
post :
|
59
|
+
post :send_order_email_to_buyer
|
60
60
|
|
61
61
|
delete :void
|
62
62
|
post :unvoid
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_orders
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 6.
|
4
|
+
version: 6.20.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
@@ -254,6 +254,7 @@ files:
|
|
254
254
|
- app/models/effective/deluxe_api.rb
|
255
255
|
- app/models/effective/item_name.rb
|
256
256
|
- app/models/effective/order.rb
|
257
|
+
- app/models/effective/order_email.rb
|
257
258
|
- app/models/effective/order_item.rb
|
258
259
|
- app/models/effective/product.rb
|
259
260
|
- app/models/effective/sold_out_validator.rb
|
@@ -283,6 +284,11 @@ files:
|
|
283
284
|
- app/views/effective/customers/_form.html.haml
|
284
285
|
- app/views/effective/customers/edit.html.haml
|
285
286
|
- app/views/effective/customers/update.js.erb
|
287
|
+
- app/views/effective/order_emails/_header.html.haml
|
288
|
+
- app/views/effective/order_emails/_info.html.haml
|
289
|
+
- app/views/effective/order_emails/_items.html.haml
|
290
|
+
- app/views/effective/order_emails/_order_email.html.haml
|
291
|
+
- app/views/effective/order_emails/_signature.html.haml
|
286
292
|
- app/views/effective/orders/_checkout_actions.html.haml
|
287
293
|
- app/views/effective/orders/_checkout_step1.html.haml
|
288
294
|
- app/views/effective/orders/_checkout_step2.html.haml
|
@@ -333,13 +339,9 @@ files:
|
|
333
339
|
- app/views/effective/orders/show.html.haml
|
334
340
|
- app/views/effective/orders/stripe/_element.html.haml
|
335
341
|
- app/views/effective/orders/stripe/_form.html.haml
|
336
|
-
- app/views/effective/orders_mailer/
|
337
|
-
- app/views/effective/orders_mailer/
|
342
|
+
- app/views/effective/orders_mailer/order_email.html.haml
|
343
|
+
- app/views/effective/orders_mailer/order_email_to_admin.html.haml
|
338
344
|
- app/views/effective/orders_mailer/order_error.html.haml
|
339
|
-
- app/views/effective/orders_mailer/order_receipt_to_admin.html.haml
|
340
|
-
- app/views/effective/orders_mailer/order_receipt_to_buyer.html.haml
|
341
|
-
- app/views/effective/orders_mailer/payment_request_to_buyer.html.haml
|
342
|
-
- app/views/effective/orders_mailer/pending_order_invoice_to_buyer.html.haml
|
343
345
|
- app/views/effective/orders_mailer/refund_notification_to_admin.html.haml
|
344
346
|
- app/views/effective/orders_mailer/subscription_canceled.html.haml
|
345
347
|
- app/views/effective/orders_mailer/subscription_created.html.haml
|
@@ -1,13 +0,0 @@
|
|
1
|
-
%p.effective-orders-receipt-info Request for Payment
|
2
|
-
|
3
|
-
%p
|
4
|
-
An order has been created on your behalf for the following items.
|
5
|
-
Please remit payment at your earliest convenience.
|
6
|
-
|
7
|
-
%p #{link_to('Click here', effective_orders.order_url(@order))} to review your order and pay online with a credit card.
|
8
|
-
|
9
|
-
- if EffectiveOrders.deferred_providers.present?
|
10
|
-
- providers = EffectiveOrders.deferred_providers.to_sentence()
|
11
|
-
%p We also accept #{providers}. We will mark your order paid upon receiving it.
|
12
|
-
|
13
|
-
= render(@order, no_order_actions: true)
|
@@ -1,23 +0,0 @@
|
|
1
|
-
%p.effective-orders-receipt-info Pending order created
|
2
|
-
|
3
|
-
%p We have received notice of your intention to purchase the following items.
|
4
|
-
|
5
|
-
- if @order.delayed?
|
6
|
-
%p{style: "margin-bottom: 4px; font-weight: bold;"} Please note:
|
7
|
-
%ul{style: "margin-top: 0;"}
|
8
|
-
%li Your credit card will be charged on <strong>#{@order.delayed_payment_date.strftime("%A, %B %d, %Y")}</strong>.
|
9
|
-
%li Changes and cancellations must be made before this date.
|
10
|
-
%li A receipt will be sent after the transaction is completed.
|
11
|
-
|
12
|
-
- elsif @order.deferred?
|
13
|
-
%p Please remit payment at your earliest convenience.
|
14
|
-
|
15
|
-
- if EffectiveOrders.deferred_providers.present?
|
16
|
-
- providers = EffectiveOrders.deferred_providers.to_sentence(last_word_connector: ', or', two_words_connector: ' or ')
|
17
|
-
%p When we receive your #{providers} we will mark your order paid.
|
18
|
-
|
19
|
-
= render(@order, no_order_actions: true)
|
20
|
-
|
21
|
-
%hr
|
22
|
-
%p{style: "text-align: center;"}
|
23
|
-
= link_to('View your order', effective_orders.order_url(@order))
|