spree-contrib / spree_paypal_express

allowing use of paypal express in spree, using (a modified version of) active merchant
BSD 3-Clause "New" or "Revised" License
113 stars 141 forks source link

undefined class ActiveMerchant::Billing::PaypalExpressResponse #32

Closed cnight closed 12 years ago

cnight commented 12 years ago

Error when trying to access order/payments in admin:

undefined class/module ActiveMerchant::Billing::PaypalExpressResponse

To recreate, simply restart the spree site and try to view payment on a paypal express payment in the admin without first doing an order checkout using paypal express. The error disappears once you do a checkout in the store using paypal express.

This looks like a required class is not being loaded in the admin but is being loaded in the checkout process.

radar commented 12 years ago

Is this class supposed to be defined in ActiveMerchant? Is it one of ours?

radar commented 12 years ago

Looks like it's from ActiveMerchant. Is that the exact error you're getting? Perhaps we're not requiring whatever defines this constant.

cnight commented 12 years ago

Yes it is certainly some type of loading issue. Here is the error in spree_core-1.0.0/app/views/spree/admin/payments/_list.html.erb:

ActionView::Template::Error (undefined class/module ActiveMerchant::Billing::PaypalExpressResponse): 13: <%= link_to payment_method_name(payment), admin_order_payment_path(@order, payment) %> 14: <%= t(payment.state, :scope => :payment_states, :default => payment.state.capitalize) %> 15: 16: <% payment.actions.each do |action| %> 17: <%= button_to t(action), fire_admin_order_payment_path(@order, payment, :e => action), :method => :put %> 18: <% end %> 19:

I was able to fix this error by adding the following line to one of the controller decorators (doesnt seem like the right place to put it, but it works):

require 'active_merchant/billing/gateways/paypal/paypal_express_response'

radar commented 12 years ago

I would recommend that you create a new file in config/initializers in the gem (as it is an engine, so this will work) called paypal_express.rb and put this line in it:

require 'active_merchant/billing/gateways/paypal_express'

This will require the necessary components and should fix the error. Once you've validated that it's fixed it, please submit it as a pull request and I'll look at merging it. Keep in mind that it's getting late here, so I may do it tonight or it may wait until tomorrow.

It depends on the scotch intake.

cnight commented 12 years ago

Will do.

Just about time for valentines beers here too ;)