From 3a1fcf17712ce9615816c93f048da553407bec1c Mon Sep 17 00:00:00 2001 From: John Dyer Date: Thu, 17 Nov 2011 10:53:07 -0500 Subject: [PATCH] Namespace Updates --- .../paypal_express_callbacks_controller.rb | 2 +- .../{ => spree}/checkout_controller_decorator.rb | 14 +++++++------- .../billing_integration/paypal_express.rb | 2 +- .../billing_integration/paypal_express_uk.rb | 2 +- app/views/checkout/payment/_paypalexpress.html.erb | 3 --- app/views/shared/_paypal_express_checkout.html.erb | 2 +- app/views/shared/paypal_express_confirm.html.erb | 2 +- .../spree/checkout/payment/_paypalexpress.html.erb | 3 +++ lib/spree_paypal_express.rb | 4 ++-- lib/tasks/spree_paypal_express.rake | 6 +++--- 10 files changed, 20 insertions(+), 20 deletions(-) rename app/controllers/{ => spree}/checkout_controller_decorator.rb (96%) rename app/models/{ => spree}/billing_integration/paypal_express.rb (81%) rename app/models/{ => spree}/billing_integration/paypal_express_uk.rb (78%) delete mode 100644 app/views/checkout/payment/_paypalexpress.html.erb create mode 100644 app/views/spree/checkout/payment/_paypalexpress.html.erb diff --git a/app/controllers/paypal_express_callbacks_controller.rb b/app/controllers/paypal_express_callbacks_controller.rb index dc2c995..90019ae 100644 --- a/app/controllers/paypal_express_callbacks_controller.rb +++ b/app/controllers/paypal_express_callbacks_controller.rb @@ -30,7 +30,7 @@ class PaypalExpressCallbacksController < Spree::BaseController private def retrieve_details - @order = Order.find_by_number(params["invoice"]) + @order = Spree::Order.find_by_number(params["invoice"]) if @order @payment = @order.payments.where(:state => "pending", :source_type => "PaypalAccount").try(:first) diff --git a/app/controllers/checkout_controller_decorator.rb b/app/controllers/spree/checkout_controller_decorator.rb similarity index 96% rename from app/controllers/checkout_controller_decorator.rb rename to app/controllers/spree/checkout_controller_decorator.rb index df05a77..8ba0fc6 100644 --- a/app/controllers/checkout_controller_decorator.rb +++ b/app/controllers/spree/checkout_controller_decorator.rb @@ -1,4 +1,4 @@ -CheckoutController.class_eval do +Spree::CheckoutController.class_eval do before_filter :redirect_to_paypal_express_form_if_needed, :only => [:update] def paypal_checkout @@ -74,12 +74,12 @@ CheckoutController.class_eval do :address1 => ship_address["address1"], :address2 => ship_address["address2"], :city => ship_address["city"], - :country => Country.find_by_iso(ship_address["country"]), + :country => Spree::Country.find_by_iso(ship_address["country"]), :zipcode => ship_address["zip"], # phone is currently blanked in AM's PPX response lib :phone => @ppx_details.params["phone"] || "(not given)" - if (state = State.find_by_abbr(ship_address["state"])) + if (state = Spree::State.find_by_abbr(ship_address["state"])) order_ship_address.state = state else order_ship_address.state_name = ship_address["state"] @@ -186,9 +186,9 @@ CheckoutController.class_eval do @order.process_coupon_code end load_order - payment_method = PaymentMethod.find(params[:order][:payments_attributes].first[:payment_method_id]) + payment_method = Spree::PaymentMethod.find(params[:order][:payments_attributes].first[:payment_method_id]) - if payment_method.kind_of?(BillingIntegration::PaypalExpress) || payment_method.kind_of?(BillingIntegration::PaypalExpressUk) + if payment_method.kind_of?(Spree::BillingIntegration::PaypalExpress) || payment_method.kind_of?(Spree::BillingIntegration::PaypalExpressUk) redirect_to paypal_payment_order_checkout_url(@order, :payment_method_id => payment_method) end end @@ -264,7 +264,7 @@ CheckoutController.class_eval do :tax => ((order.adjustments.map { |a| a.amount if ( a.source_type == 'Order' && a.label == 'Tax') }.compact.sum) * 100 ).to_i, :shipping => ((order.adjustments.map { |a| a.amount if a.source_type == 'Shipment' }.compact.sum) * 100 ).to_i, :money => (order.total * 100 ).to_i } - + # add correct tax amount by subtracting subtotal and shipping otherwise tax = 0 -> need to check adjustments.map opts[:tax] = (order.total*100).to_i - opts.slice(:subtotal, :shipping).values.sum @@ -357,7 +357,7 @@ CheckoutController.class_eval do # create the gateway from the supplied options def payment_method - PaymentMethod.find(params[:payment_method_id]) + Spree::PaymentMethod.find(params[:payment_method_id]) end def paypal_gateway diff --git a/app/models/billing_integration/paypal_express.rb b/app/models/spree/billing_integration/paypal_express.rb similarity index 81% rename from app/models/billing_integration/paypal_express.rb rename to app/models/spree/billing_integration/paypal_express.rb index a835e56..635dee8 100644 --- a/app/models/billing_integration/paypal_express.rb +++ b/app/models/spree/billing_integration/paypal_express.rb @@ -1,4 +1,4 @@ -class BillingIntegration::PaypalExpress < BillingIntegration +class Spree::BillingIntegration::PaypalExpress < Spree::BillingIntegration preference :login, :string preference :password, :password preference :signature, :string diff --git a/app/models/billing_integration/paypal_express_uk.rb b/app/models/spree/billing_integration/paypal_express_uk.rb similarity index 78% rename from app/models/billing_integration/paypal_express_uk.rb rename to app/models/spree/billing_integration/paypal_express_uk.rb index d3c9fbd..00ff40e 100644 --- a/app/models/billing_integration/paypal_express_uk.rb +++ b/app/models/spree/billing_integration/paypal_express_uk.rb @@ -1,4 +1,4 @@ -class BillingIntegration::PaypalExpressUk < BillingIntegration +class Spree::BillingIntegration::PaypalExpressUk < Spree::BillingIntegration preference :login, :string preference :password, :password preference :signature, :string diff --git a/app/views/checkout/payment/_paypalexpress.html.erb b/app/views/checkout/payment/_paypalexpress.html.erb deleted file mode 100644 index f511a03..0000000 --- a/app/views/checkout/payment/_paypalexpress.html.erb +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/app/views/shared/_paypal_express_checkout.html.erb b/app/views/shared/_paypal_express_checkout.html.erb index 2aa00d3..c371ad5 100644 --- a/app/views/shared/_paypal_express_checkout.html.erb +++ b/app/views/shared/_paypal_express_checkout.html.erb @@ -1,3 +1,3 @@ - + diff --git a/app/views/shared/paypal_express_confirm.html.erb b/app/views/shared/paypal_express_confirm.html.erb index 6acd7ef..dd34e83 100644 --- a/app/views/shared/paypal_express_confirm.html.erb +++ b/app/views/shared/paypal_express_confirm.html.erb @@ -5,6 +5,6 @@ <%= render :partial => 'shared/order_details', :locals => {:order => @order} -%>
- <%= button_to t('place_order'), paypal_finish_order_checkout_url(@order, {:token => params[:token] , :PayerID => params[:PayerID], :payment_method_id => + <%= button_to t('place_order'), main_app.paypal_finish_order_checkout_url(@order, {:token => params[:token] , :PayerID => params[:PayerID], :payment_method_id => params[:payment_method_id] } ), :class => "button primary" %>
diff --git a/app/views/spree/checkout/payment/_paypalexpress.html.erb b/app/views/spree/checkout/payment/_paypalexpress.html.erb new file mode 100644 index 0000000..8c6cfab --- /dev/null +++ b/app/views/spree/checkout/payment/_paypalexpress.html.erb @@ -0,0 +1,3 @@ + + + diff --git a/lib/spree_paypal_express.rb b/lib/spree_paypal_express.rb index ccda2ec..da31be4 100644 --- a/lib/spree_paypal_express.rb +++ b/lib/spree_paypal_express.rb @@ -14,8 +14,8 @@ module SpreePaypalExpress initializer "spree_paypal_express.register.payment_methods" do |app| app.config.spree.payment_methods += [ - BillingIntegration::PaypalExpress, - BillingIntegration::PaypalExpressUk + Spree::BillingIntegration::PaypalExpress, + Spree::BillingIntegration::PaypalExpressUk ] end diff --git a/lib/tasks/spree_paypal_express.rake b/lib/tasks/spree_paypal_express.rake index 17b0531..07567fb 100644 --- a/lib/tasks/spree_paypal_express.rake +++ b/lib/tasks/spree_paypal_express.rake @@ -11,7 +11,7 @@ namespace :spree_paypal_express do source = File.join(File.dirname(__FILE__), '..', '..', 'db') destination = File.join(Rails.root, 'db') puts "INFO: Mirroring assets from #{source} to #{destination}" - Spree::FileUtilz.mirror_files(source, destination) + Spree::Core::FileUtilz.mirror_files(source, destination) end desc "Copies all assets (NOTE: This will be obsolete with Rails 3.1)" @@ -19,8 +19,8 @@ namespace :spree_paypal_express do source = File.join(File.dirname(__FILE__), '..', '..', 'public') destination = File.join(Rails.root, 'public') puts "INFO: Mirroring assets from #{source} to #{destination}" - Spree::FileUtilz.mirror_files(source, destination) + Spree::Core::FileUtilz.mirror_files(source, destination) end end -end \ No newline at end of file +end