effective_orders 1.8.1 → 2.0.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.
Files changed (115) hide show
  1. checksums.yaml +4 -4
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +150 -60
  4. data/Rakefile +0 -3
  5. data/active_admin/effective_orders.rb +14 -9
  6. data/app/assets/javascripts/effective_orders.js +2 -0
  7. data/app/assets/javascripts/effective_orders/{stripe_charges.js.coffee → providers/stripe_charges.js.coffee} +1 -1
  8. data/app/assets/javascripts/effective_orders/{stripe_subscriptions.js.coffee → providers/stripe_subscriptions.js.coffee} +1 -1
  9. data/app/assets/stylesheets/effective_orders/_order.scss +9 -3
  10. data/app/controllers/admin/orders_controller.rb +87 -3
  11. data/app/controllers/concerns/acts_as_active_admin_controller.rb +2 -1
  12. data/app/controllers/effective/carts_controller.rb +4 -2
  13. data/app/controllers/effective/orders_controller.rb +101 -60
  14. data/app/controllers/effective/providers/app_checkout.rb +10 -2
  15. data/app/controllers/effective/providers/ccbill.rb +34 -0
  16. data/app/controllers/effective/providers/cheque.rb +30 -0
  17. data/app/controllers/effective/providers/moneris.rb +7 -7
  18. data/app/controllers/effective/providers/paypal.rb +7 -5
  19. data/app/controllers/effective/providers/pretend.rb +22 -0
  20. data/app/controllers/effective/providers/stripe.rb +26 -24
  21. data/app/controllers/effective/webhooks_controller.rb +1 -1
  22. data/app/helpers/effective_carts_helper.rb +59 -29
  23. data/app/helpers/effective_ccbill_helper.rb +25 -0
  24. data/app/helpers/effective_orders_helper.rb +50 -41
  25. data/app/helpers/effective_paypal_helper.rb +11 -11
  26. data/app/mailers/effective/orders_mailer.rb +95 -20
  27. data/app/models/concerns/acts_as_purchasable.rb +14 -22
  28. data/app/models/effective/cart.rb +9 -15
  29. data/app/models/effective/cart_item.rb +15 -13
  30. data/app/models/effective/customer.rb +9 -9
  31. data/app/models/effective/datatables/order_items.rb +14 -8
  32. data/app/models/effective/datatables/orders.rb +56 -69
  33. data/app/models/effective/order.rb +250 -139
  34. data/app/models/effective/order_item.rb +23 -16
  35. data/app/models/effective/product.rb +23 -0
  36. data/app/models/effective/providers/ccbill_postback.rb +85 -0
  37. data/app/models/effective/{stripe_charge.rb → providers/stripe_charge.rb} +1 -1
  38. data/app/models/effective/subscription.rb +16 -12
  39. data/app/models/effective/tax_rate_calculator.rb +45 -0
  40. data/app/views/admin/customers/index.html.haml +2 -5
  41. data/app/views/admin/order_items/index.html.haml +2 -5
  42. data/app/views/admin/orders/_actions.html.haml +2 -0
  43. data/app/views/admin/orders/_form.html.haml +28 -0
  44. data/app/views/admin/orders/_order_item_fields.html.haml +9 -0
  45. data/app/views/admin/orders/index.html.haml +9 -5
  46. data/app/views/admin/orders/new.html.haml +3 -0
  47. data/app/views/effective/carts/_cart.html.haml +3 -12
  48. data/app/views/effective/carts/_cart_actions.html.haml +4 -0
  49. data/app/views/effective/carts/show.html.haml +10 -12
  50. data/app/views/effective/orders/_checkout_step1.html.haml +46 -0
  51. data/app/views/effective/orders/_checkout_step2.html.haml +33 -0
  52. data/app/views/effective/orders/_order.html.haml +2 -0
  53. data/app/views/effective/orders/_order_actions.html.haml +10 -5
  54. data/app/views/effective/orders/_order_footer.html.haml +1 -0
  55. data/app/views/effective/orders/_order_items.html.haml +11 -9
  56. data/app/views/effective/orders/_order_note.html.haml +8 -0
  57. data/app/views/effective/orders/_order_note_fields.html.haml +5 -0
  58. data/app/views/effective/orders/_order_shipping.html.haml +4 -4
  59. data/app/views/effective/orders/_order_user_fields.html.haml +1 -0
  60. data/app/views/effective/orders/_orders_table.html.haml +27 -0
  61. data/app/views/effective/orders/ccbill/_form.html.haml +24 -0
  62. data/app/views/effective/orders/checkout_step1.html.haml +3 -0
  63. data/app/views/effective/orders/checkout_step2.html.haml +3 -0
  64. data/app/views/effective/orders/cheque/_form.html.haml +2 -0
  65. data/app/views/effective/orders/cheque/pay_by_cheque.html.haml +9 -0
  66. data/app/views/effective/orders/declined.html.haml +4 -2
  67. data/app/views/effective/orders/my_purchases.html.haml +1 -1
  68. data/app/views/effective/orders/my_sales.html.haml +1 -1
  69. data/app/views/effective/orders/purchased.html.haml +3 -2
  70. data/app/views/effective/orders/show.html.haml +1 -1
  71. data/app/views/effective/orders/stripe/_form.html.haml +5 -5
  72. data/app/views/effective/orders_mailer/order_error.html.haml +11 -0
  73. data/app/views/effective/orders_mailer/payment_request_to_buyer.html.haml +13 -0
  74. data/app/views/effective/orders_mailer/pending_order_invoice_to_buyer.html.haml +13 -0
  75. data/app/views/layouts/effective_orders_mailer_layout.html.haml +7 -7
  76. data/config/routes.rb +39 -24
  77. data/db/migrate/01_create_effective_orders.rb.erb +20 -1
  78. data/db/upgrade/03_upgrade_effective_orders_from1x.rb.erb +95 -0
  79. data/lib/effective_orders.rb +67 -9
  80. data/lib/effective_orders/app_checkout_service.rb +1 -2
  81. data/lib/effective_orders/engine.rb +46 -14
  82. data/lib/effective_orders/version.rb +1 -1
  83. data/lib/generators/effective_orders/install_generator.rb +1 -0
  84. data/lib/generators/effective_orders/upgrade_from03x_generator.rb +1 -0
  85. data/lib/generators/effective_orders/upgrade_from1x_generator.rb +31 -0
  86. data/lib/generators/templates/effective_orders.rb +131 -66
  87. data/lib/generators/templates/effective_orders_mailer_preview.rb +28 -13
  88. data/spec/controllers/admin/orders_controller_spec.rb +242 -0
  89. data/spec/controllers/ccbill_orders_controller_spec.rb +103 -0
  90. data/spec/controllers/moneris_orders_controller_spec.rb +23 -23
  91. data/spec/controllers/orders_controller_spec.rb +167 -79
  92. data/spec/controllers/stripe_orders_controller_spec.rb +7 -7
  93. data/spec/dummy/app/models/product.rb +0 -8
  94. data/spec/dummy/app/models/product_with_float_price.rb +0 -8
  95. data/spec/dummy/app/models/user.rb +2 -19
  96. data/spec/dummy/config/application.rb +2 -1
  97. data/spec/dummy/config/environments/test.rb +1 -0
  98. data/spec/dummy/config/initializers/effective_orders.rb +109 -64
  99. data/spec/dummy/db/schema.rb +15 -2
  100. data/spec/dummy/db/test.sqlite3 +0 -0
  101. data/spec/dummy/log/test.log +0 -258
  102. data/spec/models/acts_as_purchasable_spec.rb +8 -6
  103. data/spec/models/factories_spec.rb +7 -1
  104. data/spec/models/order_item_spec.rb +1 -1
  105. data/spec/models/order_spec.rb +165 -46
  106. data/spec/models/stripe_charge_spec.rb +5 -5
  107. data/spec/spec_helper.rb +2 -0
  108. data/spec/support/factories.rb +49 -33
  109. metadata +47 -64
  110. data/app/views/effective/orders/_checkout_step_1.html.haml +0 -43
  111. data/app/views/effective/orders/_checkout_step_2.html.haml +0 -25
  112. data/app/views/effective/orders/_my_purchases.html.haml +0 -17
  113. data/app/views/effective/orders/checkout.html.haml +0 -3
  114. data/app/views/effective/orders/new.html.haml +0 -4
  115. data/spec/dummy/log/development.log +0 -82
@@ -0,0 +1,33 @@
1
+ = render(order)
2
+
3
+ .effective-order.effective-order-purchase-actions
4
+ - if EffectiveOrders.allow_pretend_purchase_in_development
5
+ - if Rails.env.production? == false
6
+ = render partial: '/effective/orders/pretend/form', locals: {order: order, purchased_redirect_url: purchased_redirect_url, declined_redirect_url: declined_redirect_url}
7
+
8
+ - if EffectiveOrders.allow_pretend_purchase_in_production
9
+ - if Rails.env.production?
10
+ = render partial: '/effective/orders/pretend/form', locals: {order: order, purchased_redirect_url: purchased_redirect_url, declined_redirect_url: declined_redirect_url}
11
+
12
+ - if EffectiveOrders.moneris_enabled
13
+ = render partial: '/effective/orders/moneris/form', locals: {order: order, purchased_redirect_url: purchased_redirect_url, declined_redirect_url: declined_redirect_url}
14
+
15
+ - if EffectiveOrders.paypal_enabled
16
+ = render partial: '/effective/orders/paypal/form', locals: {order: order}
17
+
18
+ - if EffectiveOrders.stripe_enabled
19
+ = render partial: '/effective/orders/stripe/form', locals: {order: order}
20
+
21
+ - if EffectiveOrders.ccbill_enabled
22
+ = render partial: '/effective/orders/ccbill/form', locals: {order: order}
23
+
24
+ - if EffectiveOrders.app_checkout_enabled
25
+ - if (EffectiveOrders.authorized?(controller, :app_checkout, order) rescue false)
26
+ = render partial: '/effective/orders/app_checkout/form', locals: {order: order}
27
+
28
+ - if EffectiveOrders.cheque_enabled
29
+ = render partial: '/effective/orders/cheque/form', locals: {order: order}
30
+
31
+ - if EffectiveOrders.allow_pretend_purchase_in_production
32
+ %br
33
+ %p= EffectiveOrders.allow_pretend_purchase_in_production_message
@@ -4,7 +4,9 @@
4
4
 
5
5
  = render partial: 'effective/orders/order_header', locals: {order: order}
6
6
  = render partial: 'effective/orders/order_shipping', locals: {order: order}
7
+ = render partial: 'effective/orders/order_note', locals: {order: order}
7
8
  = render partial: 'effective/orders/order_items', locals: {order: order}
9
+ = render partial: 'effective/orders/order_footer', locals: {order: order}
8
10
 
9
11
  - if (EffectiveOrders.authorized?(controller, :show, :payment_details) rescue false)
10
12
  = render partial: 'effective/orders/order_payment_details', locals: {order: order}
@@ -1,5 +1,10 @@
1
- - if order.purchased?
2
- .effective-order-actions.pull-right
3
- %p
4
- = link_to 'Print', '#', :class => 'btn btn-default print-button', 'data-role' => 'print-button', :onClick => "window.print(); false;"
5
- = link_to 'Resend Receipt', effective_orders.resend_buyer_receipt_path(order), :class => 'btn btn-default resend-receipt-button', :data => {'confirm' => 'This action will email you a copy of the original email receipt. Send receipt now?', 'disable_with' => 'Resending...'}
1
+ .effective-order-actions.pull-right
2
+ %p
3
+ = link_to 'Print', '#', class: 'btn btn-default print-button', data: { role: 'print-button' }, onClick: 'window.print(); false;'
4
+
5
+ - if order.purchased?
6
+ = link_to 'Resend Receipt', effective_orders.resend_buyer_receipt_path(order), class: 'btn btn-default', data: { confirm: 'This action will email the buyer a copy of the original email receipt. Send receipt now?', disable_with: 'Resending...' }
7
+
8
+ - elsif (EffectiveOrders.authorized?(controller, :admin, :effective_orders) rescue false)
9
+ = link_to 'Mark as Paid', effective_orders.mark_as_paid_admin_order_path(order), class: 'btn btn-default', method: :post, data: { confirm: 'Are you sure you want to mark this order as paid?', disable_with: 'Marking as paid...' }
10
+ = link_to 'Send Payment Request', effective_orders.send_payment_request_admin_order_path(order), class: 'btn btn-default', method: :post, data: { confirm: 'This action will email buyer a payment request. Send it now?', disable_with: 'Sending...' }
@@ -0,0 +1 @@
1
+ - # intentionally left blank
@@ -31,7 +31,7 @@
31
31
  %td.price= price_to_currency(item.price)
32
32
 
33
33
  %tfoot
34
- - if order.tax > 0
34
+ - if order.tax.to_i > 0 || order.tax_rate == nil
35
35
  %tr
36
36
  - if include_quantity_column
37
37
  %th.quantity
@@ -39,17 +39,19 @@
39
39
  %th.download
40
40
  %th.subtotal Subtotal
41
41
  %td.price.subtotal-price= price_to_currency(order.subtotal)
42
+ - if order.tax.to_i > 0
42
43
  %tr
43
44
  - if include_quantity_column
44
45
  %th.quantity
45
46
  - if include_download_column
46
47
  %th.download
47
- %th.tax Tax
48
+ %th.tax Tax (#{tax_rate_to_percentage(order.tax_rate)})
48
49
  %td.price.tax-price= price_to_currency(order.tax)
49
- %tr
50
- - if include_quantity_column
51
- %th.quantity
52
- - if include_download_column
53
- %th.download
54
- %th.total Total Due
55
- %td.price.total-price= price_to_currency(order.total)
50
+ - if order.tax_rate.present?
51
+ %tr
52
+ - if include_quantity_column
53
+ %th.quantity
54
+ - if include_download_column
55
+ %th.download
56
+ %th.total Total Due
57
+ %td.price.total-price= price_to_currency(order.total)
@@ -0,0 +1,8 @@
1
+ - if order.note.present?
2
+ %table.table
3
+ %thead
4
+ %tr
5
+ %th Note
6
+ %tbody
7
+ %tr
8
+ %td= order.note
@@ -0,0 +1,5 @@
1
+ %h3 Note
2
+ - if EffectiveOrders.collect_note_message.present?
3
+ %p= EffectiveOrders.collect_note_message
4
+
5
+ = form.input :note, :required => (EffectiveOrders.collect_note_required == true)
@@ -3,20 +3,20 @@
3
3
  %thead
4
4
  %tr
5
5
  %th= "#{order.purchased? ? 'Sold to' : 'Bill to'}"
6
- - if order.shipping_address.present? && !order.shipping_address.empty?
6
+ - if order.shipping_address.present?
7
7
  %th Ship to
8
8
 
9
9
  %tbody
10
10
  %tr
11
11
  %td
12
- - if order.billing_address.present? && !order.billing_address.empty?
13
- = render :partial => 'effective/addresses/address', :locals => {:address => order.billing_address, :email => order.user.email}
12
+ - if order.billing_address.present?
13
+ = render :partial => 'effective/addresses/address', :locals => {:address => order.billing_address}
14
14
  - else
15
15
  = order.billing_name
16
16
  %br
17
17
  = mail_to(order.user.email)
18
18
  %br
19
19
 
20
- - if order.shipping_address.present? && !order.shipping_address.empty?
20
+ - if order.shipping_address.present?
21
21
  %td
22
22
  = render :partial => 'effective/addresses/address', :locals => {:address => order.shipping_address}
@@ -1,3 +1,4 @@
1
+ %h3 User Information
1
2
  = form.simple_fields_for :user, user do |fa|
2
3
  - if (EffectiveOrders.collect_user_fields || []).include?(:salutation) && fa.object.respond_to?(:salutation)
3
4
  - if defined?(fa.object.class::SALUTATIONS)
@@ -0,0 +1,27 @@
1
+ %table.table
2
+ %thead
3
+ %tr
4
+ %th Order
5
+ %th Date
6
+ %th Description
7
+ %th
8
+ %tbody
9
+ - orders.each do |order|
10
+ %tr
11
+ %td ##{order.to_param}
12
+ %td
13
+ - if order.purchased?
14
+ Purchased
15
+ = order.purchased_at.strftime("%Y-%m-%d %H:%M")
16
+ - else
17
+ Created
18
+ = order.created_at.strftime("%Y-%m-%d %H:%M")
19
+ %td= order_summary(order)
20
+ %td
21
+ - if order.pending?
22
+ = link_to_checkout(order: order)
23
+ - else
24
+ = link_to 'View', effective_orders.order_path(order)
25
+
26
+ - unless orders.present?
27
+ %p You have no orders
@@ -0,0 +1,24 @@
1
+ = form_tag('https://bill.ccbill.com/jpost/signup.cgi', :method => :post) do
2
+ = hidden_field_tag(:clientAccnum, EffectiveOrders.ccbill[:client_accnum])
3
+ = hidden_field_tag(:clientSubacc, EffectiveOrders.ccbill[:client_subacc])
4
+ = hidden_field_tag(:formName, EffectiveOrders.ccbill[:form_name])
5
+ = hidden_field_tag(:formPrice, ccbill_price(order.total))
6
+ = hidden_field_tag(:formPeriod, EffectiveOrders.ccbill[:form_period])
7
+ = hidden_field_tag(:currencyCode, EffectiveOrders.ccbill[:currency_code])
8
+ = hidden_field_tag(:formDigest, ccbill_form_digest(order))
9
+
10
+ -# CCBill 'Webhooks' (pre-filled form data)
11
+ = hidden_field_tag(:customer_fname, ccbill_customer_name(order, :first_name))
12
+ = hidden_field_tag(:customer_lname, ccbill_customer_name(order, :last_name))
13
+ = hidden_field_tag(:email, order.user.try(:email))
14
+ = hidden_field_tag(:address1, order.billing_address.try(:address1))
15
+ = hidden_field_tag(:city, order.billing_address.try(:city))
16
+ = hidden_field_tag(:state, order.billing_address.try(:state_code))
17
+ = hidden_field_tag(:zipcode, order.billing_address.try(:postal_code))
18
+ = hidden_field_tag(:country, order.billing_address.try(:country_code))
19
+
20
+ -# custom fields
21
+ = hidden_field_tag(:order_id, order.to_param)
22
+
23
+ = submit_tag(order_checkout_label(:ccbill), :class => 'btn btn-primary', :data => {'disable_with' => 'Continuing...' })
24
+
@@ -0,0 +1,3 @@
1
+ %h2.effective-orders-page-title= (@page_title || 'Checkout')
2
+
3
+ = render_checkout_step1(@order)
@@ -0,0 +1,3 @@
1
+ %h2.effective-orders-page-title= (@page_title || 'Checkout')
2
+
3
+ = render_checkout_step2(@order)
@@ -0,0 +1,2 @@
1
+ = form_tag(effective_orders.pay_by_cheque_path(order), method: :post) do
2
+ = submit_tag order_checkout_label(:cheque), class: 'btn btn-primary', data: { confirm: EffectiveOrders.cheque[:confirm].presence, disable_with: 'Continuing...' }
@@ -0,0 +1,9 @@
1
+ %h2.effective-orders-page-title= (@page_title || 'Payment Required')
2
+
3
+ %p.effective-orders-page-content
4
+ Thank you!
5
+ You have indicated that this order will be purchased by cheque.
6
+ Please send us a cheque at your earliest convenience.
7
+ We will mark this order purchased upon receiving your payment.
8
+
9
+ = render @order
@@ -1,5 +1,7 @@
1
- %h2.effective-orders-page-title Payment Declined
1
+ %h2.effective-orders-page-title= (@page_title || 'Payment Declined')
2
2
 
3
- %p Your #{link_to_current_cart(label: 'Shopping Cart')} items have been saved. Please try again.
3
+ %p= flash[:danger]
4
+
5
+ %p Your #{link_to_current_cart(label: 'Cart')} items have been saved. Please try again.
4
6
 
5
7
 
@@ -1,3 +1,3 @@
1
- %h2.effective-orders-page-title Order History
1
+ %h2.effective-orders-page-title= (@page_title || 'Order History')
2
2
 
3
3
  = render_order_history(@orders)
@@ -1,4 +1,4 @@
1
- %h2.effective-orders-page-title My Sales
1
+ %h2.effective-orders-page-title= (@page_title || 'Sales History')
2
2
 
3
3
  %table.table
4
4
  %thead
@@ -1,5 +1,6 @@
1
- %h2.effective-orders-page-title Thank You
1
+ %h2.effective-orders-page-title= (@page_title || 'Thank You')
2
2
 
3
- %p You have successfully purchased the following:
3
+ %p.effective-orders-page-content
4
+ You have successfully purchased the following:
4
5
 
5
6
  = render @order
@@ -1,3 +1,3 @@
1
- %h2.effective-orders-page-title= (@order.purchased? ? 'Receipt' : 'Order')
1
+ %h2.effective-orders-page-title= (@page_title || 'Order')
2
2
 
3
3
  = render @order
@@ -1,7 +1,7 @@
1
1
  = javascript_include_tag "https://checkout.stripe.com/checkout.js"
2
2
 
3
- #effective-orders-new-charge-form{:data => {'stripe-publishable-key' => EffectiveOrders.stripe[:publishable_key], 'site-title' => EffectiveOrders.stripe[:site_title], 'site-image' => EffectiveOrders.stripe[:site_image], 'user-email' => current_user.try(:email), 'amount' => order.total, 'description' => "#{order.num_items} items (#{price_to_currency(order.total)})"}}
4
- = simple_form_for(@stripe_charge || Effective::StripeCharge.new(order), (EffectiveOrders.simple_form_options || {}).merge(:url => effective_orders.stripe_charges_path)) do |f|
5
- = f.input :effective_order_id, :as => :hidden
6
- = f.input :token, :as => :hidden
7
- = f.submit order_checkout_label(:stripe), :class => 'stripe-button', :data => {'disable_with' => 'Continuing...' }
3
+ #effective-orders-new-charge-form{data: {'stripe-publishable-key' => EffectiveOrders.stripe[:publishable_key], 'site-title' => EffectiveOrders.stripe[:site_title], 'site-image' => EffectiveOrders.stripe[:site_image], 'user-email' => current_user.try(:email), 'amount' => order.total, 'description' => "#{order.num_items} items (#{price_to_currency(order.total)})"}}
4
+ = simple_form_for(@stripe_charge || Effective::Providers::StripeCharge.new(order), (EffectiveOrders.simple_form_options || {}).merge(url: effective_orders.stripe_charges_path)) do |f|
5
+ = f.input :effective_order_id, as: :hidden
6
+ = f.input :token, as: :hidden
7
+ = f.submit order_checkout_label(:stripe), class: 'stripe-button', data: {'disable_with' => 'Continuing...' }
@@ -0,0 +1,11 @@
1
+ %p.effective-orders-receipt-info
2
+ - if @order.present?
3
+ An error occurred with the following order:
4
+ - else
5
+ An order error occurred:
6
+
7
+ - if @error.present?
8
+ %p Error: #{@error}
9
+
10
+ - if @order.present?
11
+ = render(@order, no_order_actions: true)
@@ -0,0 +1,13 @@
1
+ %p.effective-orders-receipt-info Request for Payment
2
+
3
+ %p
4
+ An order has been created on your behalf for the following items.
5
+ Please remit payment at your earliest convenience.
6
+
7
+ %p #{link_to('Click here', effective_orders.order_url(@order))} to review your order and pay online with a credit card.
8
+
9
+ - if EffectiveOrders.cheque_enabled
10
+ %p We also accept cheques via the mail, and we will manually mark your order paid upon receiving it.
11
+
12
+ = render(@order, no_order_actions: true)
13
+
@@ -0,0 +1,13 @@
1
+ %p.effective-orders-receipt-info Pending order created
2
+
3
+ %p We have received notice of your intention to purchase the following items.
4
+
5
+ %p Please remit payment at your earliest convenience.
6
+
7
+ %p #{link_to('Click here', effective_orders.order_url(@order))} to review your order online.
8
+
9
+ - if EffectiveOrders.cheque_enabled
10
+ %p When we receive your cheque in the mail we will mark your order paid.
11
+
12
+ = render(@order, no_order_actions: true)
13
+
@@ -16,12 +16,12 @@
16
16
  %tr
17
17
  %td
18
18
  %table{style: 'max-width: 650px; margin: 4px auto 30px;'}
19
- %thead{style: 'border-bottom: 2px solid transparent; width: 100%;'}
20
- %tr{style: 'background: #000; color: #fff;'}
21
- %th{style: 'padding-top: 2px;'}
22
- %tbody{style: 'background: #fff; width: 100%; margin-bottom: 4px;'}
19
+ %thead{style: 'width: 100%;'}
20
+ %tr
21
+ %th
22
+ %tbody{style: 'width: 100%'}
23
23
  %tr
24
24
  %td= yield
25
- %tfoot{style: 'border-bottom: 2px solid transparent; width: 100%;'}
26
- %tr{style: 'background: #000; color: #fff;'}
27
- %th{style: 'padding-top: 2px;'}
25
+ %tfoot{style: 'width: 100%;'}
26
+ %tr
27
+ %th
data/config/routes.rb CHANGED
@@ -1,61 +1,76 @@
1
1
  Rails.application.routes.draw do
2
- mount EffectiveOrders::Engine => '/', :as => 'effective_orders'
2
+ unless EffectiveOrders.skip_mount_engine
3
+ mount EffectiveOrders::Engine => '/', as: 'effective_orders'
4
+ end
3
5
  end
4
6
 
5
7
  EffectiveOrders::Engine.routes.draw do
6
- scope :module => 'effective' do
8
+ scope module: 'effective' do
9
+
10
+ match 'orders/(:id)/purchased', to: 'orders#purchased', as: 'order_purchased', via: :get
11
+ match 'orders/:id/declined', to: 'orders#declined', as: 'order_declined', via: :get
12
+ match 'orders/:id/resend_buyer_receipt', to: 'orders#resend_buyer_receipt', via: :get, as: 'resend_buyer_receipt'
13
+ match 'orders/my_purchases', to: 'orders#my_purchases', as: 'my_purchases', via: :get
7
14
 
8
- match 'orders/:id/purchased', :to => 'orders#purchased', :as => 'order_purchased', :via => :get
9
- match 'orders/:id/declined', :to => 'orders#declined', :as => 'order_declined', :via => :get
10
- match 'orders/:id/resend_buyer_receipt', :to => 'orders#resend_buyer_receipt', :via => :get, :as => 'resend_buyer_receipt'
11
- match 'orders/my_purchases', :to => 'orders#my_purchases', :as => 'my_purchases', :via => :get
15
+ if EffectiveOrders.cheque_enabled
16
+ match 'orders/:id/pay_by_cheque', to: 'orders#pay_by_cheque', via: :post, as: 'pay_by_cheque'
17
+ end
12
18
 
13
19
  if EffectiveOrders.paypal_enabled
14
- match 'orders/paypal_postback', :to => 'orders#paypal_postback', :as => 'paypal_postback', :via => :post
20
+ match 'orders/paypal_postback', to: 'orders#paypal_postback', as: 'paypal_postback', via: :post
15
21
  end
16
22
 
17
23
  if EffectiveOrders.moneris_enabled
18
- match 'orders/moneris_postback', :to => 'orders#moneris_postback', :as => 'moneris_postback', :via => :post
24
+ match 'orders/moneris_postback', to: 'orders#moneris_postback', as: 'moneris_postback', via: :post
19
25
  end
20
26
 
21
27
  if EffectiveOrders.stripe_enabled
22
- match 'orders/stripe_charge', :to => 'orders#stripe_charge', :as => 'stripe_charges', :via => :post
28
+ match 'orders/stripe_charge', to: 'orders#stripe_charge', as: 'stripe_charges', via: :post
23
29
  end
24
30
 
25
31
  if EffectiveOrders.stripe_subscriptions_enabled
26
- resources :subscriptions, :only => [:index, :show, :new, :create, :destroy]
32
+ resources :subscriptions, only: [:index, :show, :new, :create, :destroy]
27
33
  end
28
34
 
29
35
  if EffectiveOrders.stripe_connect_enabled
30
- match 'orders/stripe_connect_redirect_uri', :to => 'orders#stripe_connect_redirect_uri', :as => 'stripe_connect_redirect_uri', :via => :get
31
- match 'orders/my_sales', :to => 'orders#my_sales', :as => 'my_sales', :via => :get
36
+ match 'orders/stripe_connect_redirect_uri', to: 'orders#stripe_connect_redirect_uri', as: 'stripe_connect_redirect_uri', via: :get
37
+ match 'orders/my_sales', to: 'orders#my_sales', as: 'my_sales', via: :get
38
+ end
39
+
40
+ if EffectiveOrders.ccbill_enabled
41
+ match 'orders/ccbill_postback', to: 'orders#ccbill_postback', as: 'ccbill_postback', via: :post
32
42
  end
33
43
 
34
44
  if EffectiveOrders.app_checkout_enabled
35
- match 'orders/:id/app_checkout', :to => 'orders#app_checkout', :as => 'app_checkout', :via => :post
45
+ match 'orders/:id/app_checkout', to: 'orders#app_checkout', as: 'app_checkout', via: :post
36
46
  end
37
47
 
38
48
  if (Rails.env.development? || Rails.env.test?) || EffectiveOrders.allow_pretend_purchase_in_production
39
- match 'orders/:id/pretend_purchase', :to => 'orders#pretend_purchase', :as => 'pretend_purchase', :via => [:get, :post]
49
+ match 'orders/:id/pretend_purchase', to: 'orders#pretend_purchase', as: 'pretend_purchase', via: [:get, :post]
40
50
  end
41
51
 
42
- resources :orders, :only => [:new, :create, :show, :index]
52
+ resources :orders, except: [:destroy]
43
53
 
44
- match 'cart', :to => 'carts#show', :as => 'cart', :via => :get
45
- match 'cart', :to => 'carts#destroy', :via => :delete
54
+ match 'cart', to: 'carts#show', as: 'cart', via: :get
55
+ match 'cart', to: 'carts#destroy', via: :delete
46
56
 
47
57
  # If you Tweak this route, please update EffectiveOrdersHelper too
48
- match 'cart/:purchasable_type/:purchasable_id', :to => 'carts#add_to_cart', :via => [:get, :post], :as => 'add_to_cart'
49
- match 'cart/:id', :to => 'carts#remove_from_cart', :via => [:delete], :as => 'remove_from_cart'
58
+ match 'cart/:purchasable_type/:purchasable_id', to: 'carts#add_to_cart', via: [:get, :post], as: 'add_to_cart'
59
+ match 'cart/:id', to: 'carts#remove_from_cart', via: [:delete], as: 'remove_from_cart'
50
60
 
51
- match 'webhooks/stripe', :to => 'webhooks#stripe', :via => [:post, :put]
61
+ match 'webhooks/stripe', to: 'webhooks#stripe', via: [:post, :put]
52
62
  end
53
63
 
54
- if defined?(EffectiveDatatables) && !EffectiveOrders.use_active_admin?
64
+ if !EffectiveOrders.use_active_admin? || Rails.env.test?
55
65
  namespace :admin do
56
- resources :customers, :only => [:index]
57
- resources :orders, :only => [:index, :show]
58
- resources :order_items, :only => [:index]
66
+ resources :customers, only: [:index]
67
+ resources :orders, only: [:index, :show, :new, :create] do
68
+ member do
69
+ post :send_payment_request
70
+ post :mark_as_paid
71
+ end
72
+ end
73
+ resources :order_items, only: [:index]
59
74
  end
60
75
  end
61
76
  end