Class: Effective::OrdersMailer
- Inherits:
-
ActionMailer::Base
- Object
- ActionMailer::Base
- Effective::OrdersMailer
- Defined in:
- app/mailers/effective/orders_mailer.rb
Instance Method Summary collapse
- #order_error(order: nil, error: nil, to: nil, from: nil, subject: nil, template: 'order_error') ⇒ Object
- #order_receipt_to_admin(order_param) ⇒ Object
-
#order_receipt_to_buyer(order_param) ⇒ Object
Buyer.
-
#payment_request_to_buyer(order_param) ⇒ Object
This is sent when an admin creates a new order or /admin/orders/new Or uses the order action Send Payment Request.
-
#pending_order_invoice_to_buyer(order_param) ⇒ Object
This is sent when someone chooses to Pay by Cheque.
-
#subscription_canceled(customer_param) ⇒ Object
Sent by the invoice.payment_failed webhook event.
-
#subscription_created(customer_param) ⇒ Object
Sent by the customer.subscription.created webhook event.
- #subscription_event_to_admin(event, customer_param) ⇒ Object
-
#subscription_payment_failed(customer_param) ⇒ Object
Sent by the invoice.payment_failed webhook event.
-
#subscription_payment_succeeded(customer_param) ⇒ Object
Sent by the invoice.payment_succeeded webhook event.
-
#subscription_trial_expired(subscribable) ⇒ Object
Sent by the effective_orders:notify_trial_users rake task.
-
#subscription_trialing(subscribable) ⇒ Object
Sent by the effective_orders:notify_trial_users rake task.
-
#subscription_updated(customer_param) ⇒ Object
Sent by the customer.subscription.updated webhook event.
Instance Method Details
#order_error(order: nil, error: nil, to: nil, from: nil, subject: nil, template: 'order_error') ⇒ Object
157 158 159 160 161 162 163 164 165 166 167 168 169 170 |
# File 'app/mailers/effective/orders_mailer.rb', line 157 def order_error(order: nil, error: nil, to: nil, from: nil, subject: nil, template: 'order_error') @order = (order.kind_of?(Effective::Order) ? order : Effective::Order.find(order)) @error = error.to_s @subject = subject_for(@order, :error, "An error occurred with order: ##{@order.try(:to_param)}") mail( to: (to || EffectiveOrders.mailer[:admin_email]), from: (from || EffectiveOrders.mailer[:default_from]), subject: (subject || @subject) ) do |format| format.html { render(template) } end end |
#order_receipt_to_admin(order_param) ⇒ Object
8 9 10 11 12 13 14 15 16 17 |
# File 'app/mailers/effective/orders_mailer.rb', line 8 def order_receipt_to_admin(order_param) return true unless EffectiveOrders.mailer[:send_order_receipt_to_admin] @order = (order_param.kind_of?(Effective::Order) ? order_param : Effective::Order.find(order_param)) @user = @order.user @subject = subject_for(@order, :order_receipt_to_admin, "Order Receipt: ##{@order.to_param}") mail(to: EffectiveOrders.mailer[:admin_email], from: EffectiveOrders.mailer[:default_from], subject: @subject) end |
#order_receipt_to_buyer(order_param) ⇒ Object
Buyer
19 20 21 22 23 24 25 26 27 28 |
# File 'app/mailers/effective/orders_mailer.rb', line 19 def order_receipt_to_buyer(order_param) # Buyer return true unless EffectiveOrders.mailer[:send_order_receipt_to_buyer] @order = (order_param.kind_of?(Effective::Order) ? order_param : Effective::Order.find(order_param)) @user = @order.user @subject = subject_for(@order, :order_receipt_to_buyer, "Order Receipt: ##{@order.to_param}") mail(to: @order.user.email, subject: @subject) end |
#payment_request_to_buyer(order_param) ⇒ Object
This is sent when an admin creates a new order or /admin/orders/new Or uses the order action Send Payment Request
32 33 34 35 36 37 38 39 40 41 |
# File 'app/mailers/effective/orders_mailer.rb', line 32 def payment_request_to_buyer(order_param) return true unless EffectiveOrders.mailer[:send_payment_request_to_buyer] @order = (order_param.kind_of?(Effective::Order) ? order_param : Effective::Order.find(order_param)) @user = @order.user @subject = subject_for(@order, :payment_request_to_buyer, "Request for Payment: Invoice ##{@order.to_param}") mail(to: @order.user.email, subject: @subject) end |
#pending_order_invoice_to_buyer(order_param) ⇒ Object
This is sent when someone chooses to Pay by Cheque
44 45 46 47 48 49 50 51 52 53 |
# File 'app/mailers/effective/orders_mailer.rb', line 44 def pending_order_invoice_to_buyer(order_param) return true unless EffectiveOrders.mailer[:send_pending_order_invoice_to_buyer] @order = (order_param.kind_of?(Effective::Order) ? order_param : Effective::Order.find(order_param)) @user = @order.user @subject = subject_for(@order, :pending_order_invoice_to_buyer, "Pending Order: ##{@order.to_param}") mail(to: @order.user.email, subject: @subject) end |
#subscription_canceled(customer_param) ⇒ Object
Sent by the invoice.payment_failed webhook event
108 109 110 111 112 113 114 115 116 117 118 |
# File 'app/mailers/effective/orders_mailer.rb', line 108 def subscription_canceled(customer_param) return true unless EffectiveOrders.mailer[:send_subscription_canceled] @customer = (customer_param.kind_of?(Effective::Customer) ? customer_param : Effective::Customer.find(customer_param)) @subscriptions = @customer.subscriptions @user = @customer.user @subject = subject_for(@customer, :subscription_canceled, 'Subscription canceled') mail(to: @customer.user.email, subject: @subject) end |
#subscription_created(customer_param) ⇒ Object
Sent by the customer.subscription.created webhook event
82 83 84 85 86 87 88 89 90 91 92 |
# File 'app/mailers/effective/orders_mailer.rb', line 82 def subscription_created(customer_param) return true unless EffectiveOrders.mailer[:send_subscription_created] @customer = (customer_param.kind_of?(Effective::Customer) ? customer_param : Effective::Customer.find(customer_param)) @subscriptions = @customer.subscriptions @user = @customer.user @subject = subject_for(@customer, :subscription_created, 'New Subscription') mail(to: @customer.user.email, subject: @subject) end |
#subscription_event_to_admin(event, customer_param) ⇒ Object
144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'app/mailers/effective/orders_mailer.rb', line 144 def subscription_event_to_admin(event, customer_param) return true unless EffectiveOrders.mailer[:send_subscription_event_to_admin] @customer = (customer_param.kind_of?(Effective::Customer) ? customer_param : Effective::Customer.find(customer_param)) @subscriptions = @customer.subscriptions @user = @customer.user @event = event.to_s @subject = subject_for(@customer, :subscription_event_to_admin, "Subscription event - @event - @customer").gsub('@event', @event.to_s).gsub('@customer', @customer.to_s) mail(to: EffectiveOrders.mailer[:admin_email], subject: @subject) end |
#subscription_payment_failed(customer_param) ⇒ Object
Sent by the invoice.payment_failed webhook event
69 70 71 72 73 74 75 76 77 78 79 |
# File 'app/mailers/effective/orders_mailer.rb', line 69 def subscription_payment_failed(customer_param) return true unless EffectiveOrders.mailer[:send_subscription_payment_failed] @customer = (customer_param.kind_of?(Effective::Customer) ? customer_param : Effective::Customer.find(customer_param)) @subscriptions = @customer.subscriptions @user = @customer.user @subject = subject_for(@customer, :subscription_payment_failed, 'Payment failed - please update your card details') mail(to: @customer.user.email, subject: @subject) end |
#subscription_payment_succeeded(customer_param) ⇒ Object
Sent by the invoice.payment_succeeded webhook event
56 57 58 59 60 61 62 63 64 65 66 |
# File 'app/mailers/effective/orders_mailer.rb', line 56 def subscription_payment_succeeded(customer_param) return true unless EffectiveOrders.mailer[:send_subscription_payment_succeeded] @customer = (customer_param.kind_of?(Effective::Customer) ? customer_param : Effective::Customer.find(customer_param)) @subscriptions = @customer.subscriptions @user = @customer.user @subject = subject_for(@customer, :subscription_payment_succeeded, 'Thank you for your payment') mail(to: @customer.user.email, subject: @subject) end |
#subscription_trial_expired(subscribable) ⇒ Object
Sent by the effective_orders:notify_trial_users rake task.
133 134 135 136 137 138 139 140 141 142 |
# File 'app/mailers/effective/orders_mailer.rb', line 133 def subscription_trial_expired(subscribable) return true unless EffectiveOrders.mailer[:send_subscription_trial_expired] @subscribable = subscribable @user = @subscribable.subscribable_buyer @subject = subject_for(@customer, :subscription_trial_expired, 'Trial expired') mail(to: @subscribable.subscribable_buyer.email, subject: @subject) end |
#subscription_trialing(subscribable) ⇒ Object
Sent by the effective_orders:notify_trial_users rake task.
121 122 123 124 125 126 127 128 129 130 |
# File 'app/mailers/effective/orders_mailer.rb', line 121 def subscription_trialing(subscribable) return true unless EffectiveOrders.mailer[:send_subscription_trialing] @subscribable = subscribable @user = @subscribable.subscribable_buyer @subject = subject_for(@customer, :subscription_trialing, 'Trial is active') mail(to: @subscribable.subscribable_buyer.email, subject: @subject) end |
#subscription_updated(customer_param) ⇒ Object
Sent by the customer.subscription.updated webhook event
95 96 97 98 99 100 101 102 103 104 105 |
# File 'app/mailers/effective/orders_mailer.rb', line 95 def subscription_updated(customer_param) return true unless EffectiveOrders.mailer[:send_subscription_updated] @customer = (customer_param.kind_of?(Effective::Customer) ? customer_param : Effective::Customer.find(customer_param)) @subscriptions = @customer.subscriptions @user = @customer.user @subject = subject_for(@customer, :subscription_updated, 'Subscription Changed') mail(to: @customer.user.email, subject: @subject) end |