effective_orders 4.6.1 → 4.6.2
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 +4 -4
- data/MIT-LICENSE +1 -1
- data/README.md +86 -11
- data/app/controllers/admin/customers_controller.rb +16 -5
- data/app/controllers/admin/order_items_controller.rb +9 -6
- data/app/controllers/admin/orders_controller.rb +81 -17
- data/app/controllers/effective/carts_controller.rb +6 -10
- data/app/controllers/effective/customers_controller.rb +2 -4
- data/app/controllers/effective/orders_controller.rb +23 -27
- data/app/controllers/effective/providers/cheque.rb +1 -3
- data/app/controllers/effective/providers/free.rb +1 -3
- data/app/controllers/effective/providers/mark_as_paid.rb +2 -4
- data/app/controllers/effective/providers/moneris.rb +1 -3
- data/app/controllers/effective/providers/paypal.rb +2 -3
- data/app/controllers/effective/providers/phone.rb +1 -3
- data/app/controllers/effective/providers/pretend.rb +1 -3
- data/app/controllers/effective/providers/refund.rb +1 -3
- data/app/controllers/effective/providers/stripe.rb +1 -3
- data/app/controllers/effective/subscripter_controller.rb +2 -4
- data/app/controllers/effective/webhooks_controller.rb +3 -12
- data/app/datatables/admin/effective_customers_datatable.rb +3 -7
- data/app/datatables/admin/effective_orders_datatable.rb +2 -2
- data/app/datatables/effective_orders_datatable.rb +1 -1
- data/app/mailers/effective/orders_mailer.rb +96 -131
- data/app/models/concerns/acts_as_purchasable.rb +11 -0
- data/app/models/concerns/acts_as_subscribable.rb +6 -0
- data/app/models/effective/access_denied.rb +17 -0
- data/app/models/effective/cart.rb +5 -7
- data/app/models/effective/cart_item.rb +4 -7
- data/app/models/effective/customer.rb +6 -7
- data/app/models/effective/order.rb +42 -51
- data/app/models/effective/order_item.rb +8 -10
- data/app/models/effective/product.rb +6 -9
- data/app/models/effective/subscription.rb +12 -13
- data/app/views/admin/orders/_form.html.haml +9 -5
- data/app/views/admin/orders/_order_item_fields.html.haml +12 -8
- data/app/views/effective/orders/_checkout_step2.html.haml +2 -1
- data/app/views/effective/orders/_order_actions.html.haml +1 -1
- data/config/effective_orders.rb +32 -8
- data/config/routes.rb +17 -16
- data/db/migrate/01_create_effective_orders.rb.erb +0 -4
- data/lib/effective_orders.rb +76 -34
- data/lib/effective_orders/engine.rb +7 -0
- data/lib/effective_orders/version.rb +1 -1
- data/lib/generators/templates/effective_orders_mailer_preview.rb +13 -13
- data/lib/tasks/effective_orders_tasks.rake +2 -2
- metadata +2 -1
@@ -4,11 +4,9 @@ module Effective
|
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
6
|
def cheque
|
7
|
-
raise('cheque provider is not available') unless EffectiveOrders.cheque?
|
8
|
-
|
9
7
|
@order ||= Order.find(params[:id])
|
10
8
|
|
11
|
-
|
9
|
+
EffectiveOrders.authorize!(self, :update, @order)
|
12
10
|
|
13
11
|
flash[:success] = EffectiveOrders.cheque[:success]
|
14
12
|
|
@@ -4,11 +4,9 @@ module Effective
|
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
6
|
def free
|
7
|
-
raise('free provider is not available') unless EffectiveOrders.free?
|
8
|
-
|
9
7
|
@order ||= Order.find(params[:id])
|
10
8
|
|
11
|
-
|
9
|
+
EffectiveOrders.authorize!(self, :update, @order)
|
12
10
|
|
13
11
|
unless @order.free?
|
14
12
|
flash[:danger] = 'Unable to process free order with a non-zero total'
|
@@ -4,12 +4,10 @@ module Effective
|
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
6
|
def mark_as_paid
|
7
|
-
raise('mark_as_paid provider is not available') unless EffectiveOrders.mark_as_paid?
|
8
|
-
|
9
7
|
@order ||= Order.find(params[:id])
|
10
8
|
|
11
|
-
|
12
|
-
|
9
|
+
EffectiveOrders.authorize!(self, :update, @order)
|
10
|
+
EffectiveOrders.authorize!(self, :admin, :effective_orders)
|
13
11
|
|
14
12
|
@order.assign_attributes(mark_as_paid_params.except(:payment, :payment_provider, :payment_card))
|
15
13
|
|
@@ -10,11 +10,9 @@ module Effective
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def moneris_postback
|
13
|
-
raise('moneris provider is not available') unless EffectiveOrders.moneris?
|
14
|
-
|
15
13
|
@order ||= Effective::Order.find(params[:response_order_id])
|
16
14
|
|
17
|
-
(
|
15
|
+
(EffectiveOrders.authorize!(self, :update, @order) rescue false)
|
18
16
|
|
19
17
|
# Delete the Purchased and Declined Redirect URLs
|
20
18
|
purchased_url = params.delete(:rvar_purchased_url)
|
@@ -10,11 +10,9 @@ module Effective
|
|
10
10
|
# TODO: Make paypal postback work with admin checkout workflow
|
11
11
|
|
12
12
|
def paypal_postback
|
13
|
-
raise('paypal provider is not available') unless EffectiveOrders.paypal?
|
14
|
-
|
15
13
|
@order ||= Effective::Order.where(id: (params[:invoice].to_i rescue 0)).first
|
16
14
|
|
17
|
-
(
|
15
|
+
(EffectiveOrders.authorize!(self, :update, @order) rescue false)
|
18
16
|
|
19
17
|
if @order.present?
|
20
18
|
if @order.purchased?
|
@@ -29,6 +27,7 @@ module Effective
|
|
29
27
|
head(:ok)
|
30
28
|
end
|
31
29
|
|
30
|
+
|
32
31
|
end
|
33
32
|
end
|
34
33
|
end
|
@@ -4,11 +4,9 @@ module Effective
|
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
6
|
def phone
|
7
|
-
raise('phone provider is not available') unless EffectiveOrders.phone?
|
8
|
-
|
9
7
|
@order ||= Order.find(params[:id])
|
10
8
|
|
11
|
-
|
9
|
+
EffectiveOrders.authorize!(self, :update, @order)
|
12
10
|
|
13
11
|
flash[:success] = EffectiveOrders.phone[:success]
|
14
12
|
|
@@ -4,11 +4,9 @@ module Effective
|
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
6
|
def pretend
|
7
|
-
raise('pretend provider is not available') unless EffectiveOrders.pretend?
|
8
|
-
|
9
7
|
@order ||= Order.find(params[:id])
|
10
8
|
|
11
|
-
|
9
|
+
EffectiveOrders.authorize!(self, :update, @order)
|
12
10
|
|
13
11
|
order_purchased(
|
14
12
|
payment: 'for pretend',
|
@@ -4,11 +4,9 @@ module Effective
|
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
6
|
def refund
|
7
|
-
raise('refund provider is not available') unless EffectiveOrders.refund?
|
8
|
-
|
9
7
|
@order ||= Order.find(params[:id])
|
10
8
|
|
11
|
-
|
9
|
+
EffectiveOrders.authorize!(self, :update, @order)
|
12
10
|
|
13
11
|
unless @order.refund?
|
14
12
|
flash[:danger] = 'Unable to process refund order with a positive total'
|
@@ -4,12 +4,10 @@ module Effective
|
|
4
4
|
extend ActiveSupport::Concern
|
5
5
|
|
6
6
|
def stripe
|
7
|
-
raise('stripe provider is not available') unless EffectiveOrders.stripe?
|
8
|
-
|
9
7
|
@order = Order.find(params[:id])
|
10
8
|
@customer = Effective::Customer.for_user(@order.user)
|
11
9
|
|
12
|
-
|
10
|
+
EffectiveOrders.authorize!(self, :update, @order)
|
13
11
|
|
14
12
|
payment = validate_stripe_payment(stripe_params[:payment_intent_id])
|
15
13
|
|
@@ -1,10 +1,8 @@
|
|
1
1
|
module Effective
|
2
2
|
class SubscripterController < ApplicationController
|
3
|
-
|
3
|
+
layout (EffectiveOrders.layout.kind_of?(Hash) ? EffectiveOrders.layout[:subscriptions] : EffectiveOrders.layout)
|
4
4
|
|
5
|
-
|
6
|
-
layout(config.kind_of?(Hash) ? (config[:subscriptions] || config[:application]) : config)
|
7
|
-
end
|
5
|
+
include Effective::CrudController
|
8
6
|
|
9
7
|
submit :save, 'Save', redirect: :back, success: -> { 'Successfully updated plan.' }
|
10
8
|
|
@@ -89,18 +89,9 @@ module Effective
|
|
89
89
|
end
|
90
90
|
end
|
91
91
|
|
92
|
-
def send_email(email, *
|
93
|
-
|
94
|
-
|
95
|
-
if defined?(Tenant)
|
96
|
-
tenant = Tenant.current || raise('expected a current tenant')
|
97
|
-
args << { tenant: tenant }
|
98
|
-
end
|
99
|
-
|
100
|
-
deliver_method = EffectiveOrders.mailer[:deliver_method] || EffectiveResources.deliver_method
|
101
|
-
|
102
|
-
EffectiveOrders.mailer_klass.send(email, *args).send(deliver_method)
|
103
|
-
EffectiveOrders.mailer_klass.send(:subscription_event_to_admin, email.to_s, *args).send(deliver_method)
|
92
|
+
def send_email(email, *mailer_args)
|
93
|
+
Effective::OrdersMailer.public_send(email, *mailer_args).public_send(EffectiveOrders.mailer[:deliver_method])
|
94
|
+
Effective::OrdersMailer.public_send(:subscription_event_to_admin, email.to_s, *mailer_args).public_send(EffectiveOrders.mailer[:deliver_method])
|
104
95
|
end
|
105
96
|
|
106
97
|
def run_subscribable_buyer_callbacks!
|
@@ -2,12 +2,8 @@ class Admin::EffectiveCustomersDatatable < Effective::Datatable
|
|
2
2
|
datatable do
|
3
3
|
|
4
4
|
col :id, visible: false
|
5
|
-
|
6
|
-
col
|
7
|
-
|
8
|
-
col :email do |customer|
|
9
|
-
customer.user.email
|
10
|
-
end
|
5
|
+
col :user
|
6
|
+
col 'user.email'
|
11
7
|
|
12
8
|
if EffectiveOrders.stripe?
|
13
9
|
col :stripe_customer_id
|
@@ -21,6 +17,6 @@ class Admin::EffectiveCustomersDatatable < Effective::Datatable
|
|
21
17
|
end
|
22
18
|
|
23
19
|
collection do
|
24
|
-
Effective::Customer.
|
20
|
+
Effective::Customer.joins(:user).all
|
25
21
|
end
|
26
22
|
end
|
@@ -40,7 +40,7 @@ class Admin::EffectiveOrdersDatatable < Effective::Datatable
|
|
40
40
|
end
|
41
41
|
|
42
42
|
if attributes[:user_id].blank?
|
43
|
-
col :user
|
43
|
+
col :user
|
44
44
|
col :billing_name, visible: false
|
45
45
|
col :email, visible: false
|
46
46
|
end
|
@@ -102,7 +102,7 @@ class Admin::EffectiveOrdersDatatable < Effective::Datatable
|
|
102
102
|
end
|
103
103
|
|
104
104
|
def user
|
105
|
-
@user ||=
|
105
|
+
@user ||= User.find(attributes[:user_id])
|
106
106
|
end
|
107
107
|
|
108
108
|
end
|
@@ -1,218 +1,183 @@
|
|
1
1
|
module Effective
|
2
2
|
class OrdersMailer < ActionMailer::Base
|
3
|
-
default from:
|
4
|
-
layout -> { EffectiveOrders.mailer[:layout].presence || 'effective_orders_mailer_layout' }
|
3
|
+
default from: EffectiveOrders.mailer[:default_from]
|
5
4
|
|
6
5
|
helper EffectiveOrdersHelper
|
6
|
+
layout EffectiveOrders.mailer[:layout].presence || 'effective_orders_mailer_layout'
|
7
7
|
|
8
|
-
def order_receipt_to_admin(order_param
|
9
|
-
|
10
|
-
return true unless EffectiveOrders.mailer[:send_order_receipt_to_admin]
|
8
|
+
def order_receipt_to_admin(order_param)
|
9
|
+
return true unless EffectiveOrders.mailer[:send_order_receipt_to_admin]
|
11
10
|
|
12
|
-
|
13
|
-
|
11
|
+
@order = (order_param.kind_of?(Effective::Order) ? order_param : Effective::Order.find(order_param))
|
12
|
+
@user = @order.user
|
14
13
|
|
15
|
-
|
14
|
+
@subject = subject_for(@order, :order_receipt_to_admin, "Order Receipt: ##{@order.to_param}")
|
16
15
|
|
17
|
-
|
18
|
-
end
|
16
|
+
mail(to: EffectiveOrders.mailer[:admin_email], from: EffectiveOrders.mailer[:default_from], subject: @subject)
|
19
17
|
end
|
20
18
|
|
21
|
-
def order_receipt_to_buyer(order_param
|
22
|
-
|
23
|
-
return true unless EffectiveOrders.mailer[:send_order_receipt_to_buyer]
|
19
|
+
def order_receipt_to_buyer(order_param) # Buyer
|
20
|
+
return true unless EffectiveOrders.mailer[:send_order_receipt_to_buyer]
|
24
21
|
|
25
|
-
|
26
|
-
|
22
|
+
@order = (order_param.kind_of?(Effective::Order) ? order_param : Effective::Order.find(order_param))
|
23
|
+
@user = @order.user
|
27
24
|
|
28
|
-
|
25
|
+
@subject = subject_for(@order, :order_receipt_to_buyer, "Order Receipt: ##{@order.to_param}")
|
29
26
|
|
30
|
-
|
31
|
-
end
|
27
|
+
mail(to: @order.email, cc: @order.cc, subject: @subject)
|
32
28
|
end
|
33
29
|
|
34
30
|
# This is sent when an admin creates a new order or /admin/orders/new
|
35
31
|
# Or when Pay by Cheque or Pay by Phone (deferred payments)
|
36
32
|
# Or uses the order action Send Payment Request
|
37
|
-
def payment_request_to_buyer(order_param
|
38
|
-
|
39
|
-
return true unless EffectiveOrders.mailer[:send_payment_request_to_buyer]
|
33
|
+
def payment_request_to_buyer(order_param)
|
34
|
+
return true unless EffectiveOrders.mailer[:send_payment_request_to_buyer]
|
40
35
|
|
41
|
-
|
42
|
-
|
36
|
+
@order = (order_param.kind_of?(Effective::Order) ? order_param : Effective::Order.find(order_param))
|
37
|
+
@user = @order.user
|
43
38
|
|
44
|
-
|
39
|
+
@subject = subject_for(@order, :payment_request_to_buyer, "Request for Payment: Invoice ##{@order.to_param}")
|
45
40
|
|
46
|
-
|
47
|
-
end
|
41
|
+
mail(to: @order.email, cc: @order.cc, subject: @subject)
|
48
42
|
end
|
49
43
|
|
50
|
-
|
51
44
|
# This is sent when someone chooses to Pay by Cheque
|
52
|
-
def pending_order_invoice_to_buyer(order_param
|
53
|
-
|
54
|
-
return true unless EffectiveOrders.mailer[:send_pending_order_invoice_to_buyer]
|
45
|
+
def pending_order_invoice_to_buyer(order_param)
|
46
|
+
return true unless EffectiveOrders.mailer[:send_pending_order_invoice_to_buyer]
|
55
47
|
|
56
|
-
|
57
|
-
|
48
|
+
@order = (order_param.kind_of?(Effective::Order) ? order_param : Effective::Order.find(order_param))
|
49
|
+
@user = @order.user
|
58
50
|
|
59
|
-
|
51
|
+
@subject = subject_for(@order, :pending_order_invoice_to_buyer, "Pending Order: ##{@order.to_param}")
|
60
52
|
|
61
|
-
|
62
|
-
end
|
53
|
+
mail(to: @order.email, cc: @order.cc, subject: @subject)
|
63
54
|
end
|
64
55
|
|
65
56
|
# This is sent to admin when someone Accepts Refund
|
66
|
-
def refund_notification_to_admin(order_param
|
67
|
-
|
68
|
-
|
69
|
-
@user = @order.user
|
57
|
+
def refund_notification_to_admin(order_param)
|
58
|
+
@order = (order_param.kind_of?(Effective::Order) ? order_param : Effective::Order.find(order_param))
|
59
|
+
@user = @order.user
|
70
60
|
|
71
|
-
|
61
|
+
@subject = subject_for(@order, :refund_notification_to_admin, "New Refund: ##{@order.to_param}")
|
72
62
|
|
73
|
-
|
74
|
-
end
|
63
|
+
mail(to: EffectiveOrders.mailer[:admin_email], subject: @subject)
|
75
64
|
end
|
76
65
|
|
77
66
|
# Sent by the invoice.payment_succeeded webhook event
|
78
|
-
def subscription_payment_succeeded(customer_param
|
79
|
-
|
80
|
-
return true unless EffectiveOrders.mailer[:send_subscription_payment_succeeded]
|
67
|
+
def subscription_payment_succeeded(customer_param)
|
68
|
+
return true unless EffectiveOrders.mailer[:send_subscription_payment_succeeded]
|
81
69
|
|
82
|
-
|
83
|
-
|
84
|
-
|
70
|
+
@customer = (customer_param.kind_of?(Effective::Customer) ? customer_param : Effective::Customer.find(customer_param))
|
71
|
+
@subscriptions = @customer.subscriptions
|
72
|
+
@user = @customer.user
|
85
73
|
|
86
|
-
|
74
|
+
@subject = subject_for(@customer, :subscription_payment_succeeded, 'Thank you for your payment')
|
87
75
|
|
88
|
-
|
89
|
-
end
|
76
|
+
mail(to: @customer.user.email, subject: @subject)
|
90
77
|
end
|
91
78
|
|
92
79
|
# Sent by the invoice.payment_failed webhook event
|
93
|
-
def subscription_payment_failed(customer_param
|
94
|
-
|
95
|
-
return true unless EffectiveOrders.mailer[:send_subscription_payment_failed]
|
80
|
+
def subscription_payment_failed(customer_param)
|
81
|
+
return true unless EffectiveOrders.mailer[:send_subscription_payment_failed]
|
96
82
|
|
97
|
-
|
98
|
-
|
99
|
-
|
83
|
+
@customer = (customer_param.kind_of?(Effective::Customer) ? customer_param : Effective::Customer.find(customer_param))
|
84
|
+
@subscriptions = @customer.subscriptions
|
85
|
+
@user = @customer.user
|
100
86
|
|
101
|
-
|
87
|
+
@subject = subject_for(@customer, :subscription_payment_failed, 'Payment failed - please update your card details')
|
102
88
|
|
103
|
-
|
104
|
-
end
|
89
|
+
mail(to: @customer.user.email, subject: @subject)
|
105
90
|
end
|
106
91
|
|
107
92
|
# Sent by the customer.subscription.created webhook event
|
108
|
-
def subscription_created(customer_param
|
109
|
-
|
110
|
-
return true unless EffectiveOrders.mailer[:send_subscription_created]
|
93
|
+
def subscription_created(customer_param)
|
94
|
+
return true unless EffectiveOrders.mailer[:send_subscription_created]
|
111
95
|
|
112
|
-
|
113
|
-
|
114
|
-
|
96
|
+
@customer = (customer_param.kind_of?(Effective::Customer) ? customer_param : Effective::Customer.find(customer_param))
|
97
|
+
@subscriptions = @customer.subscriptions
|
98
|
+
@user = @customer.user
|
115
99
|
|
116
|
-
|
100
|
+
@subject = subject_for(@customer, :subscription_created, 'New Subscription')
|
117
101
|
|
118
|
-
|
119
|
-
end
|
102
|
+
mail(to: @customer.user.email, subject: @subject)
|
120
103
|
end
|
121
104
|
|
122
105
|
# Sent by the customer.subscription.updated webhook event
|
123
|
-
def subscription_updated(customer_param
|
124
|
-
|
125
|
-
return true unless EffectiveOrders.mailer[:send_subscription_updated]
|
106
|
+
def subscription_updated(customer_param)
|
107
|
+
return true unless EffectiveOrders.mailer[:send_subscription_updated]
|
126
108
|
|
127
|
-
|
128
|
-
|
129
|
-
|
109
|
+
@customer = (customer_param.kind_of?(Effective::Customer) ? customer_param : Effective::Customer.find(customer_param))
|
110
|
+
@subscriptions = @customer.subscriptions
|
111
|
+
@user = @customer.user
|
130
112
|
|
131
|
-
|
113
|
+
@subject = subject_for(@customer, :subscription_updated, 'Subscription Changed')
|
132
114
|
|
133
|
-
|
134
|
-
end
|
115
|
+
mail(to: @customer.user.email, subject: @subject)
|
135
116
|
end
|
136
117
|
|
137
118
|
# Sent by the invoice.payment_failed webhook event
|
138
|
-
def subscription_canceled(customer_param
|
139
|
-
|
140
|
-
return true unless EffectiveOrders.mailer[:send_subscription_canceled]
|
119
|
+
def subscription_canceled(customer_param)
|
120
|
+
return true unless EffectiveOrders.mailer[:send_subscription_canceled]
|
141
121
|
|
142
|
-
|
143
|
-
|
144
|
-
|
122
|
+
@customer = (customer_param.kind_of?(Effective::Customer) ? customer_param : Effective::Customer.find(customer_param))
|
123
|
+
@subscriptions = @customer.subscriptions
|
124
|
+
@user = @customer.user
|
145
125
|
|
146
|
-
|
126
|
+
@subject = subject_for(@customer, :subscription_canceled, 'Subscription canceled')
|
147
127
|
|
148
|
-
|
149
|
-
end
|
128
|
+
mail(to: @customer.user.email, subject: @subject)
|
150
129
|
end
|
151
130
|
|
152
131
|
# Sent by the effective_orders:notify_trial_users rake task.
|
153
|
-
def subscription_trialing(subscribable
|
154
|
-
|
155
|
-
return true unless EffectiveOrders.mailer[:send_subscription_trialing]
|
132
|
+
def subscription_trialing(subscribable)
|
133
|
+
return true unless EffectiveOrders.mailer[:send_subscription_trialing]
|
156
134
|
|
157
|
-
|
158
|
-
|
135
|
+
@subscribable = subscribable
|
136
|
+
@user = @subscribable.subscribable_buyer
|
159
137
|
|
160
|
-
|
138
|
+
@subject = subject_for(@customer, :subscription_trialing, 'Trial is active')
|
161
139
|
|
162
|
-
|
163
|
-
end
|
140
|
+
mail(to: @subscribable.subscribable_buyer.email, subject: @subject)
|
164
141
|
end
|
165
142
|
|
166
143
|
# Sent by the effective_orders:notify_trial_users rake task.
|
167
|
-
def subscription_trial_expired(subscribable
|
168
|
-
|
169
|
-
return true unless EffectiveOrders.mailer[:send_subscription_trial_expired]
|
144
|
+
def subscription_trial_expired(subscribable)
|
145
|
+
return true unless EffectiveOrders.mailer[:send_subscription_trial_expired]
|
170
146
|
|
171
|
-
|
172
|
-
|
147
|
+
@subscribable = subscribable
|
148
|
+
@user = @subscribable.subscribable_buyer
|
173
149
|
|
174
|
-
|
150
|
+
@subject = subject_for(@customer, :subscription_trial_expired, 'Trial expired')
|
175
151
|
|
176
|
-
|
177
|
-
end
|
152
|
+
mail(to: @subscribable.subscribable_buyer.email, subject: @subject)
|
178
153
|
end
|
179
154
|
|
180
|
-
def subscription_event_to_admin(event, customer_param
|
181
|
-
|
182
|
-
return true unless EffectiveOrders.mailer[:send_subscription_event_to_admin]
|
155
|
+
def subscription_event_to_admin(event, customer_param)
|
156
|
+
return true unless EffectiveOrders.mailer[:send_subscription_event_to_admin]
|
183
157
|
|
184
|
-
|
185
|
-
|
186
|
-
|
187
|
-
|
158
|
+
@customer = (customer_param.kind_of?(Effective::Customer) ? customer_param : Effective::Customer.find(customer_param))
|
159
|
+
@subscriptions = @customer.subscriptions
|
160
|
+
@user = @customer.user
|
161
|
+
@event = event.to_s
|
188
162
|
|
189
|
-
|
163
|
+
@subject = subject_for(@customer, :subscription_event_to_admin, "Subscription event - @event - @customer").gsub('@event', @event.to_s).gsub('@customer', @customer.to_s)
|
190
164
|
|
191
|
-
|
192
|
-
end
|
165
|
+
mail(to: EffectiveOrders.mailer[:admin_email], subject: @subject)
|
193
166
|
end
|
194
167
|
|
195
168
|
def order_error(order: nil, error: nil, to: nil, from: nil, subject: nil, template: 'order_error')
|
196
|
-
|
197
|
-
|
198
|
-
@error = error.to_s
|
199
|
-
|
200
|
-
@subject = subject_for(@order, :error, "An error occurred with order: ##{@order.try(:to_param)}")
|
201
|
-
|
202
|
-
mail(
|
203
|
-
to: (to || EffectiveOrders.mailer[:admin_email]),
|
204
|
-
from: (from || EffectiveOrders.mailer[:default_from]),
|
205
|
-
subject: (subject || @subject)
|
206
|
-
) do |format|
|
207
|
-
format.html { render(template) }
|
208
|
-
end
|
209
|
-
end
|
210
|
-
end
|
169
|
+
@order = (order.kind_of?(Effective::Order) ? order : Effective::Order.find(order))
|
170
|
+
@error = error.to_s
|
211
171
|
|
212
|
-
|
172
|
+
@subject = subject_for(@order, :error, "An error occurred with order: ##{@order.try(:to_param)}")
|
213
173
|
|
214
|
-
|
215
|
-
|
174
|
+
mail(
|
175
|
+
to: (to || EffectiveOrders.mailer[:admin_email]),
|
176
|
+
from: (from || EffectiveOrders.mailer[:default_from]),
|
177
|
+
subject: (subject || @subject)
|
178
|
+
) do |format|
|
179
|
+
format.html { render(template) }
|
180
|
+
end
|
216
181
|
end
|
217
182
|
|
218
183
|
private
|