Class: Effective::OrdersMailer
- Inherits:
-
Object
- Object
- Effective::OrdersMailer
- Includes:
- EffectiveMailer
- Defined in:
- app/mailers/effective/orders_mailer.rb
Instance Method Summary collapse
- #order_declined_to_admin(resource, opts = {}) ⇒ Object
- #order_declined_to_buyer(resource, opts = {}) ⇒ Object
-
#order_error(order: nil, error: nil, to: nil, from: nil, subject: nil, template: 'order_error') ⇒ Object
This is only called by EffectiveQbSync.
- #order_receipt_to_admin(resource, opts = {}) ⇒ Object
- #order_receipt_to_buyer(resource, opts = {}) ⇒ Object
-
#payment_request_to_buyer(resource, opts = {}) ⇒ Object
This is sent when an admin creates a new order or /admin/orders/new Or when Pay by Cheque or Pay by Phone (deferred payments) Or uses the order action Send Payment Request.
-
#pending_order_invoice_to_buyer(resource, opts = {}) ⇒ Object
This is sent when someone chooses to Pay by Cheque or Pay by E-transfer This is not automatically sent for a delayed purchase.
-
#refund_notification_to_admin(resource, opts = {}) ⇒ Object
This is sent to admin when someone Accepts Refund.
-
#subscription_canceled(resource, opts = {}) ⇒ Object
Sent by the invoice.payment_failed webhook event.
-
#subscription_created(resource, opts = {}) ⇒ Object
Sent by the customer.subscription.created webhook event.
- #subscription_event_to_admin(event, resource, opts = {}) ⇒ Object
-
#subscription_payment_failed(resource, opts = {}) ⇒ Object
Sent by the invoice.payment_failed webhook event.
-
#subscription_payment_succeeded(resource, opts = {}) ⇒ Object
Sent by the invoice.payment_succeeded webhook event.
-
#subscription_trial_expired(resource, opts = {}) ⇒ Object
Sent by the effective_orders:notify_trial_users rake task.
-
#subscription_trialing(resource, opts = {}) ⇒ Object
Sent by the effective_orders:notify_trial_users rake task.
-
#subscription_updated(resource, opts = {}) ⇒ Object
Sent by the customer.subscription.updated webhook event.
Instance Method Details
#order_declined_to_admin(resource, opts = {}) ⇒ Object
28 29 30 31 32 33 34 35 36 |
# File 'app/mailers/effective/orders_mailer.rb', line 28 def order_declined_to_admin(resource, opts = {}) raise('expected an Effective::Order') unless resource.kind_of?(Effective::Order) @order = resource subject = subject_for(__method__, "Declined Order: ##{@order.to_param}", resource, opts) headers = headers_for(resource, opts) mail(to: mailer_admin, subject: subject, **headers) end |
#order_declined_to_buyer(resource, opts = {}) ⇒ Object
38 39 40 41 42 43 44 45 46 47 |
# File 'app/mailers/effective/orders_mailer.rb', line 38 def order_declined_to_buyer(resource, opts = {}) raise('expected an Effective::Order') unless resource.kind_of?(Effective::Order) @order = resource subject = subject_for(__method__, "Declined Order: ##{@order.to_param}", resource, opts) headers = headers_for(resource, opts) # Just to the purchaser. Not everyone. mail(to: @order.emails.first, cc: @order.cc.presence, subject: subject, **headers) end |
#order_error(order: nil, error: nil, to: nil, from: nil, subject: nil, template: 'order_error') ⇒ Object
This is only called by EffectiveQbSync
178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 |
# File 'app/mailers/effective/orders_mailer.rb', line 178 def order_error(order: nil, error: nil, to: nil, from: nil, subject: nil, template: 'order_error') raise('expected an Effective::Order') unless order.kind_of?(Effective::Order) @order = order @error = error.to_s to ||= EffectiveOrders.mailer_admin from ||= EffectiveOrders.mailer_sender subject ||= subject_for(__method__,"An error occurred with order: ##{@order.to_param}", @order, opts) headers = headers_for(@order, opts) mail(to: to, from: from, subject: subject, **headers) do |format| format.html { render(template) } end end |
#order_receipt_to_admin(resource, opts = {}) ⇒ Object
7 8 9 10 11 12 13 14 15 |
# File 'app/mailers/effective/orders_mailer.rb', line 7 def order_receipt_to_admin(resource, opts = {}) raise('expected an Effective::Order') unless resource.kind_of?(Effective::Order) @order = resource subject = subject_for(__method__, "Order Receipt: ##{@order.to_param}", resource, opts) headers = headers_for(resource, opts) mail(to: mailer_admin, subject: subject, **headers) end |
#order_receipt_to_buyer(resource, opts = {}) ⇒ Object
17 18 19 20 21 22 23 24 25 26 |
# File 'app/mailers/effective/orders_mailer.rb', line 17 def order_receipt_to_buyer(resource, opts = {}) raise('expected an Effective::Order') unless resource.kind_of?(Effective::Order) @order = resource subject = subject_for(__method__, "Order Receipt: ##{@order.to_param}", resource, opts) headers = headers_for(resource, opts) # Just to the purchaser. Not everyone. mail(to: @order.emails.first, cc: @order.cc.presence, subject: subject, **headers) end |
#payment_request_to_buyer(resource, opts = {}) ⇒ Object
This is sent when an admin creates a new order or /admin/orders/new Or when Pay by Cheque or Pay by Phone (deferred payments) Or uses the order action Send Payment Request
52 53 54 55 56 57 58 59 60 |
# File 'app/mailers/effective/orders_mailer.rb', line 52 def payment_request_to_buyer(resource, opts = {}) raise('expected an Effective::Order') unless resource.kind_of?(Effective::Order) @order = resource subject = subject_for(__method__, "Payment request - Order ##{@order.to_param}", resource, opts) headers = headers_for(resource, opts) mail(to: @order.emails, cc: @order.cc.presence, subject: subject, **headers) end |
#pending_order_invoice_to_buyer(resource, opts = {}) ⇒ Object
This is sent when someone chooses to Pay by Cheque or Pay by E-transfer This is not automatically sent for a delayed purchase
64 65 66 67 68 69 70 71 72 73 74 |
# File 'app/mailers/effective/orders_mailer.rb', line 64 def pending_order_invoice_to_buyer(resource, opts = {}) raise('expected an Effective::Order') unless resource.kind_of?(Effective::Order) @order = resource subject = subject_for(__method__, "Pending Order: ##{@order.to_param}", resource, opts) headers = headers_for(resource, opts) cc = (@order.cc.to_s.split(',') + [mailer_admin] - [nil, '', ' ']).compact.presence mail(to: @order.emails, cc: cc, subject: subject, **headers) end |
#refund_notification_to_admin(resource, opts = {}) ⇒ Object
This is sent to admin when someone Accepts Refund
77 78 79 80 81 82 83 84 85 |
# File 'app/mailers/effective/orders_mailer.rb', line 77 def refund_notification_to_admin(resource, opts = {}) raise('expected an Effective::Order') unless resource.kind_of?(Effective::Order) @order = resource subject = subject_for(__method__, "New Refund: ##{@order.to_param}", resource, opts) headers = headers_for(resource, opts) mail(to: mailer_admin, subject: subject, **headers) end |
#subscription_canceled(resource, opts = {}) ⇒ Object
Sent by the invoice.payment_failed webhook event
132 133 134 135 136 137 138 139 140 |
# File 'app/mailers/effective/orders_mailer.rb', line 132 def subscription_canceled(resource, opts = {}) raise('expected an Effective::Customer') unless resource.kind_of?(Effective::Customer) @customer = resource subject = subject_for(__method__, 'Subscription canceled', resource, opts) headers = headers_for(resource, opts) mail(to: @customer.user.email, subject: subject, **headers) end |
#subscription_created(resource, opts = {}) ⇒ Object
Sent by the customer.subscription.created webhook event
110 111 112 113 114 115 116 117 118 |
# File 'app/mailers/effective/orders_mailer.rb', line 110 def subscription_created(resource, opts = {}) raise('expected an Effective::Customer') unless resource.kind_of?(Effective::Customer) @customer = resource subject = subject_for(__method__, 'New Subscription', resource, opts) headers = headers_for(resource, opts) mail(to: @customer.user.email, subject: subject, **headers) end |
#subscription_event_to_admin(event, resource, opts = {}) ⇒ Object
164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'app/mailers/effective/orders_mailer.rb', line 164 def subscription_event_to_admin(event, resource, opts = {}) raise('expected an event') unless event.present? raise('expected an Effective::Customer') unless resource.kind_of?(Effective::Customer) @event = event @customer = resource subject = subject_for(__method__, "Subscription event - #{@event} - #{@customer}", resource, opts) headers = headers_for(resource, opts) mail(to: mailer_admin, subject: subject, **headers) end |
#subscription_payment_failed(resource, opts = {}) ⇒ Object
Sent by the invoice.payment_failed webhook event
99 100 101 102 103 104 105 106 107 |
# File 'app/mailers/effective/orders_mailer.rb', line 99 def subscription_payment_failed(resource, opts = {}) raise('expected an Effective::Customer') unless resource.kind_of?(Effective::Customer) @customer = resource subject = subject_for(__method__, 'Payment failed - please update your card details', resource, opts) headers = headers_for(resource, opts) mail(to: @customer.user.email, subject: subject, **headers) end |
#subscription_payment_succeeded(resource, opts = {}) ⇒ Object
Sent by the invoice.payment_succeeded webhook event
88 89 90 91 92 93 94 95 96 |
# File 'app/mailers/effective/orders_mailer.rb', line 88 def subscription_payment_succeeded(resource, opts = {}) raise('expected an Effective::Customer') unless resource.kind_of?(Effective::Customer) @customer = resource subject = subject_for(__method__, 'Thank you for your payment', resource, opts) headers = headers_for(resource, opts) mail(to: @customer.user.email, subject: subject, **headers) end |
#subscription_trial_expired(resource, opts = {}) ⇒ Object
Sent by the effective_orders:notify_trial_users rake task.
154 155 156 157 158 159 160 161 162 |
# File 'app/mailers/effective/orders_mailer.rb', line 154 def subscription_trial_expired(resource, opts = {}) raise('expected a subscribable resource') unless resource.respond_to?(:subscribable_buyer) @subscribable = resource subject = subject_for(__method__, 'Trial expired', resource, opts) headers = headers_for(resource, opts) mail(to: @subscribable.subscribable_buyer.email, subject: subject, **headers) end |
#subscription_trialing(resource, opts = {}) ⇒ Object
Sent by the effective_orders:notify_trial_users rake task.
143 144 145 146 147 148 149 150 151 |
# File 'app/mailers/effective/orders_mailer.rb', line 143 def subscription_trialing(resource, opts = {}) raise('expected a subscribable resource') unless resource.respond_to?(:subscribable_buyer) @subscribable = resource subject = subject_for(__method__, 'Trial is active', resource, opts) headers = headers_for(resource, opts) mail(to: @subscribable.subscribable_buyer.email, subject: subject, **headers) end |
#subscription_updated(resource, opts = {}) ⇒ Object
Sent by the customer.subscription.updated webhook event
121 122 123 124 125 126 127 128 129 |
# File 'app/mailers/effective/orders_mailer.rb', line 121 def subscription_updated(resource, opts = {}) raise('expected an Effective::Customer') unless resource.kind_of?(Effective::Customer) @customer = resource subject = subject_for(__method__, 'Subscription Changed', resource, opts) headers = headers_for(resource, opts) mail(to: @customer.user.email, subject: subject, **headers) end |