spree_google_checkout 0.40.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +9 -0
- data/README.markdown +22 -0
- data/Rakefile +31 -0
- data/Versionfile +3 -0
- data/app/controllers/admin/orders_controller_decorator.rb +49 -0
- data/app/controllers/google_checkout_notification_controller.rb +84 -0
- data/app/controllers/orders_controller_decorator.rb +47 -0
- data/app/helpers/google_checkout_helper.rb +19 -0
- data/app/helpers/spree_base_helper_decorator.rb +9 -0
- data/app/models/billing/google_checkout.rb +22 -0
- data/app/models/order_decorator.rb +7 -0
- data/app/models/tax_table_factory.rb +20 -0
- data/app/views/admin/shared/_google_checkout_status.html.erb +18 -0
- data/app/views/checkout/payment/_googlecheckout.erb +0 -0
- data/app/views/checkouts/payment/_googlecheckout.erb +0 -0
- data/app/views/orders/_google_order.html.erb +24 -0
- data/app/views/shared/_google_checkout_bar.html.erb +13 -0
- data/config/locales/en.yml +18 -0
- data/config/locales/ru.yml +13 -0
- data/config/routes.rb +11 -0
- data/db/migrate/20090925072036_add_google_checkout_columns_in_order.rb +15 -0
- data/lib/google_checkout/controller_extender.rb +19 -0
- data/lib/spree_google_checkout.rb +21 -0
- data/lib/spree_google_checkout_hooks.rb +13 -0
- data/lib/tasks/install.rake +25 -0
- data/lib/tasks/spree_google_checkout.rake +1 -0
- data/spree_google_checkout.gemspec +25 -0
- metadata +145 -0
data/.gitignore
ADDED
data/README.markdown
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Google Checkout
|
2
|
+
==================
|
3
|
+
|
4
|
+
### Installation
|
5
|
+
|
6
|
+
1. Add `gem 'spree_google_checkout', :git => "git://github.com/railsdog/spree-google-checkout.git"` to Gemfile
|
7
|
+
1. Run `rake spree_google_checkout:install`
|
8
|
+
1. Run `rake db:migrate`
|
9
|
+
1. Create seller account in Google Checkout
|
10
|
+
1. Open `https://sandbox.google.com/checkout/sell/settings?section=Integration`
|
11
|
+
or `https://checkout.google.com/sell/settings?section=Integration`
|
12
|
+
1. remember your merchant ID and merchant key
|
13
|
+
1. set 'API callback URL' to `https://your.spree.site/google_checkout_notification`
|
14
|
+
1. select 'Notification as XML'
|
15
|
+
1. Create a billing integration using `http://your.spree.site/admin/payment_methods` and set the merchant ID, etc.
|
16
|
+
1. Set `Spree::Config[:allow_ssl_in_production]` to true
|
17
|
+
|
18
|
+
|
19
|
+
### Usage
|
20
|
+
|
21
|
+
* After filling your gateway settings, users can place order through Google Checkout.
|
22
|
+
* After placing order through Google Checkout, you can charge it or cancel it from Spree admin-panel.
|
data/Rakefile
ADDED
@@ -0,0 +1,31 @@
|
|
1
|
+
require File.expand_path('../../config/application', __FILE__)
|
2
|
+
|
3
|
+
require 'rubygems'
|
4
|
+
require 'rake'
|
5
|
+
require 'rake/testtask'
|
6
|
+
require 'rake/packagetask'
|
7
|
+
require 'rake/gempackagetask'
|
8
|
+
|
9
|
+
spec = eval(File.read('spree_google_checkout.gemspec'))
|
10
|
+
|
11
|
+
Rake::GemPackageTask.new(spec) do |p|
|
12
|
+
p.gem_spec = spec
|
13
|
+
end
|
14
|
+
|
15
|
+
desc "Release to gemcutter"
|
16
|
+
task :release => :package do
|
17
|
+
require 'rake/gemcutter'
|
18
|
+
Rake::Gemcutter::Tasks.new(spec).define
|
19
|
+
Rake::Task['gem:push'].invoke
|
20
|
+
end
|
21
|
+
|
22
|
+
desc "Default Task"
|
23
|
+
task :default => [ :spec ]
|
24
|
+
|
25
|
+
require 'rspec/core/rake_task'
|
26
|
+
RSpec::Core::RakeTask.new
|
27
|
+
|
28
|
+
# require 'cucumber/rake/task'
|
29
|
+
# Cucumber::Rake::Task.new do |t|
|
30
|
+
# t.cucumber_opts = %w{--format pretty}
|
31
|
+
# end
|
data/Versionfile
ADDED
@@ -0,0 +1,49 @@
|
|
1
|
+
Admin::OrdersController.class_eval do
|
2
|
+
include GoogleCheckout::ControllerExtender
|
3
|
+
|
4
|
+
def charge_google_order
|
5
|
+
begin
|
6
|
+
@frontend = get_google_checkout_frontend
|
7
|
+
if @frontend
|
8
|
+
order = @frontend.create_charge_order_command
|
9
|
+
o = Order.find_by_number(params[:id])
|
10
|
+
order.google_order_number = o.google_order_number if o.google_order_number.present?
|
11
|
+
order.amount = Money.new(100 * o.total, Billing::GoogleCheckout.current[:currency])
|
12
|
+
res = order.send_to_google_checkout
|
13
|
+
|
14
|
+
payment = Payment.new(:amount => o.total, :payment_method_id => Billing::GoogleCheckout.current.id)
|
15
|
+
payment.order = o
|
16
|
+
payment.save
|
17
|
+
payment.started_processing
|
18
|
+
payment.complete
|
19
|
+
flash[:notice] = t('google_checkout.order_charged')
|
20
|
+
end
|
21
|
+
rescue
|
22
|
+
flash[:error] = t('google_checkout.order_charge_failed')
|
23
|
+
logger.error $!
|
24
|
+
end
|
25
|
+
redirect_to :back
|
26
|
+
end
|
27
|
+
|
28
|
+
def cancel_google_checkout_order
|
29
|
+
begin
|
30
|
+
@frontend = get_google_checkout_frontend
|
31
|
+
if @frontend
|
32
|
+
order = @frontend.create_cancel_order_command
|
33
|
+
o = Order.find_by_number(params[:id])
|
34
|
+
order.google_order_number = o.google_order_number if o.google_order_number.present?
|
35
|
+
order.reason = params[o.number][:reason]
|
36
|
+
order.comment = params[o.number][:comment]
|
37
|
+
res = order.send_to_google_checkout
|
38
|
+
|
39
|
+
o.cancel!
|
40
|
+
flash[:notice] = t('google_checkout.order_cancelled')
|
41
|
+
end
|
42
|
+
rescue
|
43
|
+
flash[:error] = t('google_checkout.order_cancel_failed')
|
44
|
+
logger.error $!
|
45
|
+
end
|
46
|
+
redirect_to :back
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
@@ -0,0 +1,84 @@
|
|
1
|
+
class GoogleCheckoutNotificationController < ApplicationController
|
2
|
+
protect_from_forgery :except => :create
|
3
|
+
include GoogleCheckout::ControllerExtender
|
4
|
+
include SslRequirement
|
5
|
+
ssl_required :create
|
6
|
+
|
7
|
+
def create
|
8
|
+
frontend = get_google_checkout_frontend
|
9
|
+
frontend.tax_table_factory = TaxTableFactory.new
|
10
|
+
handler = frontend.create_notification_handler
|
11
|
+
|
12
|
+
begin
|
13
|
+
notification = handler.handle(request.raw_post) # raw_post contains the XML
|
14
|
+
puts "GoogleCheckoutNotification: #{notification.inspect}"
|
15
|
+
if notification.is_a?(Google4R::Checkout::NewOrderNotification)
|
16
|
+
@order = Order.find_by_id(params[:new_order_notification][:shopping_cart][:merchant_private_data][:order_number].strip.to_i)
|
17
|
+
unless @order.completed?
|
18
|
+
@order.user_id = current_user.try(:id)
|
19
|
+
@order.email = notification.buyer_shipping_address.email || "undefined@un.def"
|
20
|
+
@order.ip_address = request.env['REMOTE_ADDR'] if @order.respond_to?('ip_address=')
|
21
|
+
@order.adjustment_total = notification.order_adjustment.adjustment_total.cents.to_f / 100
|
22
|
+
@order.buyer_id = notification.buyer_id
|
23
|
+
@order.financial_order_state = notification.financial_order_state
|
24
|
+
@order.google_order_number = notification.google_order_number
|
25
|
+
@order.gateway = "Google Checkout"
|
26
|
+
|
27
|
+
new_billing_address =
|
28
|
+
create_spree_address_from_google_address(notification.buyer_billing_address)
|
29
|
+
|
30
|
+
@order['bill_address_id'] = new_billing_address.id
|
31
|
+
|
32
|
+
new_shipping_address =
|
33
|
+
create_spree_address_from_google_address(notification.buyer_shipping_address)
|
34
|
+
|
35
|
+
@order['ship_address_id'] = new_shipping_address.id
|
36
|
+
|
37
|
+
ship_method = ShippingMethod.find_by_name(notification.order_adjustment.shipping.name)
|
38
|
+
@order.shipping_method = ship_method
|
39
|
+
@order.save
|
40
|
+
|
41
|
+
@order.next while @order.errors.blank? && @order.state != "complete"
|
42
|
+
end
|
43
|
+
render :text => 'proccess Google4R::Checkout::NewOrderNotification' and return
|
44
|
+
end
|
45
|
+
|
46
|
+
if notification.is_a?(Google4R::Checkout::ChargeAmountNotification)
|
47
|
+
@order = Order.find_by_google_order_number(notification.google_order_number)
|
48
|
+
payment = Payment.new(:amount => notification.latest_charge_amount, :payment_method_id => Billing::GoogleCheckout.current.id)
|
49
|
+
payment.order = @order
|
50
|
+
payment.save
|
51
|
+
payment.started_processing
|
52
|
+
payment.complete
|
53
|
+
render :text => 'proccess Google4R::Checkout::ChargeAmountNotification' and return
|
54
|
+
end
|
55
|
+
|
56
|
+
rescue Google4R::Checkout::UnknownNotificationType => e
|
57
|
+
# This can happen if Google adds new commands and Google4R has not been
|
58
|
+
# upgraded yet. It is not fatal.
|
59
|
+
render :text => 'ignoring unknown notification type', :status => 200 and return
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
private
|
64
|
+
def create_spree_address_from_google_address(google_address)
|
65
|
+
address = Address.new
|
66
|
+
address.country = Country.find_by_iso(google_address.country_code)
|
67
|
+
address.state = State.find_by_abbr(google_address.region)
|
68
|
+
address.state_name = (google_address.region || '-') unless address.state
|
69
|
+
|
70
|
+
address_attrs = {
|
71
|
+
:firstname => google_address.contact_name[/^\S+/] || '-',
|
72
|
+
:lastname => google_address.contact_name[/\s.*/] || '-',
|
73
|
+
:address1 => google_address.address1 || '-',
|
74
|
+
:address2 => google_address.address2 || '-',
|
75
|
+
:city => google_address.city || '-',
|
76
|
+
:phone => google_address.phone || '-',
|
77
|
+
:zipcode => google_address.postal_code || '-'
|
78
|
+
}
|
79
|
+
address.attributes = address_attrs
|
80
|
+
address.save(false)
|
81
|
+
address
|
82
|
+
end
|
83
|
+
|
84
|
+
end
|
@@ -0,0 +1,47 @@
|
|
1
|
+
OrdersController.class_eval do
|
2
|
+
helper :google_checkout
|
3
|
+
include GoogleCheckout::ControllerExtender
|
4
|
+
before_filter :clear_session, :only => [:show]
|
5
|
+
|
6
|
+
def edit
|
7
|
+
@order = current_order(true)
|
8
|
+
@frontend = get_google_checkout_frontend
|
9
|
+
if @frontend
|
10
|
+
checkout_command = @frontend.create_checkout_command
|
11
|
+
# Adding an item to shopping cart
|
12
|
+
@order.line_items.each do |l|
|
13
|
+
checkout_command.shopping_cart.create_item do |item|
|
14
|
+
item.name = l.product.name
|
15
|
+
item.description = l.product.description
|
16
|
+
item.unit_price = Money.new(100 * l.price, Billing::GoogleCheckout.current[:currency])
|
17
|
+
item.quantity = l.quantity
|
18
|
+
end
|
19
|
+
end
|
20
|
+
checkout_command.shopping_cart.private_data = { 'order_number' => @order.id }
|
21
|
+
checkout_command.edit_cart_url = edit_order_url(@order)
|
22
|
+
checkout_command.continue_shopping_url = order_url(@order, :checkout_complete => true)
|
23
|
+
|
24
|
+
fake_shipment = Shipment.new :order => @order, :address => @order.ship_address
|
25
|
+
ShippingMethod.all.each do |ship_method|
|
26
|
+
|
27
|
+
checkout_command.create_shipping_method(Google4R::Checkout::FlatRateShipping) do |shipping_method|
|
28
|
+
shipping_method.name = ship_method.name
|
29
|
+
shipping_method.price = Money.new(100*ship_method.calculator.compute(fake_shipment), Billing::GoogleCheckout.current[:currency])
|
30
|
+
shipping_method.create_allowed_area(Google4R::Checkout::UsCountryArea) do |area|
|
31
|
+
area.area = Google4R::Checkout::UsCountryArea::ALL
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
@response = checkout_command.to_xml #send_to_google_checkout
|
36
|
+
|
37
|
+
# puts "===========#{request.raw_post}"
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
private
|
42
|
+
def clear_session
|
43
|
+
session[:order_id] = nil
|
44
|
+
end
|
45
|
+
end
|
46
|
+
|
47
|
+
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module GoogleCheckoutHelper
|
2
|
+
|
3
|
+
def google_checkout_button(merchant_id)
|
4
|
+
img_src = Billing::GoogleCheckout.current[:use_sandbox] ?
|
5
|
+
"http://sandbox.google.com/checkout/buttons/checkout.gif" :
|
6
|
+
"https://checkout.google.com/buttons/checkout.gif"
|
7
|
+
params_hash = {:merchant_id => merchant_id,
|
8
|
+
:w => 180, :h => 46, :style => "white",
|
9
|
+
:variant => "text", :loc => "en_US" }
|
10
|
+
params_str = params_hash.to_a.inject([]){|arr, p| arr << p.join('=')}.join('&')
|
11
|
+
|
12
|
+
|
13
|
+
image_submit_tag( [img_src, params_str].join('?'),
|
14
|
+
:name => "Google Checkout",
|
15
|
+
:alt => "Fast checkout through Google",
|
16
|
+
:height => 46, :width => 180 )
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,9 @@
|
|
1
|
+
Spree::BaseHelper.module_eval do
|
2
|
+
def signature(base_string, consumer_secret)
|
3
|
+
secret="#{escape(consumer_secret)}"
|
4
|
+
Base64.encode64(HMAC::SHA1.digest(secret,base_string)).chomp.gsub(/\n/,'')
|
5
|
+
end
|
6
|
+
def escape(value)
|
7
|
+
CGI.escape(value.to_s).gsub("%7E", '~').gsub("+", "%20")
|
8
|
+
end
|
9
|
+
end
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class Billing::GoogleCheckout < BillingIntegration
|
2
|
+
preference :use_sandbox, :boolean, :default => true
|
3
|
+
preference :merchant_id, :string
|
4
|
+
preference :merchant_key, :string
|
5
|
+
preference :currency, :string, :default => "USD"
|
6
|
+
|
7
|
+
def tax_table_factory
|
8
|
+
TaxTableFactory.new
|
9
|
+
end
|
10
|
+
|
11
|
+
def [](config_setting)
|
12
|
+
begin
|
13
|
+
self.send("preferred_#{config_setting}")
|
14
|
+
rescue NoMethodError
|
15
|
+
super
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.current
|
20
|
+
self.where(:type => self.to_s, :environment => Rails.env, :active => true).first
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,20 @@
|
|
1
|
+
class TaxTableFactory
|
2
|
+
def effective_tax_tables_at(time)
|
3
|
+
# Tax table 1 will be used before Apr 09 2008
|
4
|
+
#if time < "Wed Apr 09 08:56:03 CDT 2008".to_time then
|
5
|
+
#if time < Time.now
|
6
|
+
table1 = Google4R::Checkout::TaxTable.new(false)
|
7
|
+
table1.name = "Default Tax Table"
|
8
|
+
# table1.create_rule do |rule|
|
9
|
+
# # Set California tax to 8%
|
10
|
+
# rule.area = Google4R::Checkout::UsStateArea.new("CA")
|
11
|
+
# rule.rate = 0.08
|
12
|
+
# end
|
13
|
+
[ table1 ]
|
14
|
+
#else
|
15
|
+
# table2 = Google4R::Checkout::TaxTable.new(false)
|
16
|
+
# ... set rules
|
17
|
+
# [ table2 ]
|
18
|
+
#end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
<% if Billing::GoogleCheckout.current && order.google_order_number.present? %>
|
2
|
+
<td><p>
|
3
|
+
<% if order.completed? && order.state != 'canceled' && order.payment_state != 'paid' %>
|
4
|
+
<%= link_to(t("google_checkout.charge"), charge_google_order_admin_order_path(order)) %>
|
5
|
+
<% end %>
|
6
|
+
</p><p>
|
7
|
+
<% if order.allow_cancel? && order.payment_state != 'paid' %>
|
8
|
+
<% form_tag cancel_google_checkout_order_admin_order_path(order) , :method => :get do %>
|
9
|
+
<p><%= t(:reason)%>:<br /><%= text_field_tag "#{order.number}[reason]" %></p>
|
10
|
+
<!--<p><%= t(:comment)%>:<br /><%= text_field_tag "#{order.number}[comment]" %></p>-->
|
11
|
+
<p><%= submit_tag t("google_checkout.cancel_order"), :onclick => "if (jQuery('##{order.number}_reason').val().length == 0) { jQuery.alerts.alert('#{t(:fill_reason)}'); return false; }" %></p>
|
12
|
+
<% end %>
|
13
|
+
<% end %>
|
14
|
+
</p>
|
15
|
+
</td>
|
16
|
+
<% else %>
|
17
|
+
<td></td>
|
18
|
+
<% end %>
|
File without changes
|
File without changes
|
@@ -0,0 +1,24 @@
|
|
1
|
+
<script type="text/javascript">
|
2
|
+
var gaJsHost = (("https:" == document.location.protocol) ? "https://ssl." : "http://www.");
|
3
|
+
document.write(unescape("%3Cscript src='" + gaJsHost + "google-analytics.com/ga.js' type='text/javascript'%3E%3C/script%3E"));
|
4
|
+
</script>
|
5
|
+
<script type="text/javascript">
|
6
|
+
var pageTracker = _gat._getTracker("<%= Spree::Config[:google_analytics_id] %>");
|
7
|
+
pageTracker._initData();
|
8
|
+
pageTracker._trackPageview();
|
9
|
+
pageTracker._addTrans(
|
10
|
+
"<%= order.number %>", //Order Number
|
11
|
+
"", //Affiliation
|
12
|
+
"<%= order.total %>", //Order total
|
13
|
+
"<%= order.tax_charges.sum(:amount).to_s %>", //Tax Amount
|
14
|
+
"<%= order.shipping_charges.sum(:amount).to_s %>", //Ship Amount
|
15
|
+
"", //City
|
16
|
+
"", //State
|
17
|
+
"" //Country
|
18
|
+
);
|
19
|
+
<% order.line_items.each do |line_item| -%>
|
20
|
+
pageTracker._addItem("<%= order.number %>", "<%= line_item.variant.sku %>", "<%= line_item.variant.product.name %>",
|
21
|
+
"" /*Product Category*/, "<%= line_item.price %>", "<%= line_item.quantity %>");
|
22
|
+
<% end -%>
|
23
|
+
pageTracker._trackTrans();
|
24
|
+
</script>
|
@@ -0,0 +1,13 @@
|
|
1
|
+
<% if Billing::GoogleCheckout.current && @order.line_items.present? && @response
|
2
|
+
handler_url = Billing::GoogleCheckout.current[:use_sandbox] ?
|
3
|
+
"https://sandbox.google.com/checkout/" : "https://checkout.google.com/"
|
4
|
+
handler_url += "api/checkout/v2/checkout/Merchant/#{Billing::GoogleCheckout.current[:merchant_id]}"
|
5
|
+
%>
|
6
|
+
<div id='google_checkout_button'>
|
7
|
+
<form method="POST" action="<%= handler_url %>">
|
8
|
+
<%= hidden_field_tag :cart, Base64.encode64(@response).chomp %>
|
9
|
+
<%= hidden_field_tag :signature, signature(@response, Billing::GoogleCheckout.current[:merchant_key]) %>
|
10
|
+
<%= google_checkout_button(Billing::GoogleCheckout.current[:merchant_id]) %>
|
11
|
+
</form>
|
12
|
+
</div>
|
13
|
+
<% end -%>
|
@@ -0,0 +1,18 @@
|
|
1
|
+
---
|
2
|
+
en:
|
3
|
+
google_checkout:
|
4
|
+
cancel_order: "Cancel order"
|
5
|
+
charge: "Charge"
|
6
|
+
order_cancelled: "Order successfully cancelled"
|
7
|
+
order_cancel_failed: "Order cancel failed"
|
8
|
+
order_charged: "Order successfully changed"
|
9
|
+
order_charge_failed: "Order charge failed"
|
10
|
+
google_checkout_status: "Google Checkout"
|
11
|
+
comment: "Comment"
|
12
|
+
reason: "Reason"
|
13
|
+
use_sandbox: Sandbox
|
14
|
+
merchant_id: Merchant Id
|
15
|
+
merchant_key: Merchant Key
|
16
|
+
currency: Currency
|
17
|
+
|
18
|
+
|
@@ -0,0 +1,13 @@
|
|
1
|
+
---
|
2
|
+
ru:
|
3
|
+
google_checkout:
|
4
|
+
cancel_order: "Отменить заказ"
|
5
|
+
charge: "Принять оплату"
|
6
|
+
order_cancelled: "Заказ успешно отменён"
|
7
|
+
order_cancel_failed: "Не удалось отменить заказ"
|
8
|
+
order_charged: "Заказ успешно оплачен"
|
9
|
+
order_charge_failed: "Оплата заказа не прошла"
|
10
|
+
google_checkout_status: "Google Checkout"
|
11
|
+
comment: "Комментарий"
|
12
|
+
reason: "Причина"
|
13
|
+
|
data/config/routes.rb
ADDED
@@ -0,0 +1,15 @@
|
|
1
|
+
class AddGoogleCheckoutColumnsInOrder < ActiveRecord::Migration
|
2
|
+
def self.up
|
3
|
+
add_column :orders, :financial_order_state , :string
|
4
|
+
add_column :orders, :google_order_number, :string
|
5
|
+
add_column :orders, :buyer_id, :string
|
6
|
+
add_column :orders, :gateway, :string
|
7
|
+
end
|
8
|
+
|
9
|
+
def self.down
|
10
|
+
remove_column :orders, :financial_order_state
|
11
|
+
remove_column :orders, :google_order_number
|
12
|
+
remove_column :orders, :buyer_id
|
13
|
+
remove_column :orders, :gateway
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,19 @@
|
|
1
|
+
module GoogleCheckout::ControllerExtender
|
2
|
+
protected
|
3
|
+
|
4
|
+
def get_google_checkout_frontend
|
5
|
+
return nil unless integration = Billing::GoogleCheckout.current
|
6
|
+
#return nil unless load_google_gateway
|
7
|
+
gc_config = {
|
8
|
+
:merchant_id => integration.preferred_merchant_id,
|
9
|
+
:merchant_key => integration.preferred_merchant_key,
|
10
|
+
:use_sandbox => integration.preferred_use_sandbox }
|
11
|
+
|
12
|
+
|
13
|
+
#@gc_currency = @gw.gateway_option_values[2].value
|
14
|
+
front_end = Google4R::Checkout::Frontend.new(gc_config)
|
15
|
+
front_end.tax_table_factory = TaxTableFactory.new
|
16
|
+
front_end
|
17
|
+
end
|
18
|
+
|
19
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
require 'google4r/checkout'
|
2
|
+
require 'hmac-sha1'
|
3
|
+
require 'spree_core'
|
4
|
+
require 'spree_google_checkout_hooks'
|
5
|
+
|
6
|
+
module SpreeGoogleCheckout
|
7
|
+
class Engine < Rails::Engine
|
8
|
+
|
9
|
+
config.autoload_paths += %W(#{config.root}/lib)
|
10
|
+
|
11
|
+
def self.activate
|
12
|
+
Dir.glob(File.join(File.dirname(__FILE__), "../app/**/*_decorator*.rb")) do |c|
|
13
|
+
Rails.env.production? ? require(c) : load(c)
|
14
|
+
end
|
15
|
+
# register the BillingIntegration
|
16
|
+
Billing::GoogleCheckout.register
|
17
|
+
end
|
18
|
+
|
19
|
+
config.to_prepare &method(:activate).to_proc
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
class SpreeGoogleCheckoutHooks < Spree::ThemeSupport::HookListener
|
2
|
+
insert_after :outside_cart_form, 'shared/google_checkout_bar'
|
3
|
+
|
4
|
+
insert_after :admin_orders_index_headers do
|
5
|
+
%(
|
6
|
+
<% if Billing::GoogleCheckout.current -%>
|
7
|
+
<th><%= t(:google_checkout_status) %></th>
|
8
|
+
<% end -%>
|
9
|
+
)
|
10
|
+
end
|
11
|
+
|
12
|
+
insert_after :admin_orders_index_rows, 'admin/shared/google_checkout_status'
|
13
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
namespace :spree_google_checkout do
|
2
|
+
desc "Copies all migrations and assets (NOTE: This will be obsolete with Rails 3.1)"
|
3
|
+
task :install do
|
4
|
+
Rake::Task['spree_google_checkout:install:migrations'].invoke
|
5
|
+
Rake::Task['spree_google_checkout:install:assets'].invoke
|
6
|
+
end
|
7
|
+
|
8
|
+
namespace :install do
|
9
|
+
desc "Copies all migrations (NOTE: This will be obsolete with Rails 3.1)"
|
10
|
+
task :migrations do
|
11
|
+
source = File.join(File.dirname(__FILE__), '..', '..', 'db')
|
12
|
+
destination = File.join(Rails.root, 'db')
|
13
|
+
Spree::FileUtilz.mirror_files(source, destination)
|
14
|
+
end
|
15
|
+
|
16
|
+
desc "Copies all assets (NOTE: This will be obsolete with Rails 3.1)"
|
17
|
+
task :assets do
|
18
|
+
source = File.join(File.dirname(__FILE__), '..', '..', 'public')
|
19
|
+
destination = File.join(Rails.root, 'public')
|
20
|
+
puts "INFO: Mirroring assets from #{source} to #{destination}"
|
21
|
+
Spree::FileUtilz.mirror_files(source, destination)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
@@ -0,0 +1 @@
|
|
1
|
+
# add custom rake tasks here
|
@@ -0,0 +1,25 @@
|
|
1
|
+
Gem::Specification.new do |s|
|
2
|
+
s.platform = Gem::Platform::RUBY
|
3
|
+
s.name = 'spree_google_checkout'
|
4
|
+
s.version = '0.40.0'
|
5
|
+
s.summary = 'Google Checkout extension for Spree'
|
6
|
+
#s.description = 'Add (optional) gem description here'
|
7
|
+
s.required_ruby_version = '>= 1.8.7'
|
8
|
+
|
9
|
+
# s.author = 'David Heinemeier Hansson'
|
10
|
+
# s.email = 'david@loudthinking.com'
|
11
|
+
# s.homepage = 'http://www.rubyonrails.org'
|
12
|
+
# s.rubyforge_project = 'actionmailer'
|
13
|
+
|
14
|
+
s.files = `git ls-files`.split("\n")
|
15
|
+
s.test_files = `git ls-files -- {test,spec,features}/*`.split("\n")
|
16
|
+
s.require_path = 'lib'
|
17
|
+
s.requirements << 'none'
|
18
|
+
|
19
|
+
s.has_rdoc = true
|
20
|
+
|
21
|
+
s.add_dependency('spree_core', '>= 0.50.0')
|
22
|
+
s.add_dependency('oauth', '>= 0.4.4')
|
23
|
+
s.add_dependency('google4r-checkout', '>= 1.0.5')
|
24
|
+
s.add_dependency('ruby-hmac', '>= 0.3.2')
|
25
|
+
end
|
metadata
ADDED
@@ -0,0 +1,145 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: spree_google_checkout
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 0
|
7
|
+
- 40
|
8
|
+
- 0
|
9
|
+
version: 0.40.0
|
10
|
+
platform: ruby
|
11
|
+
authors: []
|
12
|
+
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2011-04-05 00:00:00 +04:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: spree_core
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - ">="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 0
|
29
|
+
- 50
|
30
|
+
- 0
|
31
|
+
version: 0.50.0
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
34
|
+
- !ruby/object:Gem::Dependency
|
35
|
+
name: oauth
|
36
|
+
prerelease: false
|
37
|
+
requirement: &id002 !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - ">="
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
segments:
|
42
|
+
- 0
|
43
|
+
- 4
|
44
|
+
- 4
|
45
|
+
version: 0.4.4
|
46
|
+
type: :runtime
|
47
|
+
version_requirements: *id002
|
48
|
+
- !ruby/object:Gem::Dependency
|
49
|
+
name: google4r-checkout
|
50
|
+
prerelease: false
|
51
|
+
requirement: &id003 !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - ">="
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
segments:
|
56
|
+
- 1
|
57
|
+
- 0
|
58
|
+
- 5
|
59
|
+
version: 1.0.5
|
60
|
+
type: :runtime
|
61
|
+
version_requirements: *id003
|
62
|
+
- !ruby/object:Gem::Dependency
|
63
|
+
name: ruby-hmac
|
64
|
+
prerelease: false
|
65
|
+
requirement: &id004 !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - ">="
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
segments:
|
70
|
+
- 0
|
71
|
+
- 3
|
72
|
+
- 2
|
73
|
+
version: 0.3.2
|
74
|
+
type: :runtime
|
75
|
+
version_requirements: *id004
|
76
|
+
description:
|
77
|
+
email:
|
78
|
+
executables: []
|
79
|
+
|
80
|
+
extensions: []
|
81
|
+
|
82
|
+
extra_rdoc_files: []
|
83
|
+
|
84
|
+
files:
|
85
|
+
- .gitignore
|
86
|
+
- README.markdown
|
87
|
+
- Rakefile
|
88
|
+
- Versionfile
|
89
|
+
- app/controllers/admin/orders_controller_decorator.rb
|
90
|
+
- app/controllers/google_checkout_notification_controller.rb
|
91
|
+
- app/controllers/orders_controller_decorator.rb
|
92
|
+
- app/helpers/google_checkout_helper.rb
|
93
|
+
- app/helpers/spree_base_helper_decorator.rb
|
94
|
+
- app/models/billing/google_checkout.rb
|
95
|
+
- app/models/order_decorator.rb
|
96
|
+
- app/models/tax_table_factory.rb
|
97
|
+
- app/views/admin/shared/_google_checkout_status.html.erb
|
98
|
+
- app/views/checkout/payment/_googlecheckout.erb
|
99
|
+
- app/views/checkouts/payment/_googlecheckout.erb
|
100
|
+
- app/views/orders/_google_order.html.erb
|
101
|
+
- app/views/shared/_google_checkout_bar.html.erb
|
102
|
+
- config/locales/en.yml
|
103
|
+
- config/locales/ru.yml
|
104
|
+
- config/routes.rb
|
105
|
+
- db/migrate/20090925072036_add_google_checkout_columns_in_order.rb
|
106
|
+
- lib/google_checkout/controller_extender.rb
|
107
|
+
- lib/spree_google_checkout.rb
|
108
|
+
- lib/spree_google_checkout_hooks.rb
|
109
|
+
- lib/tasks/install.rake
|
110
|
+
- lib/tasks/spree_google_checkout.rake
|
111
|
+
- spree_google_checkout.gemspec
|
112
|
+
has_rdoc: true
|
113
|
+
homepage:
|
114
|
+
licenses: []
|
115
|
+
|
116
|
+
post_install_message:
|
117
|
+
rdoc_options: []
|
118
|
+
|
119
|
+
require_paths:
|
120
|
+
- lib
|
121
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
122
|
+
requirements:
|
123
|
+
- - ">="
|
124
|
+
- !ruby/object:Gem::Version
|
125
|
+
segments:
|
126
|
+
- 1
|
127
|
+
- 8
|
128
|
+
- 7
|
129
|
+
version: 1.8.7
|
130
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
131
|
+
requirements:
|
132
|
+
- - ">="
|
133
|
+
- !ruby/object:Gem::Version
|
134
|
+
segments:
|
135
|
+
- 0
|
136
|
+
version: "0"
|
137
|
+
requirements:
|
138
|
+
- none
|
139
|
+
rubyforge_project:
|
140
|
+
rubygems_version: 1.3.6
|
141
|
+
signing_key:
|
142
|
+
specification_version: 3
|
143
|
+
summary: Google Checkout extension for Spree
|
144
|
+
test_files: []
|
145
|
+
|