From 766c79c77a8ec18935f24cdf4a9f4432e8ef57c8 Mon Sep 17 00:00:00 2001 From: paulcc Date: Thu, 28 May 2009 09:46:41 +0100 Subject: [PATCH] Now pulls the account details from the GatewayOptions system in Spree NB Spree currently wipes all info except the selected gateway when you edit in the admin section. So be careful! I aim to change this soon. NB hard-coded to use the UK PP express gateway See the migration in this extension to see what is created/expected ps. the earlier account details included in this file were for a sandbox account - sorry! --- lib/spree/paypal_express.rb | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/lib/spree/paypal_express.rb b/lib/spree/paypal_express.rb index 2c6e123..ab5adcf 100644 --- a/lib/spree/paypal_express.rb +++ b/lib/spree/paypal_express.rb @@ -34,8 +34,8 @@ module Spree::PaypalExpress :depth => item.variant.weight } end - site = Spree::Config[:site_url] site = "localhost:3000" + site = Spree::Config[:site_url] opts = { :return_url => "https://" + site + "/orders/#{order.number}/paypal_finish", :cancel_return_url => "http://" + site + "/orders/#{order.number}/edit", @@ -140,24 +140,17 @@ module Spree::PaypalExpress private - # temporary until options are sorted out + # copied from main spree code, and slightly tweaked def paypal_gateway - gw_opts = { :login => "paul_1240924284_biz_api1.rocket-works.co.uk", - :password => "HPDLRQ5DGPAWDAUB", - :signature => "A2VYNHC1wYRx0ZwMX6dXwoFDGTMnAYt4SmzCH6LS3nVKLszXCtL-rp9o" } # or by cls - gateway = ActiveMerchant::Billing::PaypalExpressUkGateway.new gw_opts - return gateway - #? return Spree::BogusGateway.new if ENV['RAILS_ENV'] == "development" and Spree::Gateway::Config[:use_bogus] - gateway_config = GatewayConfiguration.find_by_name "Paypal Express (UK)" + paypal_gw = ::Gateway.find_by_name("Paypal Express UK") + gateway_config = GatewayConfiguration.find_by_gateway_id(paypal_gw.id) config_options = {} gateway_config.gateway_option_values.each do |option_value| key = option_value.gateway_option.name.to_sym config_options[key] = option_value.value end gateway = gateway_config.gateway.clazz.constantize.new(config_options) - # - # => [#] >> GatewayConfiguration => GatewayConfiguration(id: integer, gateway_id: integer, created_at: datetime, updated_at: datetime) >> GatewayConfiguration.all => [#] end end