caboose-cms 0.8.35 → 0.8.36
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c6d43c4905b9690830088e68bbbfacedd0221392
|
4
|
+
data.tar.gz: 5e4f8fdf7b7adb741d6698f37f73d112cf94cc73
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: e9cb9272ec36f64fd4412f571eaae7cc4d8b6c78d9c653188a9fd9a423336829027a6f353ab867730fa7b964867ea1f05027fc1a0f24bb2522357aad6b43759f
|
7
|
+
data.tar.gz: 5d81e97b983b0518e0337096339289e7d29519c13c017e82e88bc90dd152b0ff4c598e820c494c4303db9452f448a519076c424cca5a8ab2ac33d5ba8383a53e
|
@@ -96,11 +96,14 @@ module Caboose
|
|
96
96
|
# @route DELETE /admin/invoices/:invoice_id/line-items/:id
|
97
97
|
def admin_delete
|
98
98
|
return if !user_is_allowed('invoices', 'delete')
|
99
|
-
li = LineItem.find(params[:id])
|
100
|
-
invoice = li.invoice
|
99
|
+
li = LineItem.find(params[:id])
|
101
100
|
li.destroy
|
102
|
-
|
103
|
-
invoice.
|
101
|
+
|
102
|
+
invoice = Invoice.find(params[:invoice_id])
|
103
|
+
invoice.subtotal = invoice.calculate_subtotal
|
104
|
+
invoice.total = invoice.calculate_total
|
105
|
+
invoice.save
|
106
|
+
|
104
107
|
render :json => Caboose::StdClass.new({
|
105
108
|
:redirect => '/admin/invoices'
|
106
109
|
})
|
@@ -1,4 +1,7 @@
|
|
1
|
-
|
1
|
+
<%
|
2
|
+
store_config = @invoice.site.store_config
|
3
|
+
u = @logged_in_user
|
4
|
+
%>
|
2
5
|
<div id='my_account'>
|
3
6
|
<h1>My Account</h1>
|
4
7
|
<p><div id='user_<%= @user.id %>_first_name' ></div></p>
|
@@ -6,16 +9,37 @@
|
|
6
9
|
<p><div id='user_<%= @user.id %>_email' ></div></p>
|
7
10
|
<p><div id='user_<%= @user.id %>_phone' ></div></p>
|
8
11
|
<div id='message2'></div>
|
9
|
-
|
10
|
-
<input type='button' value='Reset Password' class='btn' onclick="reset_user_password();" />
|
12
|
+
|
11
13
|
<% if @site.use_store %>
|
12
|
-
<
|
14
|
+
<h2>Billing</h2>
|
15
|
+
<p id='card_details'>
|
16
|
+
<% if u.card_brand && u.card_last4 %>You have a <%= u.card_brand %> ending in <%= u.card_last4 %> on file.<% else %>You have no card on file.<% end %>
|
17
|
+
<a href='#' onclick="toggle_stripe_form();" />edit</a>
|
18
|
+
</p>
|
19
|
+
<form action='' method='post' id='stripe_form' class='stripe_form'>
|
20
|
+
<div class='card_number_container'><input id='card_number' type='tel' autocomplete='off' autocorrect='off' spellcheck='off' autocapitalize='off' placeholder='Card number' /><div class='svg icon' style='width:30px;height:30px'><svg version="1.1" viewBox="0 0 30 30" width="30" height="30" focusable="false"><g fill-rule="evenodd"><path d="M2.00585866,0 C0.898053512,0 0,0.900176167 0,1.99201702 L0,9.00798298 C0,10.1081436 0.897060126,11 2.00585866,11 L11.9941413,11 C13.1019465,11 14,10.0998238 14,9.00798298 L14,1.99201702 C14,0.891856397 13.1029399,0 11.9941413,0 L2.00585866,0 Z M2.00247329,1 C1.44882258,1 1,1.4463114 1,1.99754465 L1,9.00245535 C1,9.55338405 1.45576096,10 2.00247329,10 L11.9975267,10 C12.5511774,10 13,9.5536886 13,9.00245535 L13,1.99754465 C13,1.44661595 12.544239,1 11.9975267,1 L2.00247329,1 Z M1,3 L1,5 L13,5 L13,3 L1,3 Z M11,8 L11,9 L12,9 L12,8 L11,8 Z M9,8 L9,9 L10,9 L10,8 L9,8 Z M9,8" style="fill:#3b6faa" transform="translate(8,10)"></g></svg></div></div>
|
21
|
+
<div class='card_exp_container' ><input id='card_exp' type='tel' autocomplete='off' autocorrect='off' spellcheck='off' autocapitalize='off' placeholder='MM / YY' x-autocompletetype='off' autocompletetype'=off' /><div class='svg icon' style='width:30px;height:30px'><svg version="1.1" viewBox="0 0 30 30" width="30" height="30" focusable="false"><g fill-rule="evenodd"><path d="M2.0085302,1 C0.899249601,1 0,1.90017617 0,2.99201702 L0,10.007983 C0,11.1081436 0.901950359,12 2.0085302,12 L9.9914698,12 C11.1007504,12 12,11.0998238 12,10.007983 L12,2.99201702 C12,1.8918564 11.0980496,1 9.9914698,1 L2.0085302,1 Z M1.99539757,4 C1.44565467,4 1,4.43788135 1,5.00292933 L1,9.99707067 C1,10.5509732 1.4556644,11 1.99539757,11 L10.0046024,11 C10.5543453,11 11,10.5621186 11,9.99707067 L11,5.00292933 C11,4.44902676 10.5443356,4 10.0046024,4 L1.99539757,4 Z M3,1 L3,2 L4,2 L4,1 L3,1 Z M8,1 L8,2 L9,2 L9,1 L8,1 Z M3,0 L3,1 L4,1 L4,0 L3,0 Z M8,0 L8,1 L9,1 L9,0 L8,0 Z M8,0" style="fill:#3b6faa" transform="translate(8,9)"></g></svg></div></div>
|
22
|
+
<div class='card_cvc_container' ><input id='card_cvc' type='tel' autocomplete='off' autocorrect='off' spellcheck='off' autocapitalize='off' placeholder='CVC' maxlength='4' /><div class='svg icon' style='width:30px;height:30px'><svg version="1.1" viewBox="0 0 30 30" width="30" height="30" focusable="false"><g fill-rule="evenodd"><path d="M8.8,4 C8.8,1.79086089 7.76640339,4.18628304e-07 5.5,0 C3.23359661,-4.1480896e-07 2.2,1.79086089 2.2,4 L3.2,4 C3.2,2.34314567 3.81102123,0.999999681 5.5,1 C7.18897877,1.00000032 7.80000001,2.34314567 7.80000001,4 L8.8,4 Z M1.99201702,4 C0.891856397,4 0,4.88670635 0,5.99810135 L0,10.0018986 C0,11.1054196 0.900176167,12 1.99201702,12 L9.00798298,12 C10.1081436,12 11,11.1132936 11,10.0018986 L11,5.99810135 C11,4.89458045 10.0998238,4 9.00798298,4 L1.99201702,4 Z M1.99754465,5 C1.44661595,5 1,5.45097518 1,5.99077797 L1,10.009222 C1,10.5564136 1.4463114,11 1.99754465,11 L9.00245535,11 C9.55338405,11 10,10.5490248 10,10.009222 L10,5.99077797 C10,5.44358641 9.5536886,5 9.00245535,5 L1.99754465,5 Z M1.99754465,5" style="fill:#3b6faa" transform="translate(9,9)"></g></svg></div></div>
|
23
|
+
<div class='card_name_container' ><input id='card_name' type='text' autocomplete='off' autocorrect='off' spellcheck='off' autocapitalize='on' placeholder='Name on card' /></div>
|
24
|
+
<div class='card_zip_container' ><input id='card_zip' type='tel' autocomplete='off' autocorrect='off' spellcheck='off' autocapitalize='on' placeholder='Zip code' /></div>
|
25
|
+
<div id='message'></div>
|
26
|
+
<p class='payment_controls'><input type='submit' class='btn' id='save_payment_btn' value='Save' /></p>
|
27
|
+
</form>
|
13
28
|
<% end %>
|
29
|
+
|
30
|
+
<p>
|
31
|
+
<input type='button' value='Reset Password' class='btn' onclick="reset_user_password();" />
|
32
|
+
<% if @site.use_store %>
|
33
|
+
<input type='button' value='Invoice History' class='btn' onclick="window.location='/my-account/invoices';" />
|
34
|
+
<% end %>
|
14
35
|
</p>
|
15
36
|
</div>
|
16
37
|
|
17
38
|
<% content_for :caboose_js do %>
|
18
|
-
<%= javascript_include_tag
|
39
|
+
<%= javascript_include_tag 'https://js.stripe.com/v2/' %>
|
40
|
+
<%= javascript_include_tag 'caboose/model/all' %>
|
41
|
+
<%= javascript_include_tag 'caboose/united_states' %>
|
42
|
+
<%= javascript_include_tag 'caboose/jquery.payment' %>
|
19
43
|
<script type='text/javascript'>
|
20
44
|
|
21
45
|
$(document).ready(function() {
|
@@ -36,9 +60,73 @@ $(document).ready(function() {
|
|
36
60
|
$('#user_<%= @user.id %>_email' ).css('width', '400px');
|
37
61
|
$('#user_<%= @user.id %>_phone' ).css('width', '400px');
|
38
62
|
}
|
39
|
-
});
|
63
|
+
});
|
64
|
+
|
65
|
+
<% if @site.use_store %>
|
66
|
+
$('#stripe_form').submit(function(e) {
|
67
|
+
e.preventDefault();
|
68
|
+
update_card();
|
69
|
+
return false;
|
70
|
+
});
|
71
|
+
|
72
|
+
$('#stripe_form .card_number_container input').payment('formatCardNumber');
|
73
|
+
$('#stripe_form .card_exp_container input').payment('formatCardExpiry');
|
74
|
+
$('#stripe_form .card_cvc_container input').payment('formatCardCVC');
|
75
|
+
$('#stripe_form').hide();
|
76
|
+
<% end %>
|
40
77
|
});
|
41
78
|
|
79
|
+
<% if @site.use_store %>
|
80
|
+
function toggle_stripe_form()
|
81
|
+
{
|
82
|
+
if ($('#stripe_form').is(':visible'))
|
83
|
+
$('#stripe_form').hide();
|
84
|
+
else
|
85
|
+
$('#stripe_form').show();
|
86
|
+
}
|
87
|
+
|
88
|
+
function update_card()
|
89
|
+
{
|
90
|
+
var info = {
|
91
|
+
number: $('#card_number').val(),
|
92
|
+
exp: $('#card_exp').val(),
|
93
|
+
cvc: $('#card_cvc').val(),
|
94
|
+
name: $('card_name').val(),
|
95
|
+
address_zip: $('card_zip').val()
|
96
|
+
};
|
97
|
+
var exp = info.exp.split('/');
|
98
|
+
var m = exp.length > 0 ? exp[0] : '';
|
99
|
+
var y = exp.length > 1 ? exp[1] : '';
|
100
|
+
var error = false;
|
101
|
+
if (!$.payment.validateCardNumber(info.number)) error = "Invalid card number.";
|
102
|
+
if (!$.payment.validateCardExpiry(m, y)) error = "Invalid expiration date.";
|
103
|
+
if (!$.payment.validateCardCVC(info.cvc)) error = "Invalid CVC.";
|
104
|
+
if (error) { $('#message').html("<p class='note error'>" + error + "</p>"); return; }
|
105
|
+
|
106
|
+
$('#save_payment_btn').attr('disabled', 'true').val('Saving card...');
|
107
|
+
Stripe.setPublishableKey(<%= raw Caboose.json(store_config.stripe_publishable_key) %>);
|
108
|
+
Stripe.card.createToken(info, function(status, resp) {
|
109
|
+
if (resp.error)
|
110
|
+
{
|
111
|
+
$('#save_payment_btn').attr('disabled', 'false').val('Save Payment Method');
|
112
|
+
$('#message').html("<p class='note error'>" + resp.error.message + "</p>");
|
113
|
+
}
|
114
|
+
else
|
115
|
+
{
|
116
|
+
$.ajax({
|
117
|
+
url: '/checkout/stripe-details',
|
118
|
+
type: 'put',
|
119
|
+
data: { token: resp.id, card: resp.card },
|
120
|
+
success: function(resp2) {
|
121
|
+
if (resp2.error) $('#payment_message').html("<p class='note error'>" + resp2.error + "</p>");
|
122
|
+
if (resp2.success) window.location.reload(true);
|
123
|
+
}
|
124
|
+
});
|
125
|
+
}
|
126
|
+
});
|
127
|
+
}
|
128
|
+
<% end %>
|
129
|
+
|
42
130
|
function reset_user_password(pass1, pass2)
|
43
131
|
{
|
44
132
|
if (!pass1)
|
@@ -83,4 +171,21 @@ function reset_user_password(pass1, pass2)
|
|
83
171
|
<% end %>
|
84
172
|
<%= content_for :caboose_css do %>
|
85
173
|
<%= stylesheet_link_tag "caboose/my_account", :media => "all" %>
|
174
|
+
<style type='text/css'>
|
175
|
+
|
176
|
+
.stripe_form { width: 100%; }
|
177
|
+
.stripe_form .card_number_container { position: relative; width: 100%; } .stripe_form .card_number_container input { padding-left: 30px; height: 37px; font-size: 15px; width: 100%; border-color: #b9b9b9; border-style: solid; border-width: 1px 1px 0px 1px; }
|
178
|
+
.stripe_form .card_exp_container { position: relative; width: 50% !important; float: left; } .stripe_form .card_exp_container input { padding-left: 30px; height: 37px; font-size: 15px; width: 100%; border-color: #b9b9b9; border-style: solid; border-width: 1px 1px 0px 1px; }
|
179
|
+
.stripe_form .card_cvc_container { position: relative; width: 50%; float: left; } .stripe_form .card_cvc_container input { padding-left: 30px; height: 37px; font-size: 15px; width: 100%; border-color: #b9b9b9; border-style: solid; border-width: 1px 1px 0px 0px; }
|
180
|
+
.stripe_form .card_name_container { position: relative; width: 50%; float: left; } .stripe_form .card_name_container input { padding-left: 10px; height: 37px !important; font-size: 15px; width: 100%; border-color: #b9b9b9; border-style: solid; border-width: 1px 0px 1px 1px; }
|
181
|
+
.stripe_form .card_zip_container { position: relative; width: 50%; float: left; margin-bottom: 4px; } .stripe_form .card_zip_container input { padding-left: 10px; height: 37px; font-size: 15px; width: 100%; border-color: #b9b9b9; border-style: solid; border-width: 1px 1px 1px 0px; }
|
182
|
+
|
183
|
+
.stripe_form .card_number_container .icon { position: absolute; top: 3px; left: 1px; transform-origin: 50% 50% 0; pointer-events: none; }
|
184
|
+
.stripe_form .card_exp_container .icon { position: absolute; top: 3px; left: 1px; transform-origin: 50% 50% 0; pointer-events: none; }
|
185
|
+
.stripe_form .card_cvc_container .icon { position: absolute; top: 3px; left: 1px; transform-origin: 50% 50% 0; pointer-events: none; }
|
186
|
+
|
187
|
+
.stripe_form .note { width: 100%; margin-bottom: 10px !important; text-align: center; }
|
188
|
+
.stripe_form .payment_controls { clear: left; margin-top: 4px !important; }
|
189
|
+
|
190
|
+
</style>
|
86
191
|
<% end %>
|
data/lib/caboose/version.rb
CHANGED