pay: ActionController::RoutingError (uninitialized constant Pay::Webhooks::StripeController

Hey πŸ‘‹

On webhook callback, I have this error:

ActionController::RoutingError (uninitialized constant Pay::Webhooks::StripeController
Did you mean?  DeviseController):

Here is my initializer:

# frozen_string_literal: true

Pay.setup do |config|
  config.chargeable_class = 'Pay::Charge'
  config.chargeable_table = 'pay_charges'
  
 # For use in the receipt/refund/renewal mailers 
 # ...


  config.default_product_name = 'Gold'
  config.default_plan_name = 'gold'

  config.automount_routes = true
  config.routes_path = '/pay' # Only when automount_routes is true
end

And I don’t have catchall routes.

I ran this command to forward hooks:

stripe listen --forward-to localhost:3000/pay/webhooks/stripe

I restarted my server many times and run bundle install too.

Any idea why?

Thanks!

About this issue

  • Original URL
  • State: closed
  • Created 3 years ago
  • Comments: 22 (9 by maintainers)

Most upvoted comments

Awesome, feel free to open a new issue if the persists.

@guillaumebriday @excid3 upgrading from 3.0.23 to 3.0.24 fixed this for me! You can probably close this issue unless others are still running into this.

I’m seeing the same issue in our app. When enabling verbose logging for the zeitwerk loader (https://guides.rubyonrails.org/autoloading_and_reloading_constants.html#troubleshooting), I’m not seeing the webhook controllers being autoloaded:

Zeitwerk@rails.main: autoload set for Pay::ApplicationController, to be loaded from /Users/christoph/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/pay-2.6.10/app/controllers/pay/application_controller.rb
Zeitwerk@rails.main: autoload set for Pay::PaymentsController, to be loaded from /Users/christoph/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/pay-2.6.10/app/controllers/pay/payments_controller.rb
Zeitwerk@rails.main: autoload set for Pay::ApplicationHelper, to be loaded from /Users/christoph/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/pay-2.6.10/app/helpers/pay/application_helper.rb
Zeitwerk@rails.main: autoload set for Pay::EmailSyncJob, to be loaded from /Users/christoph/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/pay-2.6.10/app/jobs/pay/email_sync_job.rb
Zeitwerk@rails.main: autoload set for Pay::ApplicationJob, to be loaded from /Users/christoph/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/pay-2.6.10/app/jobs/pay/application_job.rb
Zeitwerk@rails.main: autoload set for Pay::UserMailer, to be loaded from /Users/christoph/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/pay-2.6.10/app/mailers/pay/user_mailer.rb
Zeitwerk@rails.main: autoload set for Pay::ApplicationMailer, to be loaded from /Users/christoph/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/pay-2.6.10/app/mailers/pay/application_mailer.rb
Zeitwerk@rails.main: autoload set for Pay::Charge, to be loaded from /Users/christoph/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/pay-2.6.10/app/models/pay/charge.rb
Zeitwerk@rails.main: autoload set for Pay::Subscription, to be loaded from /Users/christoph/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/pay-2.6.10/app/models/pay/subscription.rb
Zeitwerk@rails.main: autoload set for Pay::ApplicationRecord, to be loaded from /Users/christoph/.asdf/installs/ruby/2.7.2/lib/ruby/gems/2.7.0/gems/pay-2.6.10/app/models/pay/application_record.rb

I’ll spend some time this morning to get the dummy application up and running and replicate there (right now running into migration issues).

Edit: I think the Pay::Webhooks namespace is clashing: If I rename app/controllers/pay/webhooks to just app/controllers/pay/hooks (and adjust the files, of course), the webhook controllers get picked up.