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.
-
#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
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 |
# File 'app/mailers/effective/orders_mailer.rb', line 175 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
63 64 65 66 67 68 69 70 71 |
# File 'app/mailers/effective/orders_mailer.rb', line 63 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
74 75 76 77 78 79 80 81 82 |
# File 'app/mailers/effective/orders_mailer.rb', line 74 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
129 130 131 132 133 134 135 136 137 |
# File 'app/mailers/effective/orders_mailer.rb', line 129 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
107 108 109 110 111 112 113 114 115 |
# File 'app/mailers/effective/orders_mailer.rb', line 107 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
161 162 163 164 165 166 167 168 169 170 171 172 |
# File 'app/mailers/effective/orders_mailer.rb', line 161 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
96 97 98 99 100 101 102 103 104 |
# File 'app/mailers/effective/orders_mailer.rb', line 96 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
85 86 87 88 89 90 91 92 93 |
# File 'app/mailers/effective/orders_mailer.rb', line 85 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.
151 152 153 154 155 156 157 158 159 |
# File 'app/mailers/effective/orders_mailer.rb', line 151 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.
140 141 142 143 144 145 146 147 148 |
# File 'app/mailers/effective/orders_mailer.rb', line 140 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
118 119 120 121 122 123 124 125 126 |
# File 'app/mailers/effective/orders_mailer.rb', line 118 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 |