effective_orders 3.2.3 → 4.0.0beta1

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 (87) hide show
  1. checksums.yaml +5 -5
  2. data/MIT-LICENSE +1 -1
  3. data/README.md +11 -99
  4. data/app/assets/stylesheets/effective_orders.scss +1 -0
  5. data/app/assets/stylesheets/effective_orders/_cart.scss +4 -0
  6. data/app/assets/stylesheets/effective_orders/_order.scss +6 -2
  7. data/app/controllers/admin/orders_controller.rb +17 -17
  8. data/app/controllers/effective/carts_controller.rb +4 -2
  9. data/app/controllers/effective/orders_controller.rb +50 -105
  10. data/app/controllers/effective/providers/cheque.rb +1 -1
  11. data/app/controllers/effective/providers/moneris.rb +17 -23
  12. data/app/controllers/effective/providers/stripe.rb +2 -37
  13. data/app/datatables/effective_customers_datatable.rb +1 -5
  14. data/app/datatables/effective_order_items_datatable.rb +10 -10
  15. data/app/datatables/effective_orders_datatable.rb +23 -46
  16. data/app/helpers/effective_carts_helper.rb +5 -25
  17. data/app/helpers/effective_orders_helper.rb +29 -61
  18. data/app/helpers/effective_paypal_helper.rb +10 -8
  19. data/app/helpers/effective_stripe_helper.rb +2 -33
  20. data/app/models/concerns/acts_as_purchasable.rb +26 -37
  21. data/app/models/concerns/acts_as_subscribable.rb +1 -1
  22. data/app/models/effective/cart.rb +4 -5
  23. data/app/models/effective/customer.rb +1 -4
  24. data/app/models/effective/order.rb +132 -163
  25. data/app/models/effective/order_item.rb +2 -21
  26. data/app/models/{effective → validators/effective}/sold_out_validator.rb +0 -0
  27. data/app/views/admin/customers/index.html.haml +1 -4
  28. data/app/views/admin/order_items/index.html.haml +1 -4
  29. data/app/views/admin/orders/_actions.html.haml +18 -9
  30. data/app/views/admin/orders/_form.html.haml +12 -14
  31. data/app/views/admin/orders/_form_note_internal.html.haml +2 -2
  32. data/app/views/admin/orders/_order_actions.html.haml +8 -5
  33. data/app/views/admin/orders/_order_item_fields.html.haml +9 -8
  34. data/app/views/admin/orders/checkout.html.haml +3 -0
  35. data/app/views/admin/orders/edit.html.haml +3 -1
  36. data/app/views/admin/orders/new.html.haml +2 -1
  37. data/app/views/admin/orders/show.html.haml +2 -5
  38. data/app/views/effective/carts/_cart.html.haml +1 -1
  39. data/app/views/effective/carts/_cart_actions.html.haml +3 -4
  40. data/app/views/effective/carts/show.html.haml +4 -4
  41. data/app/views/effective/orders/_checkout_actions.html.haml +3 -0
  42. data/app/views/effective/orders/_checkout_step1.html.haml +20 -27
  43. data/app/views/effective/orders/_checkout_step2.html.haml +26 -30
  44. data/app/views/effective/orders/_order.html.haml +1 -2
  45. data/app/views/effective/orders/_order_actions.html.haml +14 -6
  46. data/app/views/effective/orders/_order_header.html.haml +2 -2
  47. data/app/views/effective/orders/_order_note_fields.html.haml +6 -4
  48. data/app/views/effective/orders/_order_notes.html.haml +15 -0
  49. data/app/views/effective/orders/_order_payment_details.html.haml +1 -1
  50. data/app/views/effective/orders/_order_shipping.html.haml +6 -6
  51. data/app/views/effective/orders/_order_terms_and_conditions_fields.html.haml +5 -6
  52. data/app/views/effective/orders/_order_user_fields.html.haml +5 -11
  53. data/app/views/effective/orders/_orders_table.html.haml +2 -6
  54. data/app/views/effective/orders/index.html.haml +2 -1
  55. data/app/views/effective/orders/mark_as_paid/_form.html.haml +8 -14
  56. data/app/views/effective/orders/moneris/_form.html.haml +43 -4
  57. data/app/views/effective/orders/pretend/_form.html.haml +1 -3
  58. data/app/views/effective/orders/refund/_form.html.haml +8 -12
  59. data/app/views/effective/orders/show.html.haml +2 -2
  60. data/app/views/effective/orders/stripe/_form.html.haml +4 -4
  61. data/app/views/effective/orders_mailer/payment_request_to_buyer.html.haml +1 -1
  62. data/app/views/effective/orders_mailer/pending_order_invoice_to_buyer.html.haml +1 -1
  63. data/config/effective_orders.rb +116 -182
  64. data/config/routes.rb +16 -27
  65. data/db/migrate/01_create_effective_orders.rb.erb +6 -5
  66. data/lib/effective_orders.rb +72 -76
  67. data/lib/effective_orders/engine.rb +8 -80
  68. data/lib/effective_orders/version.rb +1 -1
  69. data/lib/generators/templates/effective_orders_mailer_preview.rb +4 -4
  70. metadata +26 -38
  71. data/Rakefile +0 -21
  72. data/app/assets/config/effective_orders_manifest.js +0 -3
  73. data/app/assets/images/effective_orders/stripe_connect.png +0 -0
  74. data/app/controllers/effective/providers/app_checkout.rb +0 -38
  75. data/app/controllers/effective/providers/ccbill.rb +0 -34
  76. data/app/controllers/effective/providers/stripe_connect.rb +0 -47
  77. data/app/helpers/effective_ccbill_helper.rb +0 -25
  78. data/app/models/effective/providers/ccbill_postback.rb +0 -85
  79. data/app/models/effective/providers/moneris_charge.rb +0 -115
  80. data/app/views/effective/orders/_order_note.html.haml +0 -5
  81. data/app/views/effective/orders/_order_note_to_buyer.html.haml +0 -9
  82. data/app/views/effective/orders/app_checkout/_form.html.haml +0 -2
  83. data/app/views/effective/orders/ccbill/_form.html.haml +0 -24
  84. data/app/views/effective/orders/my_purchases.html.haml +0 -3
  85. data/app/views/effective/orders/my_sales.html.haml +0 -25
  86. data/app/views/effective/orders_mailer/order_receipt_to_seller.html.haml +0 -25
  87. data/lib/effective_orders/app_checkout_service.rb +0 -26
@@ -1,115 +0,0 @@
1
- require 'nokogiri'
2
-
3
- module Effective
4
- module Providers
5
- class MonerisCharge
6
- attr_accessor :order, :purchased_url, :declined_url
7
- attr_accessor :hpp_id, :ticket # return values
8
-
9
- def initialize(order:, purchased_url: nil, declined_url: nil)
10
- @order = order
11
- @purchased_url = purchased_url
12
- @declined_url = declined_url
13
-
14
- moneris_preload!
15
- end
16
-
17
- def present?
18
- ticket.present? && hpp_id.present?
19
- end
20
-
21
- def moneris_preload!
22
- # Make the moneris preload request
23
- uri = URI.parse(EffectiveOrders.moneris[:hpp_url])
24
- params = moneris_preload_payload.to_query
25
- headers = {}
26
-
27
- http = Net::HTTP.new(uri.host, uri.port)
28
- http.use_ssl = true
29
-
30
- body = http.post(uri.path, params, headers).body
31
- doc = ::Nokogiri::XML(body)
32
-
33
- # Parse preload request
34
- moneris = [:hpp_id, :ticket, :order_id, :response_code].inject({}) do |h, key|
35
- h[key] = doc.xpath("//#{key}").children.first.to_s; h
36
- end
37
-
38
- # Transaction Response Code: < 50: data successfully loaded, >= 50: data not loaded
39
- moneris[:response_code] = (moneris[:response_code].to_i rescue 50)
40
-
41
- raise 'data not loaded' unless moneris[:response_code] < 50
42
-
43
- # Our return value
44
- @hpp_id = moneris[:hpp_id]
45
- @ticket = moneris[:ticket]
46
- end
47
-
48
- def moneris_preload_payload
49
- payload = {
50
- ps_store_id: EffectiveOrders.moneris[:ps_store_id],
51
- hpp_key: EffectiveOrders.moneris[:hpp_key],
52
- hpp_preload: '',
53
- charge_total: ('%.2f' % (order.total / 100.0)),
54
-
55
- # Optional
56
- order_id: order_id,
57
- lang: 'en-ca',
58
- email: order.user.email,
59
-
60
- rvar_purchased_url: purchased_url,
61
- rvar_declined_url: declined_url
62
- }.compact
63
-
64
- if order.tax.present?
65
- payload[:gst] = ('%.2f' % (order.tax / 100.0))
66
- end
67
-
68
- if order.billing_name.present?
69
- payload[:bill_first_name] = order.billing_name.split(' ')[0]
70
- payload[:bill_last_name] = order.billing_name.split(' ')[1..-1].join(' ')
71
- end
72
-
73
- if order.billing_address.present?
74
- address = order.billing_address
75
- payload[:bill_address_one] = address.address1
76
- payload[:bill_city] = address.city
77
- payload[:bill_state_or_province] = address.state
78
- payload[:bill_postal_code] = address.postal_code
79
- payload[:bill_country] = address.country
80
- end
81
-
82
- if order.shipping_address.present?
83
- address = order.shipping_address
84
- payload[:ship_address_one] = address.address1
85
- payload[:ship_city] = address.city
86
- payload[:ship_state_or_province] = address.state
87
- payload[:ship_postal_code] = address.postal_code
88
- payload[:ship_country] = address.country
89
- end
90
-
91
- order.order_items.each_with_index do |item, index|
92
- payload["id#{index}"] = index
93
- payload["description#{index}"] = item.title
94
- payload["quantity#{index}"] = item.quantity
95
- payload["price#{index}"] = ('%.2f' % (item.price / 100.0))
96
- payload["subtotal#{index}"] = ('%.2f' % (item.subtotal / 100.0))
97
- end
98
-
99
- payload
100
- end
101
-
102
- private
103
-
104
- def order_id
105
- [
106
- order.to_param,
107
- (order.billing_name.to_s.parameterize.presence if EffectiveOrders.moneris[:include_billing_name_in_order_id]),
108
- Time.zone.now.to_i
109
- ].compact.join('-')
110
- end
111
-
112
- end
113
-
114
- end
115
- end
@@ -1,5 +0,0 @@
1
- - if order.note.present?
2
- %p
3
- %strong Note
4
- %br
5
- = order.note
@@ -1,9 +0,0 @@
1
- - if order.note_to_buyer.present?
2
- .effective-order-note-to-buyer
3
- %table.table
4
- %thead
5
- %tr
6
- %th Receipt note
7
- %tbody
8
- %tr
9
- %td= order.note_to_buyer
@@ -1,2 +0,0 @@
1
- = form_tag(effective_orders.app_checkout_order_path(order), method: :post) do
2
- = submit_tag order_checkout_label(:app_checkout), class: 'btn btn-primary', data: { disable_with: 'Continuing...' }
@@ -1,24 +0,0 @@
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
-
@@ -1,3 +0,0 @@
1
- %h1.effective-heading= @page_title
2
-
3
- = render_order_history(@orders)
@@ -1,25 +0,0 @@
1
- %h1.effective-heading= @page_title
2
-
3
- %table.table
4
- %thead
5
- %tr
6
- %th Product
7
- %th Order
8
- %th Buyer
9
- %th Date of Sale
10
- %th Description
11
- %tbody
12
- - (@order_items || {}).group_by(&:purchasable).each do |purchasable, order_items|
13
- - order_items.each_with_index do |order_item, x|
14
- %tr
15
- - if x == 0
16
- %td{:rowspan => order_items.size}
17
- = link_to purchasable.title, acts_as_purchasable_path(purchasable)
18
-
19
- %td= "##{order_item.order.to_param}"
20
- %td= order_item.order.try(:user).try(:to_s)
21
- %td= order_item.order.purchased_at.strftime("%Y-%m-%d %H:%M")
22
- %td= order_item_summary(order_item)
23
-
24
- - unless @order_items.present?
25
- %p You have no sales
@@ -1,25 +0,0 @@
1
- %p.effective-orders-receipt-info= @subject
2
-
3
- %table.table
4
- %thead
5
- %tr
6
- %th Item
7
- %th Price
8
- %tbody
9
- - @order_items.each do |item|
10
- %tr
11
- %td
12
- - if item.quantity > 1
13
- = "#{item.quantity}x "
14
- = item.title
15
- %td= price_to_currency(item.subtotal)
16
- %tfoot
17
- %tr
18
- %th Subtotal
19
- %td= price_to_currency(@order_items.map { |oi| oi.subtotal }.sum)
20
- %tr
21
- %th Tax
22
- %td= price_to_currency(@order_items.map { |oi| oi.tax }.sum)
23
- %tr
24
- %th Total
25
- %td= price_to_currency(@order_items.map { |oi| oi.total }.sum)
@@ -1,26 +0,0 @@
1
- module EffectiveOrders
2
- class AppCheckoutService
3
- def self.call(order:)
4
- new(order).tap(&:call)
5
- end
6
-
7
- attr_reader :order
8
-
9
- def initialize(order)
10
- @order = order
11
- end
12
-
13
- def call
14
- raise NotImplementedError, "overwrite the `call` instance method in #{self.class}"
15
- end
16
-
17
- def success?
18
- raise NotImplementedError, "overwrite the `success?` instance method in #{self.class}"
19
- end
20
-
21
- # A Hash or easily serializable object like a String
22
- def payment_details
23
- end
24
- end
25
- end
26
-