diff --git a/app/controllers/paypal_express_callbacks_controller.rb b/app/controllers/paypal_express_callbacks_controller.rb deleted file mode 100644 index 90019ae..0000000 --- a/app/controllers/paypal_express_callbacks_controller.rb +++ /dev/null @@ -1,42 +0,0 @@ -class PaypalExpressCallbacksController < Spree::BaseController - include ActiveMerchant::Billing::Integrations - skip_before_filter :verify_authenticity_token - - ssl_required - - def notify - retrieve_details #need to retreive details first to ensure ActiveMerchant gets configured correctly. - - - @notification = Paypal::Notification.new(request.raw_post) - - # we only care about eChecks (for now?) - if @notification.params["payment_type"] == "echeck" && @notification.acknowledge && @payment && @order.total >= @payment.amount - @payment.started_processing! - @payment.log_entries.create(:details => @notification.to_yaml) - - case @notification.params["payment_status"] - when "Denied" - @payment.fail! - - when "Completed" - @payment.complete! - end - - end - - render :nothing => true - end - - private - def retrieve_details - @order = Spree::Order.find_by_number(params["invoice"]) - - if @order - @payment = @order.payments.where(:state => "pending", :source_type => "PaypalAccount").try(:first) - - @payment.try(:payment_method).try(:provider) #configures ActiveMerchant - end - end - -end diff --git a/app/controllers/spree/paypal_express_callbacks_controller.rb b/app/controllers/spree/paypal_express_callbacks_controller.rb new file mode 100644 index 0000000..f608446 --- /dev/null +++ b/app/controllers/spree/paypal_express_callbacks_controller.rb @@ -0,0 +1,44 @@ +module Spree + class PaypalExpressCallbacksController < Spree::BaseController + include ActiveMerchant::Billing::Integrations + skip_before_filter :verify_authenticity_token + + ssl_required + + def notify + retrieve_details #need to retreive details first to ensure ActiveMerchant gets configured correctly. + + + @notification = Paypal::Notification.new(request.raw_post) + + # we only care about eChecks (for now?) + if @notification.params["payment_type"] == "echeck" && @notification.acknowledge && @payment && @order.total >= @payment.amount + @payment.started_processing! + @payment.log_entries.create(:details => @notification.to_yaml) + + case @notification.params["payment_status"] + when "Denied" + @payment.fail! + + when "Completed" + @payment.complete! + end + + end + + render :nothing => true + end + + private + def retrieve_details + @order = Spree::Order.find_by_number(params["invoice"]) + + if @order + @payment = @order.payments.where(:state => "pending", :source_type => "PaypalAccount").try(:first) + + @payment.try(:payment_method).try(:provider) #configures ActiveMerchant + end + end + + end +end