effective_orders 1.8.1 → 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/MIT-LICENSE +1 -1
- data/README.md +150 -60
- data/Rakefile +0 -3
- data/active_admin/effective_orders.rb +14 -9
- data/app/assets/javascripts/effective_orders.js +2 -0
- data/app/assets/javascripts/effective_orders/{stripe_charges.js.coffee → providers/stripe_charges.js.coffee} +1 -1
- data/app/assets/javascripts/effective_orders/{stripe_subscriptions.js.coffee → providers/stripe_subscriptions.js.coffee} +1 -1
- data/app/assets/stylesheets/effective_orders/_order.scss +9 -3
- data/app/controllers/admin/orders_controller.rb +87 -3
- data/app/controllers/concerns/acts_as_active_admin_controller.rb +2 -1
- data/app/controllers/effective/carts_controller.rb +4 -2
- data/app/controllers/effective/orders_controller.rb +101 -60
- data/app/controllers/effective/providers/app_checkout.rb +10 -2
- data/app/controllers/effective/providers/ccbill.rb +34 -0
- data/app/controllers/effective/providers/cheque.rb +30 -0
- data/app/controllers/effective/providers/moneris.rb +7 -7
- data/app/controllers/effective/providers/paypal.rb +7 -5
- data/app/controllers/effective/providers/pretend.rb +22 -0
- data/app/controllers/effective/providers/stripe.rb +26 -24
- data/app/controllers/effective/webhooks_controller.rb +1 -1
- data/app/helpers/effective_carts_helper.rb +59 -29
- data/app/helpers/effective_ccbill_helper.rb +25 -0
- data/app/helpers/effective_orders_helper.rb +50 -41
- data/app/helpers/effective_paypal_helper.rb +11 -11
- data/app/mailers/effective/orders_mailer.rb +95 -20
- data/app/models/concerns/acts_as_purchasable.rb +14 -22
- data/app/models/effective/cart.rb +9 -15
- data/app/models/effective/cart_item.rb +15 -13
- data/app/models/effective/customer.rb +9 -9
- data/app/models/effective/datatables/order_items.rb +14 -8
- data/app/models/effective/datatables/orders.rb +56 -69
- data/app/models/effective/order.rb +250 -139
- data/app/models/effective/order_item.rb +23 -16
- data/app/models/effective/product.rb +23 -0
- data/app/models/effective/providers/ccbill_postback.rb +85 -0
- data/app/models/effective/{stripe_charge.rb → providers/stripe_charge.rb} +1 -1
- data/app/models/effective/subscription.rb +16 -12
- data/app/models/effective/tax_rate_calculator.rb +45 -0
- data/app/views/admin/customers/index.html.haml +2 -5
- data/app/views/admin/order_items/index.html.haml +2 -5
- data/app/views/admin/orders/_actions.html.haml +2 -0
- data/app/views/admin/orders/_form.html.haml +28 -0
- data/app/views/admin/orders/_order_item_fields.html.haml +9 -0
- data/app/views/admin/orders/index.html.haml +9 -5
- data/app/views/admin/orders/new.html.haml +3 -0
- data/app/views/effective/carts/_cart.html.haml +3 -12
- data/app/views/effective/carts/_cart_actions.html.haml +4 -0
- data/app/views/effective/carts/show.html.haml +10 -12
- data/app/views/effective/orders/_checkout_step1.html.haml +46 -0
- data/app/views/effective/orders/_checkout_step2.html.haml +33 -0
- data/app/views/effective/orders/_order.html.haml +2 -0
- data/app/views/effective/orders/_order_actions.html.haml +10 -5
- data/app/views/effective/orders/_order_footer.html.haml +1 -0
- data/app/views/effective/orders/_order_items.html.haml +11 -9
- data/app/views/effective/orders/_order_note.html.haml +8 -0
- data/app/views/effective/orders/_order_note_fields.html.haml +5 -0
- data/app/views/effective/orders/_order_shipping.html.haml +4 -4
- data/app/views/effective/orders/_order_user_fields.html.haml +1 -0
- data/app/views/effective/orders/_orders_table.html.haml +27 -0
- data/app/views/effective/orders/ccbill/_form.html.haml +24 -0
- data/app/views/effective/orders/checkout_step1.html.haml +3 -0
- data/app/views/effective/orders/checkout_step2.html.haml +3 -0
- data/app/views/effective/orders/cheque/_form.html.haml +2 -0
- data/app/views/effective/orders/cheque/pay_by_cheque.html.haml +9 -0
- data/app/views/effective/orders/declined.html.haml +4 -2
- data/app/views/effective/orders/my_purchases.html.haml +1 -1
- data/app/views/effective/orders/my_sales.html.haml +1 -1
- data/app/views/effective/orders/purchased.html.haml +3 -2
- data/app/views/effective/orders/show.html.haml +1 -1
- data/app/views/effective/orders/stripe/_form.html.haml +5 -5
- data/app/views/effective/orders_mailer/order_error.html.haml +11 -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/layouts/effective_orders_mailer_layout.html.haml +7 -7
- data/config/routes.rb +39 -24
- data/db/migrate/01_create_effective_orders.rb.erb +20 -1
- data/db/upgrade/03_upgrade_effective_orders_from1x.rb.erb +95 -0
- data/lib/effective_orders.rb +67 -9
- data/lib/effective_orders/app_checkout_service.rb +1 -2
- data/lib/effective_orders/engine.rb +46 -14
- data/lib/effective_orders/version.rb +1 -1
- data/lib/generators/effective_orders/install_generator.rb +1 -0
- data/lib/generators/effective_orders/upgrade_from03x_generator.rb +1 -0
- data/lib/generators/effective_orders/upgrade_from1x_generator.rb +31 -0
- data/lib/generators/templates/effective_orders.rb +131 -66
- data/lib/generators/templates/effective_orders_mailer_preview.rb +28 -13
- data/spec/controllers/admin/orders_controller_spec.rb +242 -0
- data/spec/controllers/ccbill_orders_controller_spec.rb +103 -0
- data/spec/controllers/moneris_orders_controller_spec.rb +23 -23
- data/spec/controllers/orders_controller_spec.rb +167 -79
- data/spec/controllers/stripe_orders_controller_spec.rb +7 -7
- data/spec/dummy/app/models/product.rb +0 -8
- data/spec/dummy/app/models/product_with_float_price.rb +0 -8
- data/spec/dummy/app/models/user.rb +2 -19
- data/spec/dummy/config/application.rb +2 -1
- data/spec/dummy/config/environments/test.rb +1 -0
- data/spec/dummy/config/initializers/effective_orders.rb +109 -64
- data/spec/dummy/db/schema.rb +15 -2
- data/spec/dummy/db/test.sqlite3 +0 -0
- data/spec/dummy/log/test.log +0 -258
- data/spec/models/acts_as_purchasable_spec.rb +8 -6
- data/spec/models/factories_spec.rb +7 -1
- data/spec/models/order_item_spec.rb +1 -1
- data/spec/models/order_spec.rb +165 -46
- data/spec/models/stripe_charge_spec.rb +5 -5
- data/spec/spec_helper.rb +2 -0
- data/spec/support/factories.rb +49 -33
- metadata +47 -64
- data/app/views/effective/orders/_checkout_step_1.html.haml +0 -43
- data/app/views/effective/orders/_checkout_step_2.html.haml +0 -25
- data/app/views/effective/orders/_my_purchases.html.haml +0 -17
- data/app/views/effective/orders/checkout.html.haml +0 -3
- data/app/views/effective/orders/new.html.haml +0 -4
- data/spec/dummy/log/development.log +0 -82
@@ -1,43 +0,0 @@
|
|
1
|
-
.effective-order
|
2
|
-
= simple_form_for(order, (EffectiveOrders.simple_form_options || {}).merge(:url => effective_orders.orders_path)) do |f|
|
3
|
-
= render :partial => 'effective/orders/order_items', :locals => {:order => order, :form => f}
|
4
|
-
|
5
|
-
- if order.errors[:order_items].present?
|
6
|
-
%p.inline-errors= order.errors[:order_items].first
|
7
|
-
|
8
|
-
- if order.errors[:total].present?
|
9
|
-
%p.inline-errors= order.errors[:total].first.gsub(EffectiveOrders.minimum_charge.to_i.to_s, price_to_currency(EffectiveOrders.minimum_charge.to_i))
|
10
|
-
|
11
|
-
- if EffectiveOrders.collect_user_fields.present? && (f.object.user rescue nil).present?
|
12
|
-
%h3 User Information
|
13
|
-
= render :partial => 'effective/orders/order_user_fields', :locals => {:form => f, :user => f.object.user }
|
14
|
-
|
15
|
-
- num_addresses = [EffectiveOrders.require_billing_address, EffectiveOrders.require_shipping_address].count(true)
|
16
|
-
|
17
|
-
- if num_addresses > 0
|
18
|
-
.row
|
19
|
-
- if EffectiveOrders.require_billing_address
|
20
|
-
%div{:class => "col-sm-#{12 / num_addresses}"}
|
21
|
-
%h3 Billing Address
|
22
|
-
= effective_address_fields(f, :billing_address)
|
23
|
-
- if order.save_billing_address != nil
|
24
|
-
= f.input :save_billing_address, :as => :boolean, :label => 'Save as my default Billing Address'
|
25
|
-
|
26
|
-
- if EffectiveOrders.require_shipping_address
|
27
|
-
%div{:class => "col-sm-#{12 / num_addresses}"}
|
28
|
-
%h3 Shipping Address
|
29
|
-
- if EffectiveOrders.require_billing_address && EffectiveOrders.require_shipping_address
|
30
|
-
.shipping_address_fields{:style => (f.object.shipping_address_same_as_billing? && (f.object.errors[:shipping_address] || []).blank?) ? 'display: none;' : 'display: block;'}
|
31
|
-
= effective_address_fields(f, :shipping_address)
|
32
|
-
- if order.save_shipping_address != nil
|
33
|
-
= f.input :save_shipping_address, :as => :boolean, :label => 'Save as my default Shipping Address'
|
34
|
-
|
35
|
-
= f.input :shipping_address_same_as_billing, :as => :boolean, :label => 'My Shipping address is the same as my Billing address'
|
36
|
-
|
37
|
-
= link_to_current_cart :label => 'Change Items', :class => 'btn btn-default'
|
38
|
-
|
39
|
-
.text-right
|
40
|
-
- if order.total == 0 && EffectiveOrders.allow_free_orders
|
41
|
-
= f.submit order_checkout_label(:free), :class => 'btn btn-primary pull-right', :rel => :nofollow, :data => {'disable_with' => 'Processing...' }
|
42
|
-
- else
|
43
|
-
= f.submit 'Save and Continue', :class => 'btn btn-primary pull-right', :rel => :nofollow, :data => {'disable_with' => 'Saving...' }
|
@@ -1,25 +0,0 @@
|
|
1
|
-
= render order
|
2
|
-
|
3
|
-
.effective-order.effective-order-purchase-actions
|
4
|
-
- if (Rails.env.production? == false && EffectiveOrders.allow_pretend_purchase_in_development)
|
5
|
-
= render :partial => '/effective/orders/pretend/form', locals: {order: order, purchased_redirect_url: purchased_redirect_url, declined_redirect_url: declined_redirect_url}
|
6
|
-
|
7
|
-
- if (Rails.env.production? == true && EffectiveOrders.allow_pretend_purchase_in_production)
|
8
|
-
= render :partial => '/effective/orders/pretend/form', locals: {order: order, purchased_redirect_url: purchased_redirect_url, declined_redirect_url: declined_redirect_url}
|
9
|
-
|
10
|
-
- if EffectiveOrders.moneris_enabled
|
11
|
-
= render :partial => '/effective/orders/moneris/form', locals: {order: order, purchased_redirect_url: purchased_redirect_url, declined_redirect_url: declined_redirect_url}
|
12
|
-
|
13
|
-
- if EffectiveOrders.paypal_enabled
|
14
|
-
= render :partial => '/effective/orders/paypal/form', locals: {order: order}
|
15
|
-
|
16
|
-
- if EffectiveOrders.stripe_enabled
|
17
|
-
= render :partial => '/effective/orders/stripe/form', locals: {order: order}
|
18
|
-
|
19
|
-
- if EffectiveOrders.authorized?(controller, :app_checkout, order)
|
20
|
-
- if EffectiveOrders.app_checkout_enabled
|
21
|
-
= render :partial => '/effective/orders/app_checkout/form', locals: {order: order}
|
22
|
-
|
23
|
-
- if (Rails.env.production? == true && EffectiveOrders.allow_pretend_purchase_in_production)
|
24
|
-
%p= EffectiveOrders.allow_pretend_purchase_in_production_message
|
25
|
-
|
@@ -1,17 +0,0 @@
|
|
1
|
-
%table.table
|
2
|
-
%thead
|
3
|
-
%tr
|
4
|
-
%th Order
|
5
|
-
%th Date of Purchase
|
6
|
-
%th Description
|
7
|
-
%th
|
8
|
-
%tbody
|
9
|
-
- orders.each do |order|
|
10
|
-
%tr
|
11
|
-
%td= order.to_param
|
12
|
-
%td= order.purchased_at.strftime("%Y-%m-%d %H:%M")
|
13
|
-
%td= order_summary(order)
|
14
|
-
%td= link_to 'View', order_path.gsub(':id', order.to_param)
|
15
|
-
|
16
|
-
- unless orders.present?
|
17
|
-
%p You have no purchased orders
|
@@ -1,82 +0,0 @@
|
|
1
|
-
[1m[36m (1.2ms)[0m [1mCREATE TABLE "addresses" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "addressable_type" varchar, "addressable_id" integer, "category" varchar(64), "full_name" varchar, "address1" varchar, "address2" varchar, "city" varchar, "state_code" varchar, "country_code" varchar, "postal_code" varchar, "updated_at" datetime, "created_at" datetime) [0m
|
2
|
-
[1m[35m (0.1ms)[0m select sqlite_version(*)
|
3
|
-
[1m[36m (0.8ms)[0m [1mCREATE INDEX "index_addresses_on_addressable_id" ON "addresses" ("addressable_id")[0m
|
4
|
-
[1m[35m (0.2ms)[0m SELECT sql
|
5
|
-
FROM sqlite_master
|
6
|
-
WHERE name='index_addresses_on_addressable_id' AND type='index'
|
7
|
-
UNION ALL
|
8
|
-
SELECT sql
|
9
|
-
FROM sqlite_temp_master
|
10
|
-
WHERE name='index_addresses_on_addressable_id' AND type='index'
|
11
|
-
|
12
|
-
[1m[36m (0.9ms)[0m [1mCREATE INDEX "index_addresses_on_addressable_type_and_addressable_id" ON "addresses" ("addressable_type", "addressable_id")[0m
|
13
|
-
[1m[35m (1.0ms)[0m CREATE TABLE "cart_items" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "cart_id" integer, "purchasable_type" varchar, "purchasable_id" integer, "quantity" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
|
14
|
-
[1m[36m (1.0ms)[0m [1mCREATE INDEX "index_cart_items_on_cart_id" ON "cart_items" ("cart_id")[0m
|
15
|
-
[1m[35m (0.1ms)[0m SELECT sql
|
16
|
-
FROM sqlite_master
|
17
|
-
WHERE name='index_cart_items_on_cart_id' AND type='index'
|
18
|
-
UNION ALL
|
19
|
-
SELECT sql
|
20
|
-
FROM sqlite_temp_master
|
21
|
-
WHERE name='index_cart_items_on_cart_id' AND type='index'
|
22
|
-
|
23
|
-
[1m[36m (1.0ms)[0m [1mCREATE INDEX "index_cart_items_on_purchasable_id" ON "cart_items" ("purchasable_id")[0m
|
24
|
-
[1m[35m (0.1ms)[0m SELECT sql
|
25
|
-
FROM sqlite_master
|
26
|
-
WHERE name='index_cart_items_on_purchasable_id' AND type='index'
|
27
|
-
UNION ALL
|
28
|
-
SELECT sql
|
29
|
-
FROM sqlite_temp_master
|
30
|
-
WHERE name='index_cart_items_on_purchasable_id' AND type='index'
|
31
|
-
|
32
|
-
[1m[36m (0.1ms)[0m [1m SELECT sql
|
33
|
-
FROM sqlite_master
|
34
|
-
WHERE name='index_cart_items_on_cart_id' AND type='index'
|
35
|
-
UNION ALL
|
36
|
-
SELECT sql
|
37
|
-
FROM sqlite_temp_master
|
38
|
-
WHERE name='index_cart_items_on_cart_id' AND type='index'
|
39
|
-
[0m
|
40
|
-
[1m[35m (1.0ms)[0m CREATE INDEX "index_cart_items_on_purchasable_type_and_purchasable_id" ON "cart_items" ("purchasable_type", "purchasable_id")
|
41
|
-
[1m[36m (0.9ms)[0m [1mCREATE TABLE "carts" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "user_id" integer, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) [0m
|
42
|
-
[1m[35m (0.8ms)[0m CREATE INDEX "index_carts_on_user_id" ON "carts" ("user_id")
|
43
|
-
[1m[36m (0.9ms)[0m [1mCREATE TABLE "custom_products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar, "price" integer DEFAULT 0, "tax_exempt" boolean, "created_at" datetime, "updated_at" datetime) [0m
|
44
|
-
[1m[35m (1.0ms)[0m CREATE TABLE "customers" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "user_id" integer, "stripe_customer_id" varchar, "stripe_active_card" varchar, "stripe_connect_access_token" varchar, "created_at" datetime, "updated_at" datetime)
|
45
|
-
[1m[36m (1.0ms)[0m [1mCREATE TABLE "order_items" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "order_id" integer, "seller_id" integer, "purchasable_type" varchar, "purchasable_id" integer, "title" varchar, "quantity" integer, "price" integer DEFAULT 0, "tax_exempt" boolean, "tax_rate" decimal(5,3) DEFAULT 0.0, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) [0m
|
46
|
-
[1m[35m (0.9ms)[0m CREATE INDEX "index_order_items_on_order_id" ON "order_items" ("order_id")
|
47
|
-
[1m[36m (0.1ms)[0m [1m SELECT sql
|
48
|
-
FROM sqlite_master
|
49
|
-
WHERE name='index_order_items_on_order_id' AND type='index'
|
50
|
-
UNION ALL
|
51
|
-
SELECT sql
|
52
|
-
FROM sqlite_temp_master
|
53
|
-
WHERE name='index_order_items_on_order_id' AND type='index'
|
54
|
-
[0m
|
55
|
-
[1m[35m (0.9ms)[0m CREATE INDEX "index_order_items_on_purchasable_id" ON "order_items" ("purchasable_id")
|
56
|
-
[1m[36m (0.1ms)[0m [1m SELECT sql
|
57
|
-
FROM sqlite_master
|
58
|
-
WHERE name='index_order_items_on_purchasable_id' AND type='index'
|
59
|
-
UNION ALL
|
60
|
-
SELECT sql
|
61
|
-
FROM sqlite_temp_master
|
62
|
-
WHERE name='index_order_items_on_purchasable_id' AND type='index'
|
63
|
-
[0m
|
64
|
-
[1m[35m (0.1ms)[0m SELECT sql
|
65
|
-
FROM sqlite_master
|
66
|
-
WHERE name='index_order_items_on_order_id' AND type='index'
|
67
|
-
UNION ALL
|
68
|
-
SELECT sql
|
69
|
-
FROM sqlite_temp_master
|
70
|
-
WHERE name='index_order_items_on_order_id' AND type='index'
|
71
|
-
|
72
|
-
[1m[36m (0.9ms)[0m [1mCREATE INDEX "index_order_items_on_purchasable_type_and_purchasable_id" ON "order_items" ("purchasable_type", "purchasable_id")[0m
|
73
|
-
[1m[35m (0.9ms)[0m CREATE TABLE "orders" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "user_id" integer, "purchase_state" varchar, "purchased_at" datetime, "payment" text, "details" text, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL, "note" text)
|
74
|
-
[1m[36m (0.9ms)[0m [1mCREATE INDEX "index_orders_on_user_id" ON "orders" ("user_id")[0m
|
75
|
-
[1m[35m (1.1ms)[0m CREATE TABLE "products" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar, "price" integer DEFAULT 0, "tax_exempt" boolean, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL)
|
76
|
-
[1m[36m (0.9ms)[0m [1mCREATE TABLE "product_with_float_prices" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "title" varchar, "price" decimal DEFAULT 0, "tax_exempt" boolean, "created_at" datetime NOT NULL, "updated_at" datetime NOT NULL) [0m
|
77
|
-
[1m[35m (1.0ms)[0m CREATE TABLE "subscriptions" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "customer_id" integer, "stripe_plan_id" varchar, "stripe_subscription_id" varchar, "stripe_coupon_id" varchar, "title" varchar, "price" integer DEFAULT 0, "created_at" datetime, "updated_at" datetime)
|
78
|
-
[1m[36m (1.1ms)[0m [1mCREATE TABLE "users" ("id" INTEGER PRIMARY KEY AUTOINCREMENT NOT NULL, "encrypted_password" varchar, "reset_password_token" varchar, "reset_password_sent_at" datetime, "remember_created_at" datetime, "confirmation_sent_at" datetime, "confirmed_at" datetime, "confirmation_token" varchar, "unconfirmed_email" varchar, "sign_in_count" integer DEFAULT 0, "current_sign_in_at" datetime, "last_sign_in_at" datetime, "current_sign_in_ip" varchar, "last_sign_in_ip" varchar, "email" varchar, "roles_mask" integer DEFAULT 0, "archived" boolean DEFAULT 'f', "updated_at" datetime, "created_at" datetime) [0m
|
79
|
-
[1m[35m (1.0ms)[0m CREATE TABLE "schema_migrations" ("version" varchar NOT NULL)
|
80
|
-
[1m[36m (0.9ms)[0m [1mCREATE UNIQUE INDEX "unique_schema_migrations" ON "schema_migrations" ("version")[0m
|
81
|
-
[1m[35m (0.1ms)[0m SELECT version FROM "schema_migrations"
|
82
|
-
[1m[36m (0.8ms)[0m [1mINSERT INTO "schema_migrations" (version) VALUES ('4')[0m
|