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.
- #order_receipt_to_seller(order_param, seller, order_items) ⇒ Object
-
#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_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_trial_expiring(subscribable) ⇒ Object
Sent by the effective_orders:notify_trial_users rake task.
Instance Method Details
#order_error(order: nil, error: nil, to: nil, from: nil, subject: nil, template: 'order_error') ⇒ Object
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 |
# File 'app/mailers/effective/orders_mailer.rb', line 138 def order_error(order: nil, error: nil, to: nil, from: nil, subject: nil, template: 'order_error') if order.present? @order = (order.kind_of?(Effective::Order) ? order : Effective::Order.find(order)) @subject = (subject || "An error occurred with order: ##{@order.try(:to_param)}") else @subject = (subject || "An order error occurred with an unknown order") end @error = error.to_s mail( to: (to || EffectiveOrders.mailer[:admin_email]), from: (from || EffectiveOrders.mailer[:default_from]), subject: prefix_subject(@subject), ) do |format| format.html { render(template) } end end |
#order_receipt_to_admin(order_param) ⇒ Object
7 8 9 10 11 12 13 14 15 16 17 |
# File 'app/mailers/effective/orders_mailer.rb', line 7 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)) mail( to: EffectiveOrders.mailer[:admin_email], from: EffectiveOrders.mailer[:default_from], subject: subject_for_order_receipt_to_admin(@order) ) end |
#order_receipt_to_buyer(order_param) ⇒ Object
Buyer
19 20 21 22 23 24 25 26 27 28 29 |
# 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)) mail( to: @order.user.email, from: EffectiveOrders.mailer[:default_from], subject: subject_for_order_receipt_to_buyer(@order) ) end |
#order_receipt_to_seller(order_param, seller, order_items) ⇒ Object
31 32 33 34 35 36 37 38 39 40 41 42 43 44 |
# File 'app/mailers/effective/orders_mailer.rb', line 31 def order_receipt_to_seller(order_param, seller, order_items) return true unless EffectiveOrders.mailer[:send_order_receipt_to_seller] @order = (order_param.kind_of?(Effective::Order) ? order_param : Effective::Order.find(order_param)) @user = seller.user @order_items = order_items @subject = subject_for_order_receipt_to_seller(@order, @order_items, seller.user) mail( to: @user.email, from: EffectiveOrders.mailer[:default_from], 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
48 49 50 51 52 53 54 55 56 57 58 |
# File 'app/mailers/effective/orders_mailer.rb', line 48 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)) mail( to: @order.user.email, from: EffectiveOrders.mailer[:default_from], subject: subject_for_payment_request_to_buyer(@order) ) end |
#pending_order_invoice_to_buyer(order_param) ⇒ Object
This is sent when someone chooses to Pay by Cheque
61 62 63 64 65 66 67 68 69 70 71 |
# File 'app/mailers/effective/orders_mailer.rb', line 61 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)) mail( to: @order.user.email, from: EffectiveOrders.mailer[:default_from], subject: subject_for_pending_order_invoice_to_buyer(@order) ) end |
#subscription_canceled(customer_param) ⇒ Object
Sent by the invoice.payment_failed webhook event
100 101 102 103 104 105 106 107 108 109 110 |
# File 'app/mailers/effective/orders_mailer.rb', line 100 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)) mail( to: @customer.user.email, from: EffectiveOrders.mailer[:default_from], subject: subject_for_subscription_canceled(@customer) ) end |
#subscription_payment_failed(customer_param) ⇒ Object
Sent by the invoice.payment_failed webhook event
87 88 89 90 91 92 93 94 95 96 97 |
# File 'app/mailers/effective/orders_mailer.rb', line 87 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)) mail( to: @customer.user.email, from: EffectiveOrders.mailer[:default_from], subject: subject_for_subscription_payment_failed(@customer) ) end |
#subscription_payment_succeeded(customer_param) ⇒ Object
Sent by the invoice.payment_succeeded webhook event
74 75 76 77 78 79 80 81 82 83 84 |
# File 'app/mailers/effective/orders_mailer.rb', line 74 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)) mail( to: @customer.user.email, from: EffectiveOrders.mailer[:default_from], subject: subject_for_subscription_payment_succeeded(@customer) ) end |
#subscription_trial_expired(subscribable) ⇒ Object
Sent by the effective_orders:notify_trial_users rake task.
126 127 128 129 130 131 132 133 134 135 136 |
# File 'app/mailers/effective/orders_mailer.rb', line 126 def subscription_trial_expired(subscribable) return true unless EffectiveOrders.mailer[:send_subscription_trial_expired] @subscribable = subscribable mail( to: @subscribable.buyer.email, from: EffectiveOrders.mailer[:default_from], subject: subject_for_subscription_trial_expired(@subscribable) ) end |
#subscription_trial_expiring(subscribable) ⇒ Object
Sent by the effective_orders:notify_trial_users rake task.
113 114 115 116 117 118 119 120 121 122 123 |
# File 'app/mailers/effective/orders_mailer.rb', line 113 def subscription_trial_expiring(subscribable) return true unless EffectiveOrders.mailer[:send_subscription_trial_expiring] @subscribable = subscribable mail( to: @subscribable.buyer.email, from: EffectiveOrders.mailer[:default_from], subject: subject_for_subscription_trial_expiring(@subscribable) ) end |