caboose-cms 0.5.141 → 0.5.142
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/app/controllers/caboose/orders_controller.rb +53 -82
- data/lib/caboose/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
NzExN2FjYzAwODdmYjQ2ZDM5NmM4ODg1YjllYjM5ZDRjYzRhMmM3NQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
ZDc3NDc3YzEyM2VjY2UxNjk0NjdhZTRjNjIyZWI3ZDVlZDlmNWFiZA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
MGRlYWNiZGY0NjVjZjMzZGMxNjIxNWY5MjJkMjBmNTM3NzE2NzFmYTU4NTU5
|
10
|
+
YWQ5ZWQ2NjcwMjA4OGVhZWI3YjYzYzgxMmRkM2YyNjJkMTBkN2FiZDczZGNj
|
11
|
+
NzFmMDQ1ZTAxYjdmNWQxZTMzNzk4YTJlMzVmZjIyZmI5Mjk1ZWI=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
ZjQ3YmI0MmVkZmFjMGRjYTlkMGM0ZjI3MzgyYjcxMjg2ZjMyZTE2MzBmN2Zk
|
14
|
+
YWJjMzBmNzk2OWExMGVhZTRiMDE4NzEyY2IwYjM2N2ViMDQ2OGVjY2I3MDdh
|
15
|
+
YTYwZTQ4MjYyMWMxMTZiZWM2YTE1Nzg2NzA4NmFhMGZhYmRkNTk=
|
@@ -56,6 +56,59 @@ module Caboose
|
|
56
56
|
@order.calculate
|
57
57
|
render :layout => 'caboose/admin'
|
58
58
|
end
|
59
|
+
|
60
|
+
# GET /admin/orders/:id/capture
|
61
|
+
def capture_funds
|
62
|
+
return if !user_is_allowed('orders', 'edit')
|
63
|
+
|
64
|
+
response = Caboose::StdClass.new
|
65
|
+
order = Order.find(params[:id])
|
66
|
+
t = OrderTransaction.where(:order_id => order.id, :transaction_type => OrderTransaction::TYPE_AUTHORIZE, :success => true).first
|
67
|
+
|
68
|
+
if order.financial_status == Order::FINANCIAL_STATUS_CAPTURED
|
69
|
+
resp.error = "Funds for this order have already been captured."
|
70
|
+
elsif order.total > t.amount
|
71
|
+
resp.error = "The order total exceeds the authorized amount."
|
72
|
+
elsif t.nil?
|
73
|
+
resp.error = "This order doesn't seem to be authorized."
|
74
|
+
else
|
75
|
+
|
76
|
+
sc = @site.store_config
|
77
|
+
case sc.pp_name
|
78
|
+
when 'authorize.net'
|
79
|
+
|
80
|
+
response = AuthorizeNet::SIM::Transaction.new(
|
81
|
+
sc.pp_username,
|
82
|
+
sc.pp_password,
|
83
|
+
order.total,
|
84
|
+
:transaction_type => 'CAPTURE_ONLY',
|
85
|
+
:transaction_id => t.transaction_id
|
86
|
+
)
|
87
|
+
order.update_attribute(:financial_status, Order::FINANCIAL_STATUS_CAPTURED)
|
88
|
+
resp.success = 'Captured funds successfully'
|
89
|
+
when 'payscape'
|
90
|
+
# TODO: Implement capture funds for payscape
|
91
|
+
|
92
|
+
end
|
93
|
+
|
94
|
+
#if (order.discounts.any? && order.total < order.discounts.first.amount_current) || PaymentProcessor.capture(order)
|
95
|
+
# order.financial_status = 'captured'
|
96
|
+
# order.save
|
97
|
+
#
|
98
|
+
# if order.discounts.any?
|
99
|
+
# order.update_attribute(:amount_discounted, order.discounts.first.amount_current)
|
100
|
+
# order.update_gift_cards
|
101
|
+
# end
|
102
|
+
#
|
103
|
+
# response.success = "Captured funds successfully"
|
104
|
+
#else
|
105
|
+
# response.error = "Error capturing funds."
|
106
|
+
#end
|
107
|
+
|
108
|
+
end
|
109
|
+
|
110
|
+
render :json => response
|
111
|
+
end
|
59
112
|
|
60
113
|
# GET /admin/orders/:id/void
|
61
114
|
def admin_void
|
@@ -250,89 +303,7 @@ module Caboose
|
|
250
303
|
:redirect => '/admin/orders'
|
251
304
|
})
|
252
305
|
end
|
253
|
-
|
254
|
-
# GET /admin/orders/:id/capture
|
255
|
-
def capture_funds
|
256
|
-
return if !user_is_allowed('orders', 'edit')
|
257
|
-
|
258
|
-
response = Caboose::StdClass.new
|
259
|
-
order = Order.find(params[:id])
|
260
|
-
t = OrderTransaction.where(:order_id => order.id, :transaction_type => OrderTransaction::TYPE_AUTHORIZE, :success => true).first
|
261
|
-
|
262
|
-
if order.financial_status == Order::FINANCIAL_STATUS_CAPTURED
|
263
|
-
resp.error = "Funds for this order have already been captured."
|
264
|
-
elsif order.total > order.auth_amount
|
265
|
-
resp.error = "The order total exceeds the authorized amount."
|
266
|
-
elsif t.nil?
|
267
|
-
resp.error = "This order doesn't seem to be authorized."
|
268
|
-
else
|
269
|
-
|
270
|
-
sc = @site.store_config
|
271
|
-
case sc.pp_name
|
272
|
-
when 'authorize.net'
|
273
|
-
|
274
|
-
response = AuthorizeNet::SIM::Transaction.new(
|
275
|
-
sc.pp_username,
|
276
|
-
sc.pp_password,
|
277
|
-
order.total,
|
278
|
-
:transaction_type => 'CAPTURE_ONLY',
|
279
|
-
:transaction_id => t.transaction_id
|
280
|
-
)
|
281
|
-
order.update_attribute(:financial_status, Order::FINANCIAL_STATUS_CAPTURED)
|
282
|
-
resp.success = 'Captured funds successfully'
|
283
|
-
when 'payscape'
|
284
|
-
# TODO: Implement capture funds for payscape
|
285
|
-
|
286
|
-
end
|
287
|
-
|
288
|
-
#if (order.discounts.any? && order.total < order.discounts.first.amount_current) || PaymentProcessor.capture(order)
|
289
|
-
# order.financial_status = 'captured'
|
290
|
-
# order.save
|
291
|
-
#
|
292
|
-
# if order.discounts.any?
|
293
|
-
# order.update_attribute(:amount_discounted, order.discounts.first.amount_current)
|
294
|
-
# order.update_gift_cards
|
295
|
-
# end
|
296
|
-
#
|
297
|
-
# response.success = "Captured funds successfully"
|
298
|
-
#else
|
299
|
-
# response.error = "Error capturing funds."
|
300
|
-
#end
|
301
|
-
|
302
|
-
end
|
303
|
-
|
304
|
-
render :json => response
|
305
|
-
end
|
306
306
|
|
307
|
-
# GET /admin/orders/:id/void
|
308
|
-
#def void
|
309
|
-
# return if !user_is_allowed('orders', 'edit')
|
310
|
-
#
|
311
|
-
# response = Caboose::StdClass.new({
|
312
|
-
# 'refresh' => nil,
|
313
|
-
# 'error' => nil,
|
314
|
-
# 'success' => nil
|
315
|
-
# })
|
316
|
-
#
|
317
|
-
# order = Order.find(params[:id])
|
318
|
-
#
|
319
|
-
# if order.financial_status == 'captured'
|
320
|
-
# response.error = "This order has already been captured, you will need to refund instead"
|
321
|
-
# else
|
322
|
-
# if order.total < order.amount_discounted || PaymentProcessor.void(order)
|
323
|
-
# order.financial_status = 'cancelled'
|
324
|
-
# order.status = 'voided'
|
325
|
-
# order.save
|
326
|
-
#
|
327
|
-
# response.success = "Order voided successfully"
|
328
|
-
# else
|
329
|
-
# response.error = "Error voiding order."
|
330
|
-
# end
|
331
|
-
# end
|
332
|
-
#
|
333
|
-
# render json: response
|
334
|
-
#end
|
335
|
-
|
336
307
|
# GET /admin/orders/:id/refund
|
337
308
|
# def refund
|
338
309
|
# return if !user_is_allowed('orders', 'edit')
|
data/lib/caboose/version.rb
CHANGED