effective_orders 3.2.3 → 4.0.0beta1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/MIT-LICENSE +1 -1
- data/README.md +11 -99
- data/app/assets/stylesheets/effective_orders.scss +1 -0
- data/app/assets/stylesheets/effective_orders/_cart.scss +4 -0
- data/app/assets/stylesheets/effective_orders/_order.scss +6 -2
- data/app/controllers/admin/orders_controller.rb +17 -17
- data/app/controllers/effective/carts_controller.rb +4 -2
- data/app/controllers/effective/orders_controller.rb +50 -105
- data/app/controllers/effective/providers/cheque.rb +1 -1
- data/app/controllers/effective/providers/moneris.rb +17 -23
- data/app/controllers/effective/providers/stripe.rb +2 -37
- data/app/datatables/effective_customers_datatable.rb +1 -5
- data/app/datatables/effective_order_items_datatable.rb +10 -10
- data/app/datatables/effective_orders_datatable.rb +23 -46
- data/app/helpers/effective_carts_helper.rb +5 -25
- data/app/helpers/effective_orders_helper.rb +29 -61
- data/app/helpers/effective_paypal_helper.rb +10 -8
- data/app/helpers/effective_stripe_helper.rb +2 -33
- data/app/models/concerns/acts_as_purchasable.rb +26 -37
- data/app/models/concerns/acts_as_subscribable.rb +1 -1
- data/app/models/effective/cart.rb +4 -5
- data/app/models/effective/customer.rb +1 -4
- data/app/models/effective/order.rb +132 -163
- data/app/models/effective/order_item.rb +2 -21
- data/app/models/{effective → validators/effective}/sold_out_validator.rb +0 -0
- data/app/views/admin/customers/index.html.haml +1 -4
- data/app/views/admin/order_items/index.html.haml +1 -4
- data/app/views/admin/orders/_actions.html.haml +18 -9
- data/app/views/admin/orders/_form.html.haml +12 -14
- data/app/views/admin/orders/_form_note_internal.html.haml +2 -2
- data/app/views/admin/orders/_order_actions.html.haml +8 -5
- data/app/views/admin/orders/_order_item_fields.html.haml +9 -8
- data/app/views/admin/orders/checkout.html.haml +3 -0
- data/app/views/admin/orders/edit.html.haml +3 -1
- data/app/views/admin/orders/new.html.haml +2 -1
- data/app/views/admin/orders/show.html.haml +2 -5
- data/app/views/effective/carts/_cart.html.haml +1 -1
- data/app/views/effective/carts/_cart_actions.html.haml +3 -4
- data/app/views/effective/carts/show.html.haml +4 -4
- data/app/views/effective/orders/_checkout_actions.html.haml +3 -0
- data/app/views/effective/orders/_checkout_step1.html.haml +20 -27
- data/app/views/effective/orders/_checkout_step2.html.haml +26 -30
- data/app/views/effective/orders/_order.html.haml +1 -2
- data/app/views/effective/orders/_order_actions.html.haml +14 -6
- data/app/views/effective/orders/_order_header.html.haml +2 -2
- data/app/views/effective/orders/_order_note_fields.html.haml +6 -4
- data/app/views/effective/orders/_order_notes.html.haml +15 -0
- data/app/views/effective/orders/_order_payment_details.html.haml +1 -1
- data/app/views/effective/orders/_order_shipping.html.haml +6 -6
- data/app/views/effective/orders/_order_terms_and_conditions_fields.html.haml +5 -6
- data/app/views/effective/orders/_order_user_fields.html.haml +5 -11
- data/app/views/effective/orders/_orders_table.html.haml +2 -6
- data/app/views/effective/orders/index.html.haml +2 -1
- data/app/views/effective/orders/mark_as_paid/_form.html.haml +8 -14
- data/app/views/effective/orders/moneris/_form.html.haml +43 -4
- data/app/views/effective/orders/pretend/_form.html.haml +1 -3
- data/app/views/effective/orders/refund/_form.html.haml +8 -12
- data/app/views/effective/orders/show.html.haml +2 -2
- data/app/views/effective/orders/stripe/_form.html.haml +4 -4
- data/app/views/effective/orders_mailer/payment_request_to_buyer.html.haml +1 -1
- data/app/views/effective/orders_mailer/pending_order_invoice_to_buyer.html.haml +1 -1
- data/config/effective_orders.rb +116 -182
- data/config/routes.rb +16 -27
- data/db/migrate/01_create_effective_orders.rb.erb +6 -5
- data/lib/effective_orders.rb +72 -76
- data/lib/effective_orders/engine.rb +8 -80
- data/lib/effective_orders/version.rb +1 -1
- data/lib/generators/templates/effective_orders_mailer_preview.rb +4 -4
- metadata +26 -38
- data/Rakefile +0 -21
- data/app/assets/config/effective_orders_manifest.js +0 -3
- data/app/assets/images/effective_orders/stripe_connect.png +0 -0
- data/app/controllers/effective/providers/app_checkout.rb +0 -38
- data/app/controllers/effective/providers/ccbill.rb +0 -34
- data/app/controllers/effective/providers/stripe_connect.rb +0 -47
- data/app/helpers/effective_ccbill_helper.rb +0 -25
- data/app/models/effective/providers/ccbill_postback.rb +0 -85
- data/app/models/effective/providers/moneris_charge.rb +0 -115
- data/app/views/effective/orders/_order_note.html.haml +0 -5
- data/app/views/effective/orders/_order_note_to_buyer.html.haml +0 -9
- data/app/views/effective/orders/app_checkout/_form.html.haml +0 -2
- data/app/views/effective/orders/ccbill/_form.html.haml +0 -24
- data/app/views/effective/orders/my_purchases.html.haml +0 -3
- data/app/views/effective/orders/my_sales.html.haml +0 -25
- data/app/views/effective/orders_mailer/order_receipt_to_seller.html.haml +0 -25
- 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,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,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
|
-
|