caboose-cms 0.7.85 → 0.8.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/app/assets/javascripts/caboose/{admin_edit_order.js → admin_edit_invoice.js} +332 -189
- data/app/assets/javascripts/caboose/cart.js +15 -15
- data/app/assets/javascripts/caboose/cart_old.js +2 -2
- data/app/assets/javascripts/caboose/checkout/authnet_payment_method_controller.js +120 -0
- data/app/assets/javascripts/caboose/checkout/billing_address_controller.js +85 -0
- data/app/assets/javascripts/caboose/checkout/cart_controller.js +257 -0
- data/app/assets/javascripts/caboose/checkout/checkout_controller.js +258 -0
- data/app/assets/javascripts/caboose/checkout/gift_cards_controller.js +57 -0
- data/app/assets/javascripts/caboose/checkout/shipping_address_controller.js +86 -0
- data/app/assets/javascripts/caboose/checkout/shipping_method_controller.js +121 -0
- data/app/assets/javascripts/caboose/checkout/stripe_payment_method_controller.js +155 -0
- data/app/assets/javascripts/caboose/checkout_login_register.js +2 -2
- data/app/assets/javascripts/caboose/checkout_module.js +8 -8
- data/app/assets/javascripts/caboose/checkout_old.js +151 -0
- data/app/assets/javascripts/caboose/{checkout_payment.js → checkout_payment_authnet.js} +1 -1
- data/app/assets/javascripts/caboose/checkout_payment_stripe.js +212 -0
- data/app/assets/javascripts/caboose/checkout_shipping.js +1 -1
- data/app/assets/javascripts/caboose/jquery.payment.js +1 -0
- data/app/assets/javascripts/caboose/model/attribute.js +3 -2
- data/app/assets/javascripts/caboose/model/bound_control.js +56 -14
- data/app/assets/javascripts/caboose/model/bound_select.js +9 -11
- data/app/assets/javascripts/caboose/model/bound_select_simple.js +215 -0
- data/app/assets/javascripts/caboose/model/bound_text.js +7 -8
- data/app/assets/javascripts/caboose/{my_account_edit_order.js → my_account_edit_invoice.js} +55 -55
- data/app/assets/javascripts/caboose/united_states.js +65 -0
- data/app/assets/stylesheets/caboose/{my_account_edit_order.css.scss → my_account_edit_invoice.css.scss} +1 -1
- data/app/assets/templates/caboose/cart/line_items.jst.ejs +3 -3
- data/app/assets/templates/caboose/checkout/line_items.jst.ejs +7 -7
- data/app/controllers/caboose/ab_options_controller.rb +4 -4
- data/app/controllers/caboose/ab_variants_controller.rb +5 -5
- data/app/controllers/caboose/admin_controller.rb +0 -6
- data/app/controllers/caboose/application_controller.rb +16 -15
- data/app/controllers/caboose/billing_addresses_controller.rb +22 -22
- data/app/controllers/caboose/block_type_sources_controller.rb +8 -8
- data/app/controllers/caboose/block_types_controller.rb +2 -42
- data/app/controllers/caboose/blocks_controller.rb +26 -26
- data/app/controllers/caboose/calendars_controller.rb +5 -5
- data/app/controllers/caboose/cart_controller.rb +55 -36
- data/app/controllers/caboose/categories_controller.rb +78 -76
- data/app/controllers/caboose/checkout_controller.rb +313 -340
- data/app/controllers/caboose/checkout_controller_bak.rb +620 -0
- data/app/controllers/caboose/domains_controller.rb +5 -5
- data/app/controllers/caboose/event_groups_controller.rb +26 -4
- data/app/controllers/caboose/events_controller.rb +7 -6
- data/app/controllers/caboose/fonts_controller.rb +2 -2
- data/app/controllers/caboose/gift_cards_controller.rb +113 -139
- data/app/controllers/caboose/google_spreadsheets_controller.rb +1 -1
- data/app/controllers/caboose/{order_packages_controller.rb → invoice_packages_controller.rb} +49 -49
- data/app/controllers/caboose/{order_reports_controller.rb → invoice_reports_controller.rb} +11 -13
- data/app/controllers/caboose/invoice_transactions_controller.rb +35 -0
- data/app/controllers/caboose/invoices_controller.rb +328 -0
- data/app/controllers/caboose/line_items_controller.rb +35 -34
- data/app/controllers/caboose/login_controller.rb +7 -7
- data/app/controllers/caboose/login_logs_controller.rb +4 -4
- data/app/controllers/caboose/logout_controller.rb +3 -1
- data/app/controllers/caboose/media_categories_controller.rb +9 -9
- data/app/controllers/caboose/media_controller.rb +21 -46
- data/app/controllers/caboose/modal_controller.rb +4 -3
- data/app/controllers/caboose/modification_values_controller.rb +6 -6
- data/app/controllers/caboose/modifications_controller.rb +7 -6
- data/app/controllers/caboose/my_account_controller.rb +2 -2
- data/app/controllers/caboose/my_account_invoices_controller.rb +166 -0
- data/app/controllers/caboose/my_account_line_items_controller.rb +15 -13
- data/app/controllers/caboose/page_custom_fields_controller.rb +9 -8
- data/app/controllers/caboose/page_permissions_controller.rb +3 -3
- data/app/controllers/caboose/pages_controller.rb +132 -135
- data/app/controllers/caboose/permissions_controller.rb +8 -7
- data/app/controllers/caboose/post_categories_controller.rb +22 -7
- data/app/controllers/caboose/post_custom_fields_controller.rb +9 -8
- data/app/controllers/caboose/posts_controller.rb +35 -43
- data/app/controllers/caboose/product_images_controller.rb +5 -5
- data/app/controllers/caboose/products_controller.rb +53 -47
- data/app/controllers/caboose/redirects_controller.rb +7 -7
- data/app/controllers/caboose/register_controller.rb +2 -2
- data/app/controllers/caboose/retargeting_controller.rb +2 -61
- data/app/controllers/caboose/reviews_controller.rb +1 -0
- data/app/controllers/caboose/roles_controller.rb +10 -9
- data/app/controllers/caboose/settings_controller.rb +9 -7
- data/app/controllers/caboose/shipping_addresses_controller.rb +18 -18
- data/app/controllers/caboose/shipping_packages_controller.rb +24 -21
- data/app/controllers/caboose/sites_controller.rb +35 -25
- data/app/controllers/caboose/smtp_controller.rb +3 -3
- data/app/controllers/caboose/sns_controller.rb +6 -6
- data/app/controllers/caboose/social_controller.rb +5 -6
- data/app/controllers/caboose/stackable_groups_controller.rb +10 -8
- data/app/controllers/caboose/station_controller.rb +3 -3
- data/app/controllers/caboose/store_controller.rb +93 -87
- data/app/controllers/caboose/subscriptions_controller.rb +153 -0
- data/app/controllers/caboose/users_controller.rb +25 -22
- data/app/controllers/caboose/variants_controller.rb +72 -93
- data/app/controllers/caboose/vendors_controller.rb +35 -32
- data/app/mailers/caboose/{orders_mailer.rb → invoices_mailer.rb} +21 -21
- data/app/mailers/caboose/login_mailer.rb +3 -3
- data/app/models/caboose/authnet.rb +295 -195
- data/app/models/caboose/comment_routes.rb +68 -41
- data/app/models/caboose/core_plugin.rb +1 -1
- data/app/models/caboose/discount.rb +14 -3
- data/app/models/caboose/domain_constraint.rb +11 -3
- data/app/models/caboose/gift_card.rb +8 -8
- data/app/models/caboose/invoice.rb +706 -0
- data/app/models/caboose/invoice_discount.rb +10 -0
- data/app/models/caboose/invoice_package.rb +76 -0
- data/app/models/caboose/{order_package_calculator.rb → invoice_package_calculator.rb} +20 -20
- data/app/models/caboose/{order_pdf.rb → invoice_pdf.rb} +30 -30
- data/app/models/caboose/{order_reporter.rb → invoice_reporter.rb} +5 -5
- data/app/models/caboose/invoice_transaction.rb +169 -0
- data/app/models/caboose/line_item.rb +11 -8
- data/app/models/caboose/payment_processors/authorizenet.rb +15 -15
- data/app/models/caboose/payment_processors/base.rb +3 -3
- data/app/models/caboose/{pending_orders_pdf.rb → pending_invoices_pdf.rb} +31 -31
- data/app/models/caboose/product.rb +2 -4
- data/app/models/caboose/schema.rb +159 -111
- data/app/models/caboose/shipping_calculator.rb +41 -139
- data/app/models/caboose/smtp_config.rb +2 -1
- data/app/models/caboose/store_config.rb +7 -7
- data/app/models/caboose/subscription.rb +32 -0
- data/app/models/caboose/tax_calculator.rb +36 -36
- data/app/models/caboose/user.rb +6 -0
- data/app/models/caboose/user_subscription.rb +142 -0
- data/app/models/caboose/wish_list.rb +14 -0
- data/app/models/caboose/wish_list_line_item.rb +13 -0
- data/app/views/caboose/blocks/_products.html.erb +10 -13
- data/app/views/caboose/checkout/_address_form.html.erb +14 -14
- data/app/views/caboose/checkout/_billing_form.html.erb +3 -3
- data/app/views/caboose/checkout/_cart.html.erb +7 -7
- data/app/views/caboose/checkout/_cart_old.html.erb +9 -9
- data/app/views/caboose/checkout/_confirm.html.erb +9 -9
- data/app/views/caboose/checkout/_order_discount.html.erb +3 -3
- data/app/views/caboose/checkout/_shipping_address.html.erb +1 -1
- data/app/views/caboose/checkout/_shipping_method.html.erb +1 -1
- data/app/views/caboose/checkout/addresses.html.erb +10 -10
- data/app/views/caboose/checkout/authnet.html.erb +34 -0
- data/app/views/caboose/checkout/authnet_response_handler.html.erb +3 -0
- data/app/views/caboose/checkout/checkout.html.erb +100 -0
- data/app/views/caboose/checkout/confirm_without_payment.html.erb +6 -6
- data/app/views/caboose/checkout/discount.html.erb +1 -1
- data/app/views/caboose/checkout/index.html.erb +4 -4
- data/app/views/caboose/checkout/payment_authnet.html.erb +140 -0
- data/app/views/caboose/checkout/payment_stripe.html.erb +95 -0
- data/app/views/caboose/checkout/shipping.html.erb +4 -4
- data/app/views/caboose/checkout/thanks.html.erb +3 -3
- data/app/views/caboose/gift_cards/admin_edit.html.erb +19 -19
- data/app/views/caboose/gift_cards/admin_index.html.erb +9 -9
- data/app/views/caboose/{orders → invoices}/_admin_footer.html.erb +0 -0
- data/app/views/caboose/{orders → invoices}/_admin_header.html.erb +0 -0
- data/app/views/caboose/{orders/_quickbooks_order.html.erb → invoices/_quickbooks_invoice.html.erb} +0 -0
- data/app/views/caboose/{orders → invoices}/admin_city_report.html.erb +1 -1
- data/app/views/caboose/invoices/admin_delete_form.html.erb +18 -0
- data/app/views/caboose/{orders → invoices}/admin_edit.html.erb +14 -14
- data/app/views/caboose/{orders → invoices}/admin_index.html.erb +24 -24
- data/app/views/caboose/{orders → invoices}/admin_invalid_order.html.erb +2 -2
- data/app/views/caboose/{orders → invoices}/admin_new.html.erb +7 -7
- data/app/views/caboose/{orders → invoices}/admin_print.html.erb +15 -15
- data/app/views/caboose/{orders → invoices}/admin_summary_report.html.erb +4 -4
- data/app/views/caboose/{orders_mailer/customer_new_order.html.erb → invoices_mailer/customer_new_invoice.html.erb} +21 -21
- data/app/views/caboose/invoices_mailer/customer_payment_authorization.html.erb +5 -0
- data/app/views/caboose/{orders_mailer → invoices_mailer}/customer_status_updated.html.erb +22 -22
- data/app/views/caboose/{orders_mailer/fulfillment_new_order.html.erb → invoices_mailer/fulfillment_new_invoice.html.erb} +23 -23
- data/app/views/caboose/{orders_mailer/shipping_order_ready.html.erb → invoices_mailer/shipping_invoice_ready.html.erb} +0 -0
- data/app/views/caboose/{orders_mailer → invoices_mailer}/test_email.html.erb +0 -0
- data/app/views/caboose/line_items/admin_new.html.erb +1 -1
- data/app/views/caboose/login_mailer/forgot_password_email.html.erb +2 -3
- data/app/views/caboose/my_account/index.html.erb +1 -1
- data/app/views/caboose/{my_account_orders → my_account_invoices}/authnet_relay.html.erb +0 -0
- data/app/views/caboose/{my_account_orders → my_account_invoices}/authnet_response.html.erb +0 -0
- data/app/views/caboose/{my_account_orders → my_account_invoices}/edit.html.erb +9 -9
- data/app/views/caboose/my_account_invoices/index.html.erb +36 -0
- data/app/views/caboose/{my_account_orders → my_account_invoices}/payment_form.html.erb +10 -10
- data/app/views/caboose/post_categories/admin_index.html.erb +1 -1
- data/app/views/caboose/sites/admin_edit.html.erb +1 -1
- data/app/views/caboose/store/admin_edit_general.html.erb +5 -3
- data/app/views/caboose/store/admin_edit_packages.html.erb +6 -6
- data/app/views/caboose/store/admin_edit_shipping.html.erb +3 -3
- data/app/views/caboose/store/admin_edit_tax.html.erb +1 -1
- data/app/views/caboose/subscriptions/admin_edit.html.erb +82 -0
- data/app/views/caboose/subscriptions/admin_index.html.erb +45 -0
- data/config/routes.rb +1 -759
- data/config/routes_old.rb +759 -0
- data/lib/caboose/version.rb +1 -1
- data/lib/tasks/caboose.rake +41 -15
- metadata +101 -61
- data/app/controllers/caboose/my_account_orders_controller.rb +0 -165
- data/app/controllers/caboose/orders_controller.rb +0 -310
- data/app/models/caboose/order.rb +0 -479
- data/app/models/caboose/order_discount.rb +0 -10
- data/app/models/caboose/order_package.rb +0 -133
- data/app/models/caboose/order_transaction.rb +0 -41
- data/app/models/caboose/payment_processors/payscape.rb +0 -94
- data/app/views/caboose/checkout/payment.html.erb +0 -146
- data/app/views/caboose/my_account_orders/index.html.erb +0 -36
- data/app/views/caboose/orders/admin_delete_form.html.erb +0 -21
- data/app/views/caboose/orders_mailer/customer_payment_authorization.html.erb +0 -5
@@ -1,133 +0,0 @@
|
|
1
|
-
module Caboose
|
2
|
-
class OrderPackage < ActiveRecord::Base
|
3
|
-
self.table_name = 'store_order_packages'
|
4
|
-
|
5
|
-
belongs_to :order
|
6
|
-
belongs_to :shipping_package
|
7
|
-
belongs_to :shipping_method
|
8
|
-
has_many :line_items
|
9
|
-
attr_accessible :id,
|
10
|
-
:order_id,
|
11
|
-
:shipping_method_id,
|
12
|
-
:shipping_package_id,
|
13
|
-
:status,
|
14
|
-
:tracking_number,
|
15
|
-
:total
|
16
|
-
|
17
|
-
STATUS_PENDING = 'Pending'
|
18
|
-
STATUS_SHIPPED = 'Shipped'
|
19
|
-
|
20
|
-
after_initialize :check_nil_fields
|
21
|
-
|
22
|
-
def check_nil_fields
|
23
|
-
self.total = 0.00 if self.total.nil?
|
24
|
-
end
|
25
|
-
|
26
|
-
def self.custom_order_packages(store_config, order)
|
27
|
-
eval(store_config.custom_packages_function)
|
28
|
-
end
|
29
|
-
|
30
|
-
# Calculates the shipping packages required for all the items in the order
|
31
|
-
def self.create_for_order(order)
|
32
|
-
|
33
|
-
store_config = order.site.store_config
|
34
|
-
if !store_config.auto_calculate_packages
|
35
|
-
self.custom_order_packages(store_config, order)
|
36
|
-
return
|
37
|
-
end
|
38
|
-
|
39
|
-
# Make sure all the line items in the order have a quantity of 1
|
40
|
-
extra_line_items = []
|
41
|
-
order.line_items.each do |li|
|
42
|
-
if li.quantity > 1
|
43
|
-
(1..li.quantity).each{ |i|
|
44
|
-
extra_line_items << li.copy
|
45
|
-
}
|
46
|
-
li.quantity = 1
|
47
|
-
li.save
|
48
|
-
end
|
49
|
-
end
|
50
|
-
extra_line_items.each do |li|
|
51
|
-
li.quantity = 1
|
52
|
-
li.save
|
53
|
-
end
|
54
|
-
|
55
|
-
# Make sure all the items in the order have attributes set
|
56
|
-
order.line_items.each do |li|
|
57
|
-
v = li.variant
|
58
|
-
next if v.downloadable
|
59
|
-
Caboose.log("Error: variant #{v.id} has a zero weight") and return false if v.weight.nil? || v.weight == 0
|
60
|
-
next if v.volume && v.volume > 0
|
61
|
-
Caboose.log("Error: variant #{v.id} has a zero length") and return false if v.length.nil? || v.length == 0
|
62
|
-
Caboose.log("Error: variant #{v.id} has a zero width" ) and return false if v.width.nil? || v.width == 0
|
63
|
-
Caboose.log("Error: variant #{v.id} has a zero height") and return false if v.height.nil? || v.height == 0
|
64
|
-
v.volume = v.length * v.width * v.height
|
65
|
-
v.save
|
66
|
-
end
|
67
|
-
|
68
|
-
# Reorder the items in the order by volume
|
69
|
-
line_items = order.line_items.sort_by{ |li| li.quantity * (li.variant.volume ? li.variant.volume : 0.00) * -1 }
|
70
|
-
|
71
|
-
# Get all the packages we're going to use
|
72
|
-
all_packages = ShippingPackage.where(:site_id => order.site_id).reorder(:flat_rate_price).all
|
73
|
-
|
74
|
-
# Now go through each variant and fit it in a new or existing package
|
75
|
-
line_items.each do |li|
|
76
|
-
next if li.variant.downloadable
|
77
|
-
|
78
|
-
# See if the item will fit in any of the existing packages
|
79
|
-
it_fits = false
|
80
|
-
order.order_packages.all.each do |op|
|
81
|
-
it_fits = op.fits(li)
|
82
|
-
if it_fits
|
83
|
-
li.order_package_id = op.id
|
84
|
-
li.save
|
85
|
-
break
|
86
|
-
end
|
87
|
-
end
|
88
|
-
next if it_fits
|
89
|
-
|
90
|
-
# Otherwise find the cheapest package the item will fit into
|
91
|
-
it_fits = false
|
92
|
-
all_packages.each do |sp|
|
93
|
-
it_fits = sp.fits(li.variant)
|
94
|
-
if it_fits
|
95
|
-
op = OrderPackage.create(:order_id => order.id, :shipping_package_id => sp.id)
|
96
|
-
li.order_package_id = op.id
|
97
|
-
li.save
|
98
|
-
break
|
99
|
-
end
|
100
|
-
end
|
101
|
-
next if it_fits
|
102
|
-
|
103
|
-
Caboose.log("Error: line item #{li.id} (#{li.variant.product.title}) does not fit into any package.")
|
104
|
-
end
|
105
|
-
end
|
106
|
-
|
107
|
-
def fits(line_item = nil)
|
108
|
-
variants = self.line_items.collect{ |li| li.variant }
|
109
|
-
variants << line_item.variant if line_item
|
110
|
-
return self.shipping_package.fits(variants)
|
111
|
-
end
|
112
|
-
|
113
|
-
# Gets the activemerchant package based on the shipping package
|
114
|
-
def activemerchant_package
|
115
|
-
sc = self.order.site.store_config
|
116
|
-
|
117
|
-
weight = 0.0
|
118
|
-
self.line_items.each{ |li| weight = weight + (li.variant.weight * li.quantity) }
|
119
|
-
weight = weight * 0.035274 if sc.weight_unit == StoreConfig::WEIGHT_UNIT_METRIC # grams to ounces
|
120
|
-
|
121
|
-
sp = self.shipping_package
|
122
|
-
dimensions = [sp.outside_length, sp.outside_width, sp.outside_height]
|
123
|
-
if sc.length_unit == StoreConfig::LENGTH_UNIT_METRIC # cm to inches
|
124
|
-
dimensions[0] = dimensions[0] / 2.54
|
125
|
-
dimensions[1] = dimensions[0] / 2.54
|
126
|
-
dimensions[2] = dimensions[0] / 2.54
|
127
|
-
end
|
128
|
-
|
129
|
-
return ActiveShipping::Package.new(weight, dimensions, :units => :imperial, :container => :variable)
|
130
|
-
end
|
131
|
-
|
132
|
-
end
|
133
|
-
end
|
@@ -1,41 +0,0 @@
|
|
1
|
-
module Caboose
|
2
|
-
class OrderTransaction < ActiveRecord::Base
|
3
|
-
self.table_name = 'store_order_transactions'
|
4
|
-
self.primary_key = 'id'
|
5
|
-
|
6
|
-
belongs_to :order
|
7
|
-
attr_accessible :id,
|
8
|
-
:order_id,
|
9
|
-
:transaction_id,
|
10
|
-
:transaction_type,
|
11
|
-
:amount,
|
12
|
-
:auth_code,
|
13
|
-
:date_processed,
|
14
|
-
:response_code,
|
15
|
-
:success
|
16
|
-
|
17
|
-
TYPE_AUTHORIZE = 'auth'
|
18
|
-
TYPE_CAPTURE = 'capture'
|
19
|
-
TYPE_VOID = 'void'
|
20
|
-
TYPE_REFUND = 'refund'
|
21
|
-
|
22
|
-
after_initialize :check_nil_fields
|
23
|
-
|
24
|
-
def check_nil_fields
|
25
|
-
self.amount = 0.00 if self.amount.nil?
|
26
|
-
end
|
27
|
-
|
28
|
-
def self.type_from_authnet_status(status)
|
29
|
-
case status
|
30
|
-
when 'settledSuccessfully' then OrderTransaction::TYPE_CAPTURE
|
31
|
-
when 'voided' then OrderTransaction::TYPE_VOID
|
32
|
-
when 'declined' then OrderTransaction::TYPE_AUTHORIZE
|
33
|
-
when 'authorizedPendingCapture' then OrderTransaction::TYPE_AUTHORIZE
|
34
|
-
when 'refundSettledSuccessfully' then OrderTransaction::TYPE_REFUND
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
end
|
39
|
-
end
|
40
|
-
|
41
|
-
|
@@ -1,94 +0,0 @@
|
|
1
|
-
require "rexml/document"
|
2
|
-
|
3
|
-
class Caboose::PaymentProcessors::Payscape < Caboose::PaymentProcessors::Base
|
4
|
-
def self.api(root, body, test=false)
|
5
|
-
|
6
|
-
# Determine if transaction should be a test
|
7
|
-
body['api-key'] = if test or Rails.env == 'development'
|
8
|
-
'2F822Rw39fx762MaV7Yy86jXGTC7sCDy'
|
9
|
-
else
|
10
|
-
Caboose::api_key
|
11
|
-
end
|
12
|
-
|
13
|
-
ap "API key used: #{body['api-key']}"
|
14
|
-
# ap "AUTH USERNAME: #{Caboose::payscape_username}"
|
15
|
-
# ap "AUTH PASSWORD: #{Caboose::payscape_password}"
|
16
|
-
|
17
|
-
uri = URI.parse('https://secure.payscapegateway.com/api/v2/three-step')
|
18
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
19
|
-
http.use_ssl = true
|
20
|
-
request = Net::HTTP::Post.new(uri.path)
|
21
|
-
request.content_type = 'text/xml'
|
22
|
-
request.body = body.to_xml({:root => root})
|
23
|
-
xml_response = http.request(request)
|
24
|
-
document = REXML::Document.new(xml_response.body.to_s)
|
25
|
-
response = Hash.new
|
26
|
-
|
27
|
-
document.root.elements.each { |element| response[element.name] = element.text }
|
28
|
-
|
29
|
-
ap response
|
30
|
-
|
31
|
-
return response
|
32
|
-
end
|
33
|
-
|
34
|
-
def self.form_url(order)
|
35
|
-
response = self.api 'auth', {
|
36
|
-
'redirect-url' => "#{Caboose::store_url}/checkout/relay/#{order.id}",
|
37
|
-
'amount' => order.total.to_s,
|
38
|
-
'billing' => {
|
39
|
-
'first-name' => order.billing_address.first_name,
|
40
|
-
'last-name' => order.billing_address.last_name,
|
41
|
-
'address1' => order.billing_address.address1,
|
42
|
-
'address2' => order.billing_address.address2,
|
43
|
-
'city' => order.billing_address.city,
|
44
|
-
'state' => order.billing_address.state,
|
45
|
-
'postal' => order.billing_address.zip
|
46
|
-
}
|
47
|
-
}, order.test?
|
48
|
-
|
49
|
-
order.transaction_id = response['transaction-id']
|
50
|
-
order.transaction_service = 'payscape'
|
51
|
-
order.save
|
52
|
-
|
53
|
-
return response['form-url']
|
54
|
-
end
|
55
|
-
|
56
|
-
def self.authorized?(order)
|
57
|
-
uri = URI.parse("https://secure.payscapegateway.com/api/query.php?username=#{Caboose::payscape_username}&password=#{Caboose::payscape_password}&transaction_id=#{order.transaction_id}")
|
58
|
-
http = Net::HTTP.new(uri.host, uri.port)
|
59
|
-
http.use_ssl = true
|
60
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
61
|
-
request = Net::HTTP::Get.new(uri.request_uri)
|
62
|
-
response = http.request(request)
|
63
|
-
document = Nokogiri::XML response.body
|
64
|
-
actions = Hash.new
|
65
|
-
|
66
|
-
document.xpath('//action').each { |action| actions[action.xpath('action_type').text] = action.xpath('success').text == '1' }
|
67
|
-
return actions['auth']
|
68
|
-
end
|
69
|
-
|
70
|
-
def self.authorize(order, params)
|
71
|
-
response = self.api 'complete-action', { 'token-id' => params['token-id'] }, order.test?
|
72
|
-
order.update_attribute(:transaction_id, params['transaction-id']) if params['transaction-id']
|
73
|
-
return response['result-code'].to_i == 100
|
74
|
-
end
|
75
|
-
|
76
|
-
def self.void(order)
|
77
|
-
response = self.api 'void', { 'transaction-id' => order.transaction_id }, order.test?
|
78
|
-
return response['result-code'].to_i == 100
|
79
|
-
end
|
80
|
-
|
81
|
-
def self.capture(order)
|
82
|
-
response = self.api 'capture', { 'transaction-id' => order.transaction_id }, order.test?
|
83
|
-
return response['result-code'].to_i == 100
|
84
|
-
end
|
85
|
-
|
86
|
-
def self.refund(order)
|
87
|
-
response = self.api 'refund', {
|
88
|
-
'transaction-id' => order.transaction_id,
|
89
|
-
'amount' => order.total.to_s
|
90
|
-
}, order.test?
|
91
|
-
|
92
|
-
return response['result-code'].to_i == 100
|
93
|
-
end
|
94
|
-
end
|
@@ -1,146 +0,0 @@
|
|
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.authnet_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>
|
33
|
-
|
34
|
-
<div class="field" id="expiry">
|
35
|
-
<span class="field-text">Expiry</span>
|
36
|
-
<input id="expiration" name="x_exp_date" type="hidden" />
|
37
|
-
<select id="month" name="month">
|
38
|
-
<option value="01">01 - Jan</option>
|
39
|
-
<option value="02">02 - Feb</option>
|
40
|
-
<option value="03">03 - Mar</option>
|
41
|
-
<option value="04">04 - Apr</option>
|
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>
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
</form>
|
63
|
-
<% end %>
|
64
|
-
</section>
|
65
|
-
<section id='checkout-confirm'>
|
66
|
-
<% if @order.has_shippable_items? %>
|
67
|
-
<section id='shipping_address'>
|
68
|
-
<h3>Shipping Address</h3>
|
69
|
-
<% sa = @order.shipping_address %>
|
70
|
-
<address>
|
71
|
-
<%= "#{sa.first_name} #{sa.last_name}" %><br />
|
72
|
-
<%= sa.address1 %><br />
|
73
|
-
<%= "#{sa.address2}<br />" if sa.address2 and not sa.address2.empty? %>
|
74
|
-
<%= "#{sa.city}, #{sa.state} #{sa.zip}" %>
|
75
|
-
</address>
|
76
|
-
<p><a href="/checkout/addresses">Edit</a></p>
|
77
|
-
</section>
|
78
|
-
<% end %>
|
79
|
-
<section id='billing_address'>
|
80
|
-
<h3>Billing Address</h3>
|
81
|
-
<% ba = @order.billing_address %>
|
82
|
-
<address>
|
83
|
-
<%= "#{ba.first_name} #{ba.last_name}" %><br />
|
84
|
-
<%= ba.address1 %><br />
|
85
|
-
<%= "#{ba.address2}<br />" if ba.address2 and not ba.address2.empty? %>
|
86
|
-
<%= "#{ba.city}, #{ba.state} #{ba.zip}" %>
|
87
|
-
</address>
|
88
|
-
<p><a href="/checkout/addresses">Edit</a></p>
|
89
|
-
</section>
|
90
|
-
<% if @order.has_shippable_items? %>
|
91
|
-
<section id='shipping_method'>
|
92
|
-
<h3>Shipping</h3>
|
93
|
-
<% @order.order_packages.all.each do |op| %>
|
94
|
-
<p><%= op.shipping_method.service_name %> - <%= number_to_currency(op.total) %></p>
|
95
|
-
<% end %>
|
96
|
-
<p><a href="/checkout/shipping">Edit</a></p>
|
97
|
-
</section>
|
98
|
-
<% end %>
|
99
|
-
<section id='payment_method'>
|
100
|
-
<h3>Payment Method</h3>
|
101
|
-
<div id='confirm_card'>
|
102
|
-
<p id='confirm_card_number'></p>
|
103
|
-
<p><a href="#" id='edit_payment'>Edit</a></p>
|
104
|
-
</div>
|
105
|
-
</section>
|
106
|
-
<div style='clear: left;'> </div>
|
107
|
-
</section>
|
108
|
-
<section>
|
109
|
-
<div id='cart'></div>
|
110
|
-
</section>
|
111
|
-
<section id="checkout-continue">
|
112
|
-
<div id='message'><p align='center'>Your credit card will not be charged until you confirm your order.</p></div>
|
113
|
-
<button class="blue">Continue to Order Confirmation</button>
|
114
|
-
<em>or</em>
|
115
|
-
<a href="/">return to the store</a>
|
116
|
-
</section>
|
117
|
-
<iframe id="relay" name="relay" style='display: block; width: 800px; height: 400px; border: #000 1px solid;'></iframe>
|
118
|
-
</div>
|
119
|
-
|
120
|
-
<%= content_for :caboose_js do %>
|
121
|
-
<%= javascript_include_tag 'caboose/cart' %>
|
122
|
-
<%= javascript_include_tag 'caboose/checkout_payment' %>
|
123
|
-
<script type='text/javascript'>
|
124
|
-
var SHOW_RELAY = <%= @show_relay ? 'true' : 'false' %>;
|
125
|
-
|
126
|
-
var cart = false;
|
127
|
-
var CABOOSE_ORDER_TOTAL = 0.0;
|
128
|
-
$(document).ready(function() {
|
129
|
-
cart = new Cart({
|
130
|
-
allow_edit_line_items: false,
|
131
|
-
allow_edit_gift_cards: false
|
132
|
-
});
|
133
|
-
CABOOSE_ORDER_TOTAL = parseFloat(<%= raw Caboose.json(@order.total); %>);
|
134
|
-
});
|
135
|
-
|
136
|
-
</script>
|
137
|
-
<% end %>
|
138
|
-
<%= content_for :caboose_css do %>
|
139
|
-
<%= stylesheet_link_tag 'caboose/cart' %>
|
140
|
-
<%= stylesheet_link_tag 'caboose/checkout' %>
|
141
|
-
<style type='text/css'>
|
142
|
-
|
143
|
-
#checkout h3 { font-size: 14pt; font-weight: bold; }
|
144
|
-
|
145
|
-
</style>
|
146
|
-
<% end %>
|
@@ -1,36 +0,0 @@
|
|
1
|
-
|
2
|
-
<h1>Order History</h1>
|
3
|
-
|
4
|
-
<% if @orders.count > 0 %>
|
5
|
-
<table class='orders'>
|
6
|
-
<tr>
|
7
|
-
<th>Date</th>
|
8
|
-
<th>Order Number</th>
|
9
|
-
<th>Total</th>
|
10
|
-
<th>Status</th>
|
11
|
-
</tr>
|
12
|
-
<% @orders.each do |order| %>
|
13
|
-
<tr onclick="window.location='/my-account/orders/<%= order.id %>';">
|
14
|
-
<td><%= order.date_created ? order.date_created.strftime('%m/%d/%Y') : '' %></td>
|
15
|
-
<td><%= order.order_number %></td>
|
16
|
-
<td><%= number_to_currency(order.total) %></td>
|
17
|
-
<td><%= order.status.capitalize %></td>
|
18
|
-
</tr>
|
19
|
-
<% end %>
|
20
|
-
</table>
|
21
|
-
<% else %>
|
22
|
-
<p>You haven't placed any orders yet.<p>
|
23
|
-
<% end %>
|
24
|
-
|
25
|
-
<p><input type='button' value='< Back to My Account' class='btn' onclick="window.location='/my-account';" /></p>
|
26
|
-
|
27
|
-
<% content_for :caboose_css do %>
|
28
|
-
<style type='text/css'>
|
29
|
-
|
30
|
-
table.orders { border-collapse: collapse; margin-bottom: 20px; }
|
31
|
-
table.orders th { margin: 0; padding: 10px; border: #000 0px solid; font-weight: bold; text-align: center; }
|
32
|
-
table.orders td { margin: 0; padding: 10px; border: #000 1px solid; }
|
33
|
-
table.orders tr:hover td { background: #ccc; cursor: pointer; cursor: hand; }
|
34
|
-
|
35
|
-
</style>
|
36
|
-
<% end %>
|