effective_orders 4.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/MIT-LICENSE +20 -0
- data/README.md +1004 -0
- data/app/assets/images/effective_orders/stripe.png +0 -0
- data/app/assets/javascripts/effective_orders.js +6 -0
- data/app/assets/javascripts/effective_orders/customers.js.coffee +32 -0
- data/app/assets/javascripts/effective_orders/providers/stripe.js.coffee +77 -0
- data/app/assets/javascripts/effective_orders/subscriptions.js.coffee +81 -0
- data/app/assets/stylesheets/effective_orders.scss +2 -0
- data/app/assets/stylesheets/effective_orders/_cart.scss +4 -0
- data/app/assets/stylesheets/effective_orders/_order.scss +58 -0
- data/app/controllers/admin/customers_controller.rb +24 -0
- data/app/controllers/admin/order_items_controller.rb +16 -0
- data/app/controllers/admin/orders_controller.rb +223 -0
- data/app/controllers/effective/carts_controller.rb +85 -0
- data/app/controllers/effective/concerns/purchase.rb +62 -0
- data/app/controllers/effective/customers_controller.rb +20 -0
- data/app/controllers/effective/orders_controller.rb +162 -0
- data/app/controllers/effective/providers/cheque.rb +22 -0
- data/app/controllers/effective/providers/free.rb +33 -0
- data/app/controllers/effective/providers/mark_as_paid.rb +33 -0
- data/app/controllers/effective/providers/moneris.rb +60 -0
- data/app/controllers/effective/providers/paypal.rb +33 -0
- data/app/controllers/effective/providers/phone.rb +22 -0
- data/app/controllers/effective/providers/pretend.rb +26 -0
- data/app/controllers/effective/providers/refund.rb +33 -0
- data/app/controllers/effective/providers/stripe.rb +72 -0
- data/app/controllers/effective/subscripter_controller.rb +18 -0
- data/app/controllers/effective/webhooks_controller.rb +109 -0
- data/app/datatables/admin/effective_customers_datatable.rb +22 -0
- data/app/datatables/admin/effective_orders_datatable.rb +100 -0
- data/app/datatables/effective_orders_datatable.rb +79 -0
- data/app/helpers/effective_carts_helper.rb +113 -0
- data/app/helpers/effective_orders_helper.rb +143 -0
- data/app/helpers/effective_paypal_helper.rb +49 -0
- data/app/helpers/effective_stripe_helper.rb +85 -0
- data/app/helpers/effective_subscriptions_helper.rb +34 -0
- data/app/mailers/effective/orders_mailer.rb +196 -0
- data/app/models/concerns/acts_as_purchasable.rb +118 -0
- data/app/models/concerns/acts_as_subscribable.rb +90 -0
- data/app/models/concerns/acts_as_subscribable_buyer.rb +49 -0
- data/app/models/effective/access_denied.rb +17 -0
- data/app/models/effective/cart.rb +88 -0
- data/app/models/effective/cart_item.rb +40 -0
- data/app/models/effective/customer.rb +92 -0
- data/app/models/effective/order.rb +541 -0
- data/app/models/effective/order_item.rb +63 -0
- data/app/models/effective/product.rb +23 -0
- data/app/models/effective/sold_out_validator.rb +7 -0
- data/app/models/effective/subscripter.rb +185 -0
- data/app/models/effective/subscription.rb +95 -0
- data/app/models/effective/tax_rate_calculator.rb +48 -0
- data/app/views/admin/customers/_actions.html.haml +2 -0
- data/app/views/admin/customers/index.html.haml +6 -0
- data/app/views/admin/customers/show.html.haml +6 -0
- data/app/views/admin/order_items/index.html.haml +3 -0
- data/app/views/admin/orders/_datatable_actions.html.haml +18 -0
- data/app/views/admin/orders/_form.html.haml +35 -0
- data/app/views/admin/orders/_form_note_internal.html.haml +7 -0
- data/app/views/admin/orders/_order_actions.html.haml +9 -0
- data/app/views/admin/orders/_order_item_fields.html.haml +14 -0
- data/app/views/admin/orders/checkout.html.haml +3 -0
- data/app/views/admin/orders/edit.html.haml +6 -0
- data/app/views/admin/orders/index.html.haml +6 -0
- data/app/views/admin/orders/new.html.haml +4 -0
- data/app/views/admin/orders/show.html.haml +4 -0
- data/app/views/effective/carts/_cart.html.haml +28 -0
- data/app/views/effective/carts/_cart_actions.html.haml +3 -0
- data/app/views/effective/carts/show.html.haml +17 -0
- data/app/views/effective/customers/_customer.html.haml +72 -0
- data/app/views/effective/customers/_form.html.haml +21 -0
- data/app/views/effective/customers/edit.html.haml +4 -0
- data/app/views/effective/customers/update.js.erb +5 -0
- data/app/views/effective/orders/_checkout_actions.html.haml +3 -0
- data/app/views/effective/orders/_checkout_step1.html.haml +4 -0
- data/app/views/effective/orders/_checkout_step2.html.haml +37 -0
- data/app/views/effective/orders/_datatable_actions.html.haml +2 -0
- data/app/views/effective/orders/_fields.html.haml +31 -0
- data/app/views/effective/orders/_fields_note.html.haml +7 -0
- data/app/views/effective/orders/_fields_terms.html.haml +8 -0
- data/app/views/effective/orders/_order.html.haml +11 -0
- data/app/views/effective/orders/_order_actions.html.haml +18 -0
- data/app/views/effective/orders/_order_deferred.html.haml +9 -0
- data/app/views/effective/orders/_order_footer.html.haml +1 -0
- data/app/views/effective/orders/_order_header.html.haml +23 -0
- data/app/views/effective/orders/_order_items.html.haml +72 -0
- data/app/views/effective/orders/_order_notes.html.haml +17 -0
- data/app/views/effective/orders/_order_payment.html.haml +24 -0
- data/app/views/effective/orders/_order_shipping.html.haml +30 -0
- data/app/views/effective/orders/_orders_table.html.haml +23 -0
- data/app/views/effective/orders/cheque/_form.html.haml +4 -0
- data/app/views/effective/orders/declined.html.haml +12 -0
- data/app/views/effective/orders/deferred.html.haml +13 -0
- data/app/views/effective/orders/deferred/_form.html.haml +16 -0
- data/app/views/effective/orders/edit.html.haml +3 -0
- data/app/views/effective/orders/free/_form.html.haml +5 -0
- data/app/views/effective/orders/index.html.haml +3 -0
- data/app/views/effective/orders/mark_as_paid/_form.html.haml +23 -0
- data/app/views/effective/orders/moneris/_form.html.haml +47 -0
- data/app/views/effective/orders/new.html.haml +3 -0
- data/app/views/effective/orders/paypal/_form.html.haml +5 -0
- data/app/views/effective/orders/phone/_form.html.haml +4 -0
- data/app/views/effective/orders/pretend/_form.html.haml +8 -0
- data/app/views/effective/orders/purchased.html.haml +11 -0
- data/app/views/effective/orders/refund/_form.html.haml +5 -0
- data/app/views/effective/orders/show.html.haml +6 -0
- data/app/views/effective/orders/stripe/_element.html.haml +8 -0
- data/app/views/effective/orders/stripe/_form.html.haml +31 -0
- data/app/views/effective/orders_mailer/order_error.html.haml +11 -0
- data/app/views/effective/orders_mailer/order_receipt_to_admin.html.haml +2 -0
- data/app/views/effective/orders_mailer/order_receipt_to_buyer.html.haml +2 -0
- data/app/views/effective/orders_mailer/payment_request_to_buyer.html.haml +13 -0
- data/app/views/effective/orders_mailer/pending_order_invoice_to_buyer.html.haml +13 -0
- data/app/views/effective/orders_mailer/refund_notification_to_admin.html.haml +15 -0
- data/app/views/effective/orders_mailer/subscription_canceled.html.haml +9 -0
- data/app/views/effective/orders_mailer/subscription_created.html.haml +13 -0
- data/app/views/effective/orders_mailer/subscription_event_to_admin.html.haml +13 -0
- data/app/views/effective/orders_mailer/subscription_payment_failed.html.haml +9 -0
- data/app/views/effective/orders_mailer/subscription_payment_succeeded.html.haml +9 -0
- data/app/views/effective/orders_mailer/subscription_trial_expired.html.haml +5 -0
- data/app/views/effective/orders_mailer/subscription_trialing.html.haml +7 -0
- data/app/views/effective/orders_mailer/subscription_updated.html.haml +13 -0
- data/app/views/effective/subscripter/_form.html.haml +60 -0
- data/app/views/effective/subscripter/_plan.html.haml +23 -0
- data/app/views/layouts/effective_orders_mailer_layout.html.haml +25 -0
- data/config/effective_orders.rb +279 -0
- data/config/routes.rb +70 -0
- data/db/migrate/01_create_effective_orders.rb.erb +137 -0
- data/lib/effective_orders.rb +243 -0
- data/lib/effective_orders/engine.rb +60 -0
- data/lib/effective_orders/version.rb +3 -0
- data/lib/generators/effective_orders/install_generator.rb +63 -0
- data/lib/generators/templates/effective_orders_mailer_preview.rb +120 -0
- data/lib/tasks/effective_orders_tasks.rake +69 -0
- metadata +276 -0
@@ -0,0 +1,60 @@
|
|
1
|
+
module EffectiveOrders
|
2
|
+
class Engine < ::Rails::Engine
|
3
|
+
engine_name 'effective_orders'
|
4
|
+
|
5
|
+
# Include acts_as_addressable concern and allow any ActiveRecord object to call it
|
6
|
+
initializer 'effective_orders.active_record' do |app|
|
7
|
+
ActiveSupport.on_load :active_record do
|
8
|
+
ActiveRecord::Base.extend(ActsAsPurchasable::Base)
|
9
|
+
ActiveRecord::Base.extend(ActsAsSubscribable::Base)
|
10
|
+
ActiveRecord::Base.extend(ActsAsSubscribableBuyer::Base)
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
# Set up our default configuration options.
|
15
|
+
initializer 'effective_orders.defaults', before: :load_config_initializers do |app|
|
16
|
+
eval File.read("#{config.root}/config/effective_orders.rb")
|
17
|
+
end
|
18
|
+
|
19
|
+
# Set up mail delivering config option
|
20
|
+
initializer 'effective_orders.mailer', after: :load_config_initializers do |app|
|
21
|
+
EffectiveOrders.mailer[:deliver_method] ||= (
|
22
|
+
(Rails.application.config.respond_to?(:active_job) && Rails.application.config.active_job.queue_adapter) ? :deliver_later : :deliver_now
|
23
|
+
)
|
24
|
+
end
|
25
|
+
|
26
|
+
initializer "effective_orders.append_precompiled_assets" do |app|
|
27
|
+
Rails.application.config.assets.precompile += ['effective_orders/*']
|
28
|
+
end
|
29
|
+
|
30
|
+
initializer 'effective_orders.refund', after: :load_config_initializers do
|
31
|
+
if EffectiveOrders.refund?
|
32
|
+
unless (EffectiveOrders.mailer[:admin_email].to_s.include?('@') rescue false)
|
33
|
+
raise("config.mailer[:admin_email] must be present when refunds enabled.")
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
|
38
|
+
initializer 'effective_orders.stripe', after: :load_config_initializers do
|
39
|
+
if EffectiveOrders.stripe?
|
40
|
+
begin
|
41
|
+
require 'stripe'
|
42
|
+
::Stripe.api_key = EffectiveOrders.stripe[:secret_key]
|
43
|
+
rescue Exception
|
44
|
+
raise "unable to load stripe. Plese add gem 'stripe' to your Gemfile and then 'bundle install'"
|
45
|
+
end
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
initializer 'effective_orders.obfuscate_order_ids' do
|
50
|
+
if EffectiveOrders.obfuscate_order_ids
|
51
|
+
begin
|
52
|
+
require 'effective_obfuscation'
|
53
|
+
rescue Exception
|
54
|
+
raise "unable to load effective_obfuscation. Please add gem 'effective_obfuscation' to your Gemfile and then 'bundle install'"
|
55
|
+
end
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
end
|
60
|
+
end
|
@@ -0,0 +1,63 @@
|
|
1
|
+
module EffectiveOrders
|
2
|
+
module Generators
|
3
|
+
class InstallGenerator < Rails::Generators::Base
|
4
|
+
include Rails::Generators::Migration
|
5
|
+
|
6
|
+
desc 'Creates an EffectiveOrders initializer in your application.'
|
7
|
+
|
8
|
+
source_root File.expand_path('../../templates', __FILE__)
|
9
|
+
|
10
|
+
def self.next_migration_number(dirname)
|
11
|
+
unless ActiveRecord::Base.timestamped_migrations
|
12
|
+
Time.new.utc.strftime("%Y%m%d%H%M%S")
|
13
|
+
else
|
14
|
+
"%.3d" % (current_migration_number(dirname) + 1)
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
def install_effective_addresses
|
19
|
+
run 'rails generate effective_addresses:install'
|
20
|
+
end
|
21
|
+
|
22
|
+
def copy_initializer
|
23
|
+
template ('../' * 3) + 'config/effective_orders.rb', 'config/initializers/effective_orders.rb'
|
24
|
+
end
|
25
|
+
|
26
|
+
def copy_mailer_layout
|
27
|
+
layout = 'app/views/layouts/effective_orders_mailer_layout.html.haml'
|
28
|
+
template ('../' * 3) + layout, layout
|
29
|
+
end
|
30
|
+
|
31
|
+
def copy_mailer_templates
|
32
|
+
path = 'app/views/effective/orders_mailer/'
|
33
|
+
|
34
|
+
Dir["#{source_paths.first}/../../../#{path}**"].map { |file| file.split('/').last }.each do |name|
|
35
|
+
template (('../' * 3) + path + name), (path + name)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def copy_mailer_preview
|
40
|
+
mailer_preview_path = (Rails.application.config.action_mailer.preview_path rescue nil)
|
41
|
+
|
42
|
+
if mailer_preview_path.present?
|
43
|
+
template 'effective_orders_mailer_preview.rb', File.join(mailer_preview_path, 'effective_orders_mailer_preview.rb')
|
44
|
+
else
|
45
|
+
puts "couldn't find action_mailer.preview_path. Skipping effective_orders_mailer_preview."
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
def create_migration_file
|
50
|
+
@orders_table_name = ':' + EffectiveOrders.orders_table_name.to_s
|
51
|
+
@order_items_table_name = ':' + EffectiveOrders.order_items_table_name.to_s
|
52
|
+
@carts_table_name = ':' + EffectiveOrders.carts_table_name.to_s
|
53
|
+
@cart_items_table_name = ':' + EffectiveOrders.cart_items_table_name.to_s
|
54
|
+
@customers_table_name = ':' + EffectiveOrders.customers_table_name.to_s
|
55
|
+
@subscriptions_table_name = ':' + EffectiveOrders.subscriptions_table_name.to_s
|
56
|
+
@products_table_name = ':' + EffectiveOrders.products_table_name.to_s
|
57
|
+
|
58
|
+
migration_template ('../' * 3) + 'db/migrate/01_create_effective_orders.rb.erb', 'db/migrate/create_effective_orders.rb'
|
59
|
+
end
|
60
|
+
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,120 @@
|
|
1
|
+
# In Rails 4.1 and above, visit:
|
2
|
+
# http://localhost:3000/rails/mailers
|
3
|
+
# to see a preview of the following 3 emails:
|
4
|
+
|
5
|
+
class EffectiveOrdersMailerPreview < ActionMailer::Preview
|
6
|
+
def order_receipt_to_admin
|
7
|
+
Effective::OrdersMailer.order_receipt_to_admin(build_preview_order)
|
8
|
+
end
|
9
|
+
|
10
|
+
def order_receipt_to_buyer
|
11
|
+
Effective::OrdersMailer.order_receipt_to_buyer(build_preview_order)
|
12
|
+
end
|
13
|
+
|
14
|
+
def payment_request_to_buyer
|
15
|
+
Effective::OrdersMailer.payment_request_to_buyer(build_preview_order)
|
16
|
+
end
|
17
|
+
|
18
|
+
def pending_order_invoice_to_buyer
|
19
|
+
Effective::OrdersMailer.pending_order_invoice_to_buyer(build_preview_order)
|
20
|
+
end
|
21
|
+
|
22
|
+
def subscription_payment_succeeded
|
23
|
+
Effective::OrdersMailer.subscription_payment_succeeded(preview_customer)
|
24
|
+
end
|
25
|
+
|
26
|
+
def subscription_payment_failed
|
27
|
+
Effective::OrdersMailer.subscription_payment_failed(preview_customer)
|
28
|
+
end
|
29
|
+
|
30
|
+
def subscription_created
|
31
|
+
Effective::OrdersMailer.subscription_created(preview_customer)
|
32
|
+
end
|
33
|
+
|
34
|
+
def subscription_updated
|
35
|
+
Effective::OrdersMailer.subscription_updated(preview_customer)
|
36
|
+
end
|
37
|
+
|
38
|
+
def subscription_canceled
|
39
|
+
Effective::OrdersMailer.subscription_canceled(preview_customer)
|
40
|
+
end
|
41
|
+
|
42
|
+
def subscription_trialing
|
43
|
+
Effective::OrdersMailer.subscription_trialing(preview_subscribable)
|
44
|
+
end
|
45
|
+
|
46
|
+
def subscription_trial_expired
|
47
|
+
Effective::OrdersMailer.subscription_trial_expired(preview_subscribable)
|
48
|
+
end
|
49
|
+
|
50
|
+
def subscription_event_to_admin
|
51
|
+
Effective::OrdersMailer.subscription_event_to_admin(:subscription_updated, preview_customer)
|
52
|
+
end
|
53
|
+
|
54
|
+
def order_error
|
55
|
+
Effective::OrdersMailer.order_error(order: build_preview_order, error: 'Something did not work out')
|
56
|
+
end
|
57
|
+
|
58
|
+
protected
|
59
|
+
|
60
|
+
def build_preview_order
|
61
|
+
order = Effective::Order.new(id: 1)
|
62
|
+
order.user = preview_user
|
63
|
+
preview_order_items.each { |atts| order.order_items.build(atts) }
|
64
|
+
order.valid?
|
65
|
+
order
|
66
|
+
end
|
67
|
+
|
68
|
+
def build_address
|
69
|
+
Effective::Address.new(category: 'billing', full_name: 'Valued Customer', address1: '1234 Fake Street', address2: 'Suite 200', city: 'Edmonton', state_code: 'AB', country_code: 'CA', postal_code: 'T5T 2T1')
|
70
|
+
end
|
71
|
+
|
72
|
+
private
|
73
|
+
|
74
|
+
# We're building Effective::OrderItems directly rather than creating acts_as_purchasable objects
|
75
|
+
# so that this mailer will not have to guess at your app's acts_as_purchasable objects
|
76
|
+
def preview_order_items
|
77
|
+
[
|
78
|
+
{ name: 'Item One', quantity: 2, price: 999, tax_exempt: false },
|
79
|
+
{ name: 'Item Two', quantity: 1, price: 25000, tax_exempt: false },
|
80
|
+
{ name: 'Item Three', quantity: 1, price: 8999, tax_exempt: false },
|
81
|
+
{ name: 'Item Four', quantity: 1, price: 100000, tax_exempt: false }
|
82
|
+
]
|
83
|
+
end
|
84
|
+
|
85
|
+
def preview_user
|
86
|
+
User.new(email: 'buyer@website.com').tap do |user|
|
87
|
+
user.name = 'Valued Customer' if user.respond_to?(:name=)
|
88
|
+
user.full_name = 'Valued Customer' if user.respond_to?(:full_name=)
|
89
|
+
|
90
|
+
if user.respond_to?(:first_name=) && user.respond_to?(:last_name=)
|
91
|
+
user.first_name = 'Valued'
|
92
|
+
user.last_name = 'Customer'
|
93
|
+
end
|
94
|
+
|
95
|
+
user.billing_address = build_address if user.respond_to?(:billing_address=)
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def preview_customer
|
100
|
+
customer = Effective::Customer.new(user: preview_user, active_card: '**** **** **** 1234 Visa 04/20')
|
101
|
+
|
102
|
+
if preview_subscribable.present?
|
103
|
+
customer.subscriptions.build(subscribable: preview_subscribable, name: 'Bronze Plan')
|
104
|
+
customer.subscriptions.build(subscribable: preview_subscribable, name: 'Silver Plan')
|
105
|
+
end
|
106
|
+
|
107
|
+
customer
|
108
|
+
end
|
109
|
+
|
110
|
+
def preview_subscribable
|
111
|
+
Rails.application.eager_load!
|
112
|
+
|
113
|
+
klasses = Array(ActsAsSubscribable.descendants).compact
|
114
|
+
return unless klasses.present?
|
115
|
+
|
116
|
+
klasses.map { |klass| klass.all.order(Arel.sql('random()')).first }.compact.first ||
|
117
|
+
klasses.first.new(subscribable_buyer: preview_user)
|
118
|
+
end
|
119
|
+
|
120
|
+
end
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# rake effective_orders:overwrite_order_item_names
|
2
|
+
|
3
|
+
namespace :effective_orders do
|
4
|
+
desc 'Overwrite all order item names with current acts_as_purchasable object names'
|
5
|
+
task overwrite_order_item_names: :environment do
|
6
|
+
puts 'WARNING: this task will overwrite all existing order items with new names. Proceed? (y/n)'
|
7
|
+
(puts 'Aborted' and exit) unless STDIN.gets.chomp.downcase == 'y'
|
8
|
+
|
9
|
+
Effective::OrderItem.transaction do
|
10
|
+
begin
|
11
|
+
|
12
|
+
Effective::OrderItem.includes(:purchasable).find_each do |order_item|
|
13
|
+
new_name = order_item.purchasable.purchasable_name
|
14
|
+
|
15
|
+
unless new_name
|
16
|
+
raise "acts_as_purchasable object #{order_item.purchasable_type.try(:classify)}<#{order_item.purchasable_id}>.title() from Effective::OrderItem<#{order_item.id}> cannot be nil."
|
17
|
+
end
|
18
|
+
|
19
|
+
order_item.update_column(:name, new_name) # This intentionally skips validation
|
20
|
+
end
|
21
|
+
|
22
|
+
puts 'Successfully updated all order item names.'
|
23
|
+
rescue => e
|
24
|
+
puts "An error has occurred: #{e.message}"
|
25
|
+
puts "(effective_orders) Rollback. No order item names have been changed."
|
26
|
+
raise ActiveRecord::Rollback
|
27
|
+
end
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
# rake effective_orders:send_trial_emails
|
32
|
+
desc 'Sends subscription_trialing and subscription_trial_expired emails to each subscribable. Schedule me to run once per day.'
|
33
|
+
task send_trial_emails: :environment do
|
34
|
+
trial_remind_at = Array(EffectiveOrders.trial[:remind_at]).compact
|
35
|
+
exit unless trial_remind_at.present? && trial_remind_at.all? { |x| x.present? }
|
36
|
+
|
37
|
+
Rails.application.eager_load!
|
38
|
+
|
39
|
+
today = Time.zone.now.beginning_of_day
|
40
|
+
reminders = trial_remind_at.select { |remind_at| remind_at.kind_of?(ActiveSupport::Duration) }
|
41
|
+
|
42
|
+
begin
|
43
|
+
ActsAsSubscribable.descendants.each do |klass|
|
44
|
+
klass.trialing.find_each do |subscribable|
|
45
|
+
if subscribable.trialing_until == today
|
46
|
+
puts "sending trial expired to #{subscribable}"
|
47
|
+
Effective::OrdersMailer.subscription_trial_expired(subscribable).deliver_now
|
48
|
+
end
|
49
|
+
|
50
|
+
next if subscribable.trial_past_due? # We already notified them
|
51
|
+
|
52
|
+
date = (subscribable.trialing_until - EffectiveOrders.trial.fetch(:length)).beginning_of_day # Should be same as created_at.beginning_of_day
|
53
|
+
|
54
|
+
reminders.each do |remind_at|
|
55
|
+
next unless today == (date + remind_at)
|
56
|
+
Effective::OrdersMailer.subscription_trialing(subscribable).deliver_now
|
57
|
+
end
|
58
|
+
end
|
59
|
+
end
|
60
|
+
|
61
|
+
puts 'send_trial_emails completed'
|
62
|
+
EffectiveLogger.success('scheduled task send_trial_emails completed') if defined?(EffectiveLogger)
|
63
|
+
rescue => e
|
64
|
+
ExceptionNotifier.notify_exception(e) if defined?(ExceptionNotifier)
|
65
|
+
raise e
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
end
|
metadata
ADDED
@@ -0,0 +1,276 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: effective_orders
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 4.5.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Code and Effect
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2020-07-22 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: rails
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - ">="
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: 4.0.0
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - ">="
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: 4.0.0
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: coffee-rails
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - ">="
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '0'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - ">="
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '0'
|
41
|
+
- !ruby/object:Gem::Dependency
|
42
|
+
name: devise
|
43
|
+
requirement: !ruby/object:Gem::Requirement
|
44
|
+
requirements:
|
45
|
+
- - ">="
|
46
|
+
- !ruby/object:Gem::Version
|
47
|
+
version: '0'
|
48
|
+
type: :runtime
|
49
|
+
prerelease: false
|
50
|
+
version_requirements: !ruby/object:Gem::Requirement
|
51
|
+
requirements:
|
52
|
+
- - ">="
|
53
|
+
- !ruby/object:Gem::Version
|
54
|
+
version: '0'
|
55
|
+
- !ruby/object:Gem::Dependency
|
56
|
+
name: sass
|
57
|
+
requirement: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - ">="
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
type: :runtime
|
63
|
+
prerelease: false
|
64
|
+
version_requirements: !ruby/object:Gem::Requirement
|
65
|
+
requirements:
|
66
|
+
- - ">="
|
67
|
+
- !ruby/object:Gem::Version
|
68
|
+
version: '0'
|
69
|
+
- !ruby/object:Gem::Dependency
|
70
|
+
name: effective_datatables
|
71
|
+
requirement: !ruby/object:Gem::Requirement
|
72
|
+
requirements:
|
73
|
+
- - ">="
|
74
|
+
- !ruby/object:Gem::Version
|
75
|
+
version: 4.0.0
|
76
|
+
type: :runtime
|
77
|
+
prerelease: false
|
78
|
+
version_requirements: !ruby/object:Gem::Requirement
|
79
|
+
requirements:
|
80
|
+
- - ">="
|
81
|
+
- !ruby/object:Gem::Version
|
82
|
+
version: 4.0.0
|
83
|
+
- !ruby/object:Gem::Dependency
|
84
|
+
name: effective_bootstrap
|
85
|
+
requirement: !ruby/object:Gem::Requirement
|
86
|
+
requirements:
|
87
|
+
- - ">="
|
88
|
+
- !ruby/object:Gem::Version
|
89
|
+
version: '0'
|
90
|
+
type: :runtime
|
91
|
+
prerelease: false
|
92
|
+
version_requirements: !ruby/object:Gem::Requirement
|
93
|
+
requirements:
|
94
|
+
- - ">="
|
95
|
+
- !ruby/object:Gem::Version
|
96
|
+
version: '0'
|
97
|
+
- !ruby/object:Gem::Dependency
|
98
|
+
name: effective_resources
|
99
|
+
requirement: !ruby/object:Gem::Requirement
|
100
|
+
requirements:
|
101
|
+
- - ">="
|
102
|
+
- !ruby/object:Gem::Version
|
103
|
+
version: '0'
|
104
|
+
type: :runtime
|
105
|
+
prerelease: false
|
106
|
+
version_requirements: !ruby/object:Gem::Requirement
|
107
|
+
requirements:
|
108
|
+
- - ">="
|
109
|
+
- !ruby/object:Gem::Version
|
110
|
+
version: '0'
|
111
|
+
description: Quickly build an online store with carts, orders, automatic email receipts
|
112
|
+
and payment collection via Stripe, StripeConnect, PayPal and Moneris.
|
113
|
+
email:
|
114
|
+
- info@codeandeffect.com
|
115
|
+
executables: []
|
116
|
+
extensions: []
|
117
|
+
extra_rdoc_files: []
|
118
|
+
files:
|
119
|
+
- MIT-LICENSE
|
120
|
+
- README.md
|
121
|
+
- app/assets/images/effective_orders/stripe.png
|
122
|
+
- app/assets/javascripts/effective_orders.js
|
123
|
+
- app/assets/javascripts/effective_orders/customers.js.coffee
|
124
|
+
- app/assets/javascripts/effective_orders/providers/stripe.js.coffee
|
125
|
+
- app/assets/javascripts/effective_orders/subscriptions.js.coffee
|
126
|
+
- app/assets/stylesheets/effective_orders.scss
|
127
|
+
- app/assets/stylesheets/effective_orders/_cart.scss
|
128
|
+
- app/assets/stylesheets/effective_orders/_order.scss
|
129
|
+
- app/controllers/admin/customers_controller.rb
|
130
|
+
- app/controllers/admin/order_items_controller.rb
|
131
|
+
- app/controllers/admin/orders_controller.rb
|
132
|
+
- app/controllers/effective/carts_controller.rb
|
133
|
+
- app/controllers/effective/concerns/purchase.rb
|
134
|
+
- app/controllers/effective/customers_controller.rb
|
135
|
+
- app/controllers/effective/orders_controller.rb
|
136
|
+
- app/controllers/effective/providers/cheque.rb
|
137
|
+
- app/controllers/effective/providers/free.rb
|
138
|
+
- app/controllers/effective/providers/mark_as_paid.rb
|
139
|
+
- app/controllers/effective/providers/moneris.rb
|
140
|
+
- app/controllers/effective/providers/paypal.rb
|
141
|
+
- app/controllers/effective/providers/phone.rb
|
142
|
+
- app/controllers/effective/providers/pretend.rb
|
143
|
+
- app/controllers/effective/providers/refund.rb
|
144
|
+
- app/controllers/effective/providers/stripe.rb
|
145
|
+
- app/controllers/effective/subscripter_controller.rb
|
146
|
+
- app/controllers/effective/webhooks_controller.rb
|
147
|
+
- app/datatables/admin/effective_customers_datatable.rb
|
148
|
+
- app/datatables/admin/effective_orders_datatable.rb
|
149
|
+
- app/datatables/effective_orders_datatable.rb
|
150
|
+
- app/helpers/effective_carts_helper.rb
|
151
|
+
- app/helpers/effective_orders_helper.rb
|
152
|
+
- app/helpers/effective_paypal_helper.rb
|
153
|
+
- app/helpers/effective_stripe_helper.rb
|
154
|
+
- app/helpers/effective_subscriptions_helper.rb
|
155
|
+
- app/mailers/effective/orders_mailer.rb
|
156
|
+
- app/models/concerns/acts_as_purchasable.rb
|
157
|
+
- app/models/concerns/acts_as_subscribable.rb
|
158
|
+
- app/models/concerns/acts_as_subscribable_buyer.rb
|
159
|
+
- app/models/effective/access_denied.rb
|
160
|
+
- app/models/effective/cart.rb
|
161
|
+
- app/models/effective/cart_item.rb
|
162
|
+
- app/models/effective/customer.rb
|
163
|
+
- app/models/effective/order.rb
|
164
|
+
- app/models/effective/order_item.rb
|
165
|
+
- app/models/effective/product.rb
|
166
|
+
- app/models/effective/sold_out_validator.rb
|
167
|
+
- app/models/effective/subscripter.rb
|
168
|
+
- app/models/effective/subscription.rb
|
169
|
+
- app/models/effective/tax_rate_calculator.rb
|
170
|
+
- app/views/admin/customers/_actions.html.haml
|
171
|
+
- app/views/admin/customers/index.html.haml
|
172
|
+
- app/views/admin/customers/show.html.haml
|
173
|
+
- app/views/admin/order_items/index.html.haml
|
174
|
+
- app/views/admin/orders/_datatable_actions.html.haml
|
175
|
+
- app/views/admin/orders/_form.html.haml
|
176
|
+
- app/views/admin/orders/_form_note_internal.html.haml
|
177
|
+
- app/views/admin/orders/_order_actions.html.haml
|
178
|
+
- app/views/admin/orders/_order_item_fields.html.haml
|
179
|
+
- app/views/admin/orders/checkout.html.haml
|
180
|
+
- app/views/admin/orders/edit.html.haml
|
181
|
+
- app/views/admin/orders/index.html.haml
|
182
|
+
- app/views/admin/orders/new.html.haml
|
183
|
+
- app/views/admin/orders/show.html.haml
|
184
|
+
- app/views/effective/carts/_cart.html.haml
|
185
|
+
- app/views/effective/carts/_cart_actions.html.haml
|
186
|
+
- app/views/effective/carts/show.html.haml
|
187
|
+
- app/views/effective/customers/_customer.html.haml
|
188
|
+
- app/views/effective/customers/_form.html.haml
|
189
|
+
- app/views/effective/customers/edit.html.haml
|
190
|
+
- app/views/effective/customers/update.js.erb
|
191
|
+
- app/views/effective/orders/_checkout_actions.html.haml
|
192
|
+
- app/views/effective/orders/_checkout_step1.html.haml
|
193
|
+
- app/views/effective/orders/_checkout_step2.html.haml
|
194
|
+
- app/views/effective/orders/_datatable_actions.html.haml
|
195
|
+
- app/views/effective/orders/_fields.html.haml
|
196
|
+
- app/views/effective/orders/_fields_note.html.haml
|
197
|
+
- app/views/effective/orders/_fields_terms.html.haml
|
198
|
+
- app/views/effective/orders/_order.html.haml
|
199
|
+
- app/views/effective/orders/_order_actions.html.haml
|
200
|
+
- app/views/effective/orders/_order_deferred.html.haml
|
201
|
+
- app/views/effective/orders/_order_footer.html.haml
|
202
|
+
- app/views/effective/orders/_order_header.html.haml
|
203
|
+
- app/views/effective/orders/_order_items.html.haml
|
204
|
+
- app/views/effective/orders/_order_notes.html.haml
|
205
|
+
- app/views/effective/orders/_order_payment.html.haml
|
206
|
+
- app/views/effective/orders/_order_shipping.html.haml
|
207
|
+
- app/views/effective/orders/_orders_table.html.haml
|
208
|
+
- app/views/effective/orders/cheque/_form.html.haml
|
209
|
+
- app/views/effective/orders/declined.html.haml
|
210
|
+
- app/views/effective/orders/deferred.html.haml
|
211
|
+
- app/views/effective/orders/deferred/_form.html.haml
|
212
|
+
- app/views/effective/orders/edit.html.haml
|
213
|
+
- app/views/effective/orders/free/_form.html.haml
|
214
|
+
- app/views/effective/orders/index.html.haml
|
215
|
+
- app/views/effective/orders/mark_as_paid/_form.html.haml
|
216
|
+
- app/views/effective/orders/moneris/_form.html.haml
|
217
|
+
- app/views/effective/orders/new.html.haml
|
218
|
+
- app/views/effective/orders/paypal/_form.html.haml
|
219
|
+
- app/views/effective/orders/phone/_form.html.haml
|
220
|
+
- app/views/effective/orders/pretend/_form.html.haml
|
221
|
+
- app/views/effective/orders/purchased.html.haml
|
222
|
+
- app/views/effective/orders/refund/_form.html.haml
|
223
|
+
- app/views/effective/orders/show.html.haml
|
224
|
+
- app/views/effective/orders/stripe/_element.html.haml
|
225
|
+
- app/views/effective/orders/stripe/_form.html.haml
|
226
|
+
- app/views/effective/orders_mailer/order_error.html.haml
|
227
|
+
- app/views/effective/orders_mailer/order_receipt_to_admin.html.haml
|
228
|
+
- app/views/effective/orders_mailer/order_receipt_to_buyer.html.haml
|
229
|
+
- app/views/effective/orders_mailer/payment_request_to_buyer.html.haml
|
230
|
+
- app/views/effective/orders_mailer/pending_order_invoice_to_buyer.html.haml
|
231
|
+
- app/views/effective/orders_mailer/refund_notification_to_admin.html.haml
|
232
|
+
- app/views/effective/orders_mailer/subscription_canceled.html.haml
|
233
|
+
- app/views/effective/orders_mailer/subscription_created.html.haml
|
234
|
+
- app/views/effective/orders_mailer/subscription_event_to_admin.html.haml
|
235
|
+
- app/views/effective/orders_mailer/subscription_payment_failed.html.haml
|
236
|
+
- app/views/effective/orders_mailer/subscription_payment_succeeded.html.haml
|
237
|
+
- app/views/effective/orders_mailer/subscription_trial_expired.html.haml
|
238
|
+
- app/views/effective/orders_mailer/subscription_trialing.html.haml
|
239
|
+
- app/views/effective/orders_mailer/subscription_updated.html.haml
|
240
|
+
- app/views/effective/subscripter/_form.html.haml
|
241
|
+
- app/views/effective/subscripter/_plan.html.haml
|
242
|
+
- app/views/layouts/effective_orders_mailer_layout.html.haml
|
243
|
+
- config/effective_orders.rb
|
244
|
+
- config/routes.rb
|
245
|
+
- db/migrate/01_create_effective_orders.rb.erb
|
246
|
+
- lib/effective_orders.rb
|
247
|
+
- lib/effective_orders/engine.rb
|
248
|
+
- lib/effective_orders/version.rb
|
249
|
+
- lib/generators/effective_orders/install_generator.rb
|
250
|
+
- lib/generators/templates/effective_orders_mailer_preview.rb
|
251
|
+
- lib/tasks/effective_orders_tasks.rake
|
252
|
+
homepage: https://github.com/code-and-effect/effective_orders
|
253
|
+
licenses:
|
254
|
+
- MIT
|
255
|
+
metadata: {}
|
256
|
+
post_install_message:
|
257
|
+
rdoc_options: []
|
258
|
+
require_paths:
|
259
|
+
- lib
|
260
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
261
|
+
requirements:
|
262
|
+
- - ">="
|
263
|
+
- !ruby/object:Gem::Version
|
264
|
+
version: '0'
|
265
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
266
|
+
requirements:
|
267
|
+
- - ">="
|
268
|
+
- !ruby/object:Gem::Version
|
269
|
+
version: '0'
|
270
|
+
requirements: []
|
271
|
+
rubygems_version: 3.1.2
|
272
|
+
signing_key:
|
273
|
+
specification_version: 4
|
274
|
+
summary: Quickly build an online store with carts, orders, automatic email receipts
|
275
|
+
and payment collection via Stripe, StripeConnect, PayPal and Moneris.
|
276
|
+
test_files: []
|