effective_orders 4.0.0beta19 → 4.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/controllers/effective/webhooks_controller.rb +1 -0
- data/app/mailers/effective/orders_mailer.rb +13 -0
- data/app/models/effective/customer.rb +4 -0
- data/app/views/effective/orders_mailer/subscription_event_to_admin.html.haml +13 -0
- data/config/effective_orders.rb +1 -0
- data/lib/effective_orders/version.rb +1 -1
- data/lib/generators/templates/effective_orders_mailer_preview.rb +4 -0
- metadata +5 -4
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 98cd0ecbc81154a3fe1f6c7f53a829298cb17c2f
|
4
|
+
data.tar.gz: 623c5e04730aaf7aecacb0eb0cc6c2c856079e9c
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 77765ad97f3e0e1792714a32cb6a6db14906d2acdec2b0e226c2a121b965a2f914505488ff10176fb2f2d275b7172b4b160f1d71678f7d957f5dff3dd7e1108d
|
7
|
+
data.tar.gz: c9a31baa8d288bd9b480443eacfed324208494984f363187f01a1b1c27b97465a9b7a720d1653e30c11cc0276f8899e269468892722a79c84c44c1c02c059178
|
@@ -80,6 +80,7 @@ module Effective
|
|
80
80
|
|
81
81
|
def send_email(email, *mailer_args)
|
82
82
|
Effective::OrdersMailer.public_send(email, *mailer_args).public_send(EffectiveOrders.mailer[:deliver_method])
|
83
|
+
Effective::OrdersMailer.public_send(:subscription_event_to_admin, email.to_s, *mailer_args).public_send(EffectiveOrders.mailer[:deliver_method])
|
83
84
|
end
|
84
85
|
|
85
86
|
def run_subscribable_buyer_callbacks!
|
@@ -141,6 +141,19 @@ module Effective
|
|
141
141
|
mail(to: @subscribable.subscribable_buyer.email, subject: @subject)
|
142
142
|
end
|
143
143
|
|
144
|
+
def subscription_event_to_admin(event, customer_param)
|
145
|
+
return true unless EffectiveOrders.mailer[:send_subscription_event_to_admin]
|
146
|
+
|
147
|
+
@customer = (customer_param.kind_of?(Effective::Customer) ? customer_param : Effective::Customer.find(customer_param))
|
148
|
+
@subscriptions = @customer.subscriptions
|
149
|
+
@user = @customer.user
|
150
|
+
@event = event.to_s
|
151
|
+
|
152
|
+
@subject = subject_for(@customer, :subscription_event_to_admin, "Subscription event - @event").gsub('@event', @event)
|
153
|
+
|
154
|
+
mail(to: EffectiveOrders.mailer[:admin_email], subject: @subject)
|
155
|
+
end
|
156
|
+
|
144
157
|
def order_error(order: nil, error: nil, to: nil, from: nil, subject: nil, template: 'order_error')
|
145
158
|
@order = (order.kind_of?(Effective::Order) ? order : Effective::Order.find(order))
|
146
159
|
@error = error.to_s
|
@@ -36,6 +36,10 @@ module Effective
|
|
36
36
|
user.to_s.presence || 'New Customer'
|
37
37
|
end
|
38
38
|
|
39
|
+
def email
|
40
|
+
user.email if user
|
41
|
+
end
|
42
|
+
|
39
43
|
def stripe_customer
|
40
44
|
@stripe_customer ||= if stripe_customer_id.present?
|
41
45
|
Rails.logger.info "[STRIPE] get customer: #{stripe_customer_id}"
|
@@ -0,0 +1,13 @@
|
|
1
|
+
%p Hi admin,
|
2
|
+
|
3
|
+
%p A <strong>#{@event}</strong> event has occurred.
|
4
|
+
|
5
|
+
%p Customer: #{@customer}, #{@customer.email}, #{@customer.stripe_customer_id}
|
6
|
+
|
7
|
+
- if @subscriptions.present?
|
8
|
+
%p Current subscriptions:
|
9
|
+
%ul
|
10
|
+
- @subscriptions.each do |subscription|
|
11
|
+
%li #{subscription.subscribable.to_s} - #{subscription}
|
12
|
+
- else
|
13
|
+
%p This customer has no current subscriptions.
|
data/config/effective_orders.rb
CHANGED
@@ -133,6 +133,7 @@ EffectiveOrders.setup do |config|
|
|
133
133
|
send_pending_order_invoice_to_buyer: true,
|
134
134
|
send_order_receipts_when_mark_as_paid: false,
|
135
135
|
|
136
|
+
send_subscription_event_to_admin: true,
|
136
137
|
send_subscription_created: true,
|
137
138
|
send_subscription_updated: true,
|
138
139
|
send_subscription_canceled: true,
|
@@ -47,6 +47,10 @@ class EffectiveOrdersMailerPreview < ActionMailer::Preview
|
|
47
47
|
Effective::OrdersMailer.subscription_trial_expired(preview_subscribable)
|
48
48
|
end
|
49
49
|
|
50
|
+
def subscription_event_to_admin
|
51
|
+
Effective::OrdersMailer.subscription_event_to_admin(:subscription_updated, preview_customer)
|
52
|
+
end
|
53
|
+
|
50
54
|
def order_error
|
51
55
|
Effective::OrdersMailer.order_error(order: build_preview_order, error: 'Something did not work out')
|
52
56
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: effective_orders
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.0.
|
4
|
+
version: 4.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Code and Effect
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-07-
|
11
|
+
date: 2018-07-24 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -224,6 +224,7 @@ files:
|
|
224
224
|
- app/views/effective/orders_mailer/pending_order_invoice_to_buyer.html.haml
|
225
225
|
- app/views/effective/orders_mailer/subscription_canceled.html.haml
|
226
226
|
- app/views/effective/orders_mailer/subscription_created.html.haml
|
227
|
+
- app/views/effective/orders_mailer/subscription_event_to_admin.html.haml
|
227
228
|
- app/views/effective/orders_mailer/subscription_payment_failed.html.haml
|
228
229
|
- app/views/effective/orders_mailer/subscription_payment_succeeded.html.haml
|
229
230
|
- app/views/effective/orders_mailer/subscription_trial_expired.html.haml
|
@@ -257,9 +258,9 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
257
258
|
version: '0'
|
258
259
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
259
260
|
requirements:
|
260
|
-
- - "
|
261
|
+
- - ">="
|
261
262
|
- !ruby/object:Gem::Version
|
262
|
-
version:
|
263
|
+
version: '0'
|
263
264
|
requirements: []
|
264
265
|
rubyforge_project:
|
265
266
|
rubygems_version: 2.4.5.1
|