caboose-cms 0.5.165 → 0.5.166
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.
- checksums.yaml +8 -8
- data/app/assets/javascripts/caboose/my_account_edit_order.js +28 -40
- data/app/controllers/caboose/my_account_orders_controller.rb +39 -24
- data/app/views/caboose/my_account_orders/edit.html.erb +2 -33
- data/app/views/caboose/my_account_orders/payment_form.html.erb +42 -133
- data/config/routes.rb +2 -1
- 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
|
+
NzhhMGRlNTRhMDgzMzYyZjEwYzA3NDA2MzYzYzk4NjQxMGM5ZWYyZQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OTExNWRmYzc0ZGFjYzU4ZjQ2YzUzNDg1Y2UyYzI0ZGEzOGY1NjA3ZA==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
Y2QyNmZjNTdkNzljMmU5OWQ3ZmExYjMzYjE2YzNiNjUwZjM2MzY2NjBmZWE2
|
10
|
+
NmMyZjhhMjZmMjdiN2MwYzFhM2E1Yjc1MjUzNGYzMmZkMmM1ZDNmYjY2Nzg2
|
11
|
+
MDczMzNlMGJjMThlOGNkMzBiMjdlZDUwNjhlMjBkMWNkZmE0MTY=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
YjI4ZjRjNTRhYmI5MGEyZTIxODBmMjRkMzZiYWUxNjNhMjUxMDE5YmRlNWE3
|
14
|
+
Yjg1NjkwNWQ4ZDNlNjFiZjg2ZTk2MTQ3MTAyNWMxYWNjNTk1YTE5OTZkZjAx
|
15
|
+
M2JkMTliZDcyMjdmZDBlZTM1Y2QzNWE2ZWFjNTY4MDYxNDI3MGU=
|
@@ -419,56 +419,44 @@ MyAccountOrderController.prototype = {
|
|
419
419
|
payment_form: function()
|
420
420
|
{
|
421
421
|
var that = this;
|
422
|
-
var ba = that.order.billing_address;
|
423
|
-
if (ba == null || ba == false ||
|
424
|
-
ba.first_name.length == 0 ||
|
425
|
-
ba.last_name.length == 0 ||
|
426
|
-
ba.address1.length == 0 ||
|
427
|
-
ba.city.length == 0 ||
|
428
|
-
ba.state.length == 0 ||
|
429
|
-
ba.zip.length == 0
|
430
|
-
) {
|
431
|
-
$('#payment_message').empty().html("<p class='note error'>Your billing address must be valid before making payment. Please review and try again.</p>");
|
432
|
-
return;
|
433
|
-
}
|
434
422
|
var form = $('#payment_form');
|
435
|
-
if (
|
436
|
-
{
|
423
|
+
if (form.is(':visible'))
|
424
|
+
{
|
425
|
+
form.slideUp(function() { form.empty(); });
|
437
426
|
$('#payment_message').empty();
|
438
|
-
|
427
|
+
return;
|
439
428
|
}
|
440
|
-
|
441
|
-
|
429
|
+
|
430
|
+
$('#payment_message').empty().html("<p class='loading'>Getting payment form...</p>");
|
431
|
+
$.ajax({
|
432
|
+
url: '/my-account/orders/' + that.order.id + '/payment-form',
|
433
|
+
type: 'get',
|
434
|
+
success: function(html) {
|
435
|
+
form.empty().append(html);
|
436
|
+
form.slideDown();
|
437
|
+
$('#payment_message').empty();
|
438
|
+
}
|
439
|
+
});
|
442
440
|
},
|
443
441
|
|
444
442
|
submit_payment: function()
|
445
443
|
{
|
444
|
+
$('input[name=billing-cc-exp]').val($('#billing-expiration-month').val() + $('#billing-expiration-year').val());
|
446
445
|
$('#payment_message').empty().html("<p class='loading'>Processing payment...</p>");
|
447
446
|
$('#payment_form').slideUp();
|
447
|
+
$('#payment').submit();
|
448
448
|
},
|
449
|
-
|
450
|
-
|
449
|
+
|
450
|
+
payment_relay_handler: function(resp)
|
451
451
|
{
|
452
|
-
|
453
|
-
|
454
|
-
|
455
|
-
|
456
|
-
|
457
|
-
|
458
|
-
|
459
|
-
|
460
|
-
$('#message').empty().append(p);
|
461
|
-
return;
|
462
|
-
}
|
463
|
-
$('#message').html("<p class='loading'>Sending for authorization...</p>");
|
464
|
-
$.ajax({
|
465
|
-
url: '/my-account/orders/' + that.order.id + '/send-for-authorization',
|
466
|
-
success: function(resp) {
|
467
|
-
if (resp.error) $('#message').html("<p class='note error'>" + resp.error + "</p>");
|
468
|
-
if (resp.success) { $('#message').empty(); that.refresh(); }
|
469
|
-
if (resp.refresh) { $('#message').empty(); that.refresh(); }
|
470
|
-
}
|
471
|
-
});
|
452
|
+
console.log('RELAY');
|
453
|
+
console.log(resp);
|
454
|
+
if (resp.success == true)
|
455
|
+
controller.refresh();
|
456
|
+
else if (resp.error)
|
457
|
+
$('#payment_message').html("<p class='note error'>" + resp.error + "</p>");
|
458
|
+
else
|
459
|
+
$('#payment_message').html("<p class='note error'>There was an error processing your payment.</p>");
|
472
460
|
},
|
473
461
|
|
474
462
|
has_shippable_items: function()
|
@@ -486,5 +474,5 @@ MyAccountOrderController.prototype = {
|
|
486
474
|
|
487
475
|
function relay_handler(resp)
|
488
476
|
{
|
489
|
-
|
477
|
+
controller.payment_relay_handler(resp);
|
490
478
|
}
|
@@ -30,31 +30,46 @@ module Caboose
|
|
30
30
|
render :file => 'caboose/extras/error'
|
31
31
|
return
|
32
32
|
end
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
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
|
33
|
+
end
|
34
|
+
|
35
|
+
# GET /my-account/orders/:id/payment-form
|
36
|
+
def payment_form
|
37
|
+
return if !logged_in?
|
57
38
|
|
39
|
+
@order = Order.find(params[:id])
|
40
|
+
if @order.customer_id != logged_in_user.id
|
41
|
+
@error = "The given order does not belong to you."
|
42
|
+
render :file => 'caboose/extras/error'
|
43
|
+
return
|
44
|
+
end
|
45
|
+
|
46
|
+
if @order.financial_status != Order::FINANCIAL_STATUS_PENDING
|
47
|
+
@error = "This order does not require payment at this time."
|
48
|
+
render :file => 'caboose/extras/error'
|
49
|
+
return
|
50
|
+
end
|
51
|
+
|
52
|
+
sc = @site.store_config
|
53
|
+
case sc.pp_name
|
54
|
+
when 'authorize.net'
|
55
|
+
|
56
|
+
@sim_transaction = AuthorizeNet::SIM::Transaction.new(
|
57
|
+
sc.pp_username,
|
58
|
+
sc.pp_password,
|
59
|
+
@order.total,
|
60
|
+
:relay_response => 'TRUE',
|
61
|
+
:relay_url => "#{sc.pp_relay_domain}/my-account/orders/authnet-relay",
|
62
|
+
:transaction_type => 'AUTH_ONLY',
|
63
|
+
:test => sc.pp_testing
|
64
|
+
)
|
65
|
+
@request = request
|
66
|
+
@show_relay = params[:show_relay] && params[:show_relay].to_i == 1
|
67
|
+
|
68
|
+
when 'stripe'
|
69
|
+
# TODO: Implement manual order payment for stripe
|
70
|
+
|
71
|
+
end
|
72
|
+
render :layout => false
|
58
73
|
end
|
59
74
|
|
60
75
|
# GET /my-account/orders/:id/json
|
@@ -5,40 +5,9 @@ store_config = @order.site.store_config
|
|
5
5
|
|
6
6
|
<div id='overview_table'></div>
|
7
7
|
<% if @order.financial_status == Caboose::Order::FINANCIAL_STATUS_PENDING %>
|
8
|
-
<div id='payment_form'>
|
9
|
-
<% if store_config.pp_name == 'authorize.net' %>
|
10
|
-
<form id="payment" target="relay" action="https://secure.authorize.net/gateway/transact.dll" method="post">
|
11
|
-
<%= sim_fields(@sim_transaction) %>
|
12
|
-
<input type="hidden" id="x_invoice_num" name="x_invoice_num" value="<%= @order.id %>" />
|
13
|
-
<input type="hidden" id="x_description" name="x_after_relay" value="<%= raw store_config.pp_relay_domain %>/my-account/orders/<%= @order.id %>/authnet-response" />
|
14
|
-
<input type="hidden" id="x_first_name" name="x_first_name" value="<%= raw @order.billing_address.first_name %>" />
|
15
|
-
<input type="hidden" id="x_last_name" name="x_last_name" value="<%= raw @order.billing_address.last_name %>" />
|
16
|
-
<input type="hidden" id="x_address" name="x_address" value="<%= raw @order.billing_address.address1 %>" />
|
17
|
-
<input type="hidden" id="x_city" name="x_city" value="<%= raw @order.billing_address.city %>" />
|
18
|
-
<input type="hidden" id="x_state" name="x_state" value="<%= raw @order.billing_address.state %>" />
|
19
|
-
<input type="hidden" id="x_zip" name="x_zip" value="<%= raw @order.billing_address.zip %>" />
|
20
|
-
|
21
|
-
<div class="field" id="credit-card">
|
22
|
-
<span class="field-text">Credit Card Payment</span>
|
23
|
-
<div class="icons"><img src="/assets/caboose/credit_cards.png" alt="Credit Cards Accepted" /></div>
|
24
|
-
</div>
|
25
|
-
<div class="field" id="card-number">
|
26
|
-
<span class="field-text">Card</span>
|
27
|
-
<input name="x_card_num" id='billing-cc-number' type="text" maxlength="16" placeholder="Card number" />
|
28
|
-
<div class="icons"><img src="/assets/caboose/lock.png" alt="Secure Connection" /></div>
|
29
|
-
</div>
|
30
|
-
<div class="field" id="expiry">
|
31
|
-
<span class="field-text">Expiration</span>
|
32
|
-
<input id="expiration" name="x_exp_date" type="hidden" />
|
33
|
-
<select id="month" name="month"><% (1..12).each do |i| %><option value="<%= (i<10 ? "0#{i}" : i) %>"><%= (i<10 ? "0#{i}" : i) %> - <%= DateTime.new(2000, i, 1).strftime("%b") %></option><% end %></select> /
|
34
|
-
<select id="year" name="year"><% (DateTime.now.year...DateTime.now.year + 20).each do |i| %><option value="<%= i-2000 %>"><%= i %></option><% end %></select>
|
35
|
-
</div>
|
36
|
-
<input type='button' value='Confirm Payment' id='payment_confirm' class='btn' />
|
37
|
-
</form>
|
38
|
-
<iframe id="relay" name="relay" style='<% if @show_relay %>display: block; width: 800px; height: 400px; border: #000 1px solid;<% else %>display: none;<% end %>'></iframe>
|
39
|
-
<% end %>
|
40
|
-
</div>
|
8
|
+
<div id='payment_form'></div>
|
41
9
|
<div id='payment_message'></div>
|
10
|
+
<iframe id="relay" name="relay" style='<% if @show_relay %>display: block; width: 800px; height: 400px; border: #000 1px solid;<% else %>display: none;<% end %>'></iframe>
|
42
11
|
<% end %>
|
43
12
|
<div id='order_table'></div>
|
44
13
|
<div id='message'></div>
|
@@ -1,138 +1,47 @@
|
|
1
1
|
<%
|
2
|
-
store_config = @site.store_config
|
3
|
-
%>
|
4
|
-
<div id="checkout">
|
5
|
-
<h2>Payment</h2>
|
6
|
-
<section id='checkout-payment'>
|
7
|
-
<% if store_config.pp_name == 'authorize.net' %>
|
8
|
-
<form id="payment" target="relay" action="https://secure.authorize.net/gateway/transact.dll" method="post">
|
9
|
-
<%= sim_fields(@sim_transaction) %>
|
10
|
-
<input type="hidden" id="x_invoice_num" name="x_invoice_num" value="<%= @order.id %>" />
|
11
|
-
<input type="hidden" id="x_description" name="x_after_relay" value="<%= raw store_config.pp_relay_domain %>/checkout/authnet-response/<%= @order.id %>" />
|
12
|
-
<input type="hidden" id="x_first_name" name="x_first_name" value="<%= raw @order.billing_address.first_name %>" />
|
13
|
-
<input type="hidden" id="x_last_name" name="x_last_name" value="<%= raw @order.billing_address.last_name %>" />
|
14
|
-
<input type="hidden" id="x_address" name="x_address" value="<%= raw @order.billing_address.address1 %>" />
|
15
|
-
<input type="hidden" id="x_city" name="x_city" value="<%= raw @order.billing_address.city %>" />
|
16
|
-
<input type="hidden" id="x_state" name="x_state" value="<%= raw @order.billing_address.state %>" />
|
17
|
-
<input type="hidden" id="x_zip" name="x_zip" value="<%= raw @order.billing_address.zip %>" />
|
18
|
-
|
19
|
-
<div class="field" id="credit-card">
|
20
|
-
<span class="field-text">Credit Card</span>
|
21
|
-
<div class="icons">
|
22
|
-
<img src="/assets/caboose/credit_cards.png" alt="Credit Cards Accepted" />
|
23
|
-
</div>
|
24
|
-
</div>
|
25
|
-
|
26
|
-
<div class="field" id="card-number">
|
27
|
-
<span class="field-text">Card</span>
|
28
|
-
<input name="x_card_num" id='billing-cc-number' type="text" maxlength="16" placeholder="Card number" />
|
29
|
-
<div class="icons">
|
30
|
-
<img src="/assets/caboose/lock.png" alt="Secure Connection" />
|
31
|
-
</div>
|
32
|
-
</div>
|
2
|
+
store_config = @order.site.store_config
|
33
3
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
<option value="05">05 - May</option>
|
43
|
-
<option value="06">06 - Jun</option>
|
44
|
-
<option value="07">07 - Jul</option>
|
45
|
-
<option value="08">08 - Aug</option>
|
46
|
-
<option value="09">09 - Sep</option>
|
47
|
-
<option value="10">10 - Oct</option>
|
48
|
-
<option value="11">11 - Nov</option>
|
49
|
-
<option value="12">12 - Dec</option>
|
50
|
-
</select>
|
51
|
-
/
|
52
|
-
<select id="year" name="year">
|
53
|
-
<% (DateTime.now.year...DateTime.now.year + 20).each do |i| %>
|
54
|
-
<option value="<%= i-2000 %>"><%= i %></option>
|
55
|
-
<% end %>
|
56
|
-
</select>
|
57
|
-
</div>
|
4
|
+
ba = @order.billing_address
|
5
|
+
valid_address = ba &&
|
6
|
+
ba.first_name.strip.length > 0 &&
|
7
|
+
ba.last_name.strip.length > 0 &&
|
8
|
+
ba.address1.strip.length > 0 &&
|
9
|
+
ba.city.strip.length > 0 &&
|
10
|
+
ba.state.strip.length > 0 &&
|
11
|
+
ba.zip.strip.length > 0
|
58
12
|
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
<
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
<h3>Billing Address</h3>
|
77
|
-
<% ba = @order.billing_address %>
|
78
|
-
<address>
|
79
|
-
<%= "#{ba.first_name} #{ba.last_name}" %><br />
|
80
|
-
<%= ba.address1 %><br />
|
81
|
-
<%= "#{ba.address2}<br />" if ba.address2 and not ba.address2.empty? %>
|
82
|
-
<%= "#{ba.city}, #{ba.state} #{ba.zip}" %>
|
83
|
-
</address>
|
84
|
-
</section>
|
85
|
-
<% if @order.has_shippable_items? %>
|
86
|
-
<section id='shipping_method'>
|
87
|
-
<h3>Shipping</h3>
|
88
|
-
<% @order.order_packages.all.each do |op| %>
|
89
|
-
<p><%= op.shipping_method.service_name %> - <%= number_to_currency(op.total) %></p>
|
90
|
-
<% end %>
|
91
|
-
</section>
|
92
|
-
<% end %>
|
93
|
-
<section id='payment_method'>
|
94
|
-
<h3>Payment Method</h3>
|
95
|
-
<div id='confirm_card'>
|
96
|
-
<p id='confirm_card_number'></p>
|
97
|
-
<p><a href="#" id='edit_payment'>Edit</a></p>
|
13
|
+
%>
|
14
|
+
<% if valid_address %>
|
15
|
+
<% if store_config.pp_name == 'authorize.net' %>
|
16
|
+
<form id="payment" target="relay" action="https://secure.authorize.net/gateway/transact.dll" method="post">
|
17
|
+
<%= sim_fields(@sim_transaction) %>
|
18
|
+
<input type="hidden" id="x_invoice_num" name="x_invoice_num" value="<%= @order.id %>" />
|
19
|
+
<input type="hidden" id="x_description" name="x_after_relay" value="<%= raw store_config.pp_relay_domain %>/my-account/orders/<%= @order.id %>/authnet-response" />
|
20
|
+
<input type="hidden" id="x_first_name" name="x_first_name" value="<%= raw @order.billing_address.first_name %>" />
|
21
|
+
<input type="hidden" id="x_last_name" name="x_last_name" value="<%= raw @order.billing_address.last_name %>" />
|
22
|
+
<input type="hidden" id="x_address" name="x_address" value="<%= raw @order.billing_address.address1 %>" />
|
23
|
+
<input type="hidden" id="x_city" name="x_city" value="<%= raw @order.billing_address.city %>" />
|
24
|
+
<input type="hidden" id="x_state" name="x_state" value="<%= raw @order.billing_address.state %>" />
|
25
|
+
<input type="hidden" id="x_zip" name="x_zip" value="<%= raw @order.billing_address.zip %>" />
|
26
|
+
|
27
|
+
<div class="field" id="credit-card">
|
28
|
+
<span class="field-text">Credit Card Payment</span>
|
29
|
+
<div class="icons"><img src="/assets/caboose/credit_cards.png" alt="Credit Cards Accepted" /></div>
|
98
30
|
</div>
|
99
|
-
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
108
|
-
|
109
|
-
|
110
|
-
|
111
|
-
|
112
|
-
|
113
|
-
|
114
|
-
|
115
|
-
<%= javascript_include_tag 'caboose/cart' %>
|
116
|
-
<%= javascript_include_tag 'caboose/checkout_payment' %>
|
117
|
-
<script type='text/javascript'>
|
118
|
-
var SHOW_RELAY = <%= @show_relay ? 'true' : 'false' %>;
|
119
|
-
|
120
|
-
var cart = false;
|
121
|
-
$(document).ready(function() {
|
122
|
-
cart = new Cart({
|
123
|
-
allow_edit_line_items: false,
|
124
|
-
allow_edit_gift_cards: false
|
125
|
-
});
|
126
|
-
});
|
127
|
-
|
128
|
-
</script>
|
129
|
-
<% end %>
|
130
|
-
<%= content_for :caboose_css do %>
|
131
|
-
<%= stylesheet_link_tag 'caboose/cart' %>
|
132
|
-
<%= stylesheet_link_tag 'caboose/checkout' %>
|
133
|
-
<style type='text/css'>
|
134
|
-
|
135
|
-
#checkout h3 { font-size: 14pt; font-weight: bold; }
|
136
|
-
|
137
|
-
</style>
|
31
|
+
<div class="field" id="card-number">
|
32
|
+
<span class="field-text">Card</span>
|
33
|
+
<input name="x_card_num" id='billing-cc-number' type="text" maxlength="16" placeholder="Card number" />
|
34
|
+
<div class="icons"><img src="/assets/caboose/lock.png" alt="Secure Connection" /></div>
|
35
|
+
</div>
|
36
|
+
<div class="field" id="expiry">
|
37
|
+
<span class="field-text">Expiration</span>
|
38
|
+
<input id="expiration" name="x_exp_date" type="hidden" />
|
39
|
+
<select id="month" name="month"><% (1..12).each do |i| %><option value="<%= (i<10 ? "0#{i}" : i) %>"><%= (i<10 ? "0#{i}" : i) %> - <%= DateTime.new(2000, i, 1).strftime("%b") %></option><% end %></select> /
|
40
|
+
<select id="year" name="year"><% (DateTime.now.year...DateTime.now.year + 20).each do |i| %><option value="<%= i-2000 %>"><%= i %></option><% end %></select>
|
41
|
+
</div>
|
42
|
+
<input type='button' value='Confirm Payment' id='payment_confirm' class='btn' />
|
43
|
+
</form>
|
44
|
+
<% end %>
|
45
|
+
<% else %>
|
46
|
+
<p class='note error'>Your billing address must be valid before making payment. Please review and try again.</p>
|
138
47
|
<% end %>
|
data/config/routes.rb
CHANGED
@@ -39,7 +39,8 @@ Caboose::Engine.routes.draw do
|
|
39
39
|
get "my-account/orders/authnet-relay" => "my_account_orders#authnet_relay"
|
40
40
|
post "my-account/orders/authnet-relay" => "my_account_orders#authnet_relay"
|
41
41
|
get "my-account/orders/:id/authnet-response" => "my_account_orders#authnet_response"
|
42
|
-
post "my-account/orders/:id/authnet-response" => "my_account_orders#authnet_response"
|
42
|
+
post "my-account/orders/:id/authnet-response" => "my_account_orders#authnet_response"
|
43
|
+
get "my-account/orders/:id/payment-form" => "my_account_orders#payment_form"
|
43
44
|
get "my-account/orders/:id/json" => "my_account_orders#order_json"
|
44
45
|
get "my-account/orders/:id/json" => "my_account_orders#order_json"
|
45
46
|
get "my-account/orders/:id" => "my_account_orders#edit"
|
data/lib/caboose/version.rb
CHANGED