caboose-cms 0.5.60 → 0.5.61
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/authorize.net.js +187 -0
- data/app/assets/javascripts/caboose/cart.js +13 -8
- data/app/assets/javascripts/caboose/checkout_step4.js +7 -9
- data/app/controllers/caboose/#Untitled-1# +7 -0
- data/app/controllers/caboose/application_controller.rb +12 -10
- data/app/controllers/caboose/cart_controller.rb +3 -3
- data/app/controllers/caboose/checkout_controller.rb +51 -61
- data/app/controllers/caboose/orders_controller.rb +1 -0
- data/app/mailers/caboose/orders_mailer.rb +4 -2
- data/app/models/caboose/authnet.rb +140 -0
- data/app/models/caboose/order.rb +6 -0
- data/app/models/caboose/payment_processors/authorizenet.rb +18 -23
- data/app/models/caboose/schema.rb +3 -1
- data/app/models/caboose/site.rb +4 -0
- data/app/views/caboose/checkout/#Untitled-2# +41 -0
- data/app/views/caboose/checkout/_confirm.html.erb +10 -10
- data/app/views/caboose/checkout/authnet_profile_form.html.erb +14 -0
- data/app/views/caboose/checkout/authnet_relay.html.erb +16 -0
- data/app/views/caboose/checkout/authnet_response.html.erb +12 -0
- data/app/views/caboose/checkout/{relay.html.erb → payscape_relay.html.erb} +0 -0
- data/app/views/caboose/checkout/step_four.html.erb +36 -35
- data/app/views/caboose/checkout/step_four_old.html.erb +63 -0
- data/app/views/caboose/checkout/step_two.html.erb +8 -0
- data/app/views/caboose/orders/admin_edit.html.erb +14 -6
- data/app/views/caboose/orders/admin_index.html.erb +3 -3
- data/config/routes.rb +13 -8
- data/lib/caboose/version.rb +1 -1
- metadata +11 -3
checksums.yaml
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
---
|
|
2
2
|
!binary "U0hBMQ==":
|
|
3
3
|
metadata.gz: !binary |-
|
|
4
|
-
|
|
4
|
+
YmNhZDZiODIzMzY5MWNkM2EzN2EyY2E4NWIwOTYyOTE2ZjIxN2VmMA==
|
|
5
5
|
data.tar.gz: !binary |-
|
|
6
|
-
|
|
6
|
+
OTZjOWM1NmY0MjFkYTBmOGQzMzY3MTE4NTBkZmFlOTM2MmJhMTI1MQ==
|
|
7
7
|
SHA512:
|
|
8
8
|
metadata.gz: !binary |-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
9
|
+
MTI2ZTliMWYzZDI5NjczZGE1NWQ2YjNmM2FmODZlZTc4OTk0MWQ0NGUxYWRi
|
|
10
|
+
ODFlNWY0MzIyMjc2YTg1NTJkYTJjYzUyYTY2Zjc4NmQ3MTFmNTkxMDU2YTQ2
|
|
11
|
+
YzEwZTMxMTY3YWNiZDE1NDNiNGYxY2E3MDJiZGNmYWZiYmEyY2M=
|
|
12
12
|
data.tar.gz: !binary |-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
13
|
+
Mjk1OWFlYzYzMjEyZDg1MTUwYWUxYjM1ZWM4ZjM1MTFmN2NlNTVhN2IyOWQ0
|
|
14
|
+
MThjM2NmOTc1NTZjYjc5M2E0YThhYWRlMTdhYTgzNWRjMGY3MzFjZWJlMzY0
|
|
15
|
+
MjA0NTVlZWNlOWM0ODQ4ZWQzY2Q5NDM3MjAzM2YzMzMwNjY2MzE=
|
|
@@ -0,0 +1,187 @@
|
|
|
1
|
+
/* Usage:
|
|
2
|
+
|
|
3
|
+
<script type="text/javascript" src="contentx/popup.js"></script>
|
|
4
|
+
|
|
5
|
+
<script type="text/javascript">
|
|
6
|
+
//<![CDATA[
|
|
7
|
+
|
|
8
|
+
// Uncomment this line if eCheck is enabled. This does not affect functionality, only the initial sizing of the popup page for add payment.
|
|
9
|
+
//AuthorizeNetPopup.options.eCheckEnabled = true;
|
|
10
|
+
|
|
11
|
+
// Uncomment these lines to define a function that will be called when the popup is closed.
|
|
12
|
+
// For example, you may want to refresh your page and/or call the GetCustomerProfile API method from your server.
|
|
13
|
+
//AuthorizeNetPopup.options.onPopupClosed = function() {
|
|
14
|
+
// your code here.
|
|
15
|
+
//};
|
|
16
|
+
|
|
17
|
+
// Uncomment this line if you do not have absolutely positioned elements on your page that can obstruct the view of the popup.
|
|
18
|
+
// This can speed up the processing of the page slightly.
|
|
19
|
+
//AuthorizeNetPopup.options.skipZIndexCheck = true;
|
|
20
|
+
|
|
21
|
+
// Uncomment this line to use test.authorize.net instead of secure.authorize.net.
|
|
22
|
+
//AuthorizeNetPopup.options.useTestEnvironment = true;
|
|
23
|
+
|
|
24
|
+
//]]>
|
|
25
|
+
</script>
|
|
26
|
+
|
|
27
|
+
*/
|
|
28
|
+
|
|
29
|
+
(function () {
|
|
30
|
+
if (!window.AuthorizeNetPopup) window.AuthorizeNetPopup = {};
|
|
31
|
+
if (!AuthorizeNetPopup.options) AuthorizeNetPopup.options = {
|
|
32
|
+
onPopupClosed: null
|
|
33
|
+
,eCheckEnabled: false
|
|
34
|
+
,skipZIndexCheck: false
|
|
35
|
+
,useTestEnvironment: false
|
|
36
|
+
};
|
|
37
|
+
AuthorizeNetPopup.closePopup = function() {
|
|
38
|
+
document.getElementById("divAuthorizeNetPopupScreen").style.display = "none";
|
|
39
|
+
document.getElementById("divAuthorizeNetPopup").style.display = "none";
|
|
40
|
+
document.getElementById("iframeAuthorizeNet").src = "contentx/empty.html";
|
|
41
|
+
if (AuthorizeNetPopup.options.onPopupClosed) AuthorizeNetPopup.options.onPopupClosed();
|
|
42
|
+
};
|
|
43
|
+
AuthorizeNetPopup.openManagePopup = function() {
|
|
44
|
+
openSpecificPopup({action:"manage"});
|
|
45
|
+
};
|
|
46
|
+
AuthorizeNetPopup.openAddPaymentPopup = function() {
|
|
47
|
+
openSpecificPopup({action:"addPayment", paymentProfileId:"new"});
|
|
48
|
+
};
|
|
49
|
+
AuthorizeNetPopup.openEditPaymentPopup = function(paymentProfileId) {
|
|
50
|
+
openSpecificPopup({action:"editPayment", paymentProfileId:paymentProfileId});
|
|
51
|
+
};
|
|
52
|
+
AuthorizeNetPopup.openAddShippingPopup = function() {
|
|
53
|
+
openSpecificPopup({action:"addShipping", shippingAddressId:"new"});
|
|
54
|
+
};
|
|
55
|
+
AuthorizeNetPopup.openEditShippingPopup = function(shippingAddressId) {
|
|
56
|
+
openSpecificPopup({action:"editShipping", shippingAddressId:shippingAddressId});
|
|
57
|
+
};
|
|
58
|
+
AuthorizeNetPopup.onReceiveCommunication = function (querystr) {
|
|
59
|
+
var params = parseQueryString(querystr);
|
|
60
|
+
switch(params["action"]) {
|
|
61
|
+
case "successfulSave":
|
|
62
|
+
AuthorizeNetPopup.closePopup();
|
|
63
|
+
break;
|
|
64
|
+
case "cancel":
|
|
65
|
+
AuthorizeNetPopup.closePopup();
|
|
66
|
+
break;
|
|
67
|
+
case "resizeWindow":
|
|
68
|
+
var w = parseInt(params["width"]);
|
|
69
|
+
var h = parseInt(params["height"]);
|
|
70
|
+
var ifrm = document.getElementById("iframeAuthorizeNet");
|
|
71
|
+
ifrm.style.width = w.toString() + "px";
|
|
72
|
+
ifrm.style.height = h.toString() + "px";
|
|
73
|
+
centerPopup();
|
|
74
|
+
adjustPopupScreen();
|
|
75
|
+
break;
|
|
76
|
+
}
|
|
77
|
+
};
|
|
78
|
+
function openSpecificPopup(opt) {
|
|
79
|
+
var popup = document.getElementById("divAuthorizeNetPopup");
|
|
80
|
+
var popupScreen = document.getElementById("divAuthorizeNetPopupScreen");
|
|
81
|
+
var ifrm = document.getElementById("iframeAuthorizeNet");
|
|
82
|
+
var form = document.forms["formAuthorizeNetPopup"];
|
|
83
|
+
|
|
84
|
+
switch (opt.action) {
|
|
85
|
+
case "addPayment":
|
|
86
|
+
ifrm.style.width = "435px";
|
|
87
|
+
ifrm.style.height = AuthorizeNetPopup.options.eCheckEnabled ? "508px" : "479px";
|
|
88
|
+
break;
|
|
89
|
+
case "editPayment":
|
|
90
|
+
ifrm.style.width = "435px";
|
|
91
|
+
ifrm.style.height = "479px";
|
|
92
|
+
break;
|
|
93
|
+
case "addShipping":
|
|
94
|
+
ifrm.style.width = "385px";
|
|
95
|
+
ifrm.style.height = "359px";
|
|
96
|
+
break;
|
|
97
|
+
case "editShipping":
|
|
98
|
+
ifrm.style.width = "385px";
|
|
99
|
+
ifrm.style.height = "359px";
|
|
100
|
+
break;
|
|
101
|
+
case "manage":
|
|
102
|
+
ifrm.style.width = "442px";
|
|
103
|
+
ifrm.style.height = "578px";
|
|
104
|
+
break;
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
if (!AuthorizeNetPopup.options.skipZIndexCheck) {
|
|
108
|
+
var zIndexHightest = getHightestZIndex();
|
|
109
|
+
popup.style.zIndex = zIndexHightest + 2;
|
|
110
|
+
popupScreen.style.zIndex = zIndexHightest + 1;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
if (AuthorizeNetPopup.options.useTestEnvironment) {
|
|
114
|
+
form.action = "https://test.authorize.net/profile/" + opt.action;
|
|
115
|
+
} else {
|
|
116
|
+
form.action = "https://secure.authorize.net/profile/" + opt.action;
|
|
117
|
+
}
|
|
118
|
+
if (form.elements["PaymentProfileId"]) form.elements["PaymentProfileId"].value = opt.paymentProfileId ? opt.paymentProfileId : "";
|
|
119
|
+
if (form.elements["ShippingAddressId"]) form.elements["ShippingAddressId"].value = opt.shippingAddressId ? opt.shippingAddressId : "";
|
|
120
|
+
form.submit();
|
|
121
|
+
|
|
122
|
+
popup.style.display = "";
|
|
123
|
+
popupScreen.style.display = "";
|
|
124
|
+
centerPopup();
|
|
125
|
+
adjustPopupScreen();
|
|
126
|
+
};
|
|
127
|
+
function centerPopup() {
|
|
128
|
+
var d = document.getElementById("divAuthorizeNetPopup");
|
|
129
|
+
d.style.left = "50%";
|
|
130
|
+
d.style.top = "50%";
|
|
131
|
+
var left = -Math.floor(d.clientWidth / 2);
|
|
132
|
+
var top = -Math.floor(d.clientHeight / 2);
|
|
133
|
+
d.style.marginLeft = left.toString() + "px";
|
|
134
|
+
d.style.marginTop = top.toString() + "px";
|
|
135
|
+
if (d.offsetLeft < 16) {
|
|
136
|
+
d.style.left = "16px";
|
|
137
|
+
d.style.marginLeft = "0px";
|
|
138
|
+
}
|
|
139
|
+
if (d.offsetTop < 16) {
|
|
140
|
+
d.style.top = "16px";
|
|
141
|
+
d.style.marginTop = "0px";
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
function adjustPopupScreen() { // IE6 fix
|
|
145
|
+
var popupScreen = document.getElementById("divAuthorizeNetPopupScreen");
|
|
146
|
+
if (popupScreen.currentStyle && popupScreen.currentStyle.position == "absolute") {
|
|
147
|
+
if (popupScreen.clientHeight < document.documentElement.scrollHeight) {
|
|
148
|
+
popupScreen.style.height = document.documentElement.scrollHeight.toString() + "px";
|
|
149
|
+
}
|
|
150
|
+
if (popupScreen.clientWidth < document.documentElement.scrollWidth) {
|
|
151
|
+
popupScreen.style.width = document.documentElement.scrollWidth.toString() + "px";
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
}
|
|
155
|
+
function getHightestZIndex() {
|
|
156
|
+
var max = 0;
|
|
157
|
+
var z = 0;
|
|
158
|
+
var a = document.getElementsByTagName('*');
|
|
159
|
+
for (var i = 0; i < a.length; i++) {
|
|
160
|
+
z = 0;
|
|
161
|
+
if (a[i].currentStyle) {
|
|
162
|
+
var style = a[i].currentStyle;
|
|
163
|
+
if (style.display != "none") {
|
|
164
|
+
z = parseFloat(style.zIndex);
|
|
165
|
+
}
|
|
166
|
+
} else if (window.getComputedStyle) {
|
|
167
|
+
var style = window.getComputedStyle(a[i], null);
|
|
168
|
+
if (style.getPropertyValue("display") != "none") {
|
|
169
|
+
z = parseFloat(style.getPropertyValue("z-index"));
|
|
170
|
+
}
|
|
171
|
+
}
|
|
172
|
+
if (!isNaN(z) && z > max) max = z;
|
|
173
|
+
}
|
|
174
|
+
return Math.ceil(max);
|
|
175
|
+
}
|
|
176
|
+
function parseQueryString(str) {
|
|
177
|
+
var vars = [];
|
|
178
|
+
var arr = str.split('&');
|
|
179
|
+
var pair;
|
|
180
|
+
for (var i = 0; i < arr.length; i++) {
|
|
181
|
+
pair = arr[i].split('=');
|
|
182
|
+
vars.push(pair[0]);
|
|
183
|
+
vars[pair[0]] = unescape(pair[1]);
|
|
184
|
+
}
|
|
185
|
+
return vars;
|
|
186
|
+
}
|
|
187
|
+
} ());
|
|
@@ -56,13 +56,18 @@ Caboose.Store.Modules.Cart = (function() {
|
|
|
56
56
|
};
|
|
57
57
|
|
|
58
58
|
self.render_item_count = function(item_count) {
|
|
59
|
-
var $link = $('#cart-link, .cart-link');
|
|
60
|
-
if (!$link.length) return false;
|
|
61
|
-
|
|
62
|
-
function set_count(count) {
|
|
63
|
-
if
|
|
64
|
-
|
|
65
|
-
else
|
|
59
|
+
var $link = $('#cart-link, .cart-link');
|
|
60
|
+
//if (!$link.length) return false;
|
|
61
|
+
|
|
62
|
+
function set_count(count) {
|
|
63
|
+
if ($('#cart_item_count').length > 0)
|
|
64
|
+
$('#cart_item_count').html(count);
|
|
65
|
+
else if ($link.length > 0)
|
|
66
|
+
{
|
|
67
|
+
if ($link.children('i') && count < 1) { $link.children('i').remove(); }
|
|
68
|
+
else if ($link.children('i').length) { $link.children('i').empty().text(count); }
|
|
69
|
+
else { $link.append($('<i/>').text(count)); }
|
|
70
|
+
}
|
|
66
71
|
};
|
|
67
72
|
|
|
68
73
|
if (item_count) {
|
|
@@ -94,7 +99,7 @@ Caboose.Store.Modules.Cart = (function() {
|
|
|
94
99
|
type: $form.attr('method'),
|
|
95
100
|
url: $form.attr('action'),
|
|
96
101
|
data: $form.serialize(),
|
|
97
|
-
success: function(response) {
|
|
102
|
+
success: function(response) {
|
|
98
103
|
if (response.success) {
|
|
99
104
|
self.render_item_count(response.item_count);
|
|
100
105
|
if (self.$add_to_cart.length) self.$add_to_cart.trigger('added');
|
|
@@ -7,13 +7,13 @@ Caboose.Store.Modules.CheckoutStep4 = (function() {
|
|
|
7
7
|
|
|
8
8
|
self.initialize = function() {
|
|
9
9
|
$('#checkout-confirm').hide();
|
|
10
|
-
|
|
10
|
+
$('#relay').hide();
|
|
11
11
|
self.bind_event_handlers();
|
|
12
12
|
self.expiration_change_handler();
|
|
13
13
|
};
|
|
14
14
|
|
|
15
15
|
self.bind_event_handlers = function() {
|
|
16
|
-
$('#
|
|
16
|
+
$('#payment select').change(self.expiration_change_handler);
|
|
17
17
|
$('#checkout-continue button').click(self.continue_handler);
|
|
18
18
|
$('#checkout-confirm #edit_payment').click(self.edit_payment_handler);
|
|
19
19
|
|
|
@@ -29,8 +29,7 @@ Caboose.Store.Modules.CheckoutStep4 = (function() {
|
|
|
29
29
|
$('#expiration').val(month + year);
|
|
30
30
|
};
|
|
31
31
|
|
|
32
|
-
self.continue_handler = function(event) {
|
|
33
|
-
alert('Testing');
|
|
32
|
+
self.continue_handler = function(event) {
|
|
34
33
|
if (!self.is_confirm)
|
|
35
34
|
{
|
|
36
35
|
var cc = $('#billing-cc-number').val();
|
|
@@ -40,9 +39,7 @@ Caboose.Store.Modules.CheckoutStep4 = (function() {
|
|
|
40
39
|
{
|
|
41
40
|
$('#message').empty();
|
|
42
41
|
$('#checkout-payment').hide();
|
|
43
|
-
$('#checkout-confirm').show();
|
|
44
|
-
$('#checkout_nav4 a').removeClass('current').addClass('done');
|
|
45
|
-
$('#checkout_nav5 a').removeClass('not_done').addClass('current');
|
|
42
|
+
$('#checkout-confirm').show();
|
|
46
43
|
$('#confirm_card_number').html("Card ending in " + cc.substr(-4));
|
|
47
44
|
$('#checkout-continue button').html("Confirm order");
|
|
48
45
|
self.is_confirm = true;
|
|
@@ -89,10 +86,11 @@ Caboose.Store.Modules.CheckoutStep4 = (function() {
|
|
|
89
86
|
function relay_handler(resp)
|
|
90
87
|
{
|
|
91
88
|
console.log('RELAY');
|
|
89
|
+
console.log(resp);
|
|
92
90
|
if (resp.success == true)
|
|
93
91
|
window.location = '/checkout/thanks';
|
|
94
|
-
else if (resp.
|
|
95
|
-
$('#message').html("<p class='note error'>" + resp.
|
|
92
|
+
else if (resp.error)
|
|
93
|
+
$('#message').html("<p class='note error'>" + resp.error + "</p>");
|
|
96
94
|
else
|
|
97
95
|
$('#message').html("<p class='note error'>There was an error processing your payment.</p>");
|
|
98
96
|
}
|
|
@@ -55,10 +55,16 @@ module Caboose
|
|
|
55
55
|
# Initialize the cart in the session
|
|
56
56
|
def init_cart
|
|
57
57
|
# Check if the cart ID is defined and that it exists in the database
|
|
58
|
-
|
|
58
|
+
create_new_order = false
|
|
59
|
+
if session[:cart_id]
|
|
60
|
+
@order = Caboose::Order.where(:id => session[:cart_id]).first
|
|
61
|
+
create_new_order = true if @order.nil? || @order.status != 'cart'
|
|
62
|
+
else
|
|
63
|
+
create_new_order = true
|
|
64
|
+
end
|
|
59
65
|
|
|
60
|
-
|
|
61
|
-
order = Caboose::Order.create(
|
|
66
|
+
if create_new_order # Create an order to associate with the session
|
|
67
|
+
@order = Caboose::Order.create(
|
|
62
68
|
:site_id => @site.id,
|
|
63
69
|
:status => Caboose::Order::STATUS_CART,
|
|
64
70
|
:financial_status => Caboose::Order::STATUS_PENDING,
|
|
@@ -67,13 +73,9 @@ module Caboose
|
|
|
67
73
|
:landing_page => request.fullpath,
|
|
68
74
|
:landing_page_ref => params[:ref] || nil
|
|
69
75
|
)
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
end
|
|
74
|
-
|
|
75
|
-
# Log the order and set an instance variable up
|
|
76
|
-
@order = Caboose::Order.find(session[:cart_id])
|
|
76
|
+
# Save the cart ID in the session
|
|
77
|
+
session[:cart_id] = @order.id
|
|
78
|
+
end
|
|
77
79
|
end
|
|
78
80
|
|
|
79
81
|
# Parses any parameters in the URL and adds them to the params
|
|
@@ -12,7 +12,7 @@ module Caboose
|
|
|
12
12
|
|
|
13
13
|
# GET /cart/item-count
|
|
14
14
|
def item_count
|
|
15
|
-
render :json => { :item_count => @order.
|
|
15
|
+
render :json => { :item_count => @order.item_count }
|
|
16
16
|
end
|
|
17
17
|
|
|
18
18
|
# POST /cart
|
|
@@ -30,11 +30,11 @@ module Caboose
|
|
|
30
30
|
:quantity => qty,
|
|
31
31
|
:status => 'pending'
|
|
32
32
|
)
|
|
33
|
-
end
|
|
33
|
+
end
|
|
34
34
|
render :json => {
|
|
35
35
|
:success => li.save,
|
|
36
36
|
:errors => li.errors.full_messages,
|
|
37
|
-
:item_count => @order.
|
|
37
|
+
:item_count => @order.item_count
|
|
38
38
|
}
|
|
39
39
|
end
|
|
40
40
|
|
|
@@ -1,35 +1,10 @@
|
|
|
1
|
-
#def calc_shipping_rates(order)
|
|
2
|
-
# weight = 0.0
|
|
3
|
-
# order.line_items.each do |li|
|
|
4
|
-
# w = li.variant.weight ? li.variant.weight : 0.0
|
|
5
|
-
# weight = weight + (w * li.quantity)
|
|
6
|
-
# end
|
|
7
|
-
#
|
|
8
|
-
# shipping = 0.0
|
|
9
|
-
# shipping = 8.00 if weight >= 0.010 && weight <= 3.000
|
|
10
|
-
# shipping = 10.00 if weight >= 3.001 && weight <= 6.000
|
|
11
|
-
# shipping = 12.00 if weight >= 6.001 && weight <= 8.000
|
|
12
|
-
# shipping = 15.00 if weight >= 8.001 && weight <= 12.000
|
|
13
|
-
# shipping = order.total * 0.05 if weight > 12.000
|
|
14
|
-
#
|
|
15
|
-
# rates = [
|
|
16
|
-
# { :carrier => 'UPS' , :service_code => 'GND' , :service_name => 'Ground' , :total_price => shipping + (order.total > 49 ? 0.00 : 7.95) },
|
|
17
|
-
# { :carrier => 'UPS' , :service_code => '3DS' , :service_name => 'UPS 3 Day Air' , :total_price => shipping + 12.95 },
|
|
18
|
-
# { :carrier => 'UPS' , :service_code => '2DA' , :service_name => 'UPS 2 Day Air' , :total_price => shipping + 19.95 },
|
|
19
|
-
# { :carrier => 'UPS' , :service_code => '1DA' , :service_name => 'UPS Next Day Air' , :total_price => shipping + 32.95 },
|
|
20
|
-
# { :carrier => 'USPS' , :service_code => 'Priority Mail 3-Day' , :service_name => 'USPS Priority Mail' , :total_price => shipping + 12.95 },
|
|
21
|
-
# { :carrier => 'USPS' , :service_code => 'Priority Mail 2-Day' , :service_name => 'USPS Express Mail' , :total_price => shipping + 24.95 }
|
|
22
|
-
# ]
|
|
23
|
-
#
|
|
24
|
-
# return [rates]
|
|
25
|
-
#end
|
|
26
1
|
|
|
27
2
|
module Caboose
|
|
28
3
|
class CheckoutController < Caboose::ApplicationController
|
|
29
4
|
|
|
30
5
|
helper :authorize_net
|
|
31
6
|
before_filter :ensure_line_items, :only => [:step_one, :step_two]
|
|
32
|
-
protect_from_forgery :except => :
|
|
7
|
+
protect_from_forgery :except => :authnet_relay
|
|
33
8
|
|
|
34
9
|
def ensure_line_items
|
|
35
10
|
redirect_to '/checkout/empty' if @order.line_items.empty?
|
|
@@ -94,14 +69,20 @@ module Caboose
|
|
|
94
69
|
store_config = @site.store_config
|
|
95
70
|
case store_config.pp_name
|
|
96
71
|
when 'authorize.net'
|
|
72
|
+
|
|
73
|
+
sc = @site.store_config
|
|
97
74
|
@sim_transaction = AuthorizeNet::SIM::Transaction.new(
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
@order.total,
|
|
101
|
-
|
|
102
|
-
:
|
|
75
|
+
sc.pp_username,
|
|
76
|
+
sc.pp_password,
|
|
77
|
+
@order.total,
|
|
78
|
+
#:relay_url => "#{request.protocol}#{request.host_with_port}/checkout/authnet-relay/#{@order.id}",
|
|
79
|
+
:relay_response => 'TRUE',
|
|
80
|
+
:relay_url => "#{request.protocol}#{request.host_with_port}/checkout/authnet-relay",
|
|
81
|
+
:transaction_type => 'AUTH_ONLY',
|
|
103
82
|
:test => true
|
|
104
83
|
)
|
|
84
|
+
@request = request
|
|
85
|
+
|
|
105
86
|
when 'payscape'
|
|
106
87
|
@form_url = Caboose::PaymentProcessor.form_url(@order)
|
|
107
88
|
end
|
|
@@ -250,45 +231,54 @@ module Caboose
|
|
|
250
231
|
# end
|
|
251
232
|
# render :layout => false
|
|
252
233
|
#end
|
|
253
|
-
|
|
254
|
-
# POST /checkout/relay
|
|
255
|
-
def
|
|
256
|
-
|
|
257
|
-
@order = Caboose::Order.find(params[:order_id])
|
|
258
|
-
@success = Caboose::PaymentProcessor.authorize(@order, params)
|
|
259
|
-
@message = @success ? 'Payment processed successfully' : 'There was a problem processing your payment'
|
|
234
|
+
|
|
235
|
+
# POST /checkout/authnet-relay
|
|
236
|
+
def authnet_relay
|
|
237
|
+
Caboose.log("Authorize.net relay, order #{params[:x_invoice_id]}")
|
|
260
238
|
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
# @message = jarams[:x_response_reason_text]
|
|
265
|
-
# @order.transaction_id = params[:x_trans_id] if params[:x_trans_id]
|
|
266
|
-
# when 'payscape'
|
|
267
|
-
# @success = Caboose::PaymentProcessor.authorize(@order, params)
|
|
268
|
-
# @message = @success ? 'Payment processed successfully' : 'There was a problem processing your payment'
|
|
269
|
-
# @order.transaction_id = params['transaction-id'] if params['transaction-id']
|
|
270
|
-
#end
|
|
239
|
+
order = Caboose::Order.find(params[:x_invoice_num])
|
|
240
|
+
order.transaction_id = params[:x_trans_id] if params[:x_trans_id]
|
|
241
|
+
success = params[:x_response_code] && params[:x_response_code] == '1'
|
|
271
242
|
|
|
272
|
-
if
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
# Clear cart
|
|
279
|
-
session[:cart_id] = nil
|
|
243
|
+
if success
|
|
244
|
+
order.financial_status = 'authorized'
|
|
245
|
+
order.status = 'pending'
|
|
246
|
+
order.date_authorized = DateTime.now
|
|
247
|
+
order.auth_amount = order.total
|
|
280
248
|
|
|
281
249
|
# Send out emails
|
|
282
|
-
OrdersMailer.customer_new_order(
|
|
283
|
-
OrdersMailer.fulfillment_new_order(
|
|
250
|
+
OrdersMailer.customer_new_order(order).deliver
|
|
251
|
+
OrdersMailer.fulfillment_new_order(order).deliver
|
|
284
252
|
|
|
285
253
|
# Emit order event
|
|
286
|
-
Caboose.plugin_hook('order_authorized',
|
|
254
|
+
Caboose.plugin_hook('order_authorized', order)
|
|
287
255
|
else
|
|
288
|
-
|
|
256
|
+
order.financial_status = 'unauthorized'
|
|
257
|
+
error = "There was a problem processing your payment."
|
|
258
|
+
end
|
|
259
|
+
|
|
260
|
+
order.save
|
|
261
|
+
|
|
262
|
+
@url = params[:x_after_relay]
|
|
263
|
+
@url << (success ? "?success=1" : "?error=#{error}")
|
|
264
|
+
|
|
265
|
+
render :layout => false
|
|
266
|
+
end
|
|
267
|
+
|
|
268
|
+
# GET /checkout/authnet-response/:order_id
|
|
269
|
+
# POST /checkout/authnet-response/:order_id
|
|
270
|
+
def authnet_response
|
|
271
|
+
Caboose.log("Authorize.net response, order #{params[:order_id]}")
|
|
272
|
+
|
|
273
|
+
@resp = Caboose::StdClass.new
|
|
274
|
+
@resp.success = true if params[:success]
|
|
275
|
+
@resp.error = params[:error] if params[:error]
|
|
276
|
+
|
|
277
|
+
if @resp.success
|
|
278
|
+
session[:cart_id] = nil
|
|
279
|
+
init_cart
|
|
289
280
|
end
|
|
290
281
|
|
|
291
|
-
@order.save
|
|
292
282
|
render :layout => false
|
|
293
283
|
end
|
|
294
284
|
|