Class: Effective::OrdersMailer
- Inherits:
-
Object
- Object
- Effective::OrdersMailer
- Includes:
- EffectiveMailer
- 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
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.
-
#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_error(order: nil, error: nil, to: nil, from: nil, subject: nil, template: 'order_error') ⇒ Object
This is only called by EffectiveQbSync
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 |
# File 'app/mailers/effective/orders_mailer.rb', line 154 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 @order.email here. Not everyone. mail(to: @order.email, 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
31 32 33 34 35 36 37 38 39 |
# File 'app/mailers/effective/orders_mailer.rb', line 31 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
42 43 44 45 46 47 48 49 50 |
# File 'app/mailers/effective/orders_mailer.rb', line 42 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) mail(to: @order.emails, cc: @order.cc.presence, subject: subject, **headers) end |
#refund_notification_to_admin(resource, opts = {}) ⇒ Object
This is sent to admin when someone Accepts Refund
53 54 55 56 57 58 59 60 61 |
# File 'app/mailers/effective/orders_mailer.rb', line 53 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
108 109 110 111 112 113 114 115 116 |
# File 'app/mailers/effective/orders_mailer.rb', line 108 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
86 87 88 89 90 91 92 93 94 |
# File 'app/mailers/effective/orders_mailer.rb', line 86 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
140 141 142 143 144 145 146 147 148 149 150 151 |
# File 'app/mailers/effective/orders_mailer.rb', line 140 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
75 76 77 78 79 80 81 82 83 |
# File 'app/mailers/effective/orders_mailer.rb', line 75 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
64 65 66 67 68 69 70 71 72 |
# File 'app/mailers/effective/orders_mailer.rb', line 64 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.
130 131 132 133 134 135 136 137 138 |
# File 'app/mailers/effective/orders_mailer.rb', line 130 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.
119 120 121 122 123 124 125 126 127 |
# File 'app/mailers/effective/orders_mailer.rb', line 119 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
97 98 99 100 101 102 103 104 105 |
# File 'app/mailers/effective/orders_mailer.rb', line 97 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 |