caboose-cms 0.5.162 → 0.5.163
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/app/assets/javascripts/caboose/admin_edit_order.js +138 -52
- data/app/assets/javascripts/caboose/checkout_login_register.js +19 -11
- data/app/assets/javascripts/caboose/main.js +17 -0
- data/app/assets/javascripts/caboose/my_account_edit_order.js +490 -0
- data/app/assets/stylesheets/caboose/my_account_edit_order.css.scss +119 -0
- data/app/controllers/caboose/billing_addresses_controller.rb +55 -0
- data/app/controllers/caboose/line_items_controller.rb +10 -2
- data/app/controllers/caboose/my_account_orders_controller.rb +112 -32
- data/app/controllers/caboose/orders_controller.rb +9 -192
- data/app/controllers/caboose/register_controller.rb +9 -8
- data/app/controllers/caboose/shipping_addresses_controller.rb +49 -0
- data/app/models/caboose/authenticator.rb +2 -2
- data/app/models/caboose/order.rb +148 -27
- data/app/views/caboose/line_items/admin_new.html.erb +15 -2
- data/app/views/caboose/my_account_orders/authnet_relay.html.erb +16 -0
- data/app/views/caboose/my_account_orders/authnet_response.html.erb +12 -0
- data/app/views/caboose/my_account_orders/edit.html.erb +53 -111
- data/app/views/caboose/my_account_orders/payment_form.html.erb +138 -0
- data/app/views/caboose/orders/admin_edit.html.erb +3 -0
- data/config/routes.rb +18 -7
- data/lib/caboose/engine.rb +1 -0
- data/lib/caboose/version.rb +1 -1
- metadata +7 -2
@@ -0,0 +1,119 @@
|
|
1
|
+
|
2
|
+
table.order {
|
3
|
+
border-collapse: collapse;
|
4
|
+
margin-bottom: 20px;
|
5
|
+
th { margin: 0; padding: 10px; border: #000 0px solid; font-weight: bold; text-align: center; }
|
6
|
+
td {
|
7
|
+
margin: 0;
|
8
|
+
padding: 10px;
|
9
|
+
border: #000 1px solid;
|
10
|
+
vertical-align: top;
|
11
|
+
img { float: left; margin-right: 10px; }
|
12
|
+
.package_header { font-weight: bold; text-align: center; border: 0; }
|
13
|
+
.totals_header { font-weight: bold; text-align: center; border: 0; }
|
14
|
+
.line_item_unit_price { text-align: right; }
|
15
|
+
.line_item_quantity { text-align: right; }
|
16
|
+
.line_item_subtotal { text-align: right; }
|
17
|
+
}
|
18
|
+
tr.totals_row td { text-align: right; }
|
19
|
+
}
|
20
|
+
|
21
|
+
table.shipping_address td,
|
22
|
+
table.billing_address td {
|
23
|
+
padding: 0 !important;
|
24
|
+
margin: 0 !important;
|
25
|
+
border: 0 !important;
|
26
|
+
}
|
27
|
+
|
28
|
+
p { margin-bottom: 10px; }
|
29
|
+
|
30
|
+
#payment_form {
|
31
|
+
margin: 0 0 20px 0;
|
32
|
+
padding: 0;
|
33
|
+
background: #EFEFEF;
|
34
|
+
-webkit-border-radius: 5px;
|
35
|
+
-moz-border-radius: 5px;
|
36
|
+
-ms-border-radius: 5px;
|
37
|
+
-o-border-radius: 5px;
|
38
|
+
border-radius: 5px;
|
39
|
+
border: 1px solid #d8d8d8;
|
40
|
+
|
41
|
+
h2 { margin: 0; padding: 20px; }
|
42
|
+
|
43
|
+
.field {
|
44
|
+
border-bottom: 1px solid #d8d8d8;
|
45
|
+
width: 100%;
|
46
|
+
padding: 10px 2%;
|
47
|
+
&::after {
|
48
|
+
content: ".";
|
49
|
+
visibility: hidden;
|
50
|
+
display: block;
|
51
|
+
height: 0;
|
52
|
+
clear: both;
|
53
|
+
}
|
54
|
+
&:last-of-type { border-bottom: 0; }
|
55
|
+
.field-text {
|
56
|
+
float: left;
|
57
|
+
font-size: 14px;
|
58
|
+
color: #000;
|
59
|
+
line-height: 31px;
|
60
|
+
}
|
61
|
+
&#credit-card {
|
62
|
+
background: #fff;
|
63
|
+
-webkit-border-top-left-radius: 5px;
|
64
|
+
-webkit-border-top-right-radius: 5px;
|
65
|
+
-moz-border-radius-topleft: 5px;
|
66
|
+
-moz-border-radius-topright: 5px;
|
67
|
+
border-top-left-radius: 5px;
|
68
|
+
border-top-right-radius: 5px;
|
69
|
+
.icons {
|
70
|
+
float: right;
|
71
|
+
width: 120px;
|
72
|
+
position: relative;
|
73
|
+
top: 5px;
|
74
|
+
}
|
75
|
+
}
|
76
|
+
&#card-number {
|
77
|
+
.field-text {
|
78
|
+
width: 20%;
|
79
|
+
}
|
80
|
+
input[type="text"] {
|
81
|
+
background: transparent;
|
82
|
+
font-size: 15px;
|
83
|
+
border-width: 0;
|
84
|
+
outline-width: 0;
|
85
|
+
height: auto;
|
86
|
+
}
|
87
|
+
.icons {
|
88
|
+
width: 20px;
|
89
|
+
float: right;
|
90
|
+
position: relative;
|
91
|
+
top: 7px;
|
92
|
+
}
|
93
|
+
}
|
94
|
+
&#expiry {
|
95
|
+
padding: 15px 2% 5px 2%;
|
96
|
+
.field-text {
|
97
|
+
width: 20%;
|
98
|
+
position: relative;
|
99
|
+
bottom: 3px;
|
100
|
+
}
|
101
|
+
select {
|
102
|
+
&#month {
|
103
|
+
width: 20%;
|
104
|
+
min-width: 100px;
|
105
|
+
}
|
106
|
+
&#year {
|
107
|
+
width: 20%;
|
108
|
+
min-width: 100px;
|
109
|
+
}
|
110
|
+
}
|
111
|
+
}
|
112
|
+
}
|
113
|
+
iframe { display: none }
|
114
|
+
|
115
|
+
#payment_confirm {
|
116
|
+
margin: 20px;
|
117
|
+
|
118
|
+
}
|
119
|
+
}
|
@@ -45,6 +45,61 @@ module Caboose
|
|
45
45
|
resp.success = save && sa.save
|
46
46
|
render :json => resp
|
47
47
|
end
|
48
|
+
|
49
|
+
#===========================================================================
|
50
|
+
|
51
|
+
# GET /my-account/orders/:order_id/billing-address/json
|
52
|
+
def my_account_json
|
53
|
+
return if !logged_in?
|
54
|
+
order = Order.find(params[:order_id])
|
55
|
+
if order.customer_id != logged_in_user.id
|
56
|
+
render :json => { :error => "The given order does not belong to you." }
|
57
|
+
return
|
58
|
+
end
|
59
|
+
render :json => order.billing_address
|
60
|
+
end
|
61
|
+
|
62
|
+
# PUT /my-account/orders/:order_id/billing-address
|
63
|
+
def my_account_update
|
64
|
+
return if !logged_in?
|
65
|
+
|
66
|
+
resp = Caboose::StdClass.new
|
67
|
+
order = Order.find(params[:order_id])
|
68
|
+
if order.customer_id != logged_in_user.id
|
69
|
+
render :json => { :error => "The given order does not belong to you." }
|
70
|
+
return
|
71
|
+
end
|
72
|
+
|
73
|
+
sa = order.billing_address
|
74
|
+
if sa.nil?
|
75
|
+
sa = Address.create
|
76
|
+
order.billing_address_id = sa.id
|
77
|
+
order.save
|
78
|
+
end
|
79
|
+
|
80
|
+
save = true
|
81
|
+
params.each do |name, value|
|
82
|
+
case name
|
83
|
+
when 'name' then sa.name = value
|
84
|
+
when 'first_name' then sa.first_name = value
|
85
|
+
when 'last_name' then sa.last_name = value
|
86
|
+
when 'street' then sa.street = value
|
87
|
+
when 'address1' then sa.address1 = value
|
88
|
+
when 'address2' then sa.address2 = value
|
89
|
+
when 'company' then sa.company = value
|
90
|
+
when 'city' then sa.city = value
|
91
|
+
when 'state' then sa.state = value
|
92
|
+
when 'province' then sa.province = value
|
93
|
+
when 'province_code' then sa.province_code = value
|
94
|
+
when 'zip' then sa.zip = value
|
95
|
+
when 'country' then sa.country = value
|
96
|
+
when 'country_code' then sa.country_code = value
|
97
|
+
when 'phone' then sa.phone = value
|
98
|
+
end
|
99
|
+
end
|
100
|
+
resp.success = save && sa.save
|
101
|
+
render :json => resp
|
102
|
+
end
|
48
103
|
|
49
104
|
end
|
50
105
|
end
|
@@ -127,11 +127,19 @@ module Caboose
|
|
127
127
|
vars << "%#{str}%"
|
128
128
|
end
|
129
129
|
where = where.join(' and ')
|
130
|
-
query = ["select id, title from store_products where #{where} order by title limit 20"]
|
130
|
+
query = ["select id, title, option1, option2, option3 from store_products where #{where} order by title limit 20"]
|
131
131
|
vars.each{ |v| query << v }
|
132
132
|
|
133
133
|
rows = ActiveRecord::Base.connection.select_rows(ActiveRecord::Base.send(:sanitize_sql_array, query))
|
134
|
-
arr = rows.collect
|
134
|
+
arr = rows.collect do |row|
|
135
|
+
has_options = row[2] || row[3] || row[4] ? true : false
|
136
|
+
variant_id = nil
|
137
|
+
if !has_options
|
138
|
+
v = Variant.where(:product_id => row[0].to_i, :status => 'Active').first
|
139
|
+
variant_id = v.id if v
|
140
|
+
end
|
141
|
+
{ :id => row[0], :title => row[1], :variant_id => variant_id }
|
142
|
+
end
|
135
143
|
render :json => arr
|
136
144
|
end
|
137
145
|
|
@@ -1,6 +1,8 @@
|
|
1
1
|
module Caboose
|
2
2
|
class MyAccountOrdersController < Caboose::ApplicationController
|
3
3
|
|
4
|
+
helper :authorize_net
|
5
|
+
|
4
6
|
# GET /my-account/orders
|
5
7
|
def index
|
6
8
|
return if !logged_in?
|
@@ -27,43 +29,121 @@ module Caboose
|
|
27
29
|
@error = "The given order does not belong to you."
|
28
30
|
render :file => 'caboose/extras/error'
|
29
31
|
return
|
30
|
-
end
|
32
|
+
end
|
33
|
+
|
34
|
+
if @order.financial_status == Order::FINANCIAL_STATUS_PENDING
|
35
|
+
|
36
|
+
sc = @site.store_config
|
37
|
+
case sc.pp_name
|
38
|
+
when 'authorize.net'
|
39
|
+
|
40
|
+
@sim_transaction = AuthorizeNet::SIM::Transaction.new(
|
41
|
+
sc.pp_username,
|
42
|
+
sc.pp_password,
|
43
|
+
@order.total,
|
44
|
+
:relay_response => 'TRUE',
|
45
|
+
:relay_url => "#{sc.pp_relay_domain}/my-account/orders/authnet-relay",
|
46
|
+
:transaction_type => 'AUTH_ONLY',
|
47
|
+
:test => sc.pp_testing
|
48
|
+
)
|
49
|
+
@request = request
|
50
|
+
@show_relay = params[:show_relay] && params[:show_relay].to_i == 1
|
51
|
+
|
52
|
+
when 'stripe'
|
53
|
+
# TODO: Implement manual order payment for stripe
|
54
|
+
|
55
|
+
end
|
56
|
+
end
|
57
|
+
|
31
58
|
end
|
32
|
-
|
33
|
-
|
59
|
+
|
60
|
+
# GET /my-account/orders/:id/json
|
61
|
+
def order_json
|
34
62
|
return if !logged_in?
|
35
|
-
|
36
|
-
|
63
|
+
|
64
|
+
order = Order.find(params[:id])
|
65
|
+
if order.customer_id != logged_in_user.id
|
66
|
+
render :json => { :error => "The given order does not belong to you." }
|
67
|
+
return
|
68
|
+
end
|
69
|
+
|
70
|
+
if order.shipping_address_id.nil?
|
71
|
+
sa = Address.create
|
72
|
+
order.shipping_address_id = sa.id
|
73
|
+
order.save
|
74
|
+
end
|
75
|
+
render :json => order.as_json(:include => [
|
76
|
+
{ :line_items => { :include => { :variant => { :include => :product }}}},
|
77
|
+
{ :order_packages => { :include => [:shipping_package, :shipping_method] }},
|
78
|
+
{ :discounts => { :include => :gift_card }},
|
79
|
+
:customer,
|
80
|
+
:shipping_address,
|
81
|
+
:billing_address,
|
82
|
+
:order_transactions
|
83
|
+
])
|
37
84
|
end
|
38
85
|
|
39
|
-
#
|
40
|
-
def
|
41
|
-
|
86
|
+
# POST /my-account/orders/authnet-relay
|
87
|
+
def authnet_relay
|
88
|
+
Caboose.log("Authorize.net relay for my account, order #{params[:x_invoice_id]}")
|
42
89
|
|
43
|
-
|
44
|
-
|
90
|
+
order = Caboose::Order.find(params[:x_invoice_num])
|
91
|
+
ot = Caboose::OrderTransaction.new(
|
92
|
+
:order_id => order.id,
|
93
|
+
:date_processed => DateTime.now.utc,
|
94
|
+
:transaction_type => Caboose::OrderTransaction::TYPE_AUTHORIZE
|
95
|
+
)
|
96
|
+
ot.success = params[:x_response_code] && params[:x_response_code] == '1'
|
97
|
+
ot.transaction_id = params[:x_trans_id] if params[:x_trans_id]
|
98
|
+
ot.auth_code = params[:x_auth_code] if params[:x_auth_code]
|
99
|
+
ot.response_code = params[:x_response_code] if params[:x_response_code]
|
100
|
+
ot.amount = order.total
|
101
|
+
ot.save
|
102
|
+
|
103
|
+
error = nil
|
104
|
+
if ot.success
|
105
|
+
order.financial_status = Order::FINANCIAL_STATUS_AUTHORIZED
|
106
|
+
order.status = Order::STATUS_PENDING if order.status == Order::STATUS_CART
|
107
|
+
order.order_number = @site.store_config.next_order_number if order.order_number.nil?
|
108
|
+
|
109
|
+
# Send out emails
|
110
|
+
OrdersMailer.configure_for_site(@site.id).customer_new_order(order).deliver
|
111
|
+
|
112
|
+
# Emit order event
|
113
|
+
Caboose.plugin_hook('order_authorized', order)
|
114
|
+
else
|
115
|
+
order.financial_status = Order::FINANCIAL_STATUS_PENDING
|
116
|
+
error = "There was a problem processing your payment."
|
117
|
+
end
|
118
|
+
|
119
|
+
order.save
|
120
|
+
|
121
|
+
@url = params[:x_after_relay]
|
122
|
+
@url << (ot.success ? "?success=1" : "?error=#{error}")
|
123
|
+
|
124
|
+
render :layout => false
|
125
|
+
end
|
45
126
|
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
end
|
127
|
+
# GET /my-account/orders/:id/authnet-response
|
128
|
+
# POST /my-account/orders/:id/authnet-response
|
129
|
+
def authnet_response
|
130
|
+
Caboose.log("Authorize.net response for my account, order #{params[:id]}")
|
131
|
+
|
132
|
+
@resp = Caboose::StdClass.new
|
133
|
+
@resp.success = true if params[:success]
|
134
|
+
@resp.error = params[:error] if params[:error]
|
135
|
+
|
136
|
+
# Go ahead and capture funds if the order only contained downloadable items
|
137
|
+
@order = Order.find(params[:id])
|
138
|
+
if !@order.has_shippable_items?
|
139
|
+
capture_resp = @order.capture_funds
|
140
|
+
if capture_resp.error
|
141
|
+
@resp.success = false
|
142
|
+
@resp.error = capture_resp.error
|
143
|
+
end
|
144
|
+
end
|
145
|
+
render :layout => false
|
146
|
+
end
|
147
|
+
|
68
148
|
end
|
69
149
|
end
|
@@ -45,7 +45,8 @@ module Caboose
|
|
45
45
|
order = Order.create(
|
46
46
|
:site_id => @site.id,
|
47
47
|
:status => Order::STATUS_PENDING,
|
48
|
-
:financial_status => Order::FINANCIAL_STATUS_PENDING
|
48
|
+
:financial_status => Order::FINANCIAL_STATUS_PENDING,
|
49
|
+
:order_number => @site.store_config.next_order_number
|
49
50
|
)
|
50
51
|
render :json => { :sucess => true, :redirect => "/admin/orders/#{order.id}" }
|
51
52
|
end
|
@@ -61,103 +62,19 @@ module Caboose
|
|
61
62
|
# GET /admin/orders/:id/capture
|
62
63
|
def capture_funds
|
63
64
|
return if !user_is_allowed('orders', 'edit')
|
64
|
-
|
65
|
-
#resp = Caboose::StdClass.new
|
65
|
+
|
66
66
|
order = Order.find(params[:id])
|
67
67
|
resp = order.capture_funds
|
68
68
|
|
69
|
-
#t = OrderTransaction.where(:order_id => order.id, :transaction_type => OrderTransaction::TYPE_AUTHORIZE, :success => true).first
|
70
|
-
#
|
71
|
-
#if order.financial_status == Order::FINANCIAL_STATUS_CAPTURED
|
72
|
-
# resp.error = "Funds for this order have already been captured."
|
73
|
-
#elsif order.total > t.amount
|
74
|
-
# resp.error = "The order total exceeds the authorized amount."
|
75
|
-
#elsif t.nil?
|
76
|
-
# resp.error = "This order doesn't seem to be authorized."
|
77
|
-
#else
|
78
|
-
#
|
79
|
-
# sc = @site.store_config
|
80
|
-
# case sc.pp_name
|
81
|
-
# when 'authorize.net'
|
82
|
-
# transaction = AuthorizeNet::AIM::Transaction.new(sc.pp_username, sc.pp_password)
|
83
|
-
# response = transaction.prior_auth_capture(t.transaction_id, order.total)
|
84
|
-
#
|
85
|
-
# order.update_attribute(:financial_status, Order::FINANCIAL_STATUS_CAPTURED)
|
86
|
-
# resp.success = 'Captured funds successfully'
|
87
|
-
#
|
88
|
-
# ot = Caboose::OrderTransaction.new(
|
89
|
-
# :order_id => order.id,
|
90
|
-
# :date_processed => DateTime.now.utc,
|
91
|
-
# :transaction_type => Caboose::OrderTransaction::TYPE_CAPTURE
|
92
|
-
# )
|
93
|
-
# ot.success = response.response_code && response.response_code == '1'
|
94
|
-
# ot.transaction_id = response.transaction_id
|
95
|
-
# ot.auth_code = response.authorization_code
|
96
|
-
# ot.response_code = response.response_code
|
97
|
-
# ot.amount = order.total
|
98
|
-
# ot.save
|
99
|
-
#
|
100
|
-
# when 'payscape'
|
101
|
-
# # TODO: Implement capture funds for payscape
|
102
|
-
#
|
103
|
-
# end
|
104
|
-
#
|
105
|
-
# #if (order.discounts.any? && order.total < order.discounts.first.amount_current) || PaymentProcessor.capture(order)
|
106
|
-
# # order.financial_status = 'captured'
|
107
|
-
# # order.save
|
108
|
-
# #
|
109
|
-
# # if order.discounts.any?
|
110
|
-
# # order.update_attribute(:amount_discounted, order.discounts.first.amount_current)
|
111
|
-
# # order.update_gift_cards
|
112
|
-
# # end
|
113
|
-
# #
|
114
|
-
# # response.success = "Captured funds successfully"
|
115
|
-
# #else
|
116
|
-
# # response.error = "Error capturing funds."
|
117
|
-
# #end
|
118
|
-
#
|
119
|
-
#end
|
120
|
-
|
121
69
|
render :json => resp
|
122
70
|
end
|
123
71
|
|
124
72
|
# GET /admin/orders/:id/void
|
125
73
|
def admin_void
|
126
74
|
return if !user_is_allowed('orders', 'edit')
|
127
|
-
|
128
|
-
resp = Caboose::StdClass.new
|
75
|
+
|
129
76
|
order = Order.find(params[:id])
|
130
|
-
|
131
|
-
|
132
|
-
if order.financial_status == Order::FINANCIAL_STATUS_CAPTURED
|
133
|
-
resp.error = "This order has already been captured, you will need to refund instead"
|
134
|
-
elsif t.nil?
|
135
|
-
resp.error = "This order doesn't seem to be authorized."
|
136
|
-
else
|
137
|
-
|
138
|
-
sc = @site.store_config
|
139
|
-
case sc.pp_name
|
140
|
-
when 'authorize.net'
|
141
|
-
|
142
|
-
response = AuthorizeNet::SIM::Transaction.new(
|
143
|
-
sc.pp_username,
|
144
|
-
sc.pp_password,
|
145
|
-
order.total,
|
146
|
-
:transaction_type => OrderTransaction::TYPE_VOID,
|
147
|
-
:transaction_id => t.transaction_id
|
148
|
-
)
|
149
|
-
order.update_attributes(
|
150
|
-
:financial_status => Order::FINANCIAL_STATUS_VOIDED,
|
151
|
-
:status => Order::STATUS_CANCELED
|
152
|
-
)
|
153
|
-
order.save
|
154
|
-
# TODO: Add the variant quantities ordered back
|
155
|
-
resp.success = "Order voided successfully"
|
156
|
-
when 'payscape'
|
157
|
-
# TODO: Implement payscape void order
|
158
|
-
end
|
159
|
-
|
160
|
-
end
|
77
|
+
resp = order.void
|
161
78
|
|
162
79
|
render :json => resp
|
163
80
|
end
|
@@ -166,75 +83,10 @@ module Caboose
|
|
166
83
|
def admin_refund
|
167
84
|
return if !user_is_allowed('orders', 'edit')
|
168
85
|
|
169
|
-
response = Caboose::StdClass.new({
|
170
|
-
'refresh' => nil,
|
171
|
-
'error' => nil,
|
172
|
-
'success' => nil
|
173
|
-
})
|
174
|
-
|
175
86
|
order = Order.find(params[:id])
|
176
|
-
|
177
|
-
if order.financial_status != Order::FINANCIAL_STATUS_CAPTURED
|
178
|
-
response.error = "This order hasn't been captured yet, you will need to void instead"
|
179
|
-
else
|
180
|
-
if PaymentProcessor.refund(order)
|
181
|
-
order.update_attributes(
|
182
|
-
:financial_status => Order::FINANCIAL_STATUS_REFUNDED,
|
183
|
-
:status => Order::STATUS_CANCELED
|
184
|
-
)
|
185
|
-
|
186
|
-
response.success = 'Order refunded successfully'
|
187
|
-
else
|
188
|
-
response.error = 'Error refunding order'
|
189
|
-
end
|
190
|
-
|
191
|
-
#if order.calculate_net < (order.amount_discounted || 0) || PaymentProcessor.refund(order)
|
192
|
-
# order.financial_status = 'refunded'
|
193
|
-
# order.status = 'refunded'
|
194
|
-
# order.save
|
195
|
-
#
|
196
|
-
# if order.discounts.any?
|
197
|
-
# discount = order.discounts.first
|
198
|
-
# amount_to_refund = order.calculate_net < order.amount_discounted ? order.calculate_net : order.amount_discounted
|
199
|
-
# discount.update_attribute(:amount_current, amount_to_refund + discount.amount_current)
|
200
|
-
# end
|
201
|
-
#
|
202
|
-
# response.success = "Order refunded successfully"
|
203
|
-
#else
|
204
|
-
# response.error = "Error refunding order."
|
205
|
-
#end
|
206
|
-
end
|
207
|
-
|
208
|
-
render json: response
|
87
|
+
resp = order.refund
|
209
88
|
|
210
|
-
|
211
|
-
#
|
212
|
-
# response = Caboose::StdClass.new({
|
213
|
-
# 'refresh' => nil,
|
214
|
-
# 'error' => nil,
|
215
|
-
# 'success' => nil
|
216
|
-
# })
|
217
|
-
#
|
218
|
-
# order = Order.find(params[:id])
|
219
|
-
#
|
220
|
-
# if order.financial_status != 'captured'
|
221
|
-
# response.error = "This order hasn't been captured yet, you will need to void instead"
|
222
|
-
# else
|
223
|
-
# if PaymentProcessor.refund(order)
|
224
|
-
# order.financial_status = 'refunded'
|
225
|
-
# order.status = 'refunded'
|
226
|
-
# order.save
|
227
|
-
#
|
228
|
-
# # Add the variant quantities ordered back
|
229
|
-
# order.cancel
|
230
|
-
#
|
231
|
-
# response.success = "Order refunded successfully"
|
232
|
-
# else
|
233
|
-
# response.error = "Error refunding order."
|
234
|
-
# end
|
235
|
-
# end
|
236
|
-
#
|
237
|
-
# render :json => response
|
89
|
+
render :json => resp
|
238
90
|
end
|
239
91
|
|
240
92
|
# POST /admin/orders/:id/resend-confirmation
|
@@ -258,6 +110,7 @@ module Caboose
|
|
258
110
|
render :json => order.as_json(:include => [
|
259
111
|
{ :line_items => { :include => { :variant => { :include => :product }}}},
|
260
112
|
{ :order_packages => { :include => [:shipping_package, :shipping_method] }},
|
113
|
+
{ :discounts => { :include => :gift_card }},
|
261
114
|
:customer,
|
262
115
|
:shipping_address,
|
263
116
|
:billing_address,
|
@@ -317,43 +170,7 @@ module Caboose
|
|
317
170
|
})
|
318
171
|
end
|
319
172
|
|
320
|
-
|
321
|
-
# def refund
|
322
|
-
# return if !user_is_allowed('orders', 'edit')
|
323
|
-
#
|
324
|
-
# response = Caboose::StdClass.new({
|
325
|
-
# 'refresh' => nil,
|
326
|
-
# 'error' => nil,
|
327
|
-
# 'success' => nil
|
328
|
-
# })
|
329
|
-
#
|
330
|
-
# order = Order.find(params[:id])
|
331
|
-
#
|
332
|
-
# if order.financial_status != 'captured'
|
333
|
-
# response.error = "This order hasn't been captured yet, you will need to void instead"
|
334
|
-
# else
|
335
|
-
# ap order.total
|
336
|
-
# ap order.amount_discounted
|
337
|
-
#
|
338
|
-
# if order.total < order.amount_discounted || PaymentProcessor.refund(order)
|
339
|
-
# order.financial_status = 'refunded'
|
340
|
-
# order.status = 'refunded'
|
341
|
-
# order.save
|
342
|
-
#
|
343
|
-
# discount = order.discounts.first
|
344
|
-
# ap '==========================='
|
345
|
-
# ap order.amount_discounted + discount.amount_current
|
346
|
-
# ap '==========================='
|
347
|
-
# discount.update_attribute(:amount_current, order.amount_discounted + discount.amount_current) if order.discounts.any?
|
348
|
-
#
|
349
|
-
# response.success = "Order refunded successfully"
|
350
|
-
# else
|
351
|
-
# response.error = "Error refunding order."
|
352
|
-
# end
|
353
|
-
# end
|
354
|
-
#
|
355
|
-
# render json: response
|
356
|
-
# end
|
173
|
+
|
357
174
|
|
358
175
|
# GET /admin/orders/status-options
|
359
176
|
def admin_status_options
|